Added OpenWRT-specific field to imagetag so that we can record the real root length...
[openwrt.git] / target / linux / brcm47xx / patches-2.6.36 / 011-MIPS-BCM47xx-Fill-values-for-b43-into-ssb-sprom.patch
1 From 4f95d9875b74bbf804a3a83f2c3c5e2068c3f857 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 27 Nov 2010 00:44:58 +0100
4 Subject: [PATCH 2/6] MIPS: BCM47xx: Fill values for b43 into ssb sprom
5
6 Fill the sprom with all available values from the nvram. Most of these
7 new values are needed for the b43 or b43legacy driver.
8
9 Some parts of this patch have been in OpenWRT for a long time and were
10 made by Michael Buesch.
11
12 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
13 ---
14 arch/mips/bcm47xx/setup.c | 114 ++++++++++++++++++++++++++++++++++++---------
15 1 files changed, 92 insertions(+), 22 deletions(-)
16
17 --- a/arch/mips/bcm47xx/setup.c
18 +++ b/arch/mips/bcm47xx/setup.c
19 @@ -73,42 +73,112 @@ static void str2eaddr(char *str, char *d
20 }
21 }
22
23 +#define READ_FROM_NVRAM(_outvar, name, buf) \
24 + if (nvram_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 + str2eaddr(buf, sprom->il0mac);
38 + if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
39 + str2eaddr(buf, sprom->et0mac);
40 + if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
41 + str2eaddr(buf, sprom->et1mac);
42 + READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
43 + READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
44 + READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
45 + READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
46 + READ_FROM_NVRAM(board_rev, "boardrev", buf);
47 + READ_FROM_NVRAM(country_code, "ccode", buf);
48 + READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
49 + READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
50 + READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
51 + READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
52 + READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
53 + READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
54 + READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
55 + READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
56 + READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
57 + READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
58 + READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
59 + READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
60 + READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
61 + READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
62 + READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
63 + READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
64 + READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
65 + READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
66 + READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
67 + READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
68 + READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
69 + READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
70 + READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
71 + READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
72 + READ_FROM_NVRAM(tri2g, "tri2g", buf);
73 + READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
74 + READ_FROM_NVRAM(tri5g, "tri5g", buf);
75 + READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
76 + READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
77 + READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
78 + READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
79 + READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
80 + READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
81 + READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
82 + READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
83 + READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
84 + READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
85 + READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
86 + READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
87 + READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
88 + READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
89 + READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
90 + READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
91 +
92 + if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0) {
93 + boardflags = simple_strtoul(buf, NULL, 0);
94 + if (boardflags) {
95 + sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
96 + sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
97 + }
98 + }
99 + if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0) {
100 + boardflags = simple_strtoul(buf, NULL, 0);
101 + if (boardflags) {
102 + sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
103 + sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
104 + }
105 + }
106 +}
107 +
108 static int bcm47xx_get_invariants(struct ssb_bus *bus,
109 struct ssb_init_invariants *iv)
110 {
111 - char buf[100];
112 + char buf[20];
113
114 /* Fill boardinfo structure */
115 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
116
117 if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
118 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
119 + iv->boardinfo.vendor = (u16)simple_strtoul(buf, NULL, 0);
120 + else
121 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
122 if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
123 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
124 if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
125 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
126
127 - /* Fill sprom structure */
128 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
129 - iv->sprom.revision = 3;
130 -
131 - if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
132 - str2eaddr(buf, iv->sprom.et0mac);
133 -
134 - if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
135 - str2eaddr(buf, iv->sprom.et1mac);
136 -
137 - if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
138 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
139 -
140 - if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
141 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
142 -
143 - if (nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
144 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
145 + bcm47xx_fill_sprom(&iv->sprom);
146
147 - if (nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
148 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
149 + if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
150 + iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
151
152 return 0;
153 }
This page took 0.054367 seconds and 5 git commands to generate.