Commit fb7c783b authored by Andy Duan's avatar Andy Duan Committed by Greg Kroah-Hartman

net: fec: manage ahb clock in runtime pm

[ Upstream commit d7c3a206 ]

Some SOC like i.MX6SX clock have some limits:
- ahb clock should be disabled before ipg.
- ahb and ipg clocks are required for MAC MII bus.
So, move the ahb clock to runtime management together with
ipg clock.
Signed-off-by: default avatarFugang Duan <fugang.duan@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
parent c18731c2
...@@ -1850,13 +1850,9 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1850,13 +1850,9 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
int ret; int ret;
if (enable) { if (enable) {
ret = clk_prepare_enable(fep->clk_ahb);
if (ret)
return ret;
ret = clk_prepare_enable(fep->clk_enet_out); ret = clk_prepare_enable(fep->clk_enet_out);
if (ret) if (ret)
goto failed_clk_enet_out; return ret;
if (fep->clk_ptp) { if (fep->clk_ptp) {
mutex_lock(&fep->ptp_clk_mutex); mutex_lock(&fep->ptp_clk_mutex);
...@@ -1876,7 +1872,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1876,7 +1872,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
phy_reset_after_clk_enable(ndev->phydev); phy_reset_after_clk_enable(ndev->phydev);
} else { } else {
clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_enet_out); clk_disable_unprepare(fep->clk_enet_out);
if (fep->clk_ptp) { if (fep->clk_ptp) {
mutex_lock(&fep->ptp_clk_mutex); mutex_lock(&fep->ptp_clk_mutex);
...@@ -1895,8 +1890,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1895,8 +1890,6 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
failed_clk_ptp: failed_clk_ptp:
if (fep->clk_enet_out) if (fep->clk_enet_out)
clk_disable_unprepare(fep->clk_enet_out); clk_disable_unprepare(fep->clk_enet_out);
failed_clk_enet_out:
clk_disable_unprepare(fep->clk_ahb);
return ret; return ret;
} }
...@@ -3485,6 +3478,9 @@ fec_probe(struct platform_device *pdev) ...@@ -3485,6 +3478,9 @@ fec_probe(struct platform_device *pdev)
ret = clk_prepare_enable(fep->clk_ipg); ret = clk_prepare_enable(fep->clk_ipg);
if (ret) if (ret)
goto failed_clk_ipg; goto failed_clk_ipg;
ret = clk_prepare_enable(fep->clk_ahb);
if (ret)
goto failed_clk_ahb;
fep->reg_phy = devm_regulator_get(&pdev->dev, "phy"); fep->reg_phy = devm_regulator_get(&pdev->dev, "phy");
if (!IS_ERR(fep->reg_phy)) { if (!IS_ERR(fep->reg_phy)) {
...@@ -3578,6 +3574,9 @@ fec_probe(struct platform_device *pdev) ...@@ -3578,6 +3574,9 @@ fec_probe(struct platform_device *pdev)
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
failed_regulator: failed_regulator:
clk_disable_unprepare(fep->clk_ahb);
failed_clk_ahb:
clk_disable_unprepare(fep->clk_ipg);
failed_clk_ipg: failed_clk_ipg:
fec_enet_clk_enable(ndev, false); fec_enet_clk_enable(ndev, false);
failed_clk: failed_clk:
...@@ -3701,6 +3700,7 @@ static int __maybe_unused fec_runtime_suspend(struct device *dev) ...@@ -3701,6 +3700,7 @@ static int __maybe_unused fec_runtime_suspend(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev); struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg); clk_disable_unprepare(fep->clk_ipg);
return 0; return 0;
...@@ -3710,8 +3710,20 @@ static int __maybe_unused fec_runtime_resume(struct device *dev) ...@@ -3710,8 +3710,20 @@ static int __maybe_unused fec_runtime_resume(struct device *dev)
{ {
struct net_device *ndev = dev_get_drvdata(dev); struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev); struct fec_enet_private *fep = netdev_priv(ndev);
int ret;
return clk_prepare_enable(fep->clk_ipg); ret = clk_prepare_enable(fep->clk_ahb);
if (ret)
return ret;
ret = clk_prepare_enable(fep->clk_ipg);
if (ret)
goto failed_clk_ipg;
return 0;
failed_clk_ipg:
clk_disable_unprepare(fep->clk_ahb);
return ret;
} }
static const struct dev_pm_ops fec_pm_ops = { static const struct dev_pm_ops fec_pm_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment