diff options
author | Tobias Wolf <github-NTEO@vplace.de> | 2017-01-25 16:22:13 +0100 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2017-01-27 11:10:10 +0100 |
commit | 30494598f891fc4436a49eca55fc31d03c087841 (patch) | |
tree | a4c77ff1608eda7da23f382ac0abf75ec90ea240 /target/linux/generic/files/drivers/net | |
parent | e79ecb4c26471526552d2473bb50d331c3dafb87 (diff) | |
download | upstream-30494598f891fc4436a49eca55fc31d03c087841.tar.gz upstream-30494598f891fc4436a49eca55fc31d03c087841.tar.bz2 upstream-30494598f891fc4436a49eca55fc31d03c087841.zip |
generic: rtl8366s: add support support for initvals from DTS
This change provides the possibility to define per-device initvals in
the DTS file for a rlt8366s switch.
Signed-off-by: Tobias Wolf <github-NTEO@vplace.de>
Diffstat (limited to 'target/linux/generic/files/drivers/net')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8366s.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366s.c b/target/linux/generic/files/drivers/net/phy/rtl8366s.c index 3dc2a87aed..b54b4b13b0 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366s.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366s.c @@ -254,17 +254,42 @@ static int rtl8366s_setup(struct rtl8366_smi *smi) { struct rtl8366_platform_data *pdata; int err; + unsigned i; +#ifdef CONFIG_OF + struct device_node *np; + unsigned num_initvals; + const __be32 *paddr; +#endif pdata = smi->parent->platform_data; if (pdata && pdata->num_initvals && pdata->initvals) { - unsigned i; - dev_info(smi->parent, "applying initvals\n"); for (i = 0; i < pdata->num_initvals; i++) REG_WR(smi, pdata->initvals[i].reg, pdata->initvals[i].val); } +#ifdef CONFIG_OF + np = smi->parent->of_node; + + paddr = of_get_property(np, "realtek,initvals", &num_initvals); + if (paddr) { + dev_info(smi->parent, "applying initvals from DTS\n"); + + if (num_initvals < (2 * sizeof(*paddr))) + return -EINVAL; + + num_initvals /= sizeof(*paddr); + + for (i = 0; i < num_initvals - 1; i += 2) { + u32 reg = be32_to_cpup(paddr + i); + u32 val = be32_to_cpup(paddr + i + 1); + + REG_WR(smi, reg, val); + } + } +#endif + /* set maximum packet length to 1536 bytes */ REG_RMW(smi, RTL8366S_SGCR, RTL8366S_SGCR_MAX_LENGTH_MASK, RTL8366S_SGCR_MAX_LENGTH_1536); |