PolarFire SoC macb reset support
Subsystems (5)
Conor Dooley
reviewerv3 cover PolarFire SoC macb reset support
Hey all,
Jakub requested that these patches be split off from the series adding the reset controller itself that I sent ~yesterday~ last week [0].
The Cadence MACBs on PolarFire SoC (MPFS) have reset capability and are compatible with the zynqmp's init function. I have removed the zynqmp specific comments from that function & renamed it to reflect what it does, since it is no longer zynqmp only.
MPFS's MACB had previously used the generic binding, so I also added the required specific binding.
For v2, I noticed some low hanging cleanup fruit so there are extra patches added for that:
moving the init function out of the config structs, aligning the alignment of the zynqmp & default config structs with the other dozen or so structs & simplifing the error paths to use dev_err_probe().
Feel free to apply as many or as few of those as you like.
Thanks,
Conor.
Changes since v2:
- Fix a commit message typo
Changes since v1:
- added the 3 aforementioned cleanup patches
- fixed two stylistic complaints from Claudiu
Conor Dooley (5):
dt-bindings: net: cdns,macb: document polarfire soc's macb
net: macb: add polarfire soc reset support
net: macb: unify macb_config alignment style
net: macb: simplify error paths in init_reset_optional()
net: macb: sort init_reset_optional() with other init()s
.../devicetree/bindings/net/cdns,macb.yaml | 1 + drivers/net/ethernet/cadence/macb_main.c | 106 +++++++++--------- 2 files changed, 56 insertions(+), 51 deletions(-)
Signature · 1 line
2.36.1
Conor Dooley
reviewerPATCH v3 1/5 dt-bindings: net: cdns,macb: document polarfire soc's macb
Until now the PolarFire SoC (MPFS) has been using the generic "cdns,macb" compatible but has optional reset support. Add a specific compatible which falls back to the currently used generic binding.
--- Documentation/devicetree/bindings/net/cdns,macb.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/cdns,macb.yaml +1 -0
@@ -28,6 +28,7 @@ properties: - enum: - cdns,at91sam9260-macb # Atmel at91sam9 SoCs - cdns,sam9x60-macb # Microchip sam9x60 SoC + - microchip,mpfs-macb # Microchip PolarFire SoC - const: cdns,macb # Generic - items:
Signature · 1 line
2.36.1
Conor Dooley
reviewerPATCH v3 2/5 net: macb: add polarfire soc reset support
In reply to Conor DooleyTo date, the Microchip PolarFire SoC (MPFS) has been using the cdns,macb compatible, however the generic device does not have reset support. Add a new compatible & .data for MPFS to hook into the reset functionality added for zynqmp support (and make the zynqmp init function generic in the process).
--- drivers/net/ethernet/cadence/macb_main.c | 26 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +18 -8
@@ -4689,34 +4689,32 @@ static const struct macb_config np4_config = { .usrio = &macb_default_usrio, }; -static int zynqmp_init (struct platform_device *pdev) +static int init_reset_optional (struct platform_device *pdev) {struct net_device *dev =platform_get_drvdata (pdev);struct macb *bp =netdev_priv (dev);int ret;if (bp->phy_interface ==PHY_INTERFACE_MODE_SGMII ) { -/* Ensure PS-GTR PHY device used in SGMII mode is ready */ +/* Ensure PHY device used in SGMII mode is ready */ bp->sgmii_phy =devm_phy_optional_get (&pdev->dev,NULL );if (IS_ERR (bp->sgmii_phy)) { ret =PTR_ERR (bp->sgmii_phy);dev_err_probe (&pdev->dev, ret, -"failed to get PS-GTR PHY\n" ); +"failed to get SGMII PHY\n" );return ret; } ret =phy_init (bp->sgmii_phy);if (ret) { -dev_err (&pdev->dev,"failed to init PS-GTR PHY: %d\n" , +dev_err (&pdev->dev,"failed to init SGMII PHY: %d\n" , ret);return ret; } } -/* Fully reset GEM controller at hardware level using zynqmp-reset driver, -* if mapped in device tree. -*/ +/* Fully reset controller at hardware level if mapped in device tree */ ret =device_reset_optional (&pdev->dev);if (ret) {dev_err_probe (&pdev->dev, ret,"failed to reset controller" );
@@ -4737,7 +4735,7 @@ static const struct macb_config zynqmp_config = { MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_BD_RD_PREFETCH, .dma_burst_length = 16, .clk_init = macb_clk_init, - .init = zynqmp_init, + .init = init_reset_optional, .jumbo_max_len = 10240, .usrio = &macb_default_usrio, };
@@ -4751,6 +4749,17 @@ static const struct macb_config zynq_config = { .usrio = &macb_default_usrio, }; +static const struct macb_config mpfs_config = { + .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE | +MACB_CAPS_JUMBO | +MACB_CAPS_GEM_HAS_PTP , + .dma_burst_length =16 , + .clk_init = macb_clk_init, + .init = init_reset_optional, + .usrio = &macb_default_usrio, + .jumbo_max_len =10240 , +}; +static const struct macb_config sama7g5_gem_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE |MACB_CAPS_CLK_HW_CHG |MACB_CAPS_MIIONRGMII ,
@@ -4787,6 +4796,7 @@ static const struct of_device_id macb_dt_ids[] = { { .compatible = "cdns,zynqmp-gem", .data = &zynqmp_config}, { .compatible = "cdns,zynq-gem", .data = &zynq_config }, { .compatible = "sifive,fu540-c000-gem", .data = &fu540_c000_config }, + { .compatible = "microchip,mpfs-macb", .data = &mpfs_config }, { .compatible = "microchip,sama7g5-gem", .data = &sama7g5_gem_config }, { .compatible = "microchip,sama7g5-emac", .data = &sama7g5_emac_config }, { /* sentinel */ }
Signature · 1 line
2.36.1
Conor Dooley
reviewerPATCH v3 3/5 net: macb: unify macb_config alignment style
In reply to Conor DooleyThe various macb_config structs have taken different approaches to alignment when broken over newlines. Pick one style and make them match.
--- drivers/net/ethernet/cadence/macb_main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +8 -8
@@ -4626,8 +4626,8 @@ static const struct macb_config at91sam9260_config = { };static const struct macb_config sama5d3macb_config = { - .caps =MACB_CAPS_SG_DISABLED - |MACB_CAPS_USRIO_HAS_CLKEN |MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII , + .caps =MACB_CAPS_SG_DISABLED | +MACB_CAPS_USRIO_HAS_CLKEN |MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII , .clk_init = macb_clk_init, .init = macb_init, .usrio = &macb_default_usrio,
@@ -4658,8 +4658,8 @@ static const struct macb_config sama5d29_config = { };static const struct macb_config sama5d3_config = { - .caps =MACB_CAPS_SG_DISABLED |MACB_CAPS_GIGABIT_MODE_AVAILABLE - |MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |MACB_CAPS_JUMBO , + .caps =MACB_CAPS_SG_DISABLED |MACB_CAPS_GIGABIT_MODE_AVAILABLE | +MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |MACB_CAPS_JUMBO , .dma_burst_length =16 , .clk_init = macb_clk_init, .init = macb_init,
@@ -4731,8 +4731,8 @@ static int init_reset_optional(struct platform_device *pdev)static const struct macb_config zynqmp_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE | -MACB_CAPS_JUMBO | -MACB_CAPS_GEM_HAS_PTP |MACB_CAPS_BD_RD_PREFETCH , +MACB_CAPS_JUMBO | +MACB_CAPS_GEM_HAS_PTP |MACB_CAPS_BD_RD_PREFETCH , .dma_burst_length =16 , .clk_init = macb_clk_init, .init = init_reset_optional,
@@ -4806,8 +4806,8 @@ MODULE_DEVICE_TABLE(of, macb_dt_ids);static const struct macb_config default_gem_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE | -MACB_CAPS_JUMBO | -MACB_CAPS_GEM_HAS_PTP , +MACB_CAPS_JUMBO | +MACB_CAPS_GEM_HAS_PTP , .dma_burst_length =16 , .clk_init = macb_clk_init, .init = macb_init,
Signature · 1 line
2.36.1
Conor Dooley
reviewerPATCH v3 4/5 net: macb: simplify error paths in init_reset_optional()
In reply to Conor DooleyThe error handling paths in init_reset_optional() can all be simplified to return dev_err_probe(). Do so.
--- drivers/net/ethernet/cadence/macb_main.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +7 -13
@@ -4699,27 +4699,21 @@ static int init_reset_optional(struct platform_device *pdev)/* Ensure PHY device used in SGMII mode is ready */ bp->sgmii_phy =devm_phy_optional_get (&pdev->dev,NULL ); -if (IS_ERR (bp->sgmii_phy)) { - ret =PTR_ERR (bp->sgmii_phy); -dev_err_probe (&pdev->dev, ret, -"failed to get SGMII PHY\n" ); -return ret; - } +if (IS_ERR (bp->sgmii_phy)) +return dev_err_probe (&pdev->dev,PTR_ERR (bp->sgmii_phy), +"failed to get SGMII PHY\n" ); ret =phy_init (bp->sgmii_phy); -if (ret) { -dev_err (&pdev->dev,"failed to init SGMII PHY: %d\n" , - ret); -return ret; - } +if (ret) +return dev_err_probe (&pdev->dev, ret, +"failed to init SGMII PHY\n" ); }/* Fully reset controller at hardware level if mapped in device tree */ ret =device_reset_optional (&pdev->dev);if (ret) { -dev_err_probe (&pdev->dev, ret,"failed to reset controller" );phy_exit (bp->sgmii_phy); -return ret; +return dev_err_probe (&pdev->dev, ret,"failed to reset controller" ); } ret =macb_init (pdev);
Signature · 1 line
2.36.1
Conor Dooley
reviewerPATCH v3 5/5 net: macb: sort init_reset_optional() with other init()s
In reply to Conor Dooleyinit_reset_optional() is somewhat oddly placed amidst the macb_config struct definitions. Move it to a more reasonable location alongside the fu540 init functions.
--- drivers/net/ethernet/cadence/macb_main.c | 68 ++++++++++++------------ 1 file changed, 34 insertions(+), 34 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +34 -34
@@ -4600,6 +4600,40 @@ static int fu540_c000_init(struct platform_device *pdev)return macb_init (pdev); } +static int init_reset_optional (struct platform_device *pdev) +{ +struct net_device *dev =platform_get_drvdata (pdev); +struct macb *bp =netdev_priv (dev); +int ret; + +if (bp->phy_interface ==PHY_INTERFACE_MODE_SGMII ) { +/* Ensure PHY device used in SGMII mode is ready */ + bp->sgmii_phy =devm_phy_optional_get (&pdev->dev,NULL ); + +if (IS_ERR (bp->sgmii_phy)) +return dev_err_probe (&pdev->dev,PTR_ERR (bp->sgmii_phy), +"failed to get SGMII PHY\n" ); + + ret =phy_init (bp->sgmii_phy); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"failed to init SGMII PHY\n" ); + } + +/* Fully reset controller at hardware level if mapped in device tree */ + ret =device_reset_optional (&pdev->dev); +if (ret) { +phy_exit (bp->sgmii_phy); +return dev_err_probe (&pdev->dev, ret,"failed to reset controller" ); + } + + ret =macb_init (pdev); +if (ret) +phy_exit (bp->sgmii_phy); + +return ret; +} +static const struct macb_usrio_config sama7g5_usrio = { .mii =0 , .rmii =1 ,
@@ -4689,40 +4723,6 @@ static const struct macb_config np4_config = { .usrio = &macb_default_usrio, }; -static int init_reset_optional (struct platform_device *pdev) -{ -struct net_device *dev =platform_get_drvdata (pdev); -struct macb *bp =netdev_priv (dev); -int ret; - -if (bp->phy_interface ==PHY_INTERFACE_MODE_SGMII ) { -/* Ensure PHY device used in SGMII mode is ready */ - bp->sgmii_phy =devm_phy_optional_get (&pdev->dev,NULL ); - -if (IS_ERR (bp->sgmii_phy)) -return dev_err_probe (&pdev->dev,PTR_ERR (bp->sgmii_phy), -"failed to get SGMII PHY\n" ); - - ret =phy_init (bp->sgmii_phy); -if (ret) -return dev_err_probe (&pdev->dev, ret, -"failed to init SGMII PHY\n" ); - } - -/* Fully reset controller at hardware level if mapped in device tree */ - ret =device_reset_optional (&pdev->dev); -if (ret) { -phy_exit (bp->sgmii_phy); -return dev_err_probe (&pdev->dev, ret,"failed to reset controller" ); - } - - ret =macb_init (pdev); -if (ret) -phy_exit (bp->sgmii_phy); - -return ret; -} -static const struct macb_config zynqmp_config = { .caps =MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
Signature · 1 line
2.36.1
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 6 Jul 2022 10:51:24 +0100 you wrote:
Hey all,
Jakub requested that these patches be split off from the series adding the reset controller itself that I sent ~yesterday~ last week [0].The Cadence MACBs on PolarFire SoC (MPFS) have reset capability and are compatible with the zynqmp's init function. I have removed the zynqmp specific comments from that function & renamed it to reflect what it does, since it is no longer zynqmp only.
[...]
Here is the summary with links:
- [net-next,v3,1/5] dt-bindings: net: cdns,macb: document polarfire soc's macb
https://git.kernel.org/netdev/net-next/c/b09c6f8ff731 - [net-next,v3,2/5] net: macb: add polarfire soc reset support https://git.kernel.org/netdev/net-next/c/8aad66aa59be - [net-next,v3,3/5] net: macb: unify macb_config alignment style https://git.kernel.org/netdev/net-next/c/649bef9c7663 - [net-next,v3,4/5] net: macb: simplify error paths in init_reset_optional() https://git.kernel.org/netdev/net-next/c/ea242f821a2d - [net-next,v3,5/5] net: macb: sort init_reset_optional() with other init()s https://git.kernel.org/netdev/net-next/c/8a78ac73de20
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html