aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorGrygorii Strashko <grygorii.strashko@ti.com>2014-07-16 08:13:03 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-17 02:33:16 -0400
commit0a0ea068728138641037daa5fce33cb06724285d (patch)
treebada37eb1a3bca6993d078ad2d3ea98afe3e4cce /drivers/net/ethernet
parentf68c9257201ff5d443bf2e815ce01578835674e4 (diff)
net: davinci_mdio: allow to create phys from dt
This patch allows to create PHYs from DT in case if they are explicitly defined. The of_mdiobus_register() is used for such purposes. For backward compatibility, call of_mdiobus_register() only in case if at least one PHY's child is defined in DT, otherwise rollback to mdiobus_register(). Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/ti/davinci_mdio.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 735dc53d4b01..2791f6f2db11 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -38,6 +38,7 @@
38#include <linux/davinci_emac.h> 38#include <linux/davinci_emac.h>
39#include <linux/of.h> 39#include <linux/of.h>
40#include <linux/of_device.h> 40#include <linux/of_device.h>
41#include <linux/of_mdio.h>
41#include <linux/pinctrl/consumer.h> 42#include <linux/pinctrl/consumer.h>
42 43
43/* 44/*
@@ -95,6 +96,10 @@ struct davinci_mdio_data {
95 struct mii_bus *bus; 96 struct mii_bus *bus;
96 bool suspended; 97 bool suspended;
97 unsigned long access_time; /* jiffies */ 98 unsigned long access_time; /* jiffies */
99 /* Indicates that driver shouldn't modify phy_mask in case
100 * if MDIO bus is registered from DT.
101 */
102 bool skip_scan;
98}; 103};
99 104
100static void __davinci_mdio_reset(struct davinci_mdio_data *data) 105static void __davinci_mdio_reset(struct davinci_mdio_data *data)
@@ -144,6 +149,9 @@ static int davinci_mdio_reset(struct mii_bus *bus)
144 dev_info(data->dev, "davinci mdio revision %d.%d\n", 149 dev_info(data->dev, "davinci mdio revision %d.%d\n",
145 (ver >> 8) & 0xff, ver & 0xff); 150 (ver >> 8) & 0xff, ver & 0xff);
146 151
152 if (data->skip_scan)
153 return 0;
154
147 /* get phy mask from the alive register */ 155 /* get phy mask from the alive register */
148 phy_mask = __raw_readl(&data->regs->alive); 156 phy_mask = __raw_readl(&data->regs->alive);
149 if (phy_mask) { 157 if (phy_mask) {
@@ -369,8 +377,17 @@ static int davinci_mdio_probe(struct platform_device *pdev)
369 goto bail_out; 377 goto bail_out;
370 } 378 }
371 379
372 /* register the mii bus */ 380 /* register the mii bus
373 ret = mdiobus_register(data->bus); 381 * Create PHYs from DT only in case if PHY child nodes are explicitly
382 * defined to support backward compatibility with DTs which assume that
383 * Davinci MDIO will always scan the bus for PHYs detection.
384 */
385 if (dev->of_node && of_get_child_count(dev->of_node)) {
386 data->skip_scan = true;
387 ret = of_mdiobus_register(data->bus, dev->of_node);
388 } else {
389 ret = mdiobus_register(data->bus);
390 }
374 if (ret) 391 if (ret)
375 goto bail_out; 392 goto bail_out;
376 393