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>
This commit is contained in:
parent
f68c925720
commit
0a0ea06872
1 changed files with 19 additions and 2 deletions
|
@ -38,6 +38,7 @@
|
||||||
#include <linux/davinci_emac.h>
|
#include <linux/davinci_emac.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_device.h>
|
#include <linux/of_device.h>
|
||||||
|
#include <linux/of_mdio.h>
|
||||||
#include <linux/pinctrl/consumer.h>
|
#include <linux/pinctrl/consumer.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -95,6 +96,10 @@ struct davinci_mdio_data {
|
||||||
struct mii_bus *bus;
|
struct mii_bus *bus;
|
||||||
bool suspended;
|
bool suspended;
|
||||||
unsigned long access_time; /* jiffies */
|
unsigned long access_time; /* jiffies */
|
||||||
|
/* Indicates that driver shouldn't modify phy_mask in case
|
||||||
|
* if MDIO bus is registered from DT.
|
||||||
|
*/
|
||||||
|
bool skip_scan;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __davinci_mdio_reset(struct davinci_mdio_data *data)
|
static void __davinci_mdio_reset(struct davinci_mdio_data *data)
|
||||||
|
@ -144,6 +149,9 @@ static int davinci_mdio_reset(struct mii_bus *bus)
|
||||||
dev_info(data->dev, "davinci mdio revision %d.%d\n",
|
dev_info(data->dev, "davinci mdio revision %d.%d\n",
|
||||||
(ver >> 8) & 0xff, ver & 0xff);
|
(ver >> 8) & 0xff, ver & 0xff);
|
||||||
|
|
||||||
|
if (data->skip_scan)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* get phy mask from the alive register */
|
/* get phy mask from the alive register */
|
||||||
phy_mask = __raw_readl(&data->regs->alive);
|
phy_mask = __raw_readl(&data->regs->alive);
|
||||||
if (phy_mask) {
|
if (phy_mask) {
|
||||||
|
@ -369,8 +377,17 @@ static int davinci_mdio_probe(struct platform_device *pdev)
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* register the mii bus */
|
/* register the mii bus
|
||||||
|
* Create PHYs from DT only in case if PHY child nodes are explicitly
|
||||||
|
* defined to support backward compatibility with DTs which assume that
|
||||||
|
* Davinci MDIO will always scan the bus for PHYs detection.
|
||||||
|
*/
|
||||||
|
if (dev->of_node && of_get_child_count(dev->of_node)) {
|
||||||
|
data->skip_scan = true;
|
||||||
|
ret = of_mdiobus_register(data->bus, dev->of_node);
|
||||||
|
} else {
|
||||||
ret = mdiobus_register(data->bus);
|
ret = mdiobus_register(data->bus);
|
||||||
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
goto bail_out;
|
goto bail_out;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue