aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2013-04-03 09:58:33 +0000
committerJohn Crispin <john@openwrt.org>2013-04-03 09:58:33 +0000
commit1105bd2897152a8c6861a09faed56cf2fdbfdddb (patch)
treeeaa5ffd8f6ccae2fb52adc6025da335f52d501aa /target/linux/generic
parentcc34858d4a83143367531ed1152657506d579e47 (diff)
downloadupstream-1105bd2897152a8c6861a09faed56cf2fdbfdddb.tar.gz
upstream-1105bd2897152a8c6861a09faed56cf2fdbfdddb.tar.bz2
upstream-1105bd2897152a8c6861a09faed56cf2fdbfdddb.zip
add OF support to rtl8367b driver
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 36159
Diffstat (limited to 'target/linux/generic')
-rw-r--r--target/linux/generic/files/drivers/net/phy/rtl8367b.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c
index c70a14486f..5775fa4e98 100644
--- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c
+++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c
@@ -862,6 +862,40 @@ static int rtl8367b_extif_init(struct rtl8366_smi *smi, int id,
return 0;
}
+#ifdef CONFIG_OF
+static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id, const char *name)
+{
+ struct rtl8367_extif_config *cfg;
+ const __be32 *prop;
+ int size;
+
+ prop = of_get_property(smi->parent->of_node, name, &size);
+ if (!prop || size != (9 * sizeof(*prop)))
+ return 0;
+
+ cfg = kzalloc(sizeof(struct rtl8367_extif_config), GFP_KERNEL);
+ if (!cfg)
+ return -1;
+
+ cfg->txdelay = be32_to_cpup(prop++);
+ cfg->rxdelay = be32_to_cpup(prop++);
+ cfg->mode = be32_to_cpup(prop++);
+ cfg->ability.force_mode = be32_to_cpup(prop++);
+ cfg->ability.txpause = be32_to_cpup(prop++);
+ cfg->ability.rxpause = be32_to_cpup(prop++);
+ cfg->ability.link = be32_to_cpup(prop++);
+ cfg->ability.duplex = be32_to_cpup(prop++);
+ cfg->ability.speed = be32_to_cpup(prop++);
+
+ return rtl8367b_extif_init(smi, id, cfg);
+}
+#else
+static int rtl8367b_extif_init_of(struct rtl8366_smi *smi, int id, const char *name)
+{
+ return -1;
+}
+#endif
+
static int rtl8367b_setup(struct rtl8366_smi *smi)
{
struct rtl8367_platform_data *pdata;
@@ -875,13 +909,23 @@ static int rtl8367b_setup(struct rtl8366_smi *smi)
return err;
/* initialize external interfaces */
- err = rtl8367b_extif_init(smi, 0, pdata->extif0_cfg);
- if (err)
- return err;
+ if (smi->parent->of_node) {
+ err = rtl8367b_extif_init_of(smi, 0, "realtek,extif0");
+ if (err)
+ return err;
- err = rtl8367b_extif_init(smi, 1, pdata->extif1_cfg);
- if (err)
- return err;
+ err = rtl8367b_extif_init_of(smi, 1, "realtek,extif1");
+ if (err)
+ return err;
+ } else {
+ err = rtl8367b_extif_init(smi, 0, pdata->extif0_cfg);
+ if (err)
+ return err;
+
+ err = rtl8367b_extif_init(smi, 1, pdata->extif1_cfg);
+ if (err)
+ return err;
+ }
/* set maximum packet length to 1536 bytes */
REG_RMW(smi, RTL8367B_SWC0_REG, RTL8367B_SWC0_MAX_LENGTH_MASK,