]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: phy: nxp-c45-tja11xx: read PHY the speed from hardware
authorRadu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com>
Wed, 13 Dec 2023 16:14:21 +0000 (18:14 +0200)
committerPeng Fan <peng.fan@nxp.com>
Thu, 8 Feb 2024 02:41:23 +0000 (10:41 +0800)
Read PHY speed from hardware instead of assuming 100Mbps by default.
The TJA1103 works only at 100Mbps, but the driver will support more PHYs.

Signed-off-by: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@oss.nxp.com>
drivers/net/phy/nxp-c45-tja11xx.c

index 38fb38b9fb4dfa8374eacae10321b279cf742bcd..27d871c4b6f0e10ff6795f6c6089cf7008dcc6d3 100644 (file)
@@ -306,13 +306,33 @@ static int nxp_c45_config(struct phy_device *phydev)
        return nxp_c45_start_op(phydev);
 }
 
+static int nxp_c45_speed(struct phy_device *phydev)
+{
+       int val;
+
+       val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1);
+       if (val < 0)
+               return val;
+
+       if (val & MDIO_PMA_CTRL1_SPEED100)
+               phydev->speed = SPEED_100;
+       else
+               phydev->speed = 0;
+
+       return 0;
+}
+
 static int nxp_c45_startup(struct phy_device *phydev)
 {
        u32 reg;
+       int ret;
 
        reg = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT1);
        phydev->link = !!(reg & MDIO_STAT1_LSTATUS);
-       phydev->speed = SPEED_100;
+       ret = nxp_c45_speed(phydev);
+       if (ret < 0)
+               return ret;
+
        phydev->duplex = DUPLEX_FULL;
        return 0;
 }