summaryrefslogtreecommitdiffstats
path: root/drivers/net/smc911x.c
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2016-07-02 07:59:47 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2016-07-05 09:02:41 +0200
commite5c6340f42a9430ca55e49a0d935c59eddb5fbe4 (patch)
tree05596b96daa024474080f6e1b214300d6d08ee9c /drivers/net/smc911x.c
parent257abdaa36c87ce82fc41873c2004fe356301dad (diff)
downloadbarebox-e5c6340f42a9430ca55e49a0d935c59eddb5fbe4.tar.gz
barebox-e5c6340f42a9430ca55e49a0d935c59eddb5fbe4.tar.xz
net: smc911x: Add parsing devicetree options
This patch adds parsing basic devicetree options for the smc911x driver: reg-io-width, reg-shift and smsc,force-(in/ex)ternal-phy, which makes driver usable for most DTS-based boards. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/smc911x.c')
-rw-r--r--drivers/net/smc911x.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index fe9d1df502..45175bb32b 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -38,7 +38,7 @@ struct smc911x_priv {
struct mii_bus miibus;
void __iomem *base;
- int shift;
+ u32 shift;
int generation;
unsigned int flags;
unsigned int idrev;
@@ -516,6 +516,19 @@ static int smc911x_probe(struct device_d *dev)
priv->shift = pdata->shift;
priv->flags = pdata->flags;
priv->phy_mask = pdata->phy_mask;
+ } else if (IS_ENABLED(CONFIG_OFDEVICE) && dev->device_node) {
+ ret = of_property_read_u32(dev->device_node, "reg-io-width", &val);
+ if (ret)
+ return ret;
+ is_32bit = (val == 4);
+
+ of_property_read_u32(dev->device_node, "reg-shift", &priv->shift);
+
+ if (of_property_read_bool(dev->device_node, "smsc,force-internal-phy"))
+ priv->flags |= SMC911X_FORCE_INTERNAL_PHY;
+
+ if (of_property_read_bool(dev->device_node, "smsc,force-external-phy"))
+ priv->flags |= SMC911X_FORCE_EXTERNAL_PHY;
}
if (is_32bit) {
@@ -562,7 +575,7 @@ static int smc911x_probe(struct device_d *dev)
if (val != 0x87654321) {
dev_err(dev, "no smc911x found on 0x%p (byte_test=0x%08x)\n",
priv->base, val);
- if (((val >> 16) & 0xFFFF) == (val & 0xFFFF)) {
+ if ((((val >> 16) & 0xFFFF) == (val & 0xFFFF)) && is_32bit) {
/*
* This may mean the chip is set
* for 32 bit while the bus is reading 16 bit