f3213d6f63a243e557b8c2d88833e1740707e37e
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-2.6.35 / 012-MIPS-BCM47xx-Fill-values-for-b43-into-ssb-sprom.patch
1 From f382c623892dad1c6a9ebc0e12d01fd45ee50db8 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 more values 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 | 130 +++++++++++++++++++++++++++++++++-----------
14 1 files changed, 97 insertions(+), 33 deletions(-)
15
16 --- a/arch/mips/bcm47xx/setup.c
17 +++ b/arch/mips/bcm47xx/setup.c
18 @@ -74,6 +74,94 @@ static void str2eaddr(char *str, char *d
19 }
20 }
21
22 +static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
23 +{
24 + char buf[100];
25 + u32 boardflags;
26 +
27 + memset(sprom, 0, sizeof(struct ssb_sprom));
28 +
29 + sprom->revision = 3;
30 + if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0 ||
31 + cfe_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
32 + str2eaddr(buf, sprom->il0mac);
33 + if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
34 + cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
35 + str2eaddr(buf, sprom->et0mac);
36 + if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
37 + cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
38 + str2eaddr(buf, sprom->et1mac);
39 + if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
40 + cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
41 + sprom->et0phyaddr = simple_strtoul(buf, NULL, 0);
42 + if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
43 + cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
44 + sprom->et1phyaddr = simple_strtoul(buf, NULL, 0);
45 + if (nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
46 + cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
47 + sprom->et0mdcport = !!simple_strtoul(buf, NULL, 10);
48 + if (nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
49 + cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
50 + sprom->et1mdcport = !!simple_strtoul(buf, NULL, 10);
51 + if (nvram_getenv("pa0b0", buf, sizeof(buf)) >= 0 ||
52 + cfe_getenv("pa0b0", buf, sizeof(buf)) >= 0)
53 + sprom->pa0b0 = simple_strtoul(buf, NULL, 0);
54 + if (nvram_getenv("pa0b1", buf, sizeof(buf)) >= 0 ||
55 + cfe_getenv("pa0b1", buf, sizeof(buf)) >= 0)
56 + sprom->pa0b1 = simple_strtoul(buf, NULL, 0);
57 + if (nvram_getenv("pa0b2", buf, sizeof(buf)) >= 0 ||
58 + cfe_getenv("pa0b2", buf, sizeof(buf)) >= 0)
59 + sprom->pa0b2 = simple_strtoul(buf, NULL, 0);
60 + if (nvram_getenv("pa1b0", buf, sizeof(buf)) >= 0 ||
61 + cfe_getenv("pa1b0", buf, sizeof(buf)) >= 0)
62 + sprom->pa1b0 = simple_strtoul(buf, NULL, 0);
63 + if (nvram_getenv("pa1b1", buf, sizeof(buf)) >= 0 ||
64 + cfe_getenv("pa1b1", buf, sizeof(buf)) >= 0)
65 + sprom->pa1b1 = simple_strtoul(buf, NULL, 0);
66 + if (nvram_getenv("pa1b2", buf, sizeof(buf)) >= 0 ||
67 + cfe_getenv("pa1b2", buf, sizeof(buf)) >= 0)
68 + sprom->pa1b2 = simple_strtoul(buf, NULL, 0);
69 + if (nvram_getenv("wl0gpio0", buf, sizeof(buf)) >= 0 ||
70 + cfe_getenv("wl0gpio0", buf, sizeof(buf)) >= 0)
71 + sprom->gpio0 = simple_strtoul(buf, NULL, 0);
72 + if (nvram_getenv("wl0gpio1", buf, sizeof(buf)) >= 0 ||
73 + cfe_getenv("wl0gpio1", buf, sizeof(buf)) >= 0)
74 + sprom->gpio1 = simple_strtoul(buf, NULL, 0);
75 + if (nvram_getenv("wl0gpio2", buf, sizeof(buf)) >= 0 ||
76 + cfe_getenv("wl0gpio2", buf, sizeof(buf)) >= 0)
77 + sprom->gpio2 = simple_strtoul(buf, NULL, 0);
78 + if (nvram_getenv("wl0gpio3", buf, sizeof(buf)) >= 0 ||
79 + cfe_getenv("wl0gpio3", buf, sizeof(buf)) >= 0)
80 + sprom->gpio3 = simple_strtoul(buf, NULL, 0);
81 + if (nvram_getenv("pa0maxpwr", buf, sizeof(buf)) >= 0 ||
82 + cfe_getenv("pa0maxpwr", buf, sizeof(buf)) >= 0)
83 + sprom->maxpwr_bg = simple_strtoul(buf, NULL, 0);
84 + if (nvram_getenv("pa1maxpwr", buf, sizeof(buf)) >= 0 ||
85 + cfe_getenv("pa1maxpwr", buf, sizeof(buf)) >= 0)
86 + sprom->maxpwr_a = simple_strtoul(buf, NULL, 0);
87 + if (nvram_getenv("pa0itssit", buf, sizeof(buf)) >= 0 ||
88 + cfe_getenv("pa0itssit", buf, sizeof(buf)) >= 0)
89 + sprom->itssi_bg = simple_strtoul(buf, NULL, 0);
90 + if (nvram_getenv("pa1itssit", buf, sizeof(buf)) >= 0 ||
91 + cfe_getenv("pa1itssit", buf, sizeof(buf)) >= 0)
92 + sprom->itssi_a = simple_strtoul(buf, NULL, 0);
93 +
94 + if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0 ||
95 + cfe_getenv("boardflags", buf, sizeof(buf)) >= 0)
96 + boardflags = simple_strtoul(buf, NULL, 0);
97 + if (boardflags) {
98 + sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
99 + sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
100 + }
101 + if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0 ||
102 + cfe_getenv("boardflags2", buf, sizeof(buf)) >= 0)
103 + boardflags = simple_strtoul(buf, NULL, 0);
104 + if (boardflags) {
105 + sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
106 + sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
107 + }
108 +}
109 +
110 static int bcm47xx_get_invariants(struct ssb_bus *bus,
111 struct ssb_init_invariants *iv)
112 {
113 @@ -82,43 +170,19 @@ static int bcm47xx_get_invariants(struct
114 /* Fill boardinfo structure */
115 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
116
117 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
118 - nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
119 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
120 + if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
121 + cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
122 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
123 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
124 - nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
125 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
126 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
127 - nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
128 + if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
129 + cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
130 iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
131
132 - /* Fill sprom structure */
133 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
134 - iv->sprom.revision = 3;
135 -
136 - if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
137 - nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
138 - str2eaddr(buf, iv->sprom.et0mac);
139 -
140 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
141 - nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
142 - str2eaddr(buf, iv->sprom.et1mac);
143 -
144 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
145 - nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
146 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
147 -
148 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
149 - nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
150 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
151 -
152 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
153 - nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
154 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
155 -
156 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
157 - nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
158 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
159 + bcm47xx_fill_sprom(&iv->sprom);
160 +
161 + if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0 ||
162 + cfe_getenv("cardbus", buf, sizeof(buf)) >= 0)
163 + iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
164
165 return 0;
166 }