Skip to content

Commit a07364b

Browse files
Andrei Botilakuba-moo
authored andcommitted
net: phy: nxp-c45-tja11xx: add TJA112X PHY configuration errata
The most recent sillicon versions of TJA1120 and TJA1121 can achieve full silicon performance by putting the PHY in managed mode. It is necessary to apply these PHY writes before link gets established. Application of this fix is required after restart of device and wakeup from sleep. Cc: stable@vger.kernel.org Fixes: f1fe5df ("net: phy: nxp-c45-tja11xx: add TJA1120 support") Signed-off-by: Andrei Botila <andrei.botila@oss.nxp.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20250304160619.181046-2-andrei.botila@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent df8ce77 commit a07364b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

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

Lines changed: 52 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)
@@ -1593,6 +1598,50 @@ static int nxp_c45_set_phy_mode(struct phy_device *phydev)
15931598
return 0;
15941599
}
15951600

1601+
/* Errata: ES_TJA1120 and ES_TJA1121 Rev. 1.0 — 28 November 2024 Section 3.1 */
1602+
static void nxp_c45_tja1120_errata(struct phy_device *phydev)
1603+
{
1604+
int silicon_version, sample_type;
1605+
bool macsec_ability;
1606+
int phy_abilities;
1607+
int ret = 0;
1608+
1609+
ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_DEVICE_ID3);
1610+
if (ret < 0)
1611+
return;
1612+
1613+
sample_type = FIELD_GET(TJA1120_DEV_ID3_SAMPLE_TYPE, ret);
1614+
if (sample_type != DEVICE_ID3_SAMPLE_TYPE_R)
1615+
return;
1616+
1617+
silicon_version = FIELD_GET(TJA1120_DEV_ID3_SILICON_VERSION, ret);
1618+
1619+
phy_abilities = phy_read_mmd(phydev, MDIO_MMD_VEND1,
1620+
VEND1_PORT_ABILITIES);
1621+
macsec_ability = !!(phy_abilities & MACSEC_ABILITY);
1622+
if ((!macsec_ability && silicon_version == 2) ||
1623+
(macsec_ability && silicon_version == 1)) {
1624+
/* TJA1120/TJA1121 PHY configuration errata workaround.
1625+
* Apply PHY writes sequence before link up.
1626+
*/
1627+
if (!macsec_ability) {
1628+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 0x4b95);
1629+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 0xf3cd);
1630+
} else {
1631+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 0x89c7);
1632+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 0x0893);
1633+
}
1634+
1635+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0476, 0x58a0);
1636+
1637+
phy_write_mmd(phydev, MDIO_MMD_PMAPMD, 0x8921, 0xa3a);
1638+
phy_write_mmd(phydev, MDIO_MMD_PMAPMD, 0x89F1, 0x16c1);
1639+
1640+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 0x0);
1641+
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 0x0);
1642+
}
1643+
}
1644+
15961645
static int nxp_c45_config_init(struct phy_device *phydev)
15971646
{
15981647
int ret;
@@ -1609,6 +1658,9 @@ static int nxp_c45_config_init(struct phy_device *phydev)
16091658
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F8, 1);
16101659
phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x01F9, 2);
16111660

1661+
if (phy_id_compare(phydev->phy_id, PHY_ID_TJA_1120, GENMASK(31, 4)))
1662+
nxp_c45_tja1120_errata(phydev);
1663+
16121664
phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_CONFIG,
16131665
PHY_CONFIG_AUTO);
16141666

0 commit comments

Comments
 (0)