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