d3831d105d11aa742b4cc6e6f91f622616ca6e33
[openwrt/staging/dedeckeh.git] / target / linux / brcm47xx / patches-2.6.35 / 012-MIPS-BCM47xx-Fill-more-values-into-ssb-sprom.patch
1 From 493d4a90850509e5f09b4799d4fc234b734a9d30 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 | 125 +++++++++++++++++++++++++++++++++------------
14 1 files changed, 92 insertions(+), 33 deletions(-)
15
16 --- a/arch/mips/bcm47xx/setup.c
17 +++ b/arch/mips/bcm47xx/setup.c
18 @@ -74,6 +74,89 @@ 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 + u64 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_strtoll(buf, NULL, 0);
97 + if (boardflags) {
98 + sprom->boardflags_lo = (boardflags & 0x000000000000FFFFLLU);
99 + sprom->boardflags_hi = (boardflags & 0x00000000FFFF0000LLU) >> 16;
100 + sprom->boardflags2_lo = (boardflags & 0x0000FFFF00000000LLU) >> 32;
101 + sprom->boardflags2_hi = (boardflags & 0xFFFF000000000000LLU) >> 48;
102 + }
103 +}
104 +
105 static int bcm47xx_get_invariants(struct ssb_bus *bus,
106 struct ssb_init_invariants *iv)
107 {
108 @@ -82,43 +165,19 @@ static int bcm47xx_get_invariants(struct
109 /* Fill boardinfo structure */
110 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
111
112 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
113 - nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
114 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
115 + if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
116 + cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
117 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
118 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
119 - nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
120 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
121 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
122 - nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
123 + if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
124 + cfe_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 (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
132 - nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
133 - str2eaddr(buf, iv->sprom.et0mac);
134 -
135 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
136 - nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
137 - str2eaddr(buf, iv->sprom.et1mac);
138 -
139 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
140 - nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
141 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
142 -
143 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
144 - nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
145 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
146 -
147 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
148 - nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
149 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
150 -
151 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
152 - nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
153 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
154 + bcm47xx_fill_sprom(&iv->sprom);
155 +
156 + if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0 ||
157 + cfe_getenv("cardbus", buf, sizeof(buf)) >= 0)
158 + iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
159
160 return 0;
161 }