From mboxrd@z Thu Jan 1 00:00:00 1970 From: Geert Uytterhoeven Subject: Re: [PATCH 2/4] ravb: Add optional PHY reset during system resume Date: Thu, 28 Sep 2017 20:45:00 +0200 Message-ID: References: <1506614014-4398-1-git-send-email-geert+renesas@glider.be> <1506614014-4398-3-git-send-email-geert+renesas@glider.be> <406f7aff-e386-31f3-39d3-17523443c265@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <406f7aff-e386-31f3-39d3-17523443c265@gmail.com> Sender: netdev-owner@vger.kernel.org To: Florian Fainelli Cc: Geert Uytterhoeven , "David S . Miller" , Simon Horman , Magnus Damm , Sergei Shtylyov , Andrew Lunn , =?UTF-8?Q?Niklas_S=C3=B6derlund?= , "netdev@vger.kernel.org" , Linux-Renesas , "devicetree@vger.kernel.org" List-Id: devicetree@vger.kernel.org Hi Florian, On Thu, Sep 28, 2017 at 7:22 PM, Florian Fainelli wrote: > On 09/28/2017 08:53 AM, Geert Uytterhoeven wrote: >> If the optional "reset-gpios" property is specified in DT, the generic >> MDIO bus code takes care of resetting the PHY during device probe. >> However, the PHY may still have to be reset explicitly after system >> resume. >> >> This allows to restore Ethernet operation after resume from s2ram on >> Salvator-XS, where the enable pin of the regulator providing PHY power >> is connected to PRESETn, and PSCI suspend powers down the SoC. >> >> Signed-off-by: Geert Uytterhoeven >> --- >> drivers/net/ethernet/renesas/ravb_main.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c >> index fdf30bfa403bf416..96d1d48e302f8c9a 100644 >> --- a/drivers/net/ethernet/renesas/ravb_main.c >> +++ b/drivers/net/ethernet/renesas/ravb_main.c >> @@ -19,6 +19,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -2268,6 +2269,7 @@ static int __maybe_unused ravb_resume(struct device *dev) >> { >> struct net_device *ndev = dev_get_drvdata(dev); >> struct ravb_private *priv = netdev_priv(ndev); >> + struct mii_bus *bus = priv->mii_bus; >> int ret = 0; >> >> if (priv->wol_enabled) { >> @@ -2302,6 +2304,13 @@ static int __maybe_unused ravb_resume(struct device *dev) >> * reopen device if it was running before system suspended. >> */ >> >> + /* PHY reset */ >> + if (bus->reset_gpiod) { >> + gpiod_set_value_cansleep(bus->reset_gpiod, 1); >> + udelay(bus->reset_delay_us); >> + gpiod_set_value_cansleep(bus->reset_gpiod, 0); >> + } > > This is a clever hack, but unfortunately this is also misusing the MDIO > bus reset line into a PHY reset line. As commented in patch 3, if this > reset line is tied to the PHY, then this should be a PHY property and OK. > you cannot (ab)use the MDIO bus GPIO reset logic anymore... And then I should add reset-gpios support to drivers/net/phy/micrel.c? Or is there already generic code to handle per-PHY reset? I couldn't find it. > Should not you also try to manage this reset line during ravb_open() to > achiever better power savings? I don't know. The Micrel KSZ9031RNXVA datasheet doesn't mention if it's safe or not to assert reset for a prolonged time. Thanks! Gr{oetje,eeting}s, Geert