Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: c45-tja11xx: add support for outputting RMII reference clock

For TJA11xx PHYs, they have the capability to output 50MHz reference
clock on REF_CLK pin in RMII mode, which is called "revRMII" mode in
the PHY data sheet.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Wei Fang and committed by
Paolo Abeni
6d8d8987 09277e4f

+30 -1
+29 -1
drivers/net/phy/nxp-c45-tja11xx.c
··· 10 10 #include <linux/kernel.h> 11 11 #include <linux/mii.h> 12 12 #include <linux/module.h> 13 + #include <linux/of.h> 13 14 #include <linux/phy.h> 14 15 #include <linux/processor.h> 15 16 #include <linux/property.h> ··· 185 184 (ppb) * (ptp_clk_period), NSEC_PER_SEC) 186 185 187 186 #define NXP_C45_SKB_CB(skb) ((struct nxp_c45_skb_cb *)(skb)->cb) 187 + 188 + #define TJA11XX_REVERSE_MODE BIT(0) 188 189 189 190 struct nxp_c45_phy; 190 191 ··· 1513 1510 1514 1511 static int nxp_c45_set_phy_mode(struct phy_device *phydev) 1515 1512 { 1513 + struct nxp_c45_phy *priv = phydev->priv; 1514 + u16 basic_config; 1516 1515 int ret; 1517 1516 1518 1517 ret = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_ABILITIES); ··· 1566 1561 phydev_err(phydev, "rmii mode not supported\n"); 1567 1562 return -EINVAL; 1568 1563 } 1564 + 1565 + basic_config = MII_BASIC_CONFIG_RMII; 1566 + 1567 + /* This is not PHY_INTERFACE_MODE_REVRMII */ 1568 + if (priv->flags & TJA11XX_REVERSE_MODE) 1569 + basic_config |= MII_BASIC_CONFIG_REV; 1570 + 1569 1571 phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_MII_BASIC_CONFIG, 1570 - MII_BASIC_CONFIG_RMII); 1572 + basic_config); 1571 1573 break; 1572 1574 case PHY_INTERFACE_MODE_SGMII: 1573 1575 if (!(ret & SGMII_ABILITY)) { ··· 1635 1623 return genphy_c45_pma_read_abilities(phydev); 1636 1624 } 1637 1625 1626 + static int nxp_c45_parse_dt(struct phy_device *phydev) 1627 + { 1628 + struct device_node *node = phydev->mdio.dev.of_node; 1629 + struct nxp_c45_phy *priv = phydev->priv; 1630 + 1631 + if (!IS_ENABLED(CONFIG_OF_MDIO)) 1632 + return 0; 1633 + 1634 + if (of_property_read_bool(node, "nxp,rmii-refclk-out")) 1635 + priv->flags |= TJA11XX_REVERSE_MODE; 1636 + 1637 + return 0; 1638 + } 1639 + 1638 1640 static int nxp_c45_probe(struct phy_device *phydev) 1639 1641 { 1640 1642 struct nxp_c45_phy *priv; ··· 1667 1641 priv->phydev = phydev; 1668 1642 1669 1643 phydev->priv = priv; 1644 + 1645 + nxp_c45_parse_dt(phydev); 1670 1646 1671 1647 mutex_init(&priv->ptp_lock); 1672 1648
+1
drivers/net/phy/nxp-c45-tja11xx.h
··· 28 28 int extts_index; 29 29 bool extts; 30 30 struct nxp_c45_macsec *macsec; 31 + u32 flags; 31 32 }; 32 33 33 34 #if IS_ENABLED(CONFIG_MACSEC)