make PHY output RMII reference clock
Subsystems (6)
v2 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 Linl: https://lore.kernel.org/imx/[email protected]/
---
Wei Fang (2):
dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
net: phy: c45-tja11xx: add support for outputing RMII reference clock
.../devicetree/bindings/net/nxp,tja11xx.yaml | 18 ++++++++++++ drivers/net/phy/nxp-c45-tja11xx.c | 29 +++++++++++++++++-- drivers/net/phy/nxp-c45-tja11xx.h | 1 + 3 files changed, 46 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 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 is 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.
V3 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.
--- .../devicetree/bindings/net/nxp,tja11xx.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +18 -0
@@ -62,6 +62,24 @@ 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. This + property is only applicable to nxp-c45-tja11xx driver. + patternProperties: "^ethernet-phy@[0-9a-f]+$": type: object
Signature · 1 line
2.34.1
Rob Herring
maintainerRe: [PATCH v2 net-next 1/2] dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
Quoted 51 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 is 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 on
REF_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.
V3 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.--- .../devicetree/bindings/net/nxp,tja11xx.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +5
-0@@ -62,6 +62,24 @@ allOf: reference clock output when RMII mode enabled. Only supported on TJA1100 and TJA1101. + - if: + properties: + compatible: + contains: + enum:
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml allOf: · line 79
Quoted 10 lines
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +10
-0+ - 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: |
Don't need '|' if no formatting.
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml allOf: · line 81
Quoted 2 lines
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +2
-0+ Enable 50MHz RMII reference clock output on REF_CLK pin. This + property is only applicable to nxp-c45-tja11xx driver.
Reword this to not be about some driver.
Quoted 7 lines
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +1
-0+ patternProperties: "^ethernet-phy@[0-9a-f]+$": type: objectSignature · 1 line
2.34.1
RE: [PATCH v2 net-next 1/2] dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
Quoted 79 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: 2024年10月9日 23:12
To: Wei Fang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Andrei Botila (OSS) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 net-next 1/2] dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" propertyQuoted 52 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 is 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 on
REF_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.
V3 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.--- .../devicetree/bindings/net/nxp,tja11xx.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +5
-0@@ -62,6 +62,24 @@ allOf: reference clock output when RMII mode enabled. Only supported on TJA1100 and TJA1101. + - if: + properties: + compatible: + contains: + enum:Documentation/devicetree/bindings/net/nxp,tja11xx.yaml allOf: · line 79
Quoted 10 lines
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +10
-0+ - 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: |Don't need '|' if no formatting.
Quoted 5 lines
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml allOf: · line 80
Quoted 1 line
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +1
-0+ Enable 50MHz RMII reference clock output on REF_CLK pin.This
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml allOf: · line 81
Quoted 1 line
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +1
-0+ property is only applicable to nxp-c45-tja11xx driver.Reword this to not be about some driver.
Thanks, I will refine it
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/net/nxp,tja11xx.yaml +1
-1+ patternProperties: "^ethernet-phy@[0-9a-f]+$": type: object --2.34.1
PATCH v2 2/2 net: phy: c45-tja11xx: add support for outputing 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.
--- drivers/net/phy/nxp-c45-tja11xx.c | 29 +++++++++++++++++++++++++++-- drivers/net/phy/nxp-c45-tja11xx.h | 1 + 2 files changed, 28 insertions(+), 2 deletions(-)
drivers/net/phy/nxp-c45-tja11xx.c +27 -2
@@ -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,7 @@ 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;int ret; ret =phy_read_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_ABILITIES );
@@ -1561,8 +1565,13 @@ static int nxp_c45_set_phy_mode(struct phy_device *phydev)phydev_err (phydev,"rmii mode not supported\n" );return -EINVAL ; } -phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , -MII_BASIC_CONFIG_RMII ); + +if (priv->flags &TJA11XX_REVERSE_MODE ) +phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , +MII_BASIC_CONFIG_RMII |MII_BASIC_CONFIG_REV ); +else +phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , +MII_BASIC_CONFIG_RMII );break ;case PHY_INTERFACE_MODE_SGMII :if (!(ret &SGMII_ABILITY )) {
@@ -1623,6 +1632,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 +1665,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
Russell King (Oracle)
reviewerRe: [PATCH v2 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clock
drivers/net/phy/nxp-c45-tja11xx.c static int nxp_c45_set_phy_mode(struct phy_device *phydev) · line 1574
Quoted 13 lines · Wei Fang
drivers/net/phy/nxp-c45-tja11xx.c +7
-2@@ -1561,8 +1565,13 @@ static int nxp_c45_set_phy_mode(struct phy_device *phydev)phydev_err (phydev,"rmii mode not supported\n" );return -EINVAL ; } -phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , -MII_BASIC_CONFIG_RMII ); + +if (priv->flags &TJA11XX_REVERSE_MODE ) +phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , +MII_BASIC_CONFIG_RMII |MII_BASIC_CONFIG_REV ); +else +phy_write_mmd (phydev,MDIO_MMD_VEND1 ,VEND1_MII_BASIC_CONFIG , +MII_BASIC_CONFIG_RMII );
Netdev has an 80 column limit, and this needs commenting because we have PHY_INTERFACE_MODE_REVRMII which could be confused with this (although I haven't checked.)
u16 basic_config; ... 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, basic_config);
is much nicer to read.
Thanks.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
RE: [PATCH v2 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clock
Quoted 49 lines
-----Original Message-----
From: Russell King <[email protected]>
Sent: 2024年10月8日 16:31
To: Wei Fang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Andrei Botila (OSS) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clockReview static int nxp_c45_set_phy_mode(struct
Quoted 1 line · Wei Fang
(quoted diff) +0
-0@@ -1561,8 +1565,13 @@ static int nxp_c45_set_phy_mode(struct
phy_device*phydev)drivers/net/phy/nxp-c45-tja11xx.c static int nxp_c45_set_phy_mode(struct phy_device *phydev)
Quoted 4 lines
drivers/net/phy/nxp-c45-tja11xx.c +0
-1phydev_err (phydev,"rmii mode not supported\n" );return -EINVAL ; } - phy_write_mmd(phydev, MDIO_MMD_VEND1,
VEND1_MII_BASIC_CONFIG,drivers/net/phy/nxp-c45-tja11xx.c static int nxp_c45_set_phy_mode(struct phy_device *phydev)
Quoted 4 lines
drivers/net/phy/nxp-c45-tja11xx.c +3
-1- MII_BASIC_CONFIG_RMII); + +if (priv->flags &TJA11XX_REVERSE_MODE ) + phy_write_mmd(phydev, MDIO_MMD_VEND1,
VEND1_MII_BASIC_CONFIG,Review static int nxp_c45_set_phy_mode(struct · line 1571
Quoted 1 line
(quoted diff) +1
-0+ MII_BASIC_CONFIG_RMII |
MII_BASIC_CONFIG_REV);Review static int nxp_c45_set_phy_mode(struct · line 1573
Quoted 2 lines
(quoted diff) +2
-0+ else + phy_write_mmd(phydev, MDIO_MMD_VEND1,
VEND1_MII_BASIC_CONFIG,drivers/net/phy/nxp-c45-tja11xx.c static int nxp_c45_set_phy_mode(struct phy_device *phydev) · line 1574
Quoted 1 line
drivers/net/phy/nxp-c45-tja11xx.c +1
-0+ MII_BASIC_CONFIG_RMII);Netdev has an 80 column limit, and this needs commenting because we have
PHY_INTERFACE_MODE_REVRMIIwhich could be confused with this (although I haven't checked.)u16 basic_config; ... 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, basic_config);
Quoted 2 lines
is much nicer to read.
Okay, I will refine the patch, thanks!
Simon Horman
reviewerRe: [PATCH v2 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clock
In reply to Wei FangQuoted 5 lines · Wei Fang
For TJA11xx PHYs, they have the capability to output 50MHz reference clock on
REF_CLKpin in RMII mode, which is called "revRMII" mode in the PHY data sheet.Signed-off-by Wei Fang <[email protected]>
Hi,
As it looks like there will be a v3 anyway,
please consider correcting the spelling of outputting in the subject.
Thanks!
RE: [PATCH v2 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clock
Quoted 18 lines
-----Original Message-----
From: Simon Horman <[email protected]>
Sent: 2024年10月9日 19:58
To: Wei Fang <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Andrei Botila (OSS) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 net-next 2/2] net: phy: c45-tja11xx: add support for outputing RMII reference clockQuoted 4 lines · Wei Fang
For TJA11xx PHYs, they have the capability to output 50MHz reference clock on
REF_CLKpin in RMII mode, which is called "revRMII" mode in the PHY data sheet.
Quoted 8 lines
Quoted 1 line
Signed-off-by Wei Fang <[email protected]>Hi,
As it looks like there will be a v3 anyway,
please consider correcting the spelling of outputting in the subject.Thanks!
Thanks for pointing this typo, I will correct it in next version.
Quoted 30 lines
-----Original Message-----
From: Wei Fang
Sent: 2024年10月8日 15:24
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Andrei Botila (OSS) <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v2 net-next 0/2] make PHY output RMII reference clockThe 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.---
v2 Link:
https://lore.kernel.org/netdev/20240823-jersey-conducive-70863dd6fd27@spu
d/T/
v3 Linl:
https://lore.kernel.org/imx/[email protected]/
---Wei Fang (2):
dt-bindings: net: tja11xx: add "nxp,rmii-refclk-out" property
net: phy: c45-tja11xx: add support for outputing RMII reference clock
Quoted 7 lines
.../devicetree/bindings/net/nxp,tja11xx.yaml | 18 ++++++++++++ drivers/net/phy/nxp-c45-tja11xx.c | 29 +++++++++++++++++-- drivers/net/phy/nxp-c45-tja11xx.h | 1 + 3 files changed, 46 insertions(+), 2 deletions(-)--
2.34.1
Sorry for the wrong "v2" descriptor in the tile, it should be "v4". :(