brcm47xx: now hopfully realy commit the right things from r22385
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-2.6.34 / 012-MIPS-BCM47xx-Fill-values-for-b43-into-ssb-sprom.patch
1 From fbdfca0b2489ad94c6a3bc90b47adfd5c8179a89 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sun, 18 Jul 2010 13:34:32 +0200
4 Subject: [PATCH 2/5] MIPS: BCM47xx: Fill values for b43 into ssb sprom
5
6 Most of the values are stored in the nvram and not in the CFE. At first
7 the nvram should be read and if there is no value it should look into
8 the CFE. Now more values are read out because the b43 and b43legacy
9 drivers needs them.
10
11 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
12 ---
13 arch/mips/bcm47xx/setup.c | 131 +++++++++++++++++++++++++++++++++-----------
14 1 files changed, 98 insertions(+), 33 deletions(-)
15
16 --- a/arch/mips/bcm47xx/setup.c
17 +++ b/arch/mips/bcm47xx/setup.c
18 @@ -74,6 +74,95 @@ static void str2eaddr(char *str, char *d
19 }
20 }
21
22 +#define READ_FROM_NVRAM(_outvar, name, buf) \
23 + if (nvram_getenv(name, buf, sizeof(buf)) >= 0 || \
24 + cfe_getenv(name, buf, sizeof(buf)) >= 0) \
25 + sprom->_outvar = simple_strtoul(buf, NULL, 0);
26 +
27 +static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
28 +{
29 + char buf[100];
30 + u32 boardflags;
31 +
32 + memset(sprom, 0, sizeof(struct ssb_sprom));
33 +
34 + sprom->revision = 1; /* Fallback: Old hardware does not define this. */
35 + READ_FROM_NVRAM(revision, "sromrev", buf);
36 + if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0 ||
37 + cfe_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
38 + str2eaddr(buf, sprom->il0mac);
39 + if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
40 + cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
41 + str2eaddr(buf, sprom->et0mac);
42 + if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
43 + cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
44 + str2eaddr(buf, sprom->et1mac);
45 + READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
46 + READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
47 + READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
48 + READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
49 + READ_FROM_NVRAM(board_rev, "boardrev", buf);
50 + READ_FROM_NVRAM(country_code, "ccode", buf);
51 + READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
52 + READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
53 + READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
54 + READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
55 + READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
56 + READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
57 + READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
58 + READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
59 + READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
60 + READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
61 + READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
62 + READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
63 + READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
64 + READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
65 + READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
66 + READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
67 + READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
68 + READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
69 + READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
70 + READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
71 + READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
72 + READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
73 + READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
74 + READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
75 + READ_FROM_NVRAM(tri2g, "tri2g", buf);
76 + READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
77 + READ_FROM_NVRAM(tri5g, "tri5g", buf);
78 + READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
79 + READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
80 + READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
81 + READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
82 + READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
83 + READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
84 + READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
85 + READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
86 + READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
87 + READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
88 + READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
89 + READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
90 + READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
91 + READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
92 + READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
93 + READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
94 +
95 + if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0 ||
96 + cfe_getenv("boardflags", buf, sizeof(buf)) >= 0)
97 + boardflags = simple_strtoul(buf, NULL, 0);
98 + if (boardflags) {
99 + sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
100 + sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
101 + }
102 + if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0 ||
103 + cfe_getenv("boardflags2", buf, sizeof(buf)) >= 0)
104 + boardflags = simple_strtoul(buf, NULL, 0);
105 + if (boardflags) {
106 + sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
107 + sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
108 + }
109 +}
110 +
111 static int bcm47xx_get_invariants(struct ssb_bus *bus,
112 struct ssb_init_invariants *iv)
113 {
114 @@ -82,43 +171,19 @@ static int bcm47xx_get_invariants(struct
115 /* Fill boardinfo structure */
116 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
117
118 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
119 - nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
120 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
121 + if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
122 + cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
123 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
124 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
125 - nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
126 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
127 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
128 - nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
129 + if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
130 + cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
131 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
132
133 - /* Fill sprom structure */
134 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
135 - iv->sprom.revision = 3;
136 -
137 - if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
138 - nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
139 - str2eaddr(buf, iv->sprom.et0mac);
140 -
141 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
142 - nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
143 - str2eaddr(buf, iv->sprom.et1mac);
144 -
145 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
146 - nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
147 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
148 -
149 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
150 - nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
151 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
152 -
153 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
154 - nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
155 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
156 -
157 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
158 - nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
159 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
160 + bcm47xx_fill_sprom(&iv->sprom);
161 +
162 + if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0 ||
163 + cfe_getenv("cardbus", buf, sizeof(buf)) >= 0)
164 + iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
165
166 return 0;
167 }