From 6c43208a6de13a3b622c7f8ac491f66edc1126f0 Mon Sep 17 00:00:00 2001 From: "Radu Pirea (NXP OSS)" Date: Wed, 13 Dec 2023 18:14:20 +0200 Subject: net: phy: nxp-c45-tja11xx: use local definion of features 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)" --- drivers/net/phy/nxp-c45-tja11xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index f701790194c..38fb38b9fb4 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, -- cgit v1.3.1 From 84e57e7dfb395fc16bec50cf477d25144ab9747a Mon Sep 17 00:00:00 2001 From: "Radu Pirea (NXP OSS)" Date: Wed, 13 Dec 2023 18:14:21 +0200 Subject: net: phy: nxp-c45-tja11xx: read PHY the speed from hardware 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)" --- drivers/net/phy/nxp-c45-tja11xx.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 38fb38b9fb4..27d871c4b6f 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; } -- cgit v1.3.1 From 7e02c3accb464871bcdd11597b1afc72c3b46593 Mon Sep 17 00:00:00 2001 From: "Radu Pirea (NXP OSS)" Date: Wed, 13 Dec 2023 18:14:22 +0200 Subject: net: phy: nxp-c45-tja11xx: rename nxp_c45_tja11xx structure 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)" --- drivers/net/phy/nxp-c45-tja11xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index 27d871c4b6f..e787f5fbb93 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, -- cgit v1.3.1 From 55fc0cbbd6c973849371bb21b45981ad26847a4b Mon Sep 17 00:00:00 2001 From: "Radu Pirea (NXP OSS)" Date: Wed, 13 Dec 2023 18:14:23 +0200 Subject: net: phy: nxp-c45-tja11xx: add tja1120 support Add TJA1120 driver structure and report 1G speed. Signed-off-by: "Radu Pirea (NXP OSS)" --- drivers/net/phy/nxp-c45-tja11xx.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers') diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c index e787f5fbb93..f24fc5b2de6 100644 --- a/drivers/net/phy/nxp-c45-tja11xx.c +++ b/drivers/net/phy/nxp-c45-tja11xx.c @@ -14,6 +14,7 @@ #include #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, +}; -- cgit v1.3.1