brcm47xx: move patches already in the mainline kernel to the front
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.6 / 014-MIPS-BCM47xx-sprom-read-values-without-prefix-as-fal.patch
1 --- a/arch/mips/bcm47xx/setup.c
2 +++ b/arch/mips/bcm47xx/setup.c
3 @@ -94,7 +94,7 @@ static int bcm47xx_get_sprom_ssb(struct
4 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
5 bus->host_pci->bus->number + 1,
6 PCI_SLOT(bus->host_pci->devfn));
7 - bcm47xx_fill_sprom(out, prefix);
8 + bcm47xx_fill_sprom(out, prefix, false);
9 return 0;
10 } else {
11 printk(KERN_WARNING "bcm47xx: unable to fill SPROM for given bustype.\n");
12 @@ -113,7 +113,7 @@ static int bcm47xx_get_invariants(struct
13 bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL);
14
15 memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
16 - bcm47xx_fill_sprom(&iv->sprom, NULL);
17 + bcm47xx_fill_sprom(&iv->sprom, NULL, false);
18
19 if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
20 iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
21 @@ -165,18 +165,17 @@ static int bcm47xx_get_sprom_bcma(struct
22 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
23 bus->host_pci->bus->number + 1,
24 PCI_SLOT(bus->host_pci->devfn));
25 - bcm47xx_fill_sprom(out, prefix);
26 + bcm47xx_fill_sprom(out, prefix, false);
27 return 0;
28 case BCMA_HOSTTYPE_SOC:
29 memset(out, 0, sizeof(struct ssb_sprom));
30 - bcm47xx_fill_sprom_ethernet(out, NULL);
31 core = bcma_find_core(bus, BCMA_CORE_80211);
32 if (core) {
33 snprintf(prefix, sizeof(prefix), "sb/%u/",
34 core->core_index);
35 - bcm47xx_fill_sprom(out, prefix);
36 + bcm47xx_fill_sprom(out, prefix, true);
37 } else {
38 - bcm47xx_fill_sprom(out, NULL);
39 + bcm47xx_fill_sprom(out, NULL, false);
40 }
41 return 0;
42 default:
43 --- a/arch/mips/bcm47xx/sprom.c
44 +++ b/arch/mips/bcm47xx/sprom.c
45 @@ -42,25 +42,39 @@ static void create_key(const char *prefi
46 snprintf(buf, len, "%s", name);
47 }
48
49 +static int get_nvram_var(const char *prefix, const char *postfix,
50 + const char *name, char *buf, int len, bool fallback)
51 +{
52 + char key[40];
53 + int err;
54 +
55 + create_key(prefix, postfix, name, key, sizeof(key));
56 +
57 + err = nvram_getenv(key, buf, len);
58 + if (fallback && err == NVRAM_ERR_ENVNOTFOUND && prefix) {
59 + create_key(NULL, postfix, name, key, sizeof(key));
60 + err = nvram_getenv(key, buf, len);
61 + }
62 + return err;
63 +}
64 +
65 #define NVRAM_READ_VAL(type) \
66 static void nvram_read_ ## type (const char *prefix, \
67 const char *postfix, const char *name, \
68 - type *val, type allset) \
69 + type *val, type allset, bool fallback) \
70 { \
71 char buf[100]; \
72 - char key[40]; \
73 int err; \
74 type var; \
75 \
76 - create_key(prefix, postfix, name, key, sizeof(key)); \
77 - \
78 - err = nvram_getenv(key, buf, sizeof(buf)); \
79 + err = get_nvram_var(prefix, postfix, name, buf, sizeof(buf), \
80 + fallback); \
81 if (err < 0) \
82 return; \
83 err = kstrto ## type (buf, 0, &var); \
84 if (err) { \
85 - pr_warn("can not parse nvram name %s with value %s" \
86 - " got %i", key, buf, err); \
87 + pr_warn("can not parse nvram name %s%s%s with value %s got %i\n", \
88 + prefix, name, postfix, buf, err); \
89 return; \
90 } \
91 if (allset && var == allset) \
92 @@ -76,22 +90,19 @@ NVRAM_READ_VAL(u32)
93 #undef NVRAM_READ_VAL
94
95 static void nvram_read_u32_2(const char *prefix, const char *name,
96 - u16 *val_lo, u16 *val_hi)
97 + u16 *val_lo, u16 *val_hi, bool fallback)
98 {
99 char buf[100];
100 - char key[40];
101 int err;
102 u32 val;
103
104 - create_key(prefix, NULL, name, key, sizeof(key));
105 -
106 - err = nvram_getenv(key, buf, sizeof(buf));
107 + err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback);
108 if (err < 0)
109 return;
110 err = kstrtou32(buf, 0, &val);
111 if (err) {
112 - pr_warn("can not parse nvram name %s with value %s got %i",
113 - key, buf, err);
114 + pr_warn("can not parse nvram name %s%s with value %s got %i\n",
115 + prefix, name, buf, err);
116 return;
117 }
118 *val_lo = (val & 0x0000FFFFU);
119 @@ -99,22 +110,20 @@ static void nvram_read_u32_2(const char
120 }
121
122 static void nvram_read_leddc(const char *prefix, const char *name,
123 - u8 *leddc_on_time, u8 *leddc_off_time)
124 + u8 *leddc_on_time, u8 *leddc_off_time,
125 + bool fallback)
126 {
127 char buf[100];
128 - char key[40];
129 int err;
130 u32 val;
131
132 - create_key(prefix, NULL, name, key, sizeof(key));
133 -
134 - err = nvram_getenv(key, buf, sizeof(buf));
135 + err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback);
136 if (err < 0)
137 return;
138 err = kstrtou32(buf, 0, &val);
139 if (err) {
140 - pr_warn("can not parse nvram name %s with value %s got %i",
141 - key, buf, err);
142 + pr_warn("can not parse nvram name %s%s with value %s got %i\n",
143 + prefix, name, buf, err);
144 return;
145 }
146
147 @@ -126,336 +135,435 @@ static void nvram_read_leddc(const char
148 }
149
150 static void nvram_read_macaddr(const char *prefix, const char *name,
151 - u8 (*val)[6])
152 + u8 (*val)[6], bool fallback)
153 {
154 char buf[100];
155 - char key[40];
156 int err;
157
158 - create_key(prefix, NULL, name, key, sizeof(key));
159 -
160 - err = nvram_getenv(key, buf, sizeof(buf));
161 + err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback);
162 if (err < 0)
163 return;
164 +
165 nvram_parse_macaddr(buf, *val);
166 }
167
168 static void nvram_read_alpha2(const char *prefix, const char *name,
169 - char (*val)[2])
170 + char (*val)[2], bool fallback)
171 {
172 char buf[10];
173 - char key[40];
174 int err;
175
176 - create_key(prefix, NULL, name, key, sizeof(key));
177 -
178 - err = nvram_getenv(key, buf, sizeof(buf));
179 + err = get_nvram_var(prefix, NULL, name, buf, sizeof(buf), fallback);
180 if (err < 0)
181 return;
182 if (buf[0] == '0')
183 return;
184 if (strlen(buf) > 2) {
185 - pr_warn("alpha2 is too long %s", buf);
186 + pr_warn("alpha2 is too long %s\n", buf);
187 return;
188 }
189 memcpy(val, buf, sizeof(val));
190 }
191
192 static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom,
193 - const char *prefix)
194 + const char *prefix, bool fallback)
195 {
196 - nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff);
197 - nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff);
198 - nvram_read_u8(prefix, NULL, "ledbh2", &sprom->gpio2, 0xff);
199 - nvram_read_u8(prefix, NULL, "ledbh3", &sprom->gpio3, 0xff);
200 - nvram_read_u8(prefix, NULL, "aa2g", &sprom->ant_available_bg, 0);
201 - nvram_read_u8(prefix, NULL, "aa5g", &sprom->ant_available_a, 0);
202 - nvram_read_s8(prefix, NULL, "ag0", &sprom->antenna_gain.a0, 0);
203 - nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0);
204 - nvram_read_alpha2(prefix, "ccode", &sprom->alpha2);
205 + nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff, fallback);
206 + nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff, fallback);
207 + nvram_read_u8(prefix, NULL, "ledbh2", &sprom->gpio2, 0xff, fallback);
208 + nvram_read_u8(prefix, NULL, "ledbh3", &sprom->gpio3, 0xff, fallback);
209 + nvram_read_u8(prefix, NULL, "aa2g", &sprom->ant_available_bg, 0,
210 + fallback);
211 + nvram_read_u8(prefix, NULL, "aa5g", &sprom->ant_available_a, 0,
212 + fallback);
213 + nvram_read_s8(prefix, NULL, "ag0", &sprom->antenna_gain.a0, 0,
214 + fallback);
215 + nvram_read_s8(prefix, NULL, "ag1", &sprom->antenna_gain.a1, 0,
216 + fallback);
217 + nvram_read_alpha2(prefix, "ccode", &sprom->alpha2, fallback);
218 }
219
220 static void bcm47xx_fill_sprom_r12389(struct ssb_sprom *sprom,
221 - const char *prefix)
222 + const char *prefix, bool fallback)
223 {
224 - nvram_read_u16(prefix, NULL, "pa0b0", &sprom->pa0b0, 0);
225 - nvram_read_u16(prefix, NULL, "pa0b1", &sprom->pa0b1, 0);
226 - nvram_read_u16(prefix, NULL, "pa0b2", &sprom->pa0b2, 0);
227 - nvram_read_u8(prefix, NULL, "pa0itssit", &sprom->itssi_bg, 0);
228 - nvram_read_u8(prefix, NULL, "pa0maxpwr", &sprom->maxpwr_bg, 0);
229 - nvram_read_u16(prefix, NULL, "pa1b0", &sprom->pa1b0, 0);
230 - nvram_read_u16(prefix, NULL, "pa1b1", &sprom->pa1b1, 0);
231 - nvram_read_u16(prefix, NULL, "pa1b2", &sprom->pa1b2, 0);
232 - nvram_read_u8(prefix, NULL, "pa1itssit", &sprom->itssi_a, 0);
233 - nvram_read_u8(prefix, NULL, "pa1maxpwr", &sprom->maxpwr_a, 0);
234 -}
235 -
236 -static void bcm47xx_fill_sprom_r1(struct ssb_sprom *sprom, const char *prefix)
237 -{
238 - nvram_read_u16(prefix, NULL, "boardflags", &sprom->boardflags_lo, 0);
239 - nvram_read_u8(prefix, NULL, "cc", &sprom->country_code, 0);
240 + nvram_read_u16(prefix, NULL, "pa0b0", &sprom->pa0b0, 0, fallback);
241 + nvram_read_u16(prefix, NULL, "pa0b1", &sprom->pa0b1, 0, fallback);
242 + nvram_read_u16(prefix, NULL, "pa0b2", &sprom->pa0b2, 0, fallback);
243 + nvram_read_u8(prefix, NULL, "pa0itssit", &sprom->itssi_bg, 0, fallback);
244 + nvram_read_u8(prefix, NULL, "pa0maxpwr", &sprom->maxpwr_bg, 0,
245 + fallback);
246 + nvram_read_u16(prefix, NULL, "pa1b0", &sprom->pa1b0, 0, fallback);
247 + nvram_read_u16(prefix, NULL, "pa1b1", &sprom->pa1b1, 0, fallback);
248 + nvram_read_u16(prefix, NULL, "pa1b2", &sprom->pa1b2, 0, fallback);
249 + nvram_read_u8(prefix, NULL, "pa1itssit", &sprom->itssi_a, 0, fallback);
250 + nvram_read_u8(prefix, NULL, "pa1maxpwr", &sprom->maxpwr_a, 0, fallback);
251 +}
252 +
253 +static void bcm47xx_fill_sprom_r1(struct ssb_sprom *sprom, const char *prefix,
254 + bool fallback)
255 +{
256 + nvram_read_u16(prefix, NULL, "boardflags", &sprom->boardflags_lo, 0,
257 + fallback);
258 + nvram_read_u8(prefix, NULL, "cc", &sprom->country_code, 0, fallback);
259 }
260
261 static void bcm47xx_fill_sprom_r2389(struct ssb_sprom *sprom,
262 - const char *prefix)
263 + const char *prefix, bool fallback)
264 {
265 - nvram_read_u8(prefix, NULL, "opo", &sprom->opo, 0);
266 - nvram_read_u16(prefix, NULL, "pa1lob0", &sprom->pa1lob0, 0);
267 - nvram_read_u16(prefix, NULL, "pa1lob1", &sprom->pa1lob1, 0);
268 - nvram_read_u16(prefix, NULL, "pa1lob2", &sprom->pa1lob2, 0);
269 - nvram_read_u16(prefix, NULL, "pa1hib0", &sprom->pa1hib0, 0);
270 - nvram_read_u16(prefix, NULL, "pa1hib1", &sprom->pa1hib1, 0);
271 - nvram_read_u16(prefix, NULL, "pa1hib2", &sprom->pa1hib2, 0);
272 - nvram_read_u8(prefix, NULL, "pa1lomaxpwr", &sprom->maxpwr_al, 0);
273 - nvram_read_u8(prefix, NULL, "pa1himaxpwr", &sprom->maxpwr_ah, 0);
274 -}
275 -
276 -static void bcm47xx_fill_sprom_r389(struct ssb_sprom *sprom, const char *prefix)
277 -{
278 - nvram_read_u8(prefix, NULL, "bxa2g", &sprom->bxa2g, 0);
279 - nvram_read_u8(prefix, NULL, "rssisav2g", &sprom->rssisav2g, 0);
280 - nvram_read_u8(prefix, NULL, "rssismc2g", &sprom->rssismc2g, 0);
281 - nvram_read_u8(prefix, NULL, "rssismf2g", &sprom->rssismf2g, 0);
282 - nvram_read_u8(prefix, NULL, "bxa5g", &sprom->bxa5g, 0);
283 - nvram_read_u8(prefix, NULL, "rssisav5g", &sprom->rssisav5g, 0);
284 - nvram_read_u8(prefix, NULL, "rssismc5g", &sprom->rssismc5g, 0);
285 - nvram_read_u8(prefix, NULL, "rssismf5g", &sprom->rssismf5g, 0);
286 - nvram_read_u8(prefix, NULL, "tri2g", &sprom->tri2g, 0);
287 - nvram_read_u8(prefix, NULL, "tri5g", &sprom->tri5g, 0);
288 - nvram_read_u8(prefix, NULL, "tri5gl", &sprom->tri5gl, 0);
289 - nvram_read_u8(prefix, NULL, "tri5gh", &sprom->tri5gh, 0);
290 - nvram_read_s8(prefix, NULL, "rxpo2g", &sprom->rxpo2g, 0);
291 - nvram_read_s8(prefix, NULL, "rxpo5g", &sprom->rxpo5g, 0);
292 + nvram_read_u8(prefix, NULL, "opo", &sprom->opo, 0, fallback);
293 + nvram_read_u16(prefix, NULL, "pa1lob0", &sprom->pa1lob0, 0, fallback);
294 + nvram_read_u16(prefix, NULL, "pa1lob1", &sprom->pa1lob1, 0, fallback);
295 + nvram_read_u16(prefix, NULL, "pa1lob2", &sprom->pa1lob2, 0, fallback);
296 + nvram_read_u16(prefix, NULL, "pa1hib0", &sprom->pa1hib0, 0, fallback);
297 + nvram_read_u16(prefix, NULL, "pa1hib1", &sprom->pa1hib1, 0, fallback);
298 + nvram_read_u16(prefix, NULL, "pa1hib2", &sprom->pa1hib2, 0, fallback);
299 + nvram_read_u8(prefix, NULL, "pa1lomaxpwr", &sprom->maxpwr_al, 0,
300 + fallback);
301 + nvram_read_u8(prefix, NULL, "pa1himaxpwr", &sprom->maxpwr_ah, 0,
302 + fallback);
303 +}
304 +
305 +static void bcm47xx_fill_sprom_r389(struct ssb_sprom *sprom, const char *prefix,
306 + bool fallback)
307 +{
308 + nvram_read_u8(prefix, NULL, "bxa2g", &sprom->bxa2g, 0, fallback);
309 + nvram_read_u8(prefix, NULL, "rssisav2g", &sprom->rssisav2g, 0,
310 + fallback);
311 + nvram_read_u8(prefix, NULL, "rssismc2g", &sprom->rssismc2g, 0,
312 + fallback);
313 + nvram_read_u8(prefix, NULL, "rssismf2g", &sprom->rssismf2g, 0,
314 + fallback);
315 + nvram_read_u8(prefix, NULL, "bxa5g", &sprom->bxa5g, 0, fallback);
316 + nvram_read_u8(prefix, NULL, "rssisav5g", &sprom->rssisav5g, 0,
317 + fallback);
318 + nvram_read_u8(prefix, NULL, "rssismc5g", &sprom->rssismc5g, 0,
319 + fallback);
320 + nvram_read_u8(prefix, NULL, "rssismf5g", &sprom->rssismf5g, 0,
321 + fallback);
322 + nvram_read_u8(prefix, NULL, "tri2g", &sprom->tri2g, 0, fallback);
323 + nvram_read_u8(prefix, NULL, "tri5g", &sprom->tri5g, 0, fallback);
324 + nvram_read_u8(prefix, NULL, "tri5gl", &sprom->tri5gl, 0, fallback);
325 + nvram_read_u8(prefix, NULL, "tri5gh", &sprom->tri5gh, 0, fallback);
326 + nvram_read_s8(prefix, NULL, "rxpo2g", &sprom->rxpo2g, 0, fallback);
327 + nvram_read_s8(prefix, NULL, "rxpo5g", &sprom->rxpo5g, 0, fallback);
328 }
329
330 -static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, const char *prefix)
331 +static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, const char *prefix,
332 + bool fallback)
333 {
334 - nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0);
335 + nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0, fallback);
336 nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
337 - &sprom->leddc_off_time);
338 + &sprom->leddc_off_time, fallback);
339 }
340
341 static void bcm47xx_fill_sprom_r4589(struct ssb_sprom *sprom,
342 - const char *prefix)
343 + const char *prefix, bool fallback)
344 {
345 - nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0);
346 - nvram_read_s8(prefix, NULL, "ag2", &sprom->antenna_gain.a2, 0);
347 - nvram_read_s8(prefix, NULL, "ag3", &sprom->antenna_gain.a3, 0);
348 - nvram_read_u8(prefix, NULL, "txchain", &sprom->txchain, 0xf);
349 - nvram_read_u8(prefix, NULL, "rxchain", &sprom->rxchain, 0xf);
350 - nvram_read_u8(prefix, NULL, "antswitch", &sprom->antswitch, 0xff);
351 + nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0, fallback);
352 + nvram_read_s8(prefix, NULL, "ag2", &sprom->antenna_gain.a2, 0,
353 + fallback);
354 + nvram_read_s8(prefix, NULL, "ag3", &sprom->antenna_gain.a3, 0,
355 + fallback);
356 + nvram_read_u8(prefix, NULL, "txchain", &sprom->txchain, 0xf, fallback);
357 + nvram_read_u8(prefix, NULL, "rxchain", &sprom->rxchain, 0xf, fallback);
358 + nvram_read_u8(prefix, NULL, "antswitch", &sprom->antswitch, 0xff,
359 + fallback);
360 nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
361 - &sprom->leddc_off_time);
362 + &sprom->leddc_off_time, fallback);
363 }
364
365 -static void bcm47xx_fill_sprom_r458(struct ssb_sprom *sprom, const char *prefix)
366 +static void bcm47xx_fill_sprom_r458(struct ssb_sprom *sprom, const char *prefix,
367 + bool fallback)
368 {
369 - nvram_read_u16(prefix, NULL, "cck2gpo", &sprom->cck2gpo, 0);
370 - nvram_read_u32(prefix, NULL, "ofdm2gpo", &sprom->ofdm2gpo, 0);
371 - nvram_read_u32(prefix, NULL, "ofdm5gpo", &sprom->ofdm5gpo, 0);
372 - nvram_read_u32(prefix, NULL, "ofdm5glpo", &sprom->ofdm5glpo, 0);
373 - nvram_read_u32(prefix, NULL, "ofdm5ghpo", &sprom->ofdm5ghpo, 0);
374 - nvram_read_u16(prefix, NULL, "cddpo", &sprom->cddpo, 0);
375 - nvram_read_u16(prefix, NULL, "stbcpo", &sprom->stbcpo, 0);
376 - nvram_read_u16(prefix, NULL, "bw40po", &sprom->bw40po, 0);
377 - nvram_read_u16(prefix, NULL, "bwduppo", &sprom->bwduppo, 0);
378 - nvram_read_u16(prefix, NULL, "mcs2gpo0", &sprom->mcs2gpo[0], 0);
379 - nvram_read_u16(prefix, NULL, "mcs2gpo1", &sprom->mcs2gpo[1], 0);
380 - nvram_read_u16(prefix, NULL, "mcs2gpo2", &sprom->mcs2gpo[2], 0);
381 - nvram_read_u16(prefix, NULL, "mcs2gpo3", &sprom->mcs2gpo[3], 0);
382 - nvram_read_u16(prefix, NULL, "mcs2gpo4", &sprom->mcs2gpo[4], 0);
383 - nvram_read_u16(prefix, NULL, "mcs2gpo5", &sprom->mcs2gpo[5], 0);
384 - nvram_read_u16(prefix, NULL, "mcs2gpo6", &sprom->mcs2gpo[6], 0);
385 - nvram_read_u16(prefix, NULL, "mcs2gpo7", &sprom->mcs2gpo[7], 0);
386 - nvram_read_u16(prefix, NULL, "mcs5gpo0", &sprom->mcs5gpo[0], 0);
387 - nvram_read_u16(prefix, NULL, "mcs5gpo1", &sprom->mcs5gpo[1], 0);
388 - nvram_read_u16(prefix, NULL, "mcs5gpo2", &sprom->mcs5gpo[2], 0);
389 - nvram_read_u16(prefix, NULL, "mcs5gpo3", &sprom->mcs5gpo[3], 0);
390 - nvram_read_u16(prefix, NULL, "mcs5gpo4", &sprom->mcs5gpo[4], 0);
391 - nvram_read_u16(prefix, NULL, "mcs5gpo5", &sprom->mcs5gpo[5], 0);
392 - nvram_read_u16(prefix, NULL, "mcs5gpo6", &sprom->mcs5gpo[6], 0);
393 - nvram_read_u16(prefix, NULL, "mcs5gpo7", &sprom->mcs5gpo[7], 0);
394 - nvram_read_u16(prefix, NULL, "mcs5glpo0", &sprom->mcs5glpo[0], 0);
395 - nvram_read_u16(prefix, NULL, "mcs5glpo1", &sprom->mcs5glpo[1], 0);
396 - nvram_read_u16(prefix, NULL, "mcs5glpo2", &sprom->mcs5glpo[2], 0);
397 - nvram_read_u16(prefix, NULL, "mcs5glpo3", &sprom->mcs5glpo[3], 0);
398 - nvram_read_u16(prefix, NULL, "mcs5glpo4", &sprom->mcs5glpo[4], 0);
399 - nvram_read_u16(prefix, NULL, "mcs5glpo5", &sprom->mcs5glpo[5], 0);
400 - nvram_read_u16(prefix, NULL, "mcs5glpo6", &sprom->mcs5glpo[6], 0);
401 - nvram_read_u16(prefix, NULL, "mcs5glpo7", &sprom->mcs5glpo[7], 0);
402 - nvram_read_u16(prefix, NULL, "mcs5ghpo0", &sprom->mcs5ghpo[0], 0);
403 - nvram_read_u16(prefix, NULL, "mcs5ghpo1", &sprom->mcs5ghpo[1], 0);
404 - nvram_read_u16(prefix, NULL, "mcs5ghpo2", &sprom->mcs5ghpo[2], 0);
405 - nvram_read_u16(prefix, NULL, "mcs5ghpo3", &sprom->mcs5ghpo[3], 0);
406 - nvram_read_u16(prefix, NULL, "mcs5ghpo4", &sprom->mcs5ghpo[4], 0);
407 - nvram_read_u16(prefix, NULL, "mcs5ghpo5", &sprom->mcs5ghpo[5], 0);
408 - nvram_read_u16(prefix, NULL, "mcs5ghpo6", &sprom->mcs5ghpo[6], 0);
409 - nvram_read_u16(prefix, NULL, "mcs5ghpo7", &sprom->mcs5ghpo[7], 0);
410 -}
411 -
412 -static void bcm47xx_fill_sprom_r45(struct ssb_sprom *sprom, const char *prefix)
413 -{
414 - nvram_read_u8(prefix, NULL, "txpid2ga0", &sprom->txpid2g[0], 0);
415 - nvram_read_u8(prefix, NULL, "txpid2ga1", &sprom->txpid2g[1], 0);
416 - nvram_read_u8(prefix, NULL, "txpid2ga2", &sprom->txpid2g[2], 0);
417 - nvram_read_u8(prefix, NULL, "txpid2ga3", &sprom->txpid2g[3], 0);
418 - nvram_read_u8(prefix, NULL, "txpid5ga0", &sprom->txpid5g[0], 0);
419 - nvram_read_u8(prefix, NULL, "txpid5ga1", &sprom->txpid5g[1], 0);
420 - nvram_read_u8(prefix, NULL, "txpid5ga2", &sprom->txpid5g[2], 0);
421 - nvram_read_u8(prefix, NULL, "txpid5ga3", &sprom->txpid5g[3], 0);
422 - nvram_read_u8(prefix, NULL, "txpid5gla0", &sprom->txpid5gl[0], 0);
423 - nvram_read_u8(prefix, NULL, "txpid5gla1", &sprom->txpid5gl[1], 0);
424 - nvram_read_u8(prefix, NULL, "txpid5gla2", &sprom->txpid5gl[2], 0);
425 - nvram_read_u8(prefix, NULL, "txpid5gla3", &sprom->txpid5gl[3], 0);
426 - nvram_read_u8(prefix, NULL, "txpid5gha0", &sprom->txpid5gh[0], 0);
427 - nvram_read_u8(prefix, NULL, "txpid5gha1", &sprom->txpid5gh[1], 0);
428 - nvram_read_u8(prefix, NULL, "txpid5gha2", &sprom->txpid5gh[2], 0);
429 - nvram_read_u8(prefix, NULL, "txpid5gha3", &sprom->txpid5gh[3], 0);
430 + nvram_read_u16(prefix, NULL, "cck2gpo", &sprom->cck2gpo, 0, fallback);
431 + nvram_read_u32(prefix, NULL, "ofdm2gpo", &sprom->ofdm2gpo, 0, fallback);
432 + nvram_read_u32(prefix, NULL, "ofdm5gpo", &sprom->ofdm5gpo, 0, fallback);
433 + nvram_read_u32(prefix, NULL, "ofdm5glpo", &sprom->ofdm5glpo, 0,
434 + fallback);
435 + nvram_read_u32(prefix, NULL, "ofdm5ghpo", &sprom->ofdm5ghpo, 0,
436 + fallback);
437 + nvram_read_u16(prefix, NULL, "cddpo", &sprom->cddpo, 0, fallback);
438 + nvram_read_u16(prefix, NULL, "stbcpo", &sprom->stbcpo, 0, fallback);
439 + nvram_read_u16(prefix, NULL, "bw40po", &sprom->bw40po, 0, fallback);
440 + nvram_read_u16(prefix, NULL, "bwduppo", &sprom->bwduppo, 0, fallback);
441 + nvram_read_u16(prefix, NULL, "mcs2gpo0", &sprom->mcs2gpo[0], 0,
442 + fallback);
443 + nvram_read_u16(prefix, NULL, "mcs2gpo1", &sprom->mcs2gpo[1], 0,
444 + fallback);
445 + nvram_read_u16(prefix, NULL, "mcs2gpo2", &sprom->mcs2gpo[2], 0,
446 + fallback);
447 + nvram_read_u16(prefix, NULL, "mcs2gpo3", &sprom->mcs2gpo[3], 0,
448 + fallback);
449 + nvram_read_u16(prefix, NULL, "mcs2gpo4", &sprom->mcs2gpo[4], 0,
450 + fallback);
451 + nvram_read_u16(prefix, NULL, "mcs2gpo5", &sprom->mcs2gpo[5], 0,
452 + fallback);
453 + nvram_read_u16(prefix, NULL, "mcs2gpo6", &sprom->mcs2gpo[6], 0,
454 + fallback);
455 + nvram_read_u16(prefix, NULL, "mcs2gpo7", &sprom->mcs2gpo[7], 0,
456 + fallback);
457 + nvram_read_u16(prefix, NULL, "mcs5gpo0", &sprom->mcs5gpo[0], 0,
458 + fallback);
459 + nvram_read_u16(prefix, NULL, "mcs5gpo1", &sprom->mcs5gpo[1], 0,
460 + fallback);
461 + nvram_read_u16(prefix, NULL, "mcs5gpo2", &sprom->mcs5gpo[2], 0,
462 + fallback);
463 + nvram_read_u16(prefix, NULL, "mcs5gpo3", &sprom->mcs5gpo[3], 0,
464 + fallback);
465 + nvram_read_u16(prefix, NULL, "mcs5gpo4", &sprom->mcs5gpo[4], 0,
466 + fallback);
467 + nvram_read_u16(prefix, NULL, "mcs5gpo5", &sprom->mcs5gpo[5], 0,
468 + fallback);
469 + nvram_read_u16(prefix, NULL, "mcs5gpo6", &sprom->mcs5gpo[6], 0,
470 + fallback);
471 + nvram_read_u16(prefix, NULL, "mcs5gpo7", &sprom->mcs5gpo[7], 0,
472 + fallback);
473 + nvram_read_u16(prefix, NULL, "mcs5glpo0", &sprom->mcs5glpo[0], 0,
474 + fallback);
475 + nvram_read_u16(prefix, NULL, "mcs5glpo1", &sprom->mcs5glpo[1], 0,
476 + fallback);
477 + nvram_read_u16(prefix, NULL, "mcs5glpo2", &sprom->mcs5glpo[2], 0,
478 + fallback);
479 + nvram_read_u16(prefix, NULL, "mcs5glpo3", &sprom->mcs5glpo[3], 0,
480 + fallback);
481 + nvram_read_u16(prefix, NULL, "mcs5glpo4", &sprom->mcs5glpo[4], 0,
482 + fallback);
483 + nvram_read_u16(prefix, NULL, "mcs5glpo5", &sprom->mcs5glpo[5], 0,
484 + fallback);
485 + nvram_read_u16(prefix, NULL, "mcs5glpo6", &sprom->mcs5glpo[6], 0,
486 + fallback);
487 + nvram_read_u16(prefix, NULL, "mcs5glpo7", &sprom->mcs5glpo[7], 0,
488 + fallback);
489 + nvram_read_u16(prefix, NULL, "mcs5ghpo0", &sprom->mcs5ghpo[0], 0,
490 + fallback);
491 + nvram_read_u16(prefix, NULL, "mcs5ghpo1", &sprom->mcs5ghpo[1], 0,
492 + fallback);
493 + nvram_read_u16(prefix, NULL, "mcs5ghpo2", &sprom->mcs5ghpo[2], 0,
494 + fallback);
495 + nvram_read_u16(prefix, NULL, "mcs5ghpo3", &sprom->mcs5ghpo[3], 0,
496 + fallback);
497 + nvram_read_u16(prefix, NULL, "mcs5ghpo4", &sprom->mcs5ghpo[4], 0,
498 + fallback);
499 + nvram_read_u16(prefix, NULL, "mcs5ghpo5", &sprom->mcs5ghpo[5], 0,
500 + fallback);
501 + nvram_read_u16(prefix, NULL, "mcs5ghpo6", &sprom->mcs5ghpo[6], 0,
502 + fallback);
503 + nvram_read_u16(prefix, NULL, "mcs5ghpo7", &sprom->mcs5ghpo[7], 0,
504 + fallback);
505 +}
506 +
507 +static void bcm47xx_fill_sprom_r45(struct ssb_sprom *sprom, const char *prefix,
508 + bool fallback)
509 +{
510 + nvram_read_u8(prefix, NULL, "txpid2ga0", &sprom->txpid2g[0], 0,
511 + fallback);
512 + nvram_read_u8(prefix, NULL, "txpid2ga1", &sprom->txpid2g[1], 0,
513 + fallback);
514 + nvram_read_u8(prefix, NULL, "txpid2ga2", &sprom->txpid2g[2], 0,
515 + fallback);
516 + nvram_read_u8(prefix, NULL, "txpid2ga3", &sprom->txpid2g[3], 0,
517 + fallback);
518 + nvram_read_u8(prefix, NULL, "txpid5ga0", &sprom->txpid5g[0], 0,
519 + fallback);
520 + nvram_read_u8(prefix, NULL, "txpid5ga1", &sprom->txpid5g[1], 0,
521 + fallback);
522 + nvram_read_u8(prefix, NULL, "txpid5ga2", &sprom->txpid5g[2], 0,
523 + fallback);
524 + nvram_read_u8(prefix, NULL, "txpid5ga3", &sprom->txpid5g[3], 0,
525 + fallback);
526 + nvram_read_u8(prefix, NULL, "txpid5gla0", &sprom->txpid5gl[0], 0,
527 + fallback);
528 + nvram_read_u8(prefix, NULL, "txpid5gla1", &sprom->txpid5gl[1], 0,
529 + fallback);
530 + nvram_read_u8(prefix, NULL, "txpid5gla2", &sprom->txpid5gl[2], 0,
531 + fallback);
532 + nvram_read_u8(prefix, NULL, "txpid5gla3", &sprom->txpid5gl[3], 0,
533 + fallback);
534 + nvram_read_u8(prefix, NULL, "txpid5gha0", &sprom->txpid5gh[0], 0,
535 + fallback);
536 + nvram_read_u8(prefix, NULL, "txpid5gha1", &sprom->txpid5gh[1], 0,
537 + fallback);
538 + nvram_read_u8(prefix, NULL, "txpid5gha2", &sprom->txpid5gh[2], 0,
539 + fallback);
540 + nvram_read_u8(prefix, NULL, "txpid5gha3", &sprom->txpid5gh[3], 0,
541 + fallback);
542 }
543
544 -static void bcm47xx_fill_sprom_r89(struct ssb_sprom *sprom, const char *prefix)
545 +static void bcm47xx_fill_sprom_r89(struct ssb_sprom *sprom, const char *prefix,
546 + bool fallback)
547 {
548 - nvram_read_u8(prefix, NULL, "tssipos2g", &sprom->fem.ghz2.tssipos, 0);
549 + nvram_read_u8(prefix, NULL, "tssipos2g", &sprom->fem.ghz2.tssipos, 0,
550 + fallback);
551 nvram_read_u8(prefix, NULL, "extpagain2g",
552 - &sprom->fem.ghz2.extpa_gain, 0);
553 + &sprom->fem.ghz2.extpa_gain, 0, fallback);
554 nvram_read_u8(prefix, NULL, "pdetrange2g",
555 - &sprom->fem.ghz2.pdet_range, 0);
556 - nvram_read_u8(prefix, NULL, "triso2g", &sprom->fem.ghz2.tr_iso, 0);
557 - nvram_read_u8(prefix, NULL, "antswctl2g", &sprom->fem.ghz2.antswlut, 0);
558 - nvram_read_u8(prefix, NULL, "tssipos5g", &sprom->fem.ghz5.tssipos, 0);
559 + &sprom->fem.ghz2.pdet_range, 0, fallback);
560 + nvram_read_u8(prefix, NULL, "triso2g", &sprom->fem.ghz2.tr_iso, 0,
561 + fallback);
562 + nvram_read_u8(prefix, NULL, "antswctl2g", &sprom->fem.ghz2.antswlut, 0,
563 + fallback);
564 + nvram_read_u8(prefix, NULL, "tssipos5g", &sprom->fem.ghz5.tssipos, 0,
565 + fallback);
566 nvram_read_u8(prefix, NULL, "extpagain5g",
567 - &sprom->fem.ghz5.extpa_gain, 0);
568 + &sprom->fem.ghz5.extpa_gain, 0, fallback);
569 nvram_read_u8(prefix, NULL, "pdetrange5g",
570 - &sprom->fem.ghz5.pdet_range, 0);
571 - nvram_read_u8(prefix, NULL, "triso5g", &sprom->fem.ghz5.tr_iso, 0);
572 - nvram_read_u8(prefix, NULL, "antswctl5g", &sprom->fem.ghz5.antswlut, 0);
573 - nvram_read_u8(prefix, NULL, "tempthresh", &sprom->tempthresh, 0);
574 - nvram_read_u8(prefix, NULL, "tempoffset", &sprom->tempoffset, 0);
575 - nvram_read_u16(prefix, NULL, "rawtempsense", &sprom->rawtempsense, 0);
576 - nvram_read_u8(prefix, NULL, "measpower", &sprom->measpower, 0);
577 + &sprom->fem.ghz5.pdet_range, 0, fallback);
578 + nvram_read_u8(prefix, NULL, "triso5g", &sprom->fem.ghz5.tr_iso, 0,
579 + fallback);
580 + nvram_read_u8(prefix, NULL, "antswctl5g", &sprom->fem.ghz5.antswlut, 0,
581 + fallback);
582 + nvram_read_u8(prefix, NULL, "tempthresh", &sprom->tempthresh, 0,
583 + fallback);
584 + nvram_read_u8(prefix, NULL, "tempoffset", &sprom->tempoffset, 0,
585 + fallback);
586 + nvram_read_u16(prefix, NULL, "rawtempsense", &sprom->rawtempsense, 0,
587 + fallback);
588 + nvram_read_u8(prefix, NULL, "measpower", &sprom->measpower, 0,
589 + fallback);
590 nvram_read_u8(prefix, NULL, "tempsense_slope",
591 - &sprom->tempsense_slope, 0);
592 - nvram_read_u8(prefix, NULL, "tempcorrx", &sprom->tempcorrx, 0);
593 + &sprom->tempsense_slope, 0, fallback);
594 + nvram_read_u8(prefix, NULL, "tempcorrx", &sprom->tempcorrx, 0,
595 + fallback);
596 nvram_read_u8(prefix, NULL, "tempsense_option",
597 - &sprom->tempsense_option, 0);
598 + &sprom->tempsense_option, 0, fallback);
599 nvram_read_u8(prefix, NULL, "freqoffset_corr",
600 - &sprom->freqoffset_corr, 0);
601 - nvram_read_u8(prefix, NULL, "iqcal_swp_dis", &sprom->iqcal_swp_dis, 0);
602 - nvram_read_u8(prefix, NULL, "hw_iqcal_en", &sprom->hw_iqcal_en, 0);
603 - nvram_read_u8(prefix, NULL, "elna2g", &sprom->elna2g, 0);
604 - nvram_read_u8(prefix, NULL, "elna5g", &sprom->elna5g, 0);
605 + &sprom->freqoffset_corr, 0, fallback);
606 + nvram_read_u8(prefix, NULL, "iqcal_swp_dis", &sprom->iqcal_swp_dis, 0,
607 + fallback);
608 + nvram_read_u8(prefix, NULL, "hw_iqcal_en", &sprom->hw_iqcal_en, 0,
609 + fallback);
610 + nvram_read_u8(prefix, NULL, "elna2g", &sprom->elna2g, 0, fallback);
611 + nvram_read_u8(prefix, NULL, "elna5g", &sprom->elna5g, 0, fallback);
612 nvram_read_u8(prefix, NULL, "phycal_tempdelta",
613 - &sprom->phycal_tempdelta, 0);
614 - nvram_read_u8(prefix, NULL, "temps_period", &sprom->temps_period, 0);
615 + &sprom->phycal_tempdelta, 0, fallback);
616 + nvram_read_u8(prefix, NULL, "temps_period", &sprom->temps_period, 0,
617 + fallback);
618 nvram_read_u8(prefix, NULL, "temps_hysteresis",
619 - &sprom->temps_hysteresis, 0);
620 - nvram_read_u8(prefix, NULL, "measpower1", &sprom->measpower1, 0);
621 - nvram_read_u8(prefix, NULL, "measpower2", &sprom->measpower2, 0);
622 + &sprom->temps_hysteresis, 0, fallback);
623 + nvram_read_u8(prefix, NULL, "measpower1", &sprom->measpower1, 0,
624 + fallback);
625 + nvram_read_u8(prefix, NULL, "measpower2", &sprom->measpower2, 0,
626 + fallback);
627 nvram_read_u8(prefix, NULL, "rxgainerr2ga0",
628 - &sprom->rxgainerr2ga[0], 0);
629 + &sprom->rxgainerr2ga[0], 0, fallback);
630 nvram_read_u8(prefix, NULL, "rxgainerr2ga1",
631 - &sprom->rxgainerr2ga[1], 0);
632 + &sprom->rxgainerr2ga[1], 0, fallback);
633 nvram_read_u8(prefix, NULL, "rxgainerr2ga2",
634 - &sprom->rxgainerr2ga[2], 0);
635 + &sprom->rxgainerr2ga[2], 0, fallback);
636 nvram_read_u8(prefix, NULL, "rxgainerr5gla0",
637 - &sprom->rxgainerr5gla[0], 0);
638 + &sprom->rxgainerr5gla[0], 0, fallback);
639 nvram_read_u8(prefix, NULL, "rxgainerr5gla1",
640 - &sprom->rxgainerr5gla[1], 0);
641 + &sprom->rxgainerr5gla[1], 0, fallback);
642 nvram_read_u8(prefix, NULL, "rxgainerr5gla2",
643 - &sprom->rxgainerr5gla[2], 0);
644 + &sprom->rxgainerr5gla[2], 0, fallback);
645 nvram_read_u8(prefix, NULL, "rxgainerr5gma0",
646 - &sprom->rxgainerr5gma[0], 0);
647 + &sprom->rxgainerr5gma[0], 0, fallback);
648 nvram_read_u8(prefix, NULL, "rxgainerr5gma1",
649 - &sprom->rxgainerr5gma[1], 0);
650 + &sprom->rxgainerr5gma[1], 0, fallback);
651 nvram_read_u8(prefix, NULL, "rxgainerr5gma2",
652 - &sprom->rxgainerr5gma[2], 0);
653 + &sprom->rxgainerr5gma[2], 0, fallback);
654 nvram_read_u8(prefix, NULL, "rxgainerr5gha0",
655 - &sprom->rxgainerr5gha[0], 0);
656 + &sprom->rxgainerr5gha[0], 0, fallback);
657 nvram_read_u8(prefix, NULL, "rxgainerr5gha1",
658 - &sprom->rxgainerr5gha[1], 0);
659 + &sprom->rxgainerr5gha[1], 0, fallback);
660 nvram_read_u8(prefix, NULL, "rxgainerr5gha2",
661 - &sprom->rxgainerr5gha[2], 0);
662 + &sprom->rxgainerr5gha[2], 0, fallback);
663 nvram_read_u8(prefix, NULL, "rxgainerr5gua0",
664 - &sprom->rxgainerr5gua[0], 0);
665 + &sprom->rxgainerr5gua[0], 0, fallback);
666 nvram_read_u8(prefix, NULL, "rxgainerr5gua1",
667 - &sprom->rxgainerr5gua[1], 0);
668 + &sprom->rxgainerr5gua[1], 0, fallback);
669 nvram_read_u8(prefix, NULL, "rxgainerr5gua2",
670 - &sprom->rxgainerr5gua[2], 0);
671 - nvram_read_u8(prefix, NULL, "noiselvl2ga0", &sprom->noiselvl2ga[0], 0);
672 - nvram_read_u8(prefix, NULL, "noiselvl2ga1", &sprom->noiselvl2ga[1], 0);
673 - nvram_read_u8(prefix, NULL, "noiselvl2ga2", &sprom->noiselvl2ga[2], 0);
674 + &sprom->rxgainerr5gua[2], 0, fallback);
675 + nvram_read_u8(prefix, NULL, "noiselvl2ga0", &sprom->noiselvl2ga[0], 0,
676 + fallback);
677 + nvram_read_u8(prefix, NULL, "noiselvl2ga1", &sprom->noiselvl2ga[1], 0,
678 + fallback);
679 + nvram_read_u8(prefix, NULL, "noiselvl2ga2", &sprom->noiselvl2ga[2], 0,
680 + fallback);
681 nvram_read_u8(prefix, NULL, "noiselvl5gla0",
682 - &sprom->noiselvl5gla[0], 0);
683 + &sprom->noiselvl5gla[0], 0, fallback);
684 nvram_read_u8(prefix, NULL, "noiselvl5gla1",
685 - &sprom->noiselvl5gla[1], 0);
686 + &sprom->noiselvl5gla[1], 0, fallback);
687 nvram_read_u8(prefix, NULL, "noiselvl5gla2",
688 - &sprom->noiselvl5gla[2], 0);
689 + &sprom->noiselvl5gla[2], 0, fallback);
690 nvram_read_u8(prefix, NULL, "noiselvl5gma0",
691 - &sprom->noiselvl5gma[0], 0);
692 + &sprom->noiselvl5gma[0], 0, fallback);
693 nvram_read_u8(prefix, NULL, "noiselvl5gma1",
694 - &sprom->noiselvl5gma[1], 0);
695 + &sprom->noiselvl5gma[1], 0, fallback);
696 nvram_read_u8(prefix, NULL, "noiselvl5gma2",
697 - &sprom->noiselvl5gma[2], 0);
698 + &sprom->noiselvl5gma[2], 0, fallback);
699 nvram_read_u8(prefix, NULL, "noiselvl5gha0",
700 - &sprom->noiselvl5gha[0], 0);
701 + &sprom->noiselvl5gha[0], 0, fallback);
702 nvram_read_u8(prefix, NULL, "noiselvl5gha1",
703 - &sprom->noiselvl5gha[1], 0);
704 + &sprom->noiselvl5gha[1], 0, fallback);
705 nvram_read_u8(prefix, NULL, "noiselvl5gha2",
706 - &sprom->noiselvl5gha[2], 0);
707 + &sprom->noiselvl5gha[2], 0, fallback);
708 nvram_read_u8(prefix, NULL, "noiselvl5gua0",
709 - &sprom->noiselvl5gua[0], 0);
710 + &sprom->noiselvl5gua[0], 0, fallback);
711 nvram_read_u8(prefix, NULL, "noiselvl5gua1",
712 - &sprom->noiselvl5gua[1], 0);
713 + &sprom->noiselvl5gua[1], 0, fallback);
714 nvram_read_u8(prefix, NULL, "noiselvl5gua2",
715 - &sprom->noiselvl5gua[2], 0);
716 + &sprom->noiselvl5gua[2], 0, fallback);
717 nvram_read_u8(prefix, NULL, "pcieingress_war",
718 - &sprom->pcieingress_war, 0);
719 + &sprom->pcieingress_war, 0, fallback);
720 }
721
722 -static void bcm47xx_fill_sprom_r9(struct ssb_sprom *sprom, const char *prefix)
723 +static void bcm47xx_fill_sprom_r9(struct ssb_sprom *sprom, const char *prefix,
724 + bool fallback)
725 {
726 - nvram_read_u16(prefix, NULL, "cckbw202gpo", &sprom->cckbw202gpo, 0);
727 - nvram_read_u16(prefix, NULL, "cckbw20ul2gpo", &sprom->cckbw20ul2gpo, 0);
728 + nvram_read_u16(prefix, NULL, "cckbw202gpo", &sprom->cckbw202gpo, 0,
729 + fallback);
730 + nvram_read_u16(prefix, NULL, "cckbw20ul2gpo", &sprom->cckbw20ul2gpo, 0,
731 + fallback);
732 nvram_read_u32(prefix, NULL, "legofdmbw202gpo",
733 - &sprom->legofdmbw202gpo, 0);
734 + &sprom->legofdmbw202gpo, 0, fallback);
735 nvram_read_u32(prefix, NULL, "legofdmbw20ul2gpo",
736 - &sprom->legofdmbw20ul2gpo, 0);
737 + &sprom->legofdmbw20ul2gpo, 0, fallback);
738 nvram_read_u32(prefix, NULL, "legofdmbw205glpo",
739 - &sprom->legofdmbw205glpo, 0);
740 + &sprom->legofdmbw205glpo, 0, fallback);
741 nvram_read_u32(prefix, NULL, "legofdmbw20ul5glpo",
742 - &sprom->legofdmbw20ul5glpo, 0);
743 + &sprom->legofdmbw20ul5glpo, 0, fallback);
744 nvram_read_u32(prefix, NULL, "legofdmbw205gmpo",
745 - &sprom->legofdmbw205gmpo, 0);
746 + &sprom->legofdmbw205gmpo, 0, fallback);
747 nvram_read_u32(prefix, NULL, "legofdmbw20ul5gmpo",
748 - &sprom->legofdmbw20ul5gmpo, 0);
749 + &sprom->legofdmbw20ul5gmpo, 0, fallback);
750 nvram_read_u32(prefix, NULL, "legofdmbw205ghpo",
751 - &sprom->legofdmbw205ghpo, 0);
752 + &sprom->legofdmbw205ghpo, 0, fallback);
753 nvram_read_u32(prefix, NULL, "legofdmbw20ul5ghpo",
754 - &sprom->legofdmbw20ul5ghpo, 0);
755 - nvram_read_u32(prefix, NULL, "mcsbw202gpo", &sprom->mcsbw202gpo, 0);
756 - nvram_read_u32(prefix, NULL, "mcsbw20ul2gpo", &sprom->mcsbw20ul2gpo, 0);
757 - nvram_read_u32(prefix, NULL, "mcsbw402gpo", &sprom->mcsbw402gpo, 0);
758 - nvram_read_u32(prefix, NULL, "mcsbw205glpo", &sprom->mcsbw205glpo, 0);
759 + &sprom->legofdmbw20ul5ghpo, 0, fallback);
760 + nvram_read_u32(prefix, NULL, "mcsbw202gpo", &sprom->mcsbw202gpo, 0,
761 + fallback);
762 + nvram_read_u32(prefix, NULL, "mcsbw20ul2gpo", &sprom->mcsbw20ul2gpo, 0,
763 + fallback);
764 + nvram_read_u32(prefix, NULL, "mcsbw402gpo", &sprom->mcsbw402gpo, 0,
765 + fallback);
766 + nvram_read_u32(prefix, NULL, "mcsbw205glpo", &sprom->mcsbw205glpo, 0,
767 + fallback);
768 nvram_read_u32(prefix, NULL, "mcsbw20ul5glpo",
769 - &sprom->mcsbw20ul5glpo, 0);
770 - nvram_read_u32(prefix, NULL, "mcsbw405glpo", &sprom->mcsbw405glpo, 0);
771 - nvram_read_u32(prefix, NULL, "mcsbw205gmpo", &sprom->mcsbw205gmpo, 0);
772 + &sprom->mcsbw20ul5glpo, 0, fallback);
773 + nvram_read_u32(prefix, NULL, "mcsbw405glpo", &sprom->mcsbw405glpo, 0,
774 + fallback);
775 + nvram_read_u32(prefix, NULL, "mcsbw205gmpo", &sprom->mcsbw205gmpo, 0,
776 + fallback);
777 nvram_read_u32(prefix, NULL, "mcsbw20ul5gmpo",
778 - &sprom->mcsbw20ul5gmpo, 0);
779 - nvram_read_u32(prefix, NULL, "mcsbw405gmpo", &sprom->mcsbw405gmpo, 0);
780 - nvram_read_u32(prefix, NULL, "mcsbw205ghpo", &sprom->mcsbw205ghpo, 0);
781 + &sprom->mcsbw20ul5gmpo, 0, fallback);
782 + nvram_read_u32(prefix, NULL, "mcsbw405gmpo", &sprom->mcsbw405gmpo, 0,
783 + fallback);
784 + nvram_read_u32(prefix, NULL, "mcsbw205ghpo", &sprom->mcsbw205ghpo, 0,
785 + fallback);
786 nvram_read_u32(prefix, NULL, "mcsbw20ul5ghpo",
787 - &sprom->mcsbw20ul5ghpo, 0);
788 - nvram_read_u32(prefix, NULL, "mcsbw405ghpo", &sprom->mcsbw405ghpo, 0);
789 - nvram_read_u16(prefix, NULL, "mcs32po", &sprom->mcs32po, 0);
790 + &sprom->mcsbw20ul5ghpo, 0, fallback);
791 + nvram_read_u32(prefix, NULL, "mcsbw405ghpo", &sprom->mcsbw405ghpo, 0,
792 + fallback);
793 + nvram_read_u16(prefix, NULL, "mcs32po", &sprom->mcs32po, 0, fallback);
794 nvram_read_u16(prefix, NULL, "legofdm40duppo",
795 - &sprom->legofdm40duppo, 0);
796 - nvram_read_u8(prefix, NULL, "sar2g", &sprom->sar2g, 0);
797 - nvram_read_u8(prefix, NULL, "sar5g", &sprom->sar5g, 0);
798 + &sprom->legofdm40duppo, 0, fallback);
799 + nvram_read_u8(prefix, NULL, "sar2g", &sprom->sar2g, 0, fallback);
800 + nvram_read_u8(prefix, NULL, "sar5g", &sprom->sar5g, 0, fallback);
801 }
802
803 static void bcm47xx_fill_sprom_path_r4589(struct ssb_sprom *sprom,
804 - const char *prefix)
805 + const char *prefix, bool fallback)
806 {
807 char postfix[2];
808 int i;
809 @@ -464,46 +572,46 @@ static void bcm47xx_fill_sprom_path_r458
810 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i];
811 snprintf(postfix, sizeof(postfix), "%i", i);
812 nvram_read_u8(prefix, postfix, "maxp2ga",
813 - &pwr_info->maxpwr_2g, 0);
814 + &pwr_info->maxpwr_2g, 0, fallback);
815 nvram_read_u8(prefix, postfix, "itt2ga",
816 - &pwr_info->itssi_2g, 0);
817 + &pwr_info->itssi_2g, 0, fallback);
818 nvram_read_u8(prefix, postfix, "itt5ga",
819 - &pwr_info->itssi_5g, 0);
820 + &pwr_info->itssi_5g, 0, fallback);
821 nvram_read_u16(prefix, postfix, "pa2gw0a",
822 - &pwr_info->pa_2g[0], 0);
823 + &pwr_info->pa_2g[0], 0, fallback);
824 nvram_read_u16(prefix, postfix, "pa2gw1a",
825 - &pwr_info->pa_2g[1], 0);
826 + &pwr_info->pa_2g[1], 0, fallback);
827 nvram_read_u16(prefix, postfix, "pa2gw2a",
828 - &pwr_info->pa_2g[2], 0);
829 + &pwr_info->pa_2g[2], 0, fallback);
830 nvram_read_u8(prefix, postfix, "maxp5ga",
831 - &pwr_info->maxpwr_5g, 0);
832 + &pwr_info->maxpwr_5g, 0, fallback);
833 nvram_read_u8(prefix, postfix, "maxp5gha",
834 - &pwr_info->maxpwr_5gh, 0);
835 + &pwr_info->maxpwr_5gh, 0, fallback);
836 nvram_read_u8(prefix, postfix, "maxp5gla",
837 - &pwr_info->maxpwr_5gl, 0);
838 + &pwr_info->maxpwr_5gl, 0, fallback);
839 nvram_read_u16(prefix, postfix, "pa5gw0a",
840 - &pwr_info->pa_5g[0], 0);
841 + &pwr_info->pa_5g[0], 0, fallback);
842 nvram_read_u16(prefix, postfix, "pa5gw1a",
843 - &pwr_info->pa_5g[1], 0);
844 + &pwr_info->pa_5g[1], 0, fallback);
845 nvram_read_u16(prefix, postfix, "pa5gw2a",
846 - &pwr_info->pa_5g[2], 0);
847 + &pwr_info->pa_5g[2], 0, fallback);
848 nvram_read_u16(prefix, postfix, "pa5glw0a",
849 - &pwr_info->pa_5gl[0], 0);
850 + &pwr_info->pa_5gl[0], 0, fallback);
851 nvram_read_u16(prefix, postfix, "pa5glw1a",
852 - &pwr_info->pa_5gl[1], 0);
853 + &pwr_info->pa_5gl[1], 0, fallback);
854 nvram_read_u16(prefix, postfix, "pa5glw2a",
855 - &pwr_info->pa_5gl[2], 0);
856 + &pwr_info->pa_5gl[2], 0, fallback);
857 nvram_read_u16(prefix, postfix, "pa5ghw0a",
858 - &pwr_info->pa_5gh[0], 0);
859 + &pwr_info->pa_5gh[0], 0, fallback);
860 nvram_read_u16(prefix, postfix, "pa5ghw1a",
861 - &pwr_info->pa_5gh[1], 0);
862 + &pwr_info->pa_5gh[1], 0, fallback);
863 nvram_read_u16(prefix, postfix, "pa5ghw2a",
864 - &pwr_info->pa_5gh[2], 0);
865 + &pwr_info->pa_5gh[2], 0, fallback);
866 }
867 }
868
869 static void bcm47xx_fill_sprom_path_r45(struct ssb_sprom *sprom,
870 - const char *prefix)
871 + const char *prefix, bool fallback)
872 {
873 char postfix[2];
874 int i;
875 @@ -512,104 +620,112 @@ static void bcm47xx_fill_sprom_path_r45(
876 struct ssb_sprom_core_pwr_info *pwr_info = &sprom->core_pwr_info[i];
877 snprintf(postfix, sizeof(postfix), "%i", i);
878 nvram_read_u16(prefix, postfix, "pa2gw3a",
879 - &pwr_info->pa_2g[3], 0);
880 + &pwr_info->pa_2g[3], 0, fallback);
881 nvram_read_u16(prefix, postfix, "pa5gw3a",
882 - &pwr_info->pa_5g[3], 0);
883 + &pwr_info->pa_5g[3], 0, fallback);
884 nvram_read_u16(prefix, postfix, "pa5glw3a",
885 - &pwr_info->pa_5gl[3], 0);
886 + &pwr_info->pa_5gl[3], 0, fallback);
887 nvram_read_u16(prefix, postfix, "pa5ghw3a",
888 - &pwr_info->pa_5gh[3], 0);
889 + &pwr_info->pa_5gh[3], 0, fallback);
890 }
891 }
892
893 -void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix)
894 -{
895 - nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac);
896 - nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0);
897 - nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0);
898 -
899 - nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac);
900 - nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0);
901 - nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0);
902 -
903 - nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac);
904 - nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac);
905 -}
906 -
907 -static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix)
908 +static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom,
909 + const char *prefix, bool fallback)
910 {
911 - nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0);
912 - if (!sprom->board_rev)
913 - nvram_read_u16(NULL, NULL, "boardrev", &sprom->board_rev, 0);
914 - nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0);
915 - nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
916 + nvram_read_macaddr(prefix, "et0macaddr", &sprom->et0mac, fallback);
917 + nvram_read_u8(prefix, NULL, "et0mdcport", &sprom->et0mdcport, 0,
918 + fallback);
919 + nvram_read_u8(prefix, NULL, "et0phyaddr", &sprom->et0phyaddr, 0,
920 + fallback);
921 +
922 + nvram_read_macaddr(prefix, "et1macaddr", &sprom->et1mac, fallback);
923 + nvram_read_u8(prefix, NULL, "et1mdcport", &sprom->et1mdcport, 0,
924 + fallback);
925 + nvram_read_u8(prefix, NULL, "et1phyaddr", &sprom->et1phyaddr, 0,
926 + fallback);
927 +
928 + nvram_read_macaddr(prefix, "macaddr", &sprom->il0mac, fallback);
929 + nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac, fallback);
930 +}
931 +
932 +static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix,
933 + bool fallback)
934 +{
935 + nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0,
936 + fallback);
937 + nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0,
938 + fallback);
939 + nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0,
940 + fallback);
941 nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
942 - &sprom->boardflags_hi);
943 + &sprom->boardflags_hi, fallback);
944 nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo,
945 - &sprom->boardflags2_hi);
946 + &sprom->boardflags2_hi, fallback);
947 }
948
949 -void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
950 +void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
951 + bool fallback)
952 {
953 - bcm47xx_fill_sprom_ethernet(sprom, prefix);
954 - bcm47xx_fill_board_data(sprom, prefix);
955 + bcm47xx_fill_sprom_ethernet(sprom, prefix, fallback);
956 + bcm47xx_fill_board_data(sprom, prefix, fallback);
957
958 - nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0);
959 + nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0, fallback);
960
961 switch (sprom->revision) {
962 case 1:
963 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
964 - bcm47xx_fill_sprom_r12389(sprom, prefix);
965 - bcm47xx_fill_sprom_r1(sprom, prefix);
966 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
967 + bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
968 + bcm47xx_fill_sprom_r1(sprom, prefix, fallback);
969 break;
970 case 2:
971 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
972 - bcm47xx_fill_sprom_r12389(sprom, prefix);
973 - bcm47xx_fill_sprom_r2389(sprom, prefix);
974 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
975 + bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
976 + bcm47xx_fill_sprom_r2389(sprom, prefix, fallback);
977 break;
978 case 3:
979 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
980 - bcm47xx_fill_sprom_r12389(sprom, prefix);
981 - bcm47xx_fill_sprom_r2389(sprom, prefix);
982 - bcm47xx_fill_sprom_r389(sprom, prefix);
983 - bcm47xx_fill_sprom_r3(sprom, prefix);
984 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
985 + bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
986 + bcm47xx_fill_sprom_r2389(sprom, prefix, fallback);
987 + bcm47xx_fill_sprom_r389(sprom, prefix, fallback);
988 + bcm47xx_fill_sprom_r3(sprom, prefix, fallback);
989 break;
990 case 4:
991 case 5:
992 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
993 - bcm47xx_fill_sprom_r4589(sprom, prefix);
994 - bcm47xx_fill_sprom_r458(sprom, prefix);
995 - bcm47xx_fill_sprom_r45(sprom, prefix);
996 - bcm47xx_fill_sprom_path_r4589(sprom, prefix);
997 - bcm47xx_fill_sprom_path_r45(sprom, prefix);
998 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
999 + bcm47xx_fill_sprom_r4589(sprom, prefix, fallback);
1000 + bcm47xx_fill_sprom_r458(sprom, prefix, fallback);
1001 + bcm47xx_fill_sprom_r45(sprom, prefix, fallback);
1002 + bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
1003 + bcm47xx_fill_sprom_path_r45(sprom, prefix, fallback);
1004 break;
1005 case 8:
1006 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
1007 - bcm47xx_fill_sprom_r12389(sprom, prefix);
1008 - bcm47xx_fill_sprom_r2389(sprom, prefix);
1009 - bcm47xx_fill_sprom_r389(sprom, prefix);
1010 - bcm47xx_fill_sprom_r4589(sprom, prefix);
1011 - bcm47xx_fill_sprom_r458(sprom, prefix);
1012 - bcm47xx_fill_sprom_r89(sprom, prefix);
1013 - bcm47xx_fill_sprom_path_r4589(sprom, prefix);
1014 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
1015 + bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
1016 + bcm47xx_fill_sprom_r2389(sprom, prefix, fallback);
1017 + bcm47xx_fill_sprom_r389(sprom, prefix, fallback);
1018 + bcm47xx_fill_sprom_r4589(sprom, prefix, fallback);
1019 + bcm47xx_fill_sprom_r458(sprom, prefix, fallback);
1020 + bcm47xx_fill_sprom_r89(sprom, prefix, fallback);
1021 + bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
1022 break;
1023 case 9:
1024 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
1025 - bcm47xx_fill_sprom_r12389(sprom, prefix);
1026 - bcm47xx_fill_sprom_r2389(sprom, prefix);
1027 - bcm47xx_fill_sprom_r389(sprom, prefix);
1028 - bcm47xx_fill_sprom_r4589(sprom, prefix);
1029 - bcm47xx_fill_sprom_r89(sprom, prefix);
1030 - bcm47xx_fill_sprom_r9(sprom, prefix);
1031 - bcm47xx_fill_sprom_path_r4589(sprom, prefix);
1032 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
1033 + bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
1034 + bcm47xx_fill_sprom_r2389(sprom, prefix, fallback);
1035 + bcm47xx_fill_sprom_r389(sprom, prefix, fallback);
1036 + bcm47xx_fill_sprom_r4589(sprom, prefix, fallback);
1037 + bcm47xx_fill_sprom_r89(sprom, prefix, fallback);
1038 + bcm47xx_fill_sprom_r9(sprom, prefix, fallback);
1039 + bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
1040 break;
1041 default:
1042 pr_warn("Unsupported SPROM revision %d detected. Will extract"
1043 " v1\n", sprom->revision);
1044 sprom->revision = 1;
1045 - bcm47xx_fill_sprom_r1234589(sprom, prefix);
1046 - bcm47xx_fill_sprom_r12389(sprom, prefix);
1047 - bcm47xx_fill_sprom_r1(sprom, prefix);
1048 + bcm47xx_fill_sprom_r1234589(sprom, prefix, fallback);
1049 + bcm47xx_fill_sprom_r12389(sprom, prefix, fallback);
1050 + bcm47xx_fill_sprom_r1(sprom, prefix, fallback);
1051 }
1052 }
1053
1054 @@ -617,11 +733,12 @@ void bcm47xx_fill_sprom(struct ssb_sprom
1055 void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
1056 const char *prefix)
1057 {
1058 - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0);
1059 + nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
1060 + true);
1061 if (!boardinfo->vendor)
1062 boardinfo->vendor = SSB_BOARDVENDOR_BCM;
1063
1064 - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0);
1065 + nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
1066 }
1067 #endif
1068
1069 @@ -629,10 +746,11 @@ void bcm47xx_fill_ssb_boardinfo(struct s
1070 void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
1071 const char *prefix)
1072 {
1073 - nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0);
1074 + nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0,
1075 + true);
1076 if (!boardinfo->vendor)
1077 boardinfo->vendor = SSB_BOARDVENDOR_BCM;
1078
1079 - nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0);
1080 + nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0, true);
1081 }
1082 #endif
1083 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
1084 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx.h
1085 @@ -44,8 +44,8 @@ union bcm47xx_bus {
1086 extern union bcm47xx_bus bcm47xx_bus;
1087 extern enum bcm47xx_bus_type bcm47xx_bus_type;
1088
1089 -void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix);
1090 -void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix);
1091 +void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
1092 + bool fallback);
1093
1094 #ifdef CONFIG_BCM47XX_SSB
1095 void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,