From: Florian Fainelli <f.fainelli@gmail.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Geert Uytterhoeven" <geert+renesas@glider.be>,
"David S . Miller" <davem@davemloft.net>,
"Simon Horman" <horms@verge.net.au>,
"Magnus Damm" <magnus.damm@gmail.com>,
"Sergei Shtylyov" <sergei.shtylyov@cogentembedded.com>,
"Andrew Lunn" <andrew@lunn.ch>,
"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [PATCH 2/4] ravb: Add optional PHY reset during system resume
Date: Thu, 28 Sep 2017 12:21:57 -0700 [thread overview]
Message-ID: <1a474c45-29ea-82fa-1ab0-0febfdc38bcb@gmail.com> (raw)
In-Reply-To: <CAMuHMdWOAnT3xONPfU8pJi9fbAgtWL2GyRbooAxrfGDb=bsB_A@mail.gmail.com>
On 09/28/2017 11:45 AM, Geert Uytterhoeven wrote:
> Hi Florian,
>
> On Thu, Sep 28, 2017 at 7:22 PM, Florian Fainelli <f.fainelli@gmail.com> 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 <geert+renesas@glider.be>
>>> ---
>>> 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 <linux/etherdevice.h>
>>> #include <linux/ethtool.h>
>>> #include <linux/if_vlan.h>
>>> +#include <linux/gpio/consumer.h>
>>> #include <linux/kernel.h>
>>> #include <linux/list.h>
>>> #include <linux/module.h>
>>> @@ -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.
There is not such a thing unfortunately, but it would presumably be
called within drivers/net/phy/mdio_bus.c during bus->reset() time
because you need the PHY reset to be deasserted before you can
successfully read/write from the PHY, and if you can't read/write from
the PHY, the MDIO bus layer cannot read the PHY ID, and therefore cannot
match a PHY device with its driver, so things don't work.
NB: you could move this entirely to the Micrel PHY driver if you specify
a compatible string that has a the PHY OUI in it, because that bypasses
the need to match the PHY driver with the PHY device, but this may not
be an acceptable solution for non-DT platforms or other platforms where
the PHY can't be determined based on the board DTS.
I was going to suggest writing some sort of generic helper that walks
the list of child nodes from a MDIO bus device node and deassert reset
lines and enables clocks, but there is absolutely nothing generic about
that. Things like which of the reset should come first, and if there are
multiple, in which order, etc.
>
>> 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
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
>
--
Florian
next prev parent reply other threads:[~2017-09-28 19:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 15:53 [PATCH 0/4] ravb: Add PHY reset support Geert Uytterhoeven
2017-09-28 15:53 ` [PATCH 1/4] dt-bindings: net: ravb: Document optional reset-gpios property Geert Uytterhoeven
2017-09-28 20:07 ` Sergei Shtylyov
2017-10-05 23:24 ` Rob Herring
[not found] ` <1506614014-4398-1-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2017-09-28 15:53 ` [PATCH 2/4] ravb: Add optional PHY reset during system resume Geert Uytterhoeven
2017-09-28 17:22 ` Florian Fainelli
2017-09-28 18:45 ` Geert Uytterhoeven
2017-09-28 19:21 ` Florian Fainelli [this message]
2017-09-30 20:23 ` Sergei Shtylyov
2017-10-01 16:34 ` Florian Fainelli
2017-10-09 9:37 ` Sergei Shtylyov
2017-10-09 12:50 ` Sergei Shtylyov
2017-09-28 15:53 ` [PATCH 3/4] arm64: dts: renesas: salvator-common: Add EthernetAVB PHY reset Geert Uytterhoeven
[not found] ` <1506614014-4398-4-git-send-email-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
2017-09-28 17:20 ` Florian Fainelli
2017-09-28 15:53 ` [PATCH 4/4] arm64: dts: renesas: ulcb: " Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a474c45-29ea-82fa-1ab0-0febfdc38bcb@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=geert@linux-m68k.org \
--cc=horms@verge.net.au \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
--cc=sergei.shtylyov@cogentembedded.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).