diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2013-04-06 12:37:36 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2013-04-06 12:37:36 +0000 |
commit | 4455e179637593951e751a751d46a1ab39756441 (patch) | |
tree | f8d50acdc219809847d7a4e6022eee01e701fa15 /target/linux/generic/files/drivers/net/phy | |
parent | d705fd0c51ed448d5a75e6eb5e28f0b532d30174 (diff) | |
download | upstream-4455e179637593951e751a751d46a1ab39756441.tar.gz upstream-4455e179637593951e751a751d46a1ab39756441.tar.bz2 upstream-4455e179637593951e751a751d46a1ab39756441.zip |
generic: rtl8367: allow to load extif config from OF
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36220 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8367.c | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.c b/target/linux/generic/files/drivers/net/phy/rtl8367.c index cab07c831b..3cd811e75f 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8367.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8367.c @@ -1073,6 +1073,51 @@ static int rtl8367_led_blinkrate_set(struct rtl8366_smi *smi, unsigned int rate) return 0; } +#ifdef CONFIG_OF +static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id, + const char *name) +{ + struct rtl8367_extif_config *cfg; + const __be32 *prop; + int size; + int err; + + prop = of_get_property(smi->parent->of_node, name, &size); + if (!prop) + return rtl8367_extif_init(smi, id, NULL); + + if (size != (9 * sizeof(*prop))) { + dev_err(smi->parent, "%s property is invalid\n", name); + return -EINVAL; + } + + cfg = kzalloc(sizeof(struct rtl8367_extif_config), GFP_KERNEL); + if (!cfg) + return -ENOMEM; + + 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++); + + err = rtl8367_extif_init(smi, id, cfg); + kfree(cfg); + + return err; +} +#else +static int rtl8367_extif_init_of(struct rtl8366_smi *smi, int id, + const char *name) +{ + return -EINVAL; +} +#endif + static int rtl8367_setup(struct rtl8366_smi *smi) { struct rtl8367_platform_data *pdata; @@ -1086,13 +1131,23 @@ static int rtl8367_setup(struct rtl8366_smi *smi) return err; /* initialize external interfaces */ - err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg); - if (err) - return err; + if (smi->parent->of_node) { + err = rtl8367_extif_init_of(smi, 0, "realtek,extif0"); + if (err) + return err; - err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg); - if (err) - return err; + err = rtl8367_extif_init_of(smi, 1, "realtek,extif1"); + if (err) + return err; + } else { + err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg); + if (err) + return err; + + err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg); + if (err) + return err; + } /* set maximum packet length to 1536 bytes */ REG_RMW(smi, RTL8367_SWC0_REG, RTL8367_SWC0_MAX_LENGTH_MASK, |