devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Rob Herring <robh+dt@kernel.org>
Cc: netdev <netdev@vger.kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	adam.rudzinski@arf.net.pl, Marco Felsch <m.felsch@pengutronix.de>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Richard Leitner <richard.leitner@skidata.com>,
	Dejin Zheng <zhengdejin5@gmail.com>,
	devicetree@vger.kernel.org, Sascha Hauer <kernel@pengutronix.de>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next 1/3] net: phy: Support enabling clocks prior to bus probe
Date: Thu, 3 Sep 2020 14:43:54 -0700	[thread overview]
Message-ID: <81972e9c-c664-08b4-a9f2-636df3cd801d@gmail.com> (raw)
In-Reply-To: <CAL_JsqL=XLJo9nrX+AMs41QvA3qpW6zoyB8qNwRx3V-+U-+uLg@mail.gmail.com>



On 9/3/2020 2:28 PM, Rob Herring wrote:
> On Wed, Sep 2, 2020 at 10:39 PM Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>> Some Ethernet PHYs may require that their clock, which typically drives
>> their logic to respond to reads on the MDIO bus be enabled before
>> issusing a MDIO bus scan.
>>
>> We have a chicken and egg problem though which is that we cannot enable
>> a given Ethernet PHY's device clock until we have a phy_device instance
>> create and called the driver's probe function. This will not happen
>> unless we are successful in probing the PHY device, which requires its
>> clock(s) to be turned on.
>>
>> For DT based systems we can solve this by using of_clk_get() which
>> operates on a device_node reference, and make sure that all clocks
>> associaed with the node are enabled prior to doing any reads towards the
>> device. In order to avoid drivers having to know the a priori reference
>> count of the resources, we drop them back to 0 right before calling
>> ->probe() which is then supposed to manage the resources normally.
> 
> What if a device requires clocks enabled in a certain order or timing?
> It's not just clocks, you could have some GPIOs or a regulator that
> need enabling first. It's device specific, so really needs a per
> device solution. This is not just an issue with MDIO. I think we
> really need some sort of pre-probe hook in the driver model in order
> to do any non-discoverable init for discoverable buses. Or perhaps
> forcing probe when there are devices defined in DT if they're not
> discovered by normal means.

I like the pre-probe hook idea, and there are other devices that I have 
access to that would benefit from that, like PCIe end-points that 
require regulators to be turned on in order for them to be discoverable.

For MDIO we might actually be able to create the backing device 
reference without having read the device ID yet, provided that we know 
its address on the bus, which DT can tell us.

Bartosz attempted to do that not so long ago and we sort of stalled 
there, too:

https://lkml.org/lkml/2020/6/22/253

Let me see if I can just add a pre-probe hook, make use of it in the 
MDIO layer, and we see how we can apply it to other subsystems?
-- 
Florian

  parent reply	other threads:[~2020-09-03 21:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03  4:39 [PATCH net-next 0/3] net: phy: Support enabling clocks prior to bus probe Florian Fainelli
2020-09-03  4:39 ` [PATCH net-next 1/3] " Florian Fainelli
2020-09-03 20:39   ` Andrew Lunn
2020-09-03 21:25   ` Andrew Lunn
2020-09-03 21:28   ` Rob Herring
2020-09-03 21:42     ` Andrew Lunn
2020-09-03 21:50       ` Florian Fainelli
2020-09-03 21:43     ` Florian Fainelli [this message]
2020-09-03  4:39 ` [PATCH net-next 2/3] net: phy: mdio-bcm-unimac: Enable GPHY resources during bus reset Florian Fainelli
2020-09-03  4:39 ` [PATCH net-next 3/3] net: phy: bcm7xxx: request and manage GPHY clock Florian Fainelli
2020-09-04  6:15   ` Marco Felsch
2020-09-04 15:37     ` Florian Fainelli
2020-09-07  7:34       ` Marco Felsch
2020-09-07 19:07       ` Marco Felsch
2020-09-04  6:18   ` Marco Felsch
2020-09-04 15:38     ` Florian Fainelli
2020-09-07  7:37       ` Marco Felsch
2020-09-04  4:04 ` [PATCH net-next 0/3] net: phy: Support enabling clocks prior to bus probe Florian Fainelli
2020-09-04  6:19   ` Adam Rudziński
2020-09-04 13:45     ` Andrew Lunn
2020-09-04 14:00       ` Adam Rudziński
2020-09-04 14:23         ` Andrew Lunn
2020-09-04 17:21           ` Adam Rudziński
2020-09-04 13:58   ` Andrew Lunn

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=81972e9c-c664-08b4-a9f2-636df3cd801d@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=adam.rudzinski@arf.net.pl \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=richard.leitner@skidata.com \
    --cc=robh+dt@kernel.org \
    --cc=zhengdejin5@gmail.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).