[PATCH net-next v5 06/15] net: ravb: Assert/de-assert reset on suspend/resume

From: Claudiu
Date: Wed Jan 31 2024 - 03:44:34 EST


From: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>

RZ/G3S can go to deep sleep states where power to most of the SoC parts is
off. When resuming from such a state, the Ethernet controller needs to be
reinitialized. De-asserting the reset signal for it should also be done.
Thus, add reset assert/de-assert on suspend/resume functions.

On the resume function, the de-assert was not reverted in case of failures
to give the user a chance to restore the interface (e.g., bringing down/up
the interface) in case suspend/resume failed.

Reviewed-by: Sergey Shtylyov <s.shtylyov@xxxxxx>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@xxxxxxxxxxxxxx>
---

Changes in v5:
- none

Changes in v4:
- none

Changes in v3:
- collected tags

Changes in v2:
- fixed typos in patch description and subject
- on ravb_suspend() assert the reset signal in case interface is down;
due to this the Sergey's Rb tag was left aside in this version

drivers/net/ethernet/renesas/ravb_main.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index c05d4a2664eb..c2b65bdad13c 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2978,7 +2978,7 @@ static int ravb_suspend(struct device *dev)
int ret;

if (!netif_running(ndev))
- return 0;
+ goto reset_assert;

netif_device_detach(ndev);

@@ -2990,7 +2990,11 @@ static int ravb_suspend(struct device *dev)
if (priv->info->ccc_gac)
ravb_ptp_stop(ndev);

- return ret;
+ if (priv->wol_enabled)
+ return ret;
+
+reset_assert:
+ return reset_control_assert(priv->rstc);
}

static int ravb_resume(struct device *dev)
@@ -2998,7 +3002,11 @@ static int ravb_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct ravb_private *priv = netdev_priv(ndev);
const struct ravb_hw_info *info = priv->info;
- int ret = 0;
+ int ret;
+
+ ret = reset_control_deassert(priv->rstc);
+ if (ret)
+ return ret;

/* If WoL is enabled set reset mode to rearm the WoL logic */
if (priv->wol_enabled) {
--
2.39.2