diff options
author | Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk> | 2017-04-20 19:14:35 +0100 |
---|---|---|
committer | Mathias Kresin <dev@kresin.me> | 2017-04-25 19:29:59 +0200 |
commit | f4ae444f3ed94d89ea6d239c944ae2956ba92d3b (patch) | |
tree | af4a7ee3c7e54a367754dde9db1d1826db148434 /target/linux/generic/files/drivers | |
parent | 4b195a611fe146969e813ce77ecf74ce5f9c176b (diff) | |
download | upstream-f4ae444f3ed94d89ea6d239c944ae2956ba92d3b.tar.gz upstream-f4ae444f3ed94d89ea6d239c944ae2956ba92d3b.tar.bz2 upstream-f4ae444f3ed94d89ea6d239c944ae2956ba92d3b.zip |
generic: rtl8366rb: add support for initvals from DTS
Allow per-device initvals in the DTS file for rlt8366rb
switches.
Shamelessly copies 30494598f891fc4436a49eca55fc31d03c087841
Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
Diffstat (limited to 'target/linux/generic/files/drivers')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8366rb.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c index a0aaabf546..264343a81f 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366rb.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366rb.c @@ -282,6 +282,31 @@ static int rtl8366rb_reset_chip(struct rtl8366_smi *smi) static int rtl8366rb_setup(struct rtl8366_smi *smi) { int err; +#ifdef CONFIG_OF + unsigned i; + struct device_node *np; + unsigned num_initvals; + const __be32 *paddr; + + 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, RTL8366RB_SGCR, RTL8366RB_SGCR_MAX_LENGTH_MASK, |