[PATCH v1 0/4] Add TJA1120 driver support

TJA1120 is a 1Gbps automotive PHY. The nxp-c45-tja11xx driver is updated to support multiple PHYs and TJA1120. Link speed is read from hardware instead of assuming a default value of 100Mbps.
Radu P.
Radu Pirea (NXP OSS) (4): net: phy: nxp-c45-tja11xx: use local definion of features net: phy: nxp-c45-tja11xx: read PHY the speed from hardware net: phy: nxp-c45-tja11xx: rename nxp_c45_tja11xx structure net: phy: nxp-c45-tja11xx: add tja1120 support
drivers/net/phy/nxp-c45-tja11xx.c | 43 ++++++++++++++++++++++++++++--- include/phy.h | 4 --- 2 files changed, 40 insertions(+), 7 deletions(-)

Use a local definition for the PHY features. PHY_100BT1_FEATURES are not defined using the 100BaseT1 bit, so keep this workaround in the driver.
Signed-off-by: Radu Pirea (NXP OSS) radu-nicolae.pirea@oss.nxp.com --- drivers/net/phy/nxp-c45-tja11xx.c | 5 ++++- include/phy.h | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index f701790194..38fb38b9fb 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -330,11 +330,14 @@ static int nxp_c45_probe(struct phy_device *phydev) return 0; }
+#define NXP_C45_COMMON_FEATURES (SUPPORTED_TP | \ + SUPPORTED_MII) + U_BOOT_PHY_DRIVER(nxp_c45_tja11xx) = { .name = "NXP C45 TJA1103", .uid = PHY_ID_TJA_1103, .mask = 0xfffff0, - .features = PHY_100BT1_FEATURES, + .features = NXP_C45_COMMON_FEATURES | SUPPORTED_100baseT_Full, .probe = &nxp_c45_probe, .config = &nxp_c45_config, .startup = &nxp_c45_startup, diff --git a/include/phy.h b/include/phy.h index 27effdb576..e02cbdb58c 100644 --- a/include/phy.h +++ b/include/phy.h @@ -51,10 +51,6 @@ struct udevice; PHY_100BT_FEATURES | \ PHY_DEFAULT_FEATURES)
-#define PHY_100BT1_FEATURES (SUPPORTED_TP | \ - SUPPORTED_MII | \ - SUPPORTED_100baseT_Full) - #define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \ PHY_1000BT_FEATURES)

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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 38fb38b9fb..27d871c4b6 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -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; }

Rename nxp_c45_tja11xx structure to nxp_c45_tja1103. The driver will support more PHYs and nxp_c45_tja11xx is too generic.
Signed-off-by: Radu Pirea (NXP OSS) radu-nicolae.pirea@oss.nxp.com --- drivers/net/phy/nxp-c45-tja11xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 27d871c4b6..e787f5fbb9 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -353,7 +353,7 @@ static int nxp_c45_probe(struct phy_device *phydev) #define NXP_C45_COMMON_FEATURES (SUPPORTED_TP | \ SUPPORTED_MII)
-U_BOOT_PHY_DRIVER(nxp_c45_tja11xx) = { +U_BOOT_PHY_DRIVER(nxp_c45_tja1103) = { .name = "NXP C45 TJA1103", .uid = PHY_ID_TJA_1103, .mask = 0xfffff0,

Add TJA1120 driver structure and report 1G speed.
Signed-off-by: Radu Pirea (NXP OSS) radu-nicolae.pirea@oss.nxp.com --- drivers/net/phy/nxp-c45-tja11xx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index e787f5fbb9..f24fc5b2de 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -14,6 +14,7 @@ #include <phy.h>
#define PHY_ID_TJA_1103 0x001BB010 +#define PHY_ID_TJA_1120 0x001BB031
#define VEND1_DEVICE_CONTROL 0x0040 #define DEVICE_CONTROL_RESET BIT(15) @@ -316,6 +317,8 @@ static int nxp_c45_speed(struct phy_device *phydev)
if (val & MDIO_PMA_CTRL1_SPEED100) phydev->speed = SPEED_100; + else if (val & MDIO_PMA_CTRL1_SPEED1000) + phydev->speed = SPEED_1000; else phydev->speed = 0;
@@ -363,3 +366,14 @@ U_BOOT_PHY_DRIVER(nxp_c45_tja1103) = { .startup = &nxp_c45_startup, .shutdown = &genphy_shutdown, }; + +U_BOOT_PHY_DRIVER(nxp_c45_tja1120) = { + .name = "NXP C45 TJA1120", + .uid = PHY_ID_TJA_1120, + .mask = 0xfffff0, + .features = NXP_C45_COMMON_FEATURES | SUPPORTED_1000baseT_Full, + .probe = &nxp_c45_probe, + .config = &nxp_c45_config, + .startup = &nxp_c45_startup, + .shutdown = &genphy_shutdown, +};
participants (1)
-
Radu Pirea (NXP OSS)