aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2010-11-27 11:45:59 -0500
committerRalf Baechle <ralf@linux-mips.org>2010-12-16 13:10:59 -0500
commit2aa088d6fd8a6c6e6020ea46b70141f0b7ccf5d2 (patch)
tree756cabc4f7cd4007f2b8f94f4a8f35e56d111554 /arch
parent825710843640dd173bc4b2ea99f1296923e4aa06 (diff)
MIPS: BCM47xx: Fill values for b43 into SSB sprom
Fill the sprom with all available values from the nvram. Most of these new values are needed for the b43 or b43legacy driver. Parts of this patch have been in OpenWRT for a long time and were written by Michael Buesch. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> To: linux-mips@linux-mips.org Cc: Hauke Mehrtens <hauke@hauke-m.de> Patchwork: https://patchwork.linux-mips.org/patch/1846/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/bcm47xx/setup.c114
1 files changed, 92 insertions, 22 deletions
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 2c6bdade3f13..1f61dfd71ac7 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -73,42 +73,112 @@ static void str2eaddr(char *str, char *dest)
73 } 73 }
74} 74}
75 75
76#define READ_FROM_NVRAM(_outvar, name, buf) \
77 if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
78 sprom->_outvar = simple_strtoul(buf, NULL, 0);
79
80static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
81{
82 char buf[100];
83 u32 boardflags;
84
85 memset(sprom, 0, sizeof(struct ssb_sprom));
86
87 sprom->revision = 1; /* Fallback: Old hardware does not define this. */
88 READ_FROM_NVRAM(revision, "sromrev", buf);
89 if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
90 str2eaddr(buf, sprom->il0mac);
91 if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
92 str2eaddr(buf, sprom->et0mac);
93 if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
94 str2eaddr(buf, sprom->et1mac);
95 READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
96 READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
97 READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
98 READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
99 READ_FROM_NVRAM(board_rev, "boardrev", buf);
100 READ_FROM_NVRAM(country_code, "ccode", buf);
101 READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
102 READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
103 READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
104 READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
105 READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
106 READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
107 READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
108 READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
109 READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
110 READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
111 READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
112 READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
113 READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
114 READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
115 READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
116 READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
117 READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
118 READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
119 READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
120 READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
121 READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
122 READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
123 READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
124 READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
125 READ_FROM_NVRAM(tri2g, "tri2g", buf);
126 READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
127 READ_FROM_NVRAM(tri5g, "tri5g", buf);
128 READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
129 READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
130 READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
131 READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
132 READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
133 READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
134 READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
135 READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
136 READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
137 READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
138 READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
139 READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
140 READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
141 READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
142 READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
143 READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
144
145 if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0) {
146 boardflags = simple_strtoul(buf, NULL, 0);
147 if (boardflags) {
148 sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
149 sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
150 }
151 }
152 if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0) {
153 boardflags = simple_strtoul(buf, NULL, 0);
154 if (boardflags) {
155 sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
156 sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
157 }
158 }
159}
160
76static int bcm47xx_get_invariants(struct ssb_bus *bus, 161static int bcm47xx_get_invariants(struct ssb_bus *bus,
77 struct ssb_init_invariants *iv) 162 struct ssb_init_invariants *iv)
78{ 163{
79 char buf[100]; 164 char buf[20];
80 165
81 /* Fill boardinfo structure */ 166 /* Fill boardinfo structure */
82 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo)); 167 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
83 168
84 if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0) 169 if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
85 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 170 iv->boardinfo.vendor = (u16)simple_strtoul(buf, NULL, 0);
171 else
172 iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
86 if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) 173 if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
87 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 174 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
88 if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0) 175 if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
89 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); 176 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
90 177
91 /* Fill sprom structure */ 178 bcm47xx_fill_sprom(&iv->sprom);
92 memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
93 iv->sprom.revision = 3;
94
95 if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
96 str2eaddr(buf, iv->sprom.et0mac);
97
98 if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
99 str2eaddr(buf, iv->sprom.et1mac);
100
101 if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
102 iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
103
104 if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
105 iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
106
107 if (nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
108 iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
109 179
110 if (nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0) 180 if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
111 iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10); 181 iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
112 182
113 return 0; 183 return 0;
114} 184}