Add support for VSC85xx DT RGMII delays
Subsystems (3)
v4 cover Add support for VSC85xx DT RGMII delays
Provide an option to change RGMII delay value via devicetree.
v4:
- Remove VSC8531_02 support. Existing code will identify VSC8531_01/02 and there is no unique functionality to be added for either version.
- Correct type of rx/tx_delay to accept correct return value.
- Added Andrew's tag to patch 1
Lore link for v3:
https://lore.kernel.org/netdev/[email protected]/
v3 changes:
- Remove patch 2/3 from v2 as custom mscc properties dont need to be defined. rx-internal-delay-ps and tx-internal-delay-ps can be used.
- Change RGMII delay precedence as advised by Vladimir:
phy-mode rgmii rgmii-rxid/rgmii-id
--------------------------------------------------------------------------------------------
rx-internal-delay-ps absent 0.2 ns 2 ns rx-internal-delay-ps present follow rx-internal-delay-ps follow rx-internal-delay-ps
- Split VSC8531-02 and RGMII delay config into separate patches.
- Correct vendor ID
- Update commit description and subject everywhere to say RGMII delays instead of RGMII tuning.
v2 changes:
- Added patch to use a common vendor phy id match
- Removed dt include header patch because delays should be specied in ps, not register values
- Updated DT binding description and commit for optional delay tuning to be clearer on the precedence
- Updated dt property name to include vendor instead of phy device name
- Switch both VSC8531 and VSC8531-02 to use exact phy id match as they share the same model number
- Ensure RCT
- Improve optional property read
Harini Katakam (2):
phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table
phy: mscc: Add support for RGMII delay configuration
drivers/net/phy/mscc/mscc.h | 3 ++ drivers/net/phy/mscc/mscc_main.c | 49 +++++++++++++++++++------------- 2 files changed, 32 insertions(+), 20 deletions(-)
Signature · 1 line
2.17.1
PATCH v4 1/2 phy: mscc: Use PHY_ID_MATCH_VENDOR to minimize PHY ID table
All the PHY devices variants specified have the same mask and hence can be simplified to one vendor look up for 0x00070400. Any individual config can be identified by PHY_ID_MATCH_EXACT in the respective structure.
---
v4:
Added Andrew's tag
v3:
Correct vendor ID
v2:
New patch
drivers/net/phy/mscc/mscc.h | 1 + drivers/net/phy/mscc/mscc_main.c | 14 +------------- 2 files changed, 2 insertions(+), 13 deletions(-)
drivers/net/phy/mscc/mscc.h +1 -0
@@ -290,6 +290,7 @@ enum rgmii_clock_delay {#define PHY_ID_VSC8575 0x000707d0#define PHY_ID_VSC8582 0x000707b0#define PHY_ID_VSC8584 0x000707c0 +#define PHY_VENDOR_MSCC 0x00070400#define MSCC_VDDMAC_1500 1500#define MSCC_VDDMAC_1800 1800
drivers/net/phy/mscc/mscc_main.c +1 -13
@@ -2656,19 +2656,7 @@ static struct phy_driver vsc85xx_driver[] = {module_phy_driver (vsc85xx_driver);static struct mdio_device_id __maybe_unused vsc85xx_tbl[] = { - {PHY_ID_VSC8504 ,0xfffffff0 , }, - {PHY_ID_VSC8514 ,0xfffffff0 , }, - {PHY_ID_VSC8530 ,0xfffffff0 , }, - {PHY_ID_VSC8531 ,0xfffffff0 , }, - {PHY_ID_VSC8540 ,0xfffffff0 , }, - {PHY_ID_VSC8541 ,0xfffffff0 , }, - {PHY_ID_VSC8552 ,0xfffffff0 , }, - {PHY_ID_VSC856X ,0xfffffff0 , }, - {PHY_ID_VSC8572 ,0xfffffff0 , }, - {PHY_ID_VSC8574 ,0xfffffff0 , }, - {PHY_ID_VSC8575 ,0xfffffff0 , }, - {PHY_ID_VSC8582 ,0xfffffff0 , }, - {PHY_ID_VSC8584 ,0xfffffff0 , }, + {PHY_ID_MATCH_VENDOR (PHY_VENDOR_MSCC ) }, { } };
Signature · 1 line
2.17.1
PATCH v4 2/2 phy: mscc: Add support for RGMII delay configuration
In reply to Harini KatakamAdd support for optional rx/tx-internal-delay-ps from devicetree.
- When rx/tx-internal-delay-ps is/are specified, these take priority
- When either is absent,
1) use 2ns for respective settings if rgmii-id/rxid/txid is/are present
2) use 0.2ns for respective settings if mode is rgmii
---
v4:
Fix type of rx_delay and tx_delay
Reported by Simon Horman and
v3 - Patch split:
- Use rx/tx-internal-delay-ps with phy_get_internal_delay
- Change RGMII delay selection precedence
- Update commit description and subject everywhere to say RGMII delays instead of RGMII tuning.
drivers/net/phy/mscc/mscc.h | 2 ++ drivers/net/phy/mscc/mscc_main.c | 35 +++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-)
drivers/net/phy/mscc/mscc.h +2 -0
@@ -374,6 +374,8 @@ struct vsc8531_private {* package. */ unsigned int base_addr; +s32 rx_delay; +s32 tx_delay;#if IS_ENABLED (CONFIG_MACSEC )/* MACsec fields:
drivers/net/phy/mscc/mscc_main.c +28 -7
@@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, {u16 rgmii_rx_delay_pos =ffs (rgmii_rx_delay_mask) -1 ;u16 rgmii_tx_delay_pos =ffs (rgmii_tx_delay_mask) -1 ; +struct vsc8531_private *vsc8531 = phydev->priv;u16 reg_val =0 ;int rc;mutex_lock (&phydev->lock); -if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) - reg_val |=RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos; -if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) - reg_val |=RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos; + reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos; + reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos; rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, rgmii_cntl,
@@ -1808,10 +1805,34 @@ static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev)return IRQ_HANDLED ; } +static const int vsc8531_internal_delay[] = {200 ,800 ,1100 ,1700 ,2000 ,2300 , +2600 ,3400 };static int vsc85xx_config_init (struct phy_device *phydev) { -int rc, i, phy_id; +int delay_size =ARRAY_SIZE (vsc8531_internal_delay);struct vsc8531_private *vsc8531 = phydev->priv; +struct device *dev = &phydev->mdio.dev; +int rc, i, phy_id; + + vsc8531->rx_delay =phy_get_internal_delay (phydev, dev, &vsc8531_internal_delay[0 ], + delay_size, true); +if (vsc8531->rx_delay <0 ) { +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID || + phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) + vsc8531->rx_delay =RGMII_CLK_DELAY_2_0_NS ; +else + vsc8531->rx_delay =RGMII_CLK_DELAY_0_2_NS ; + } + + vsc8531->tx_delay =phy_get_internal_delay (phydev, dev, &vsc8531_internal_delay[0 ], + delay_size, false); +if (vsc8531->tx_delay <0 ) { +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID || + phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) + vsc8531->rx_delay =RGMII_CLK_DELAY_2_0_NS ; +else + vsc8531->rx_delay =RGMII_CLK_DELAY_0_2_NS ; + } rc =vsc85xx_default_config (phydev);if (rc)
Signature · 1 line
2.17.1
Jakub Kicinski
maintainerRe: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
Quoted 7 lines · On Mon, 22 May 2023 17:58:29 +0530 Harini Katakam wrote:
Add support for optional rx/tx-internal-delay-ps from devicetree.
- When rx/tx-internal-delay-ps is/are specified, these take priority
- When either is absent,
1) use 2ns for respective settings if rgmii-id/rxid/txid is/are present
2) use 0.2ns for respective settings if mode is rgmiiSigned-off-by Harini Katakam <[email protected]>
PHY folks, looks good?
Re: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
In reply to Harini KatakamQuoted 12 lines · Harini Katakam
drivers/net/phy/mscc/mscc_main.c +1
-0@@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, {u16 rgmii_rx_delay_pos =ffs (rgmii_rx_delay_mask) -1 ;u16 rgmii_tx_delay_pos =ffs (rgmii_tx_delay_mask) -1 ; +struct vsc8531_private *vsc8531 = phydev->priv;u16 reg_val =0 ;int rc;
drivers/net/phy/mscc/mscc_main.c static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, · line 535
Quoted 10 lines
drivers/net/phy/mscc/mscc_main.c +2
-6mutex_lock (&phydev->lock); -if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) - reg_val |=RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos; -if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) - reg_val |=RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos; + reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos; + reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos;
What about vsc8584_config_init() -> vsc85xx_rgmii_set_skews()? Who will have configured rx_delay and tx_delay for that call path?
Isn't it better to absorb the device tree parsing logic into vsc85xx_rgmii_set_skews(), I wonder?
And if we do that, is it still necessary to use struct vsc8531_private as temporary storage space from vsc85xx_config_init() to vsc85xx_rgmii_set_skews(), or will two local variables (rx_delay, tx_delay) serve that purpose just fine?
drivers/net/phy/mscc/mscc_main.c static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev) · line 1809
Quoted 9 lines
drivers/net/phy/mscc/mscc_main.c +2
-0rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, rgmii_cntl,@@ -1808,10 +1805,34 @@ static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev)return IRQ_HANDLED ; } +static const int vsc8531_internal_delay[] = {200 ,800 ,1100 ,1700 ,2000 ,2300 , +2600 ,3400 };
Could you please avoid intermingling this with the function code, and move it at the top of mscc_main.c?
Also, vsc8531_internal_delay[] or vsc85xx_internal_delay[]? The values are also good for VSC8572, the other caller of vsc85xx_rgmii_set_skews().
drivers/net/phy/mscc/mscc_main.c static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev) · line 1817
Quoted 9 lines
drivers/net/phy/mscc/mscc_main.c +5
-1static int vsc85xx_config_init (struct phy_device *phydev) { -int rc, i, phy_id; +int delay_size =ARRAY_SIZE (vsc8531_internal_delay);struct vsc8531_private *vsc8531 = phydev->priv; +struct device *dev = &phydev->mdio.dev; +int rc, i, phy_id; + + vsc8531->rx_delay = phy_get_internal_delay(phydev, dev, &vsc8531_internal_delay[0],
You can just write "x" rather than "&x[0]".
Quoted 24 lines
drivers/net/phy/mscc/mscc_main.c +18
-0+ delay_size, true); +if (vsc8531->rx_delay <0 ) { +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID || + phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) + vsc8531->rx_delay =RGMII_CLK_DELAY_2_0_NS ; +else + vsc8531->rx_delay =RGMII_CLK_DELAY_0_2_NS ; + } + + vsc8531->tx_delay =phy_get_internal_delay (phydev, dev, &vsc8531_internal_delay[0 ], + delay_size, false); +if (vsc8531->tx_delay <0 ) { +if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID || + phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) + vsc8531->rx_delay =RGMII_CLK_DELAY_2_0_NS ; +else + vsc8531->rx_delay =RGMII_CLK_DELAY_0_2_NS ; + } rc =vsc85xx_default_config (phydev);if (rc)Signature · 1 line
2.17.1
RE: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configuration
Hi Vladimir,
Quoted 31 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Wednesday, May 24, 2023 3:39 PM
To: Katakam, Harini <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Simek, Michal <[email protected]>; Pandey, Radhey Shyam <[email protected]>
Subject: Re: [PATCH net-next v4 2/2] phy: mscc: Add support for RGMII delay configurationReview
Quoted 1 line · Harini Katakam
(quoted diff) +0
-0
b/drivers/net/phy/mscc/mscc_main.cdrivers/net/phy/mscc/mscc_main.c static int vsc85xx_rgmii_set_skews(struct
Quoted 4 lines
index
91010524e03d..9e856231e464100644drivers/net/phy/mscc/mscc_main.c +0
-0@@ -525,17 +525,14 @@ static int vsc85xx_rgmii_set_skews(struct
phy_device*phydev, u32rgmii_cntl,Quoted 9 lines
drivers/net/phy/mscc/mscc_main.c +1
-0{u16 rgmii_rx_delay_pos =ffs (rgmii_rx_delay_mask) -1 ;u16 rgmii_tx_delay_pos =ffs (rgmii_tx_delay_mask) -1 ; +struct vsc8531_private *vsc8531 = phydev->priv;u16 reg_val =0 ;int rc;mutex_lock (&phydev->lock);
Quoted 11 lines
drivers/net/phy/mscc/mscc_main.c static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, · line 535
Quoted 8 lines
drivers/net/phy/mscc/mscc_main.c +2
-6-if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_RXID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) - reg_val |=RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos; -if (phydev->interface ==PHY_INTERFACE_MODE_RGMII_TXID || - phydev->interface ==PHY_INTERFACE_MODE_RGMII_ID ) - reg_val |=RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos; + reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos; + reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos;What about
vsc8584_config_init()->vsc85xx_rgmii_set_skews()? Who will have configuredrx_delayandtx_delayfor that call path?
In my current series "rx_delay" and "tx_delay" would end up 0 and a delay of 0.2 ns will be programmed (default for that field).
I guess if the phy-mode is RGMII/-ID on VSC8584, 2ns will not be programmed. This will be a problem for any device not using vsc85xx_config_init
Quoted 3 lines
Isn't it better to absorb the device tree parsing logic into
vsc85xx_rgmii_set_skews(), I wonder?
Yes, that is possible, let me respin. That will ensure existing values are not broken for any VSC85xx user, if they do not have delay properties in the DT.
Quoted 5 lines
And if we do that, is it still necessary to use struct
vsc8531_privateas temporary storage space fromvsc85xx_config_init()tovsc85xx_rgmii_set_skews(),
or will two local variables (rx_delay,tx_delay) serve that purpose just fine?
No need of the structure member, local variables will do.
Quoted 10 lines
drivers/net/phy/mscc/mscc_main.c static irqreturn_t
Quoted 5 lines
drivers/net/phy/mscc/mscc_main.c +0
-0rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, rgmii_cntl,@@ -1808,10 +1805,34 @@ static irqreturn_t
vsc8584_handle_interrupt(struct phy_device *phydev)drivers/net/phy/mscc/mscc_main.c static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev)
Quoted 4 lines
drivers/net/phy/mscc/mscc_main.c +1
-0return IRQ_HANDLED ; } +static const int vsc8531_internal_delay[] = {200 ,800 ,1100 ,1700 ,2000 ,
Quoted 8 lines
2300,
drivers/net/phy/mscc/mscc_main.c static irqreturn_t vsc8584_handle_interrupt(struct phy_device *phydev) · line 1809
Quoted 1 line
drivers/net/phy/mscc/mscc_main.c +1
-0+ 2600, 3400};Could you please avoid intermingling this with the function code, and move it at the top of
mscc_main.c?Also, vsc8531_internal_delay[] or vsc85xx_internal_delay[]? The values are also good for VSC8572, the other caller of
vsc85xx_rgmii_set_skews().
vsc85xx_internal_delay is more appropriate, will change.
Thanks for the review.
Regards,
Harini
Hi Harini,
Quoted 7 lines · Harini Katakam
Provide an option to change RGMII delay value via devicetree.
v4:
- RemoveVSC8531_02support. Existing code will identify VSC8531_01/02 and there is no unique functionality to be added for either version.
- Correct type of rx/tx_delay to accept correct return value.
- Added Andrew's tag to patch 1
Would you mind waiting until this patch set for "net" is merged first, then rebasing your "net-next" work on top of it?
https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/
You should be able to resend your patch set tomorrow, after the net pull request and the subsequent net -> net-next merge.
There are going to be merge conflicts if your series gets applied simultaneously, and they're ugly enough that I would prefer you to deal with them locally, before submitting, rather than leaving the netdev maintainers do it.
Hi Vladimir,
Quoted 30 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Wednesday, May 24, 2023 3:27 PM
To: Katakam, Harini <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; Simek, Michal <[email protected]>; Pandey, Radhey Shyam <[email protected]>
Subject: Re: [PATCH net-next v4 0/2] Add support for VSC85xx DT RGMII delaysHi Harini,
Quoted 7 lines · Harini Katakam
Provide an option to change RGMII delay value via devicetree.
v4:
- RemoveVSC8531_02support. Existing code will identify VSC8531_01/02 and there is no unique functionality to be added for either version.
- Correct type of rx/tx_delay to accept correct return value.
- Added Andrew's tag to patch 1Would you mind waiting until this patch set for "net" is merged first, then rebasing your "net-next" work on top of it?
https://patchwork.kernel.org/project/netdevbpf/cover/20230523153108.1854
[email protected]/
Quoted 7 lines
You should be able to resend your patch set tomorrow, after the net pull request and the subsequent net -> net-next merge.
There are going to be merge conflicts if your series gets applied simultaneously, and they're ugly enough that I would prefer you to deal with them locally, before submitting, rather than leaving the netdev maintainers do it.
Ok sure, I'll wait and rebase after the above set is merged.
Regards,
Harini