Message ID | 20170927073414.17361-12-clabbe.montjoie@gmail.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
Series | net: stmmac: dwmac-sun8i: Handle integrated PHY | expand |
On Wed, Sep 27, 2017 at 09:34:14AM +0200, Corentin Labbe wrote: > Each child node of an MDIO node is scanned as a PHY when calling > of_mdiobus_register() givint the following result: > [ 18.175379] mdio_bus stmmac-0: /soc/ethernet@1c30000/mdio/mdio-mux has invalid PHY address > [ 18.175408] mdio_bus stmmac-0: scan phy mdio-mux at address 0 > [ 18.175450] mdio_bus stmmac-0: scan phy mdio-mux at address 1 > [...] > [ 18.176420] mdio_bus stmmac-0: scan phy mdio-mux at address 30 > [ 18.176452] mdio_bus stmmac-0: scan phy mdio-mux at address 31 > > Since mdio-mux nodes are not PHY, this patch a way to to not scan > them. Hi Corentin I still don't like this, but ... > > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> > --- > drivers/of/of_mdio.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c > index d94dd8b77abd..d90ddb0d90f2 100644 > --- a/drivers/of/of_mdio.c > +++ b/drivers/of/of_mdio.c > @@ -190,6 +190,10 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) > struct device_node *child; > bool scanphys = false; > int addr, rc; > + static const struct of_device_id do_not_scan[] = { > + { .compatible = "mdio-mux" }, > + {} > + }; Please rename this to some less generic. What i don't want is other compatible strings added here. We want to make the exception for muxes, but nothing else. So something like compatible_muxes? Andrew
On 09/27/2017 07:12 AM, Andrew Lunn wrote: > On Wed, Sep 27, 2017 at 09:34:14AM +0200, Corentin Labbe wrote: >> Each child node of an MDIO node is scanned as a PHY when calling >> of_mdiobus_register() givint the following result: >> [ 18.175379] mdio_bus stmmac-0: /soc/ethernet@1c30000/mdio/mdio-mux has invalid PHY address >> [ 18.175408] mdio_bus stmmac-0: scan phy mdio-mux at address 0 >> [ 18.175450] mdio_bus stmmac-0: scan phy mdio-mux at address 1 >> [...] >> [ 18.176420] mdio_bus stmmac-0: scan phy mdio-mux at address 30 >> [ 18.176452] mdio_bus stmmac-0: scan phy mdio-mux at address 31 >> >> Since mdio-mux nodes are not PHY, this patch a way to to not scan >> them. > > Hi Corentin > > I still don't like this, but ... Me neither, even more so as I don't understand the reasoning behind putting the mux as a child node of the MDIO bus controller in the first place. Also, you need to re-order patches such that this patch comes before the DTS changes. > >> >> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> >> --- >> drivers/of/of_mdio.c | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c >> index d94dd8b77abd..d90ddb0d90f2 100644 >> --- a/drivers/of/of_mdio.c >> +++ b/drivers/of/of_mdio.c >> @@ -190,6 +190,10 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) >> struct device_node *child; >> bool scanphys = false; >> int addr, rc; >> + static const struct of_device_id do_not_scan[] = { >> + { .compatible = "mdio-mux" }, >> + {} >> + }; > > Please rename this to some less generic. What i don't want is other > compatible strings added here. We want to make the exception for > muxes, but nothing else. So something like compatible_muxes? > > Andrew >
On Wed, Sep 27, 2017 at 09:50:46PM -0700, Florian Fainelli wrote: > > > On 09/27/2017 07:12 AM, Andrew Lunn wrote: > > On Wed, Sep 27, 2017 at 09:34:14AM +0200, Corentin Labbe wrote: > >> Each child node of an MDIO node is scanned as a PHY when calling > >> of_mdiobus_register() givint the following result: > >> [ 18.175379] mdio_bus stmmac-0: /soc/ethernet@1c30000/mdio/mdio-mux has invalid PHY address > >> [ 18.175408] mdio_bus stmmac-0: scan phy mdio-mux at address 0 > >> [ 18.175450] mdio_bus stmmac-0: scan phy mdio-mux at address 1 > >> [...] > >> [ 18.176420] mdio_bus stmmac-0: scan phy mdio-mux at address 30 > >> [ 18.176452] mdio_bus stmmac-0: scan phy mdio-mux at address 31 > >> > >> Since mdio-mux nodes are not PHY, this patch a way to to not scan > >> them. > > > > Hi Corentin > > > > I still don't like this, but ... > > Me neither, even more so as I don't understand the reasoning behind > putting the mux as a child node of the MDIO bus controller in the first > place. If no one agrees with me, then you shouldn't just accept my answers. I'm not always right. Looking at this some more, why can't mdio-mux-mmio be used? Then there is nothing to review or discuss. If you want to extend that then make it clear this is just extending/inheriting already defined bindings. That being said, if we were starting over I would probably do mux designs differently with DT hierarchy reflecting the mux hierarchy, but that ship has sailed. Rob
> Looking at this some more, why can't mdio-mux-mmio be used?
Hi Rob
That was my first thought. And then i dug into the details. The mux is
more than just a couple of bits in an address space. Clocks needs to
be enabled/disabled, and the MAC needs a reset, when the mux changes.
So the mux needs intimate knowledge of MAC.
Andrew
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index d94dd8b77abd..d90ddb0d90f2 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -190,6 +190,10 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) struct device_node *child; bool scanphys = false; int addr, rc; + static const struct of_device_id do_not_scan[] = { + { .compatible = "mdio-mux" }, + {} + }; /* Do not continue if the node is disabled */ if (!of_device_is_available(np)) @@ -212,6 +216,9 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) /* Loop over the child nodes and register a phy_device for each phy */ for_each_available_child_of_node(np, child) { + if (of_match_node(do_not_scan, child)) + continue; + addr = of_mdio_parse_addr(&mdio->dev, child); if (addr < 0) { scanphys = true; @@ -229,6 +236,9 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) /* auto scan for PHYs with empty reg property */ for_each_available_child_of_node(np, child) { + if (of_match_node(do_not_scan, child)) + continue; + /* Skip PHYs with reg property set */ if (of_find_property(child, "reg", NULL)) continue;
Each child node of an MDIO node is scanned as a PHY when calling of_mdiobus_register() givint the following result: [ 18.175379] mdio_bus stmmac-0: /soc/ethernet@1c30000/mdio/mdio-mux has invalid PHY address [ 18.175408] mdio_bus stmmac-0: scan phy mdio-mux at address 0 [ 18.175450] mdio_bus stmmac-0: scan phy mdio-mux at address 1 [...] [ 18.176420] mdio_bus stmmac-0: scan phy mdio-mux at address 30 [ 18.176452] mdio_bus stmmac-0: scan phy mdio-mux at address 31 Since mdio-mux nodes are not PHY, this patch a way to to not scan them. Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> --- drivers/of/of_mdio.c | 10 ++++++++++ 1 file changed, 10 insertions(+)