diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2015-12-10 01:36:51 +0300 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2015-12-16 17:36:25 +0300 |
commit | 541c9a84cd85203244307d9ebb821102eed82789 (patch) | |
tree | 55c3f1cfe18cf4c14c26dd4772241fcc564281fe /drivers/ssb/host_soc.c | |
parent | d0ca9900675860d2857f40df88393b199a558634 (diff) | |
download | linux-541c9a84cd85203244307d9ebb821102eed82789.tar.xz |
ssb: pick SoC invariants code from MIPS BCM47xx arch
There is code in ssb fetching "invariants" that is basically a set of
board specific data. Every host requires its own implementation of
reading function. In ssb we have support for PCI, PCMCIA & SDIO.
For some (historical?) reason code reading "invariants" for SoC was
placed in arch code and provided by a callback. This is not needed
nowadays, so lets move that into ssb. This way we keep all "invariants"
functions in a single module making code cleaner.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/ssb/host_soc.c')
-rw-r--r-- | drivers/ssb/host_soc.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/ssb/host_soc.c b/drivers/ssb/host_soc.c index c809f255af34..d62992dc08b2 100644 --- a/drivers/ssb/host_soc.c +++ b/drivers/ssb/host_soc.c @@ -8,6 +8,7 @@ * Licensed under the GNU/GPL. See COPYING for details. */ +#include <linux/bcm47xx_nvram.h> #include <linux/ssb/ssb.h> #include "ssb_private.h" @@ -171,3 +172,39 @@ const struct ssb_bus_ops ssb_host_soc_ops = { .block_write = ssb_host_soc_block_write, #endif }; + +int ssb_host_soc_get_invariants(struct ssb_bus *bus, + struct ssb_init_invariants *iv) +{ + char buf[20]; + int len, err; + + /* Fill boardinfo structure */ + memset(&iv->boardinfo, 0, sizeof(struct ssb_boardinfo)); + + len = bcm47xx_nvram_getenv("boardvendor", buf, sizeof(buf)); + if (len > 0) { + err = kstrtou16(strim(buf), 0, &iv->boardinfo.vendor); + if (err) + pr_warn("Couldn't parse nvram board vendor entry with value \"%s\"\n", + buf); + } + if (!iv->boardinfo.vendor) + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM; + + len = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)); + if (len > 0) { + err = kstrtou16(strim(buf), 0, &iv->boardinfo.type); + if (err) + pr_warn("Couldn't parse nvram board type entry with value \"%s\"\n", + buf); + } + + memset(&iv->sprom, 0, sizeof(struct ssb_sprom)); + ssb_fill_sprom_with_fallback(bus, &iv->sprom); + + if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0) + iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10); + + return 0; +} |