Skip to content

Commit e6360f0

Browse files
committed
Merge branch 'net-phy-nxp-c45-tja11xx-add-errata-for-tja112xa-b'
Andrei Botila says: ==================== net: phy: nxp-c45-tja11xx: add errata for TJA112XA/B This patch series implements two errata for TJA1120 and TJA1121. The first errata applicable to both RGMII and SGMII version of TJA1120 and TJA1121 deals with achieving full silicon performance. The workaround in this case is putting the PHY in managed mode and applying a series of PHY writes before the link gest established. The second errata applicable only to SGMII version of TJA1120 and TJA1121 deals with achieving a stable operation of SGMII after a startup event. The workaround puts the SGMII PCS into power down mode and back up after restart or wakeup from sleep. ==================== Link: https://patch.msgid.link/20250304160619.181046-1-andrei.botila@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents df8ce77 + 4893952 commit e6360f0

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

drivers/net/phy/nxp-c45-tja11xx.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#define PHY_ID_TJA_1103 0x001BB010
2323
#define PHY_ID_TJA_1120 0x001BB031
2424

25+
#define VEND1_DEVICE_ID3 0x0004
26+
#define TJA1120_DEV_ID3_SILICON_VERSION GENMASK(15, 12)
27+
#define TJA1120_DEV_ID3_SAMPLE_TYPE GENMASK(11, 8)
28+
#define DEVICE_ID3_SAMPLE_TYPE_R 0x9
29+
2530
#define VEND1_DEVICE_CONTROL 0x0040
2631
#define DEVICE_CONTROL_RESET BIT(15)
2732
#define DEVICE_CONTROL_CONFIG_GLOBAL_EN BIT(14)
@@ -109,6 +114,9 @@
109114
#define MII_BASIC_CONFIG_RMII 0x5
110115
#define MII_BASIC_CONFIG_MII 0x4
111116

117+
#define VEND1_SGMII_BASIC_CONTROL 0xB000
118+
#define SGMII_LPM BIT(11)
119+
112120
#define VEND1_SYMBOL_ERROR_CNT_XTD 0x8351
113121
#define EXTENDED_CNT_EN BIT(15)
114122
#define VEND1_MONITOR_STATUS 0xAC80
@@ -1593,6 +1601,63 @@ static int nxp_c45_set_phy_mode(struct phy_device *phydev)
15931601
return 0;
15941602
}
15951603

1604+
/* Errata: ES_TJA1120 and ES_TJA1121 Rev. 1.0 — 28 November 2024 Section 3.1 & 3.2 */
1605+
static void nxp_c45_tja1120_errata(struct phy_device *phydev)
1606+
{
1607+
bool macsec_ability, sgmii_ability;
1608+
int silicon_version, sample_type;
1609+
int phy_abilities;
1610+
int ret = 0;
1611+
1612+
ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_DEVICE_ID3);
1613+
if (ret < 0)
1614+
return;
1615+
1616+
sample_type = FIELD_GET(TJA1120_DEV_ID3_SAMPLE_TYPE, ret);
1617+
if (sample_type != DEVICE_ID3_SAMPLE_TYPE_R)
1618+
return;
1619+
1620+
silicon_version = FIELD_GET(TJA1120_DEV_ID3_SILICON_VERSION, ret);
1621+
1622+
phy_abilities = phy_read_mmd(phydev, MDIO_MMD_VEND1,
1623+
VEND1_PORT_ABILITIES);
1624+
macsec_ability = !!(phy_abilities & MACSEC_ABILITY);
1625+
sgmii_ability = !!(phy_abilities & SGMII_ABILITY);
1626+
if ((!macsec_ability && silicon_version == 2) ||
1627+
(macsec_ability && silicon_version == 1)) {
1628+
/* TJA1120/TJA1121 PHY configuration errata workaround.
1629+
* Apply PHY writes sequence before link up.
1630+
*/
1631+
if (!macsec_ability) {
1632+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 0x4b95);
1633+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 0xf3cd);
1634+
} else {
1635+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 0x89c7);
1636+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 0x0893);
1637+
}
1638+
1639+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0476, 0x58a0);
1640+
1641+
phy_write_mmd(phydev, MDIO_MMD_PMAPMD, 0x8921, 0xa3a);
1642+
phy_write_mmd(phydev, MDIO_MMD_PMAPMD, 0x89F1, 0x16c1);
1643+
1644+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 0x0);
1645+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 0x0);
1646+
1647+
if (sgmii_ability) {
1648+
/* TJA1120B/TJA1121B SGMII PCS restart errata workaround.
1649+
* Put SGMII PCS into power down mode and back up.
1650+
*/
1651+
phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
1652+
VEND1_SGMII_BASIC_CONTROL,
1653+
SGMII_LPM);
1654+
phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
1655+
VEND1_SGMII_BASIC_CONTROL,
1656+
SGMII_LPM);
1657+
}
1658+
}
1659+
}
1660+
15961661
static int nxp_c45_config_init(struct phy_device *phydev)
15971662
{
15981663
int ret;
@@ -1609,6 +1674,9 @@ static int nxp_c45_config_init(struct phy_device *phydev)
16091674
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 1);
16101675
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 2);
16111676

1677+
if (phy_id_compare(phydev->phy_id, PHY_ID_TJA_1120, GENMASK(31, 4)))
1678+
nxp_c45_tja1120_errata(phydev);
1679+
16121680
phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_CONFIG,
16131681
PHY_CONFIG_AUTO);
16141682

0 commit comments

Comments
 (0)