[ep93xx] update to 2.6.39.1
[openwrt.git] / target / linux / brcm47xx / patches-2.6.37 / 034-bcm47xx-extend-and-fix-fill-sprom.patch
1 --- a/arch/mips/bcm47xx/setup.c
2 +++ b/arch/mips/bcm47xx/setup.c
3 @@ -63,6 +63,11 @@ static void bcm47xx_machine_halt(void)
4 if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\
5 sprom->_outvar = simple_strtoul(buf, NULL, 0);
6
7 +#define READ_FROM_NVRAM2(_outvar, name1, name2, buf) \
8 + if (nvram_getprefix(prefix, name1, buf, sizeof(buf)) >= 0 || \
9 + nvram_getprefix(prefix, name2, buf, sizeof(buf)) >= 0)\
10 + sprom->_outvar = simple_strtoul(buf, NULL, 0);
11 +
12 static inline int nvram_getprefix(const char *prefix, char *name,
13 char *buf, int len)
14 {
15 @@ -76,6 +81,27 @@ static inline int nvram_getprefix(const
16 return nvram_getenv(name, buf, len);
17 }
18
19 +static u32 nvram_getu32(const char *name, char *buf, int len)
20 +{
21 + int rv;
22 + char key[100];
23 + u16 var0, var1;
24 +
25 + snprintf(key, sizeof(key), "%s0", name);
26 + rv = nvram_getenv(key, buf, len);
27 + /* return 0 here so this looks like unset */
28 + if (rv < 0)
29 + return 0;
30 + var0 = simple_strtoul(buf, NULL, 0);
31 +
32 + snprintf(key, sizeof(key), "%s1", name);
33 + rv = nvram_getenv(key, buf, len);
34 + if (rv < 0)
35 + return 0;
36 + var1 = simple_strtoul(buf, NULL, 0);
37 + return var1 << 16 | var0;
38 +}
39 +
40 static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
41 {
42 char buf[100];
43 @@ -85,7 +111,8 @@ static void bcm47xx_fill_sprom(struct ss
44
45 sprom->revision = 1; /* Fallback: Old hardware does not define this. */
46 READ_FROM_NVRAM(revision, "sromrev", buf);
47 - if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0)
48 + if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0 ||
49 + nvram_getprefix(prefix, "macaddr", buf, sizeof(buf)) >= 0)
50 nvram_parse_macaddr(buf, sprom->il0mac);
51 if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0)
52 nvram_parse_macaddr(buf, sprom->et0mac);
53 @@ -111,20 +138,36 @@ static void bcm47xx_fill_sprom(struct ss
54 READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
55 READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
56 READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
57 - READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
58 - READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
59 - READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
60 - READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
61 - READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
62 - READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
63 - READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
64 - READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
65 - READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
66 - READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
67 + READ_FROM_NVRAM2(gpio0, "ledbh0", "wl0gpio0", buf);
68 + READ_FROM_NVRAM2(gpio1, "ledbh1", "wl0gpio1", buf);
69 + READ_FROM_NVRAM2(gpio2, "ledbh2", "wl0gpio2", buf);
70 + READ_FROM_NVRAM2(gpio3, "ledbh3", "wl0gpio3", buf);
71 + READ_FROM_NVRAM2(maxpwr_bg, "maxp2ga0", "pa0maxpwr", buf);
72 + READ_FROM_NVRAM2(maxpwr_al, "maxp5gla0", "pa1lomaxpwr", buf);
73 + READ_FROM_NVRAM2(maxpwr_a, "maxp5ga0", "pa1maxpwr", buf);
74 + READ_FROM_NVRAM2(maxpwr_ah, "maxp5gha0", "pa1himaxpwr", buf);
75 + READ_FROM_NVRAM2(itssi_bg, "itt5ga0", "pa0itssit", buf);
76 + READ_FROM_NVRAM2(itssi_a, "itt2ga0", "pa1itssit", buf);
77 READ_FROM_NVRAM(tri2g, "tri2g", buf);
78 READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
79 READ_FROM_NVRAM(tri5g, "tri5g", buf);
80 READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
81 + READ_FROM_NVRAM(txpid2g[0], "txpid2ga0", buf);
82 + READ_FROM_NVRAM(txpid2g[1], "txpid2ga1", buf);
83 + READ_FROM_NVRAM(txpid2g[2], "txpid2ga2", buf);
84 + READ_FROM_NVRAM(txpid2g[3], "txpid2ga3", buf);
85 + READ_FROM_NVRAM(txpid5g[0], "txpid5ga0", buf);
86 + READ_FROM_NVRAM(txpid5g[1], "txpid5ga1", buf);
87 + READ_FROM_NVRAM(txpid5g[2], "txpid5ga2", buf);
88 + READ_FROM_NVRAM(txpid5g[3], "txpid5ga3", buf);
89 + READ_FROM_NVRAM(txpid5gl[0], "txpid5gla0", buf);
90 + READ_FROM_NVRAM(txpid5gl[1], "txpid5gla1", buf);
91 + READ_FROM_NVRAM(txpid5gl[2], "txpid5gla2", buf);
92 + READ_FROM_NVRAM(txpid5gl[3], "txpid5gla3", buf);
93 + READ_FROM_NVRAM(txpid5gh[0], "txpid5gha0", buf);
94 + READ_FROM_NVRAM(txpid5gh[1], "txpid5gha1", buf);
95 + READ_FROM_NVRAM(txpid5gh[2], "txpid5gha2", buf);
96 + READ_FROM_NVRAM(txpid5gh[3], "txpid5gha3", buf);
97 READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
98 READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
99 READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
100 @@ -136,10 +179,18 @@ static void bcm47xx_fill_sprom(struct ss
101 READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
102 READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
103 READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
104 - READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
105 - READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
106 - READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
107 - READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
108 +
109 + sprom->ofdm2gpo = nvram_getu32("ofdm2gpo", buf, sizeof(buf));
110 + sprom->ofdm5glpo = nvram_getu32("ofdm5glpo", buf, sizeof(buf));
111 + sprom->ofdm5gpo = nvram_getu32("ofdm5gpo", buf, sizeof(buf));
112 + sprom->ofdm5ghpo = nvram_getu32("ofdm5ghpo", buf, sizeof(buf));
113 +
114 + READ_FROM_NVRAM(antenna_gain.ghz24.a0, "ag0", buf);
115 + READ_FROM_NVRAM(antenna_gain.ghz24.a1, "ag1", buf);
116 + READ_FROM_NVRAM(antenna_gain.ghz24.a2, "ag2", buf);
117 + READ_FROM_NVRAM(antenna_gain.ghz24.a3, "ag3", buf);
118 + memcpy(&sprom->antenna_gain.ghz5, &sprom->antenna_gain.ghz24,
119 + sizeof(sprom->antenna_gain.ghz5));
120
121 if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) {
122 boardflags = simple_strtoul(buf, NULL, 0);
This page took 0.052559 seconds and 5 git commands to generate.