diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2011-05-10 17:31:31 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-05-19 04:55:47 -0400 |
commit | a7c62f8564357532872e106f0fa383728cf886cc (patch) | |
tree | 50c799310306d77e7dea9a9dc07e5ef75a5955bb /arch/mips/bcm47xx | |
parent | b3ae52b6b0335eba547221aad2cb3c50902e3d2d (diff) |
MIPS: BCM47xx: Extend bcm47xx_fill_sprom with prefix.
When an other SSB based device without an own SPROM is attached, using the
PCI bus to the main SSB based device, the data normally found in the SPROM
will be stored in the NVRAM on modern devices. The keys, to load the data
from the NVRAM, are all using some sort of prefix like pci/1/1/, pci/1/3/
or sb/1/ before the actual key. This patch extends bcm47xx_fill_sprom() to
make it possible to read out these values when some prefix was used.
The keys for the SPROM data used on the main chip does not have a prefix.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2363/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/bcm47xx')
-rw-r--r-- | arch/mips/bcm47xx/setup.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index c95f90bf734c..bbfcf9bd38db 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c | |||
@@ -57,10 +57,23 @@ static void bcm47xx_machine_halt(void) | |||
57 | } | 57 | } |
58 | 58 | ||
59 | #define READ_FROM_NVRAM(_outvar, name, buf) \ | 59 | #define READ_FROM_NVRAM(_outvar, name, buf) \ |
60 | if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\ | 60 | if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\ |
61 | sprom->_outvar = simple_strtoul(buf, NULL, 0); | 61 | sprom->_outvar = simple_strtoul(buf, NULL, 0); |
62 | 62 | ||
63 | static void bcm47xx_fill_sprom(struct ssb_sprom *sprom) | 63 | static inline int nvram_getprefix(const char *prefix, char *name, |
64 | char *buf, int len) | ||
65 | { | ||
66 | if (prefix) { | ||
67 | char key[100]; | ||
68 | |||
69 | snprintf(key, sizeof(key), "%s%s", prefix, name); | ||
70 | return nvram_getenv(key, buf, len); | ||
71 | } | ||
72 | |||
73 | return nvram_getenv(name, buf, len); | ||
74 | } | ||
75 | |||
76 | static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) | ||
64 | { | 77 | { |
65 | char buf[100]; | 78 | char buf[100]; |
66 | u32 boardflags; | 79 | u32 boardflags; |
@@ -69,11 +82,11 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom) | |||
69 | 82 | ||
70 | sprom->revision = 1; /* Fallback: Old hardware does not define this. */ | 83 | sprom->revision = 1; /* Fallback: Old hardware does not define this. */ |
71 | READ_FROM_NVRAM(revision, "sromrev", buf); | 84 | READ_FROM_NVRAM(revision, "sromrev", buf); |
72 | if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0) | 85 | if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0) |
73 | nvram_parse_macaddr(buf, sprom->il0mac); | 86 | nvram_parse_macaddr(buf, sprom->il0mac); |
74 | if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0) | 87 | if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0) |
75 | nvram_parse_macaddr(buf, sprom->et0mac); | 88 | nvram_parse_macaddr(buf, sprom->et0mac); |
76 | if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0) | 89 | if (nvram_getprefix(prefix, "et1macaddr", buf, sizeof(buf)) >= 0) |
77 | nvram_parse_macaddr(buf, sprom->et1mac); | 90 | nvram_parse_macaddr(buf, sprom->et1mac); |
78 | READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf); | 91 | READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf); |
79 | READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf); | 92 | READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf); |
@@ -125,14 +138,14 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom) | |||
125 | READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf); | 138 | READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf); |
126 | READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf); | 139 | READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf); |
127 | 140 | ||
128 | if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0) { | 141 | if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) { |
129 | boardflags = simple_strtoul(buf, NULL, 0); | 142 | boardflags = simple_strtoul(buf, NULL, 0); |
130 | if (boardflags) { | 143 | if (boardflags) { |
131 | sprom->boardflags_lo = (boardflags & 0x0000FFFFU); | 144 | sprom->boardflags_lo = (boardflags & 0x0000FFFFU); |
132 | sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16; | 145 | sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16; |
133 | } | 146 | } |
134 | } | 147 | } |
135 | if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0) { | 148 | if (nvram_getprefix(prefix, "boardflags2", buf, sizeof(buf)) >= 0) { |
136 | boardflags = simple_strtoul(buf, NULL, 0); | 149 | boardflags = simple_strtoul(buf, NULL, 0); |
137 | if (boardflags) { | 150 | if (boardflags) { |
138 | sprom->boardflags2_lo = (boardflags & 0x0000FFFFU); | 151 | sprom->boardflags2_lo = (boardflags & 0x0000FFFFU); |
@@ -158,7 +171,7 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus, | |||
158 | if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0) | 171 | if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0) |
159 | iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); | 172 | iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); |
160 | 173 | ||
161 | bcm47xx_fill_sprom(&iv->sprom); | 174 | bcm47xx_fill_sprom(&iv->sprom, NULL); |
162 | 175 | ||
163 | if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0) | 176 | if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0) |
164 | iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10); | 177 | iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10); |