net: stmmac: rk: convert to suspend()/resume() methods

Convert rk to use the new suspend() and resume() methods rather than
implementing these in custom wrappers around the main driver's
suspend/resume methods. This allows this driver to use the simmac
simple PM ops structure.

We can further simplify the driver as there is no need to track whether
the device was suspended, we only need to check whether the device is
wakeup capable in the resume method. This is because the resume method
will only be called after the suspend method.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1ulXc2-008grB-9k@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
pull/1354/merge
Russell King (Oracle) 2025-08-11 19:51:14 +01:00 committed by Jakub Kicinski
parent c91918a1e9
commit d7a276a576
1 changed files with 25 additions and 33 deletions

View File

@ -71,7 +71,6 @@ struct rk_priv_data {
phy_interface_t phy_iface; phy_interface_t phy_iface;
int id; int id;
struct regulator *regulator; struct regulator *regulator;
bool suspended;
const struct rk_gmac_ops *ops; const struct rk_gmac_ops *ops;
bool clk_enabled; bool clk_enabled;
@ -1706,6 +1705,28 @@ static int rk_set_clk_tx_rate(void *bsp_priv_, struct clk *clk_tx_i,
return -EINVAL; return -EINVAL;
} }
static int rk_gmac_suspend(struct device *dev, void *bsp_priv_)
{
struct rk_priv_data *bsp_priv = bsp_priv_;
/* Keep the PHY up if we use Wake-on-Lan. */
if (!device_may_wakeup(dev))
rk_gmac_powerdown(bsp_priv);
return 0;
}
static int rk_gmac_resume(struct device *dev, void *bsp_priv_)
{
struct rk_priv_data *bsp_priv = bsp_priv_;
/* The PHY was up for Wake-on-Lan. */
if (!device_may_wakeup(dev))
rk_gmac_powerup(bsp_priv);
return 0;
}
static int rk_gmac_probe(struct platform_device *pdev) static int rk_gmac_probe(struct platform_device *pdev)
{ {
struct plat_stmmacenet_data *plat_dat; struct plat_stmmacenet_data *plat_dat;
@ -1738,6 +1759,8 @@ static int rk_gmac_probe(struct platform_device *pdev)
plat_dat->get_interfaces = rk_get_interfaces; plat_dat->get_interfaces = rk_get_interfaces;
plat_dat->set_clk_tx_rate = rk_set_clk_tx_rate; plat_dat->set_clk_tx_rate = rk_set_clk_tx_rate;
plat_dat->suspend = rk_gmac_suspend;
plat_dat->resume = rk_gmac_resume;
plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data); plat_dat->bsp_priv = rk_gmac_setup(pdev, plat_dat, data);
if (IS_ERR(plat_dat->bsp_priv)) if (IS_ERR(plat_dat->bsp_priv))
@ -1772,37 +1795,6 @@ static void rk_gmac_remove(struct platform_device *pdev)
rk_gmac_powerdown(bsp_priv); rk_gmac_powerdown(bsp_priv);
} }
#ifdef CONFIG_PM_SLEEP
static int rk_gmac_suspend(struct device *dev)
{
struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(dev);
int ret = stmmac_suspend(dev);
/* Keep the PHY up if we use Wake-on-Lan. */
if (!device_may_wakeup(dev)) {
rk_gmac_powerdown(bsp_priv);
bsp_priv->suspended = true;
}
return ret;
}
static int rk_gmac_resume(struct device *dev)
{
struct rk_priv_data *bsp_priv = get_stmmac_bsp_priv(dev);
/* The PHY was up for Wake-on-Lan. */
if (bsp_priv->suspended) {
rk_gmac_powerup(bsp_priv);
bsp_priv->suspended = false;
}
return stmmac_resume(dev);
}
#endif /* CONFIG_PM_SLEEP */
static SIMPLE_DEV_PM_OPS(rk_gmac_pm_ops, rk_gmac_suspend, rk_gmac_resume);
static const struct of_device_id rk_gmac_dwmac_match[] = { static const struct of_device_id rk_gmac_dwmac_match[] = {
{ .compatible = "rockchip,px30-gmac", .data = &px30_ops }, { .compatible = "rockchip,px30-gmac", .data = &px30_ops },
{ .compatible = "rockchip,rk3128-gmac", .data = &rk3128_ops }, { .compatible = "rockchip,rk3128-gmac", .data = &rk3128_ops },
@ -1828,7 +1820,7 @@ static struct platform_driver rk_gmac_dwmac_driver = {
.remove = rk_gmac_remove, .remove = rk_gmac_remove,
.driver = { .driver = {
.name = "rk_gmac-dwmac", .name = "rk_gmac-dwmac",
.pm = &rk_gmac_pm_ops, .pm = &stmmac_simple_pm_ops,
.of_match_table = rk_gmac_dwmac_match, .of_match_table = rk_gmac_dwmac_match,
}, },
}; };