diff options
-rw-r--r-- | arch/mips/bcm47xx/setup.c | 81 |
1 files changed, 66 insertions, 15 deletions
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c index 258ffcf92754..73b529b57433 100644 --- a/arch/mips/bcm47xx/setup.c +++ b/arch/mips/bcm47xx/setup.c | |||
@@ -61,6 +61,11 @@ static void bcm47xx_machine_halt(void) | |||
61 | if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\ | 61 | if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\ |
62 | sprom->_outvar = simple_strtoul(buf, NULL, 0); | 62 | sprom->_outvar = simple_strtoul(buf, NULL, 0); |
63 | 63 | ||
64 | #define READ_FROM_NVRAM2(_outvar, name1, name2, buf) \ | ||
65 | if (nvram_getprefix(prefix, name1, buf, sizeof(buf)) >= 0 || \ | ||
66 | nvram_getprefix(prefix, name2, buf, sizeof(buf)) >= 0)\ | ||
67 | sprom->_outvar = simple_strtoul(buf, NULL, 0); | ||
68 | |||
64 | static inline int nvram_getprefix(const char *prefix, char *name, | 69 | static inline int nvram_getprefix(const char *prefix, char *name, |
65 | char *buf, int len) | 70 | char *buf, int len) |
66 | { | 71 | { |
@@ -74,6 +79,27 @@ static inline int nvram_getprefix(const char *prefix, char *name, | |||
74 | return nvram_getenv(name, buf, len); | 79 | return nvram_getenv(name, buf, len); |
75 | } | 80 | } |
76 | 81 | ||
82 | static u32 nvram_getu32(const char *name, char *buf, int len) | ||
83 | { | ||
84 | int rv; | ||
85 | char key[100]; | ||
86 | u16 var0, var1; | ||
87 | |||
88 | snprintf(key, sizeof(key), "%s0", name); | ||
89 | rv = nvram_getenv(key, buf, len); | ||
90 | /* return 0 here so this looks like unset */ | ||
91 | if (rv < 0) | ||
92 | return 0; | ||
93 | var0 = simple_strtoul(buf, NULL, 0); | ||
94 | |||
95 | snprintf(key, sizeof(key), "%s1", name); | ||
96 | rv = nvram_getenv(key, buf, len); | ||
97 | if (rv < 0) | ||
98 | return 0; | ||
99 | var1 = simple_strtoul(buf, NULL, 0); | ||
100 | return var1 << 16 | var0; | ||
101 | } | ||
102 | |||
77 | static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) | 103 | static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) |
78 | { | 104 | { |
79 | char buf[100]; | 105 | char buf[100]; |
@@ -83,7 +109,8 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) | |||
83 | 109 | ||
84 | sprom->revision = 1; /* Fallback: Old hardware does not define this. */ | 110 | sprom->revision = 1; /* Fallback: Old hardware does not define this. */ |
85 | READ_FROM_NVRAM(revision, "sromrev", buf); | 111 | READ_FROM_NVRAM(revision, "sromrev", buf); |
86 | if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0) | 112 | if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0 || |
113 | nvram_getprefix(prefix, "macaddr", buf, sizeof(buf)) >= 0) | ||
87 | nvram_parse_macaddr(buf, sprom->il0mac); | 114 | nvram_parse_macaddr(buf, sprom->il0mac); |
88 | if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0) | 115 | if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0) |
89 | nvram_parse_macaddr(buf, sprom->et0mac); | 116 | nvram_parse_macaddr(buf, sprom->et0mac); |
@@ -109,20 +136,36 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) | |||
109 | READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf); | 136 | READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf); |
110 | READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf); | 137 | READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf); |
111 | READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf); | 138 | READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf); |
112 | READ_FROM_NVRAM(gpio0, "wl0gpio0", buf); | 139 | READ_FROM_NVRAM2(gpio0, "ledbh0", "wl0gpio0", buf); |
113 | READ_FROM_NVRAM(gpio1, "wl0gpio1", buf); | 140 | READ_FROM_NVRAM2(gpio1, "ledbh1", "wl0gpio1", buf); |
114 | READ_FROM_NVRAM(gpio2, "wl0gpio2", buf); | 141 | READ_FROM_NVRAM2(gpio2, "ledbh2", "wl0gpio2", buf); |
115 | READ_FROM_NVRAM(gpio3, "wl0gpio3", buf); | 142 | READ_FROM_NVRAM2(gpio3, "ledbh3", "wl0gpio3", buf); |
116 | READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf); | 143 | READ_FROM_NVRAM2(maxpwr_bg, "maxp2ga0", "pa0maxpwr", buf); |
117 | READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf); | 144 | READ_FROM_NVRAM2(maxpwr_al, "maxp5gla0", "pa1lomaxpwr", buf); |
118 | READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf); | 145 | READ_FROM_NVRAM2(maxpwr_a, "maxp5ga0", "pa1maxpwr", buf); |
119 | READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf); | 146 | READ_FROM_NVRAM2(maxpwr_ah, "maxp5gha0", "pa1himaxpwr", buf); |
120 | READ_FROM_NVRAM(itssi_a, "pa1itssit", buf); | 147 | READ_FROM_NVRAM2(itssi_bg, "itt5ga0", "pa0itssit", buf); |
121 | READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf); | 148 | READ_FROM_NVRAM2(itssi_a, "itt2ga0", "pa1itssit", buf); |
122 | READ_FROM_NVRAM(tri2g, "tri2g", buf); | 149 | READ_FROM_NVRAM(tri2g, "tri2g", buf); |
123 | READ_FROM_NVRAM(tri5gl, "tri5gl", buf); | 150 | READ_FROM_NVRAM(tri5gl, "tri5gl", buf); |
124 | READ_FROM_NVRAM(tri5g, "tri5g", buf); | 151 | READ_FROM_NVRAM(tri5g, "tri5g", buf); |
125 | READ_FROM_NVRAM(tri5gh, "tri5gh", buf); | 152 | READ_FROM_NVRAM(tri5gh, "tri5gh", buf); |
153 | READ_FROM_NVRAM(txpid2g[0], "txpid2ga0", buf); | ||
154 | READ_FROM_NVRAM(txpid2g[1], "txpid2ga1", buf); | ||
155 | READ_FROM_NVRAM(txpid2g[2], "txpid2ga2", buf); | ||
156 | READ_FROM_NVRAM(txpid2g[3], "txpid2ga3", buf); | ||
157 | READ_FROM_NVRAM(txpid5g[0], "txpid5ga0", buf); | ||
158 | READ_FROM_NVRAM(txpid5g[1], "txpid5ga1", buf); | ||
159 | READ_FROM_NVRAM(txpid5g[2], "txpid5ga2", buf); | ||
160 | READ_FROM_NVRAM(txpid5g[3], "txpid5ga3", buf); | ||
161 | READ_FROM_NVRAM(txpid5gl[0], "txpid5gla0", buf); | ||
162 | READ_FROM_NVRAM(txpid5gl[1], "txpid5gla1", buf); | ||
163 | READ_FROM_NVRAM(txpid5gl[2], "txpid5gla2", buf); | ||
164 | READ_FROM_NVRAM(txpid5gl[3], "txpid5gla3", buf); | ||
165 | READ_FROM_NVRAM(txpid5gh[0], "txpid5gha0", buf); | ||
166 | READ_FROM_NVRAM(txpid5gh[1], "txpid5gha1", buf); | ||
167 | READ_FROM_NVRAM(txpid5gh[2], "txpid5gha2", buf); | ||
168 | READ_FROM_NVRAM(txpid5gh[3], "txpid5gha3", buf); | ||
126 | READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf); | 169 | READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf); |
127 | READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf); | 170 | READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf); |
128 | READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf); | 171 | READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf); |
@@ -134,10 +177,18 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) | |||
134 | READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf); | 177 | READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf); |
135 | READ_FROM_NVRAM(bxa5g, "bxa5g", buf); | 178 | READ_FROM_NVRAM(bxa5g, "bxa5g", buf); |
136 | READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf); | 179 | READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf); |
137 | READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf); | 180 | |
138 | READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf); | 181 | sprom->ofdm2gpo = nvram_getu32("ofdm2gpo", buf, sizeof(buf)); |
139 | READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf); | 182 | sprom->ofdm5glpo = nvram_getu32("ofdm5glpo", buf, sizeof(buf)); |
140 | READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf); | 183 | sprom->ofdm5gpo = nvram_getu32("ofdm5gpo", buf, sizeof(buf)); |
184 | sprom->ofdm5ghpo = nvram_getu32("ofdm5ghpo", buf, sizeof(buf)); | ||
185 | |||
186 | READ_FROM_NVRAM(antenna_gain.ghz24.a0, "ag0", buf); | ||
187 | READ_FROM_NVRAM(antenna_gain.ghz24.a1, "ag1", buf); | ||
188 | READ_FROM_NVRAM(antenna_gain.ghz24.a2, "ag2", buf); | ||
189 | READ_FROM_NVRAM(antenna_gain.ghz24.a3, "ag3", buf); | ||
190 | memcpy(&sprom->antenna_gain.ghz5, &sprom->antenna_gain.ghz24, | ||
191 | sizeof(sprom->antenna_gain.ghz5)); | ||
141 | 192 | ||
142 | if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) { | 193 | if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) { |
143 | boardflags = simple_strtoul(buf, NULL, 0); | 194 | boardflags = simple_strtoul(buf, NULL, 0); |