net: stmmac: sti cleanups
Subsystems (4)
cover net: stmmac: sti cleanups
Clean up the STI platform glue code.
- IS_PHY_IF_MODE_RGMII() is just a duplicate for phy_interface_mode_is_rgmii(), so use the generic version that we already have.
- add init/exit functions that call clk_prepare_enable(), sti_dwmac_set_mode() and clk_disable_unprepare() as appropriate, converting to devm_stmmac_pltfr_probe().
- the custom suspend/resume ops do basically what the generic ones do with init/exit functions populated, but also add runtime and noirq ops. Update STI to use the generic ops.
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 88 ++++++++----------------- 1 file changed, 29 insertions(+), 59 deletions(-)
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!
PATCH 1/3 net: stmmac: sti: use phy_interface_mode_is_rgmii()
Replace the custom IS_PHY_IF_MODE_RGMII() macro with our generic phy_interface_mode_is_rgmii() inline function.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +2 -7
@@ -23,12 +23,7 @@#define DWMAC_50MHZ 50000000 -#define IS_PHY_IF_MODE_RGMII (iface) (iface == PHY_INTERFACE_MODE_RGMII || \ - iface == PHY_INTERFACE_MODE_RGMII_ID || \ - iface == PHY_INTERFACE_MODE_RGMII_RXID || \ - iface == PHY_INTERFACE_MODE_RGMII_TXID) - -#define IS_PHY_IF_MODE_GBIT (iface) (IS_PHY_IF_MODE_RGMII(iface) || \ +#define IS_PHY_IF_MODE_GBIT (iface) (phy_interface_mode_is_rgmii(iface) || \ iface == PHY_INTERFACE_MODE_GMII)/* STiH4xx register definitions (STiH407/STiH410 families)
@@ -148,7 +143,7 @@ static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode) src =TX_RETIME_SRC_CLKGEN ; freq =DWMAC_50MHZ ; } - }else if (IS_PHY_IF_MODE_RGMII (dwmac->interface)) { + }else if (phy_interface_mode_is_rgmii (dwmac->interface)) {/* On GiGa clk source can be either ext or from clkgen */ freq =rgmii_clock (spd);
Signature · 1 line
2.30.2
PATCH 2/3 net: stmmac: sti: convert to devm_stmmac_pltfr_probe()
In reply to Russell King (Oracle)Convert sti to use the generic devm_stmmac_pltfr_probe() which will call plat_dat->init()/plat_dat->exit() as appropriate, thus simplifying the code.
--- .../net/ethernet/stmicro/stmmac/dwmac-sti.c | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +26 -28
@@ -233,6 +233,29 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,return 0 ; } +static int sti_dwmac_init (struct platform_device *pdev,void *bsp_priv) +{ +struct sti_dwmac *dwmac = bsp_priv; +int ret; + + ret =clk_prepare_enable (dwmac->clk); +if (ret) +return ret; + + ret =sti_dwmac_set_mode (dwmac); +if (ret) +clk_disable_unprepare (dwmac->clk); + +return ret; +} + +static void sti_dwmac_exit (struct platform_device *pdev,void *bsp_priv) +{ +struct sti_dwmac *dwmac = bsp_priv; + +clk_disable_unprepare (dwmac->clk); +} +static int sti_dwmac_probe (struct platform_device *pdev) {struct plat_stmmacenet_data *plat_dat;
@@ -269,34 +292,10 @@ static int sti_dwmac_probe(struct platform_device *pdev) plat_dat->bsp_priv = dwmac; plat_dat->fix_mac_speed = data->fix_retime_src; + plat_dat->init = sti_dwmac_init; + plat_dat->exit = sti_dwmac_exit; - ret =clk_prepare_enable (dwmac->clk); -if (ret) -return ret; - - ret =sti_dwmac_set_mode (dwmac); -if (ret) - goto disable_clk; - - ret =stmmac_dvr_probe (&pdev->dev, plat_dat, &stmmac_res); -if (ret) - goto disable_clk; - -return 0 ; - -disable_clk: -clk_disable_unprepare (dwmac->clk); - -return ret; -} - -static void sti_dwmac_remove (struct platform_device *pdev) -{ -struct sti_dwmac *dwmac =get_stmmac_bsp_priv (&pdev->dev); - -stmmac_dvr_remove (&pdev->dev); - -clk_disable_unprepare (dwmac->clk); +return devm_stmmac_pltfr_probe (pdev, plat_dat, &stmmac_res); }static int sti_dwmac_suspend (struct device *dev)
@@ -334,7 +333,6 @@ MODULE_DEVICE_TABLE(of, sti_dwmac_match);static struct platform_driver sti_dwmac_driver = { .probe = sti_dwmac_probe, - .remove = sti_dwmac_remove, .driver = { .name ="sti-dwmac" , .pm =pm_sleep_ptr (&sti_dwmac_pm_ops),
Signature · 1 line
2.30.2
PATCH 3/3 net: stmmac: sti: convert to stmmac_pltfr_pm_ops
In reply to Russell King (Oracle)As we now have the plat_dat->init()/plat_dat->exit() populated which have the required functionality on suspend/resume, we can now use stmmac_pltfr_pm_ops which has methods that call these two functions. Switch over to use this.
Doing so also fills in the runtime PM ops and _noirq variants as well.
--- .../net/ethernet/stmicro/stmmac/dwmac-sti.c | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +1 -24
@@ -298,29 +298,6 @@ static int sti_dwmac_probe(struct platform_device *pdev)return devm_stmmac_pltfr_probe (pdev, plat_dat, &stmmac_res); } -static int sti_dwmac_suspend (struct device *dev) -{ -struct sti_dwmac *dwmac =get_stmmac_bsp_priv (dev); -int ret =stmmac_suspend (dev); - -clk_disable_unprepare (dwmac->clk); - -return ret; -} - -static int sti_dwmac_resume (struct device *dev) -{ -struct sti_dwmac *dwmac =get_stmmac_bsp_priv (dev); - -clk_prepare_enable (dwmac->clk); -sti_dwmac_set_mode (dwmac); - -return stmmac_resume (dev); -} - -static DEFINE_SIMPLE_DEV_PM_OPS(sti_dwmac_pm_ops, sti_dwmac_suspend, - sti_dwmac_resume); -static const struct sti_dwmac_of_data stih4xx_dwmac_data = { .fix_retime_src = stih4xx_fix_retime_src, };
@@ -335,7 +312,7 @@ static struct platform_driver sti_dwmac_driver = { .probe = sti_dwmac_probe, .driver = { .name = "sti-dwmac", - .pm = pm_sleep_ptr(&sti_dwmac_pm_ops), + .pm = &stmmac_pltfr_pm_ops, .of_match_table = sti_dwmac_match, }, };
Signature · 1 line
2.30.2
Re: [PATCH net-next 1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii()
In reply to Russell King (Oracle)Quoted 4 lines · Russell King (Oracle)
Replace the custom
IS_PHY_IF_MODE_RGMII()macro with our genericphy_interface_mode_is_rgmii()inline function.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe()
In reply to Russell King (Oracle)Quoted 5 lines · Russell King (Oracle)
Convert sti to use the generic
devm_stmmac_pltfr_probe()which will call plat_dat->init()/plat_dat->exit() as appropriate, thus simplifying the code.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
Re: [PATCH net-next 3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops
In reply to Russell King (Oracle)Quoted 8 lines · Russell King (Oracle)
As we now have the plat_dat->init()/plat_dat->exit() populated which have the required functionality on suspend/resume, we can now use
stmmac_pltfr_pm_opswhich has methods that call these two functions. Switch over to use this.Doing so also fills in the runtime PM ops and
_noirqvariants as well.Signed-off-by Russell King (Oracle) <[email protected]>
Andrew
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 15 Apr 2025 17:42:39 +0100 you wrote:
Clean up the STI platform glue code.
-
IS_PHY_IF_MODE_RGMII()is just a duplicate forphy_interface_mode_is_rgmii(), so use the generic version that we already have.- add init/exit functions that call
clk_prepare_enable(),sti_dwmac_set_mode()andclk_disable_unprepare()as appropriate, converting todevm_stmmac_pltfr_probe().[...]
Here is the summary with links:
- [net-next,1/3] net: stmmac: sti: use phy_interface_mode_is_rgmii()
https://git.kernel.org/netdev/net-next/c/72d02a9f9410 - [net-next,2/3] net: stmmac: sti: convert to devm_stmmac_pltfr_probe() https://git.kernel.org/netdev/net-next/c/403068c6c9c2 - [net-next,3/3] net: stmmac: sti: convert to stmmac_pltfr_pm_ops https://git.kernel.org/netdev/net-next/c/b3334f9f708c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html