Commit da970726 authored by Wei Fang's avatar Wei Fang Committed by David S. Miller

net: fec: add pm runtime force suspend and resume support

Force mii bus into runtime pm suspend state during device suspends,
since phydev state is already PHY_HALTED, and there is no need to
access mii bus during device suspend state. Then force mii bus into
runtime pm resume state when device resumes.
Signed-off-by: default avatarWei Fang <wei.fang@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8a26a9de
...@@ -584,6 +584,7 @@ struct fec_enet_private { ...@@ -584,6 +584,7 @@ struct fec_enet_private {
struct device_node *phy_node; struct device_node *phy_node;
bool rgmii_txc_dly; bool rgmii_txc_dly;
bool rgmii_rxc_dly; bool rgmii_rxc_dly;
bool rpm_active;
int link; int link;
int full_duplex; int full_duplex;
int speed; int speed;
......
...@@ -4135,6 +4135,7 @@ static int __maybe_unused fec_suspend(struct device *dev) ...@@ -4135,6 +4135,7 @@ static int __maybe_unused fec_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);
int ret;
rtnl_lock(); rtnl_lock();
if (netif_running(ndev)) { if (netif_running(ndev)) {
...@@ -4159,6 +4160,15 @@ static int __maybe_unused fec_suspend(struct device *dev) ...@@ -4159,6 +4160,15 @@ static int __maybe_unused fec_suspend(struct device *dev)
} }
/* It's safe to disable clocks since interrupts are masked */ /* It's safe to disable clocks since interrupts are masked */
fec_enet_clk_enable(ndev, false); fec_enet_clk_enable(ndev, false);
fep->rpm_active = !pm_runtime_status_suspended(dev);
if (fep->rpm_active) {
ret = pm_runtime_force_suspend(dev);
if (ret < 0) {
rtnl_unlock();
return ret;
}
}
} }
rtnl_unlock(); rtnl_unlock();
...@@ -4189,6 +4199,9 @@ static int __maybe_unused fec_resume(struct device *dev) ...@@ -4189,6 +4199,9 @@ static int __maybe_unused fec_resume(struct device *dev)
rtnl_lock(); rtnl_lock();
if (netif_running(ndev)) { if (netif_running(ndev)) {
if (fep->rpm_active)
pm_runtime_force_resume(dev);
ret = fec_enet_clk_enable(ndev, true); ret = fec_enet_clk_enable(ndev, true);
if (ret) { if (ret) {
rtnl_unlock(); rtnl_unlock();
......
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