net: phy: mscc: support VSC8501
Subsystems (3)
v3 cover net: phy: mscc: support VSC8501
Hello,
this updated series of patches adds support for the VSC8501 Ethernet PHY and fixes support for the VSC8502 PHY in cases where no other software (like U-Boot) has initialized the PHY after power up.
The first patch simply adds the VSC8502 to the MODULE_DEVICE_TABLE, where I guess it was unintentionally missing. I have no hardware to test my change.
The second patch adds the VSC8501 PHY with exactly the same driver implementation as the existing VSC8502.
The (new) third patch removes phydev locking from vsc85xx_rgmii_set_skews(), as discussed for v2 of the patch set.
The (now) fourth patch fixes the initialization for VSC8501 and VSC8502. I have tested this patch with VSC8501 on hardware in RGMII mode only.
https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/DataSheets/VSC8501-03_Datasheet_60001741A.PDF
https://ww1.microchip.com/downloads/aemDocuments/documents/UNG/ProductDocuments/DataSheets/VSC8502-03_Datasheet_60001742B.pdf
Table 4-42 "RGMII CONTROL, ADDRESS 20E2 (0X14)" Bit 11 for each of them.
By default the RX_CLK is disabled for these PHYs. In cases where no other software, like U-Boot, enabled the clock, this results in no received packets being handed to the MAC.
The patch enables this clock output.
According to Microchip support (case number 01268776) this applies to all modes (RGMII, GMII, and MII).
Other PHYs sharing the same register map and code, like VSC8530/31/40/41 have the clock enabled and the relevant bit 11 is reserved and read-only for them. As per previous discussion the patch still clears the bit on these PHYs, too, possibly more easily supporting other future PHYs implementing this functionality.
For the VSC8572 family of PHYs, having a different register map, no such changes are applied.
Thanks for your feedback,
David
--
Changes in v3:
- adjust cover letter and "additional notes"
- insert new patch to remove phydev locks from set_skews()
Changes in v2:
- adjust cover letter (U-Boot, PHY families)
- add reviewed-by tags to patch 1/3 and 2/3
- patch 3/3: combine vsc85xx_rgmii_set_skews() and vsc85xx_rgmii_enable_rx_clk() into vsc85xx_update_rgmii_cntl() for fewer MDIO accesses
- patch 3/3: treat all VSC8502 family PHYs the same (regardless of bit 11 reserved status)
Additional notes:
- If you want to, feel free to add something like
Co developed by ... I did not do that, because the Kernel documentation requires a signed off by to go with it. Significant parts of the new patch are from your emails.
- For cases of not RGMII mode and not VSC8502 family there is no MDIO access. Same as with the current mainline code.
--
David Epping (4):
net: phy: mscc: add VSC8502 to MODULE_DEVICE_TABLE
net: phy: mscc: add support for VSC8501
net: phy: mscc: remove unnecessary phydev locking
net: phy: mscc: enable VSC8501/2 RGMII RX clock
drivers/net/phy/mscc/mscc.h | 2 + drivers/net/phy/mscc/mscc_main.c | 82 +++++++++++++++++++++----------- 2 files changed, 55 insertions(+), 29 deletions(-)
base-commit: 3632679d9e4f879f49949bb5b050e0de553e4739
Signature · 1 line
2.17.1
PATCH v3 1/4 net: phy: mscc: add VSC8502 to MODULE_DEVICE_TABLE
The mscc driver implements support for VSC8502, so its ID should be in the MODULE_DEVICE_TABLE for automatic loading.
--- drivers/net/phy/mscc/mscc_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/mscc/mscc_main.c +1 -0
@@ -2656,6 +2656,7 @@ static struct phy_driver vsc85xx_driver[] = {module_phy_driver (vsc85xx_driver);static struct mdio_device_id __maybe_unused vsc85xx_tbl[] = { + {PHY_ID_VSC8502 ,0xfffffff0 , }, {PHY_ID_VSC8504 ,0xfffffff0 , }, {PHY_ID_VSC8514 ,0xfffffff0 , }, {PHY_ID_VSC8530 ,0xfffffff0 , },
Signature · 1 line
2.17.1
PATCH v3 2/4 net: phy: mscc: add support for VSC8501
In reply to David EppingThe VSC8501 PHY can use the same driver implementation as the VSC8502. Adding the PHY ID and copying the handler functions of VSC8502 is sufficient to operate it.
--- drivers/net/phy/mscc/mscc.h | 1 + drivers/net/phy/mscc/mscc_main.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
drivers/net/phy/mscc/mscc.h +1 -0
@@ -276,6 +276,7 @@ enum rgmii_clock_delay {/* Microsemi PHY ID's * Code assumes lowest nibble is 0 */ +#define PHY_ID_VSC8501 0x00070530#define PHY_ID_VSC8502 0x00070630#define PHY_ID_VSC8504 0x000704c0#define PHY_ID_VSC8514 0x00070670
drivers/net/phy/mscc/mscc_main.c +25 -0
@@ -2316,6 +2316,30 @@ static int vsc85xx_probe(struct phy_device *phydev)/* Microsemi VSC85xx PHYs */ static struct phy_driver vsc85xx_driver[] = { +{ + .phy_id =PHY_ID_VSC8501 , + .name ="Microsemi GE VSC8501 SyncE" , + .phy_id_mask =0xfffffff0 , +/* PHY_BASIC_FEATURES */ + .soft_reset = &genphy_soft_reset, + .config_init = &vsc85xx_config_init, + .config_aneg = &vsc85xx_config_aneg, + .read_status = &vsc85xx_read_status, + .handle_interrupt = vsc85xx_handle_interrupt, + .config_intr = &vsc85xx_config_intr, + .suspend = &genphy_suspend, + .resume = &genphy_resume, + .probe = &vsc85xx_probe, + .set_wol = &vsc85xx_wol_set, + .get_wol = &vsc85xx_wol_get, + .get_tunable = &vsc85xx_get_tunable, + .set_tunable = &vsc85xx_set_tunable, + .read_page = &vsc85xx_phy_read_page, + .write_page = &vsc85xx_phy_write_page, + .get_sset_count = &vsc85xx_get_sset_count, + .get_strings = &vsc85xx_get_strings, + .get_stats = &vsc85xx_get_stats, +}, { .phy_id =PHY_ID_VSC8502 , .name ="Microsemi GE VSC8502 SyncE" ,
@@ -2656,6 +2680,7 @@ static struct phy_driver vsc85xx_driver[] = {module_phy_driver (vsc85xx_driver);static struct mdio_device_id __maybe_unused vsc85xx_tbl[] = { + {PHY_ID_VSC8501 ,0xfffffff0 , }, {PHY_ID_VSC8502 ,0xfffffff0 , }, {PHY_ID_VSC8504 ,0xfffffff0 , }, {PHY_ID_VSC8514 ,0xfffffff0 , },
Signature · 1 line
2.17.1
PATCH v3 3/4 net: phy: mscc: remove unnecessary phydev locking
In reply to David EppingHolding the struct phy_device (phydev) lock is unnecessary when accessing phydev->interface in the PHY driver .config_init method, which is the only place that vsc85xx_rgmii_set_skews() is called from.
The phy_modify_paged() function implements required MDIO bus level locking, which can not be achieved by a phydev lock.
--- drivers/net/phy/mscc/mscc_main.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/phy/mscc/mscc_main.c +0 -4
@@ -528,8 +528,6 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,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;
@@ -542,8 +540,6 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl, rgmii_rx_delay_mask | rgmii_tx_delay_mask, reg_val); -mutex_unlock (&phydev->lock); -return rc; }
Signature · 1 line
2.17.1
PATCH v3 4/4 net: phy: mscc: enable VSC8501/2 RGMII RX clock
In reply to David EppingBy default the VSC8501 and VSC8502 RGMII/GMII/MII RX_CLK output is disabled. To allow packet forwarding towards the MAC it needs to be enabled.
For other PHYs supported by this driver the clock output is enabled by default.
--- drivers/net/phy/mscc/mscc.h | 1 + drivers/net/phy/mscc/mscc_main.c | 54 +++++++++++++++++--------------- 2 files changed, 29 insertions(+), 26 deletions(-)
drivers/net/phy/mscc/mscc.h +1 -0
@@ -179,6 +179,7 @@ enum rgmii_clock_delay {#define VSC8502_RGMII_CNTL 20#define VSC8502_RGMII_RX_DELAY_MASK 0x0070#define VSC8502_RGMII_TX_DELAY_MASK 0x0007 +#define VSC8502_RGMII_RX_CLK_DISABLE 0x0800#define MSCC_PHY_WOL_LOWER_MAC_ADDR 21#define MSCC_PHY_WOL_MID_MAC_ADDR 22
drivers/net/phy/mscc/mscc_main.c +28 -26
84 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH net v3 4/4] net: phy: mscc: enable VSC8501/2 RGMII RX clock
Quoted 8 lines · David Epping
By default the VSC8501 and VSC8502 RGMII/GMII/MII
RX_CLKoutput is disabled. To allow packet forwarding towards the MAC it needs to be enabled.For other PHYs supported by this driver the clock output is enabled by default.
Signed-off-by David Epping <[email protected]>
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 net v3 3/4] net: phy: mscc: remove unnecessary phydev locking
In reply to David EppingQuoted 8 lines · David Epping
Holding the struct
phy_device(phydev) lock is unnecessary when accessingphydev->interfacein the PHY driver .config_init method, which is the only place thatvsc85xx_rgmii_set_skews()is called from.The
phy_modify_paged()function implements required MDIO bus level locking, which can not be achieved by a phydev lock.Signed-off-by David Epping <[email protected]>
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 net v3 4/4] net: phy: mscc: enable VSC8501/2 RGMII RX clock
In reply to David EppingQuoted 9 lines · David Epping
By default the VSC8501 and VSC8502 RGMII/GMII/MII
RX_CLKoutput is disabled. To allow packet forwarding towards the MAC it needs to be enabled.For other PHYs supported by this driver the clock output is enabled by default.
Signed-off-by David Epping <[email protected]>---
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 23 May 2023 17:31:04 +0200 you wrote:
Hello,
this updated series of patches adds support for the VSC8501 Ethernet PHY and fixes support for the VSC8502 PHY in cases where no other software (like U-Boot) has initialized the PHY after power up.
The first patch simply adds the VSC8502 to the
MODULE_DEVICE_TABLE, where I guess it was unintentionally missing. I have no hardware to test my change.[...]
Here is the summary with links:
- [net,v3,1/4] net: phy: mscc: add VSC8502 to MODULE_DEVICE_TABLE
https://git.kernel.org/netdev/net/c/57fb54ab9f69 - [net,v3,2/4] net: phy: mscc: add support for VSC8501 https://git.kernel.org/netdev/net/c/fb055ce4a9e3 - [net,v3,3/4] net: phy: mscc: remove unnecessary phydev locking https://git.kernel.org/netdev/net/c/7df0b33d7993 - [net,v3,4/4] net: phy: mscc: enable VSC8501/2 RGMII RX clock https://git.kernel.org/netdev/net/c/71460c9ec5c7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html