make PHY output RMII reference clock
Subsystems (6)
v5 cover make PHY output RMII reference clock
The TJA11xx PHYs have the capability to provide 50MHz reference clock in RMII mode and output on REF_CLK pin. Therefore, add the new property "nxp,rmii-refclk-output" to support this feature. This property is only available for PHYs which use nxp-c45-tja11xx driver, such as TJA1103, TJA1104, TJA1120 and TJA1121.
---
v2 Link: https://lore.kernel.org/netdev/20240823-jersey-conducive-70863dd6fd27@spud/T/
v3 Link: https://lore.kernel.org/imx/[email protected]/
v4 Link: https://lore.kernel.org/netdev/[email protected]/T/
---
Wei Fang (2):
dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
net: phy: c45-tja11xx: add support for outputting RMII reference clock
.../devicetree/bindings/net/nxp,tja11xx.yaml | 16 ++++++++++ drivers/net/phy/nxp-c45-tja11xx.c | 30 ++++++++++++++++++- drivers/net/phy/nxp-c45-tja11xx.h | 1 + 3 files changed, 46 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH v5 1/2 dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
Per the RMII specification, the REF_CLK is sourced from MAC to PHY or from an external source. But for TJA11xx PHYs, they support to output a 50MHz RMII reference clock on REF_CLK pin. Previously the "nxp,rmii-refclk-in" was added to indicate that in RMII mode, if this property present, REF_CLK is input to the PHY, otherwise it is output. This seems inappropriate now. Because according to the RMII specification, the REF_CLK is originally input, so there is no need to add an additional "nxp,rmii-refclk-in" property to declare that REF_CLK is input.
Unfortunately, because the "nxp,rmii-refclk-in" property has been added for a while, and we cannot confirm which DTS use the TJA1100 and TJA1101 PHYs, changing it to switch polarity will cause an ABI break. But fortunately, this property is only valid for TJA1100 and TJA1101. For TJA1103/TJA1104/TJA1120/TJA1121 PHYs, this property is invalid because they use the nxp-c45-tja11xx driver, which is a different driver from TJA1100/TJA1101. Therefore, for PHYs using nxp-c45-tja11xx driver, add "nxp,rmii-refclk-out" property to support outputting RMII reference clock on REF_CLK pin.
---
V2 changes:
1. Change the property name from "nxp,reverse-mode" to "nxp,phy-output-refclk".
2. Simplify the description of the property.
3. Modify the subject and commit message.
V3 changes:
1. Keep the "nxp,rmii-refclk-in" property for TJA1100 and TJA1101.
2. Rephrase the commit message and subject.
V4 changes:
1. Change the property name from "nxp,phy-output-refclk" to "nxp,rmii-refclk-out", which means the opposite of "nxp,rmii-refclk-in".
2. Refactor the patch after fixing the original issue with this YAML. V5 changes:
1. Reword the description of "nxp,rmii-refclk-out" property.
--- .../devicetree/bindings/net/nxp,tja11xx.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +16 -0
@@ -62,6 +62,22 @@ allOf: reference clock output when RMII mode enabled. Only supported on TJA1100 and TJA1101. + - if: + properties: + compatible: + contains: + enum: + - ethernet-phy-id001b.b010 + - ethernet-phy-id001b.b013 + - ethernet-phy-id001b.b030 + - ethernet-phy-id001b.b031 + + then: + properties: + nxp,rmii-refclk-out: + type: boolean + description: Enable 50MHz RMII reference clock output on REF_CLK pin. + patternProperties: "^ethernet-phy@[0-9a-f]+$": type: object
Signature · 1 line
2.34.1
PATCH v5 2/2 net: phy: c45-tja11xx: add support for outputting RMII reference clock
In reply to Wei FangFor 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.
---
V2 changes:
1. Change the property name.
2. Modify the subject and commit message.
V3 changes:
No changes.
V4 changes:
1. Change the property name based on patch 1.
V5 changes:
1. Fix a typo in the title.
2. Based on Russel's suggestion, add comment to MII_BASIC_CONFIG_REV and the basic_config variable to make the code clearer.
--- drivers/net/phy/nxp-c45-tja11xx.c | 30 +++++++++++++++++++++++++++++- drivers/net/phy/nxp-c45-tja11xx.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-)
drivers/net/phy/nxp-c45-tja11xx.c +29 -1
@@ -10,6 +10,7 @@#include <linux/kernel.h> #include <linux/mii.h> #include <linux/module.h> +#include <linux/of.h> #include <linux/phy.h> #include <linux/processor.h> #include <linux/property.h>
@@ -185,6 +186,8 @@#define NXP_C45_SKB_CB (skb) ((struct nxp_c45_skb_cb *)(skb)->cb) +#define TJA11XX_REVERSE_MODE BIT(0) +struct nxp_c45_phy ;struct nxp_c45_skb_cb {
@@ -1510,6 +1513,8 @@ static int nxp_c45_get_delays(struct phy_device *phydev)static int nxp_c45_set_phy_mode (struct phy_device *phydev) { +struct nxp_c45_phy *priv = phydev->priv; +u16 basic_config;int ret; ret =phy_read_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_ABILITIES );
@@ -1561,8 +1566,15 @@ static int nxp_c45_set_phy_mode(struct phy_device *phydev)phydev_err (phydev,"rmii mode not supported\n" );return -EINVAL ; } + + basic_config =MII_BASIC_CONFIG_RMII ; + +/* This is not PHY_INTERFACE_MODE_REVRMII */ +if (priv->flags &TJA11XX_REVERSE_MODE ) + basic_config |=MII_BASIC_CONFIG_REV ; +phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , -MII_BASIC_CONFIG_RMII ); + basic_config);break ;case PHY_INTERFACE_MODE_SGMII :if (!(ret &SGMII_ABILITY )) {
@@ -1623,6 +1635,20 @@ static int nxp_c45_get_features(struct phy_device *phydev)return genphy_c45_pma_read_abilities (phydev); } +static int nxp_c45_parse_dt (struct phy_device *phydev) +{ +struct device_node *node = phydev->mdio.dev.of_node; +struct nxp_c45_phy *priv = phydev->priv; + +if (!IS_ENABLED (CONFIG_OF_MDIO )) +return 0 ; + +if (of_property_read_bool (node,"nxp,rmii-refclk-out" )) + priv->flags |=TJA11XX_REVERSE_MODE ; + +return 0 ; +} +static int nxp_c45_probe (struct phy_device *phydev) {struct nxp_c45_phy *priv;
@@ -1642,6 +1668,8 @@ static int nxp_c45_probe(struct phy_device *phydev) phydev->priv = priv; +nxp_c45_parse_dt (phydev); +mutex_init (&priv->ptp_lock); phy_abilities = phy_read_mmd(phydev, MDIO_MMD_VEND1,
drivers/net/phy/nxp-c45-tja11xx.h +1 -0
@@ -28,6 +28,7 @@ struct nxp_c45_phy {int extts_index;bool extts;struct nxp_c45_macsec *macsec; +u32 flags; };#if IS_ENABLED (CONFIG_MACSEC )
Signature · 1 line
2.34.1
Re: [PATCH v5 net-next 1/2] dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
In reply to Wei FangQuoted 35 lines · Wei Fang
Per the RMII specification, the
REF_CLKis sourced from MAC to PHY or from an external source. But for TJA11xx PHYs, they support to output a 50MHz RMII reference clock onREF_CLKpin. Previously the "nxp,rmii-refclk-in" was added to indicate that in RMII mode, if this property present,REF_CLKis input to the PHY, otherwise it is output. This seems inappropriate now. Because according to the RMII specification, theREF_CLKis originally input, so there is no need to add an additional "nxp,rmii-refclk-in" property to declare thatREF_CLKis input.
Unfortunately, because the "nxp,rmii-refclk-in" property has been added for a while, and we cannot confirm which DTS use the TJA1100 and TJA1101 PHYs, changing it to switch polarity will cause an ABI break. But fortunately, this property is only valid for TJA1100 and TJA1101. For TJA1103/TJA1104/TJA1120/TJA1121 PHYs, this property is invalid because they use the nxp-c45-tja11xx driver, which is a different driver from TJA1100/TJA1101. Therefore, for PHYs using nxp-c45-tja11xx driver, add "nxp,rmii-refclk-out" property to support outputting RMII reference clock onREF_CLKpin.Signed-off-by Wei Fang <[email protected]>---
V2 changes:
1. Change the property name from "nxp,reverse-mode" to "nxp,phy-output-refclk".
2. Simplify the description of the property.
3. Modify the subject and commit message.
V3 changes:
1. Keep the "nxp,rmii-refclk-in" property for TJA1100 and TJA1101.
2. Rephrase the commit message and subject.
V4 changes:
1. Change the property name from "nxp,phy-output-refclk" to "nxp,rmii-refclk-out", which means the opposite of "nxp,rmii-refclk-in".
2. Refactor the patch after fixing the original issue with this YAML. V5 changes:
1. Reword the description of "nxp,rmii-refclk-out" property.
Quoted 4 lines
--- .../devicetree/bindings/net/nxp,tja11xx.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Thu, 10 Oct 2024 14:19:42 +0800 you wrote:
The TJA11xx PHYs have the capability to provide 50MHz reference clock in RMII mode and output on
REF_CLKpin. Therefore, add the new property "nxp,rmii-refclk-output" to support this feature. This property is only available for PHYs which use nxp-c45-tja11xx driver, such as TJA1103, TJA1104, TJA1120 and TJA1121.[...]
Here is the summary with links:
- [v5,net-next,1/2] dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
https://git.kernel.org/netdev/net-next/c/09277e4fc9a6 - [v5,net-next,2/2] net: phy: c45-tja11xx: add support for outputting RMII reference clock https://git.kernel.org/netdev/net-next/c/6d8d89873ae0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html