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