Message ID | 1449551582-6599-2-git-send-email-preid@electromag.com.au |
---|---|
State | Not Applicable, archived |
Headers | show |
On Tuesday 08 December 2015 13:12:59 Phil Reid wrote: > @@ -201,6 +201,25 @@ int stmmac_mdio_register(struct net_device *ndev) > struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; > int addr, found; > > +#ifdef CONFIG_OF > + struct device_node *mdio_node = NULL; > + struct device_node *child_node = NULL; > + > + for_each_child_of_node(priv->device->of_node, child_node) { > + if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) { > + mdio_node = child_node; > + break; > + } > + } Can you use "if (IS_ENABLED(CONFIG_OF))" here instead of a preprocessor "#if"? > @@ -231,7 +250,11 @@ int stmmac_mdio_register(struct net_device *ndev) > new_bus->irq = irqlist; > new_bus->phy_mask = mdio_bus_data->phy_mask; > new_bus->parent = priv->device; > +#ifdef CONFIG_OF > + err = of_mdiobus_register(new_bus, mdio_node); > +#else > err = mdiobus_register(new_bus); > +#endif This looks like it should be done in the header file. Can you make a separate patch that changes the header file declaring of_mdiobus_register to make it a static inline function calling mdiobus_register() if CONFIG_OF is disabled? Arnd -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2015-12-08 at 10:35:05 +0100, Arnd Bergmann <arnd@arndb.de> wrote: > On Tuesday 08 December 2015 13:12:59 Phil Reid wrote: > > > @@ -201,6 +201,25 @@ int stmmac_mdio_register(struct net_device *ndev) > > struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; > > int addr, found; > > > > +#ifdef CONFIG_OF > > + struct device_node *mdio_node = NULL; > > + struct device_node *child_node = NULL; > > + > > + for_each_child_of_node(priv->device->of_node, child_node) { > > + if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) { > > + mdio_node = child_node; > > + break; > > + } > > + } > > Can you use "if (IS_ENABLED(CONFIG_OF))" here instead of a preprocessor "#if"? > > > @@ -231,7 +250,11 @@ int stmmac_mdio_register(struct net_device *ndev) > > new_bus->irq = irqlist; > > new_bus->phy_mask = mdio_bus_data->phy_mask; > > new_bus->parent = priv->device; > > +#ifdef CONFIG_OF > > + err = of_mdiobus_register(new_bus, mdio_node); > > +#else > > err = mdiobus_register(new_bus); > > +#endif > > This looks like it should be done in the header file. Can you make > a separate patch that changes the header file declaring of_mdiobus_register > to make it a static inline function calling mdiobus_register() if CONFIG_OF > is disabled? This is already the case since commit 23a456f0 ("net: mdio: of_mdiobus_register(): fall back to mdiobus_register() for !CONFIG_OF"), so just calling of_mdiobus_register() regardless of CONFIG_OF is sufficient here. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt index f34fc3c..fd5ddf8 100644 --- a/Documentation/devicetree/bindings/net/stmmac.txt +++ b/Documentation/devicetree/bindings/net/stmmac.txt @@ -47,6 +47,7 @@ Optional properties: - snps,burst_len: The AXI burst lenth value of the AXI BUS MODE register. - tx-fifo-depth: See ethernet.txt file in the same directory - rx-fifo-depth: See ethernet.txt file in the same directory +- mdio: with compatible = "snps,dwmac-mdio", create and register mdio bus. Examples: @@ -65,4 +66,11 @@ Examples: tx-fifo-depth = <16384>; clocks = <&clock>; clock-names = "stmmaceth"; + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + phy1: ethernet-phy@0 { + }; + }; }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index bba670c..90170d5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -29,7 +29,7 @@ #include <linux/slab.h> #include <linux/of.h> #include <linux/of_gpio.h> - +#include <linux/of_mdio.h> #include <asm/io.h> #include "stmmac.h" @@ -201,6 +201,25 @@ int stmmac_mdio_register(struct net_device *ndev) struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; int addr, found; +#ifdef CONFIG_OF + struct device_node *mdio_node = NULL; + struct device_node *child_node = NULL; + + for_each_child_of_node(priv->device->of_node, child_node) { + if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) { + mdio_node = child_node; + break; + } + } + + if (mdio_node) { + netdev_dbg(ndev, "FOUND MDIO subnode\n"); + } else { + netdev_err(ndev, "NO MDIO subnode\n"); + return 0; + } +#endif + if (!mdio_bus_data) return 0; @@ -231,7 +250,11 @@ int stmmac_mdio_register(struct net_device *ndev) new_bus->irq = irqlist; new_bus->phy_mask = mdio_bus_data->phy_mask; new_bus->parent = priv->device; +#ifdef CONFIG_OF + err = of_mdiobus_register(new_bus, mdio_node); +#else err = mdiobus_register(new_bus); +#endif if (err != 0) { pr_err("%s: Cannot register as MDIO bus\n", new_bus->name); goto bus_register_fail; @@ -284,13 +307,6 @@ int stmmac_mdio_register(struct net_device *ndev) } } - if (!found) { - pr_warn("%s: No PHY found\n", ndev->name); - mdiobus_unregister(new_bus); - mdiobus_free(new_bus); - return -ENODEV; - } - priv->mii = new_bus; return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index d02691b..6863420 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -146,7 +146,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0) dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); - if (plat->phy_node || plat->phy_bus_name) + if (plat->phy_bus_name) plat->mdio_bus_data = NULL; else plat->mdio_bus_data =