brcm47xx: fix r21042, nuke (boardnum == 42 section)
[openwrt.git] / target / linux / brcm47xx / patches-2.6.34 / 400-arch-bcm47xx.patch
1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -62,6 +62,7 @@ config BCM47XX
4 select SSB_DRIVER_MIPS
5 select SSB_DRIVER_EXTIF
6 select SSB_EMBEDDED
7 + select SSB_B43_PCI_BRIDGE if PCI
8 select SSB_PCICORE_HOSTMODE if PCI
9 select GENERIC_GPIO
10 select SYS_HAS_EARLY_PRINTK
11 --- a/arch/mips/bcm47xx/Makefile
12 +++ b/arch/mips/bcm47xx/Makefile
13 @@ -3,4 +3,4 @@
14 # under Linux.
15 #
16
17 -obj-y := gpio.o irq.o prom.o serial.o setup.o time.o wgt634u.o
18 +obj-y := cfe_env.o gpio.o irq.o nvram.o prom.o serial.o setup.o time.o wgt634u.o
19 --- a/arch/mips/bcm47xx/irq.c
20 +++ b/arch/mips/bcm47xx/irq.c
21 @@ -1,5 +1,6 @@
22 /*
23 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
24 + * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
25 *
26 * This program is free software; you can redistribute it and/or modify it
27 * under the terms of the GNU General Public License as published by the
28 @@ -23,10 +24,19 @@
29 */
30
31 #include <linux/types.h>
32 +#include <linux/errno.h>
33 +#include <linux/init.h>
34 #include <linux/interrupt.h>
35 #include <linux/irq.h>
36 +#include <linux/pci.h>
37 +#include <linux/ssb/ssb.h>
38 +
39 #include <asm/irq_cpu.h>
40
41 +
42 +extern struct ssb_bus ssb_bcm47xx;
43 +
44 +
45 void plat_irq_dispatch(void)
46 {
47 u32 cause;
48 --- a/arch/mips/bcm47xx/nvram.c
49 +++ b/arch/mips/bcm47xx/nvram.c
50 @@ -24,10 +24,10 @@
51 #include <asm/io.h>
52 #include <asm/uaccess.h>
53
54 -#include <nvram.h>
55 +#include "include/nvram.h"
56
57 #define MB * 1048576
58 -extern struct ssb_bus ssb;
59 +extern struct ssb_bus ssb_bcm47xx;
60
61 static char nvram_buf[NVRAM_SPACE];
62 static int cfe_env;
63 @@ -36,7 +36,7 @@ extern char *cfe_env_get(char *nv_buf, c
64 /* Probe for NVRAM header */
65 static void __init early_nvram_init(void)
66 {
67 - struct ssb_mipscore *mcore = &ssb.mipscore;
68 + struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
69 struct nvram_header *header;
70 int i;
71 u32 base, lim, off;
72 --- a/arch/mips/bcm47xx/setup.c
73 +++ b/arch/mips/bcm47xx/setup.c
74 @@ -2,7 +2,7 @@
75 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
76 * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
77 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
78 - * Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
79 + * Copyright (C) 2006-2008 Michael Buesch <mb@bu3sch.de>
80 *
81 * This program is free software; you can redistribute it and/or modify it
82 * under the terms of the GNU General Public License as published by the
83 @@ -25,18 +25,28 @@
84 * 675 Mass Ave, Cambridge, MA 02139, USA.
85 */
86
87 +#include <linux/init.h>
88 #include <linux/types.h>
89 #include <linux/ssb/ssb.h>
90 #include <linux/ssb/ssb_embedded.h>
91 +#include <linux/tty.h>
92 +#include <linux/serial.h>
93 +#include <linux/serial_core.h>
94 +#include <linux/serial_reg.h>
95 +#include <linux/serial_8250.h>
96 #include <asm/bootinfo.h>
97 #include <asm/reboot.h>
98 #include <asm/time.h>
99 -#include <bcm47xx.h>
100 #include <asm/fw/cfe/cfe_api.h>
101 +#include <linux/pm.h>
102 +
103 +#include "include/nvram.h"
104
105 struct ssb_bus ssb_bcm47xx;
106 EXPORT_SYMBOL(ssb_bcm47xx);
107
108 +extern void bcm47xx_pci_init(void);
109 +
110 static void bcm47xx_machine_restart(char *command)
111 {
112 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
113 @@ -56,7 +66,7 @@ static void bcm47xx_machine_halt(void)
114 cpu_relax();
115 }
116
117 -static void str2eaddr(char *str, char *dest)
118 +static void e_aton(char *str, char *dest)
119 {
120 int i = 0;
121
122 @@ -73,51 +83,143 @@ static void str2eaddr(char *str, char *d
123 }
124 }
125
126 -static int bcm47xx_get_invariants(struct ssb_bus *bus,
127 - struct ssb_init_invariants *iv)
128 +static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
129 {
130 char buf[100];
131 + char *s;
132 +
133 + memset(sprom, 0xFF, sizeof(struct ssb_sprom));
134 +
135 + sprom->revision = 1;
136 + if ((s = nvram_get("il0macaddr")))
137 + e_aton(s, sprom->il0mac);
138 + if ((s = nvram_get("et0macaddr")))
139 + e_aton(s, sprom->et0mac);
140 + if ((s = nvram_get("et1macaddr")))
141 + e_aton(s, sprom->et1mac);
142 + if ((s = nvram_get("et0phyaddr")))
143 + sprom->et0phyaddr = simple_strtoul(s, NULL, 0);
144 + if ((s = nvram_get("et1phyaddr")))
145 + sprom->et1phyaddr = simple_strtoul(s, NULL, 0);
146 + if ((s = nvram_get("et0mdcport")))
147 + sprom->et0mdcport = !!simple_strtoul(s, NULL, 10);
148 + if ((s = nvram_get("et1mdcport")))
149 + sprom->et1mdcport = !!simple_strtoul(s, NULL, 10);
150 + if ((s = nvram_get("pa0b0")))
151 + sprom->pa0b0 = simple_strtoul(s, NULL, 0);
152 + if ((s = nvram_get("pa0b1")))
153 + sprom->pa0b1 = simple_strtoul(s, NULL, 0);
154 + if ((s = nvram_get("pa0b2")))
155 + sprom->pa0b2 = simple_strtoul(s, NULL, 0);
156 + if ((s = nvram_get("pa1b0")))
157 + sprom->pa1b0 = simple_strtoul(s, NULL, 0);
158 + if ((s = nvram_get("pa1b1")))
159 + sprom->pa1b1 = simple_strtoul(s, NULL, 0);
160 + if ((s = nvram_get("pa1b2")))
161 + sprom->pa1b2 = simple_strtoul(s, NULL, 0);
162 + if ((s = nvram_get("wl0gpio0")))
163 + sprom->gpio0 = simple_strtoul(s, NULL, 0);
164 + if ((s = nvram_get("wl0gpio1")))
165 + sprom->gpio1 = simple_strtoul(s, NULL, 0);
166 + if ((s = nvram_get("wl0gpio2")))
167 + sprom->gpio2 = simple_strtoul(s, NULL, 0);
168 + if ((s = nvram_get("wl0gpio3")))
169 + sprom->gpio3 = simple_strtoul(s, NULL, 0);
170 + if ((s = nvram_get("pa0maxpwr")))
171 + sprom->maxpwr_bg = simple_strtoul(s, NULL, 0);
172 + if ((s = nvram_get("pa1maxpwr")))
173 + sprom->maxpwr_a = simple_strtoul(s, NULL, 0);
174 + if ((s = nvram_get("pa0itssit")))
175 + sprom->itssi_bg = simple_strtoul(s, NULL, 0);
176 + if ((s = nvram_get("pa1itssit")))
177 + sprom->itssi_a = simple_strtoul(s, NULL, 0);
178 + sprom->boardflags_lo = 0;
179 + if ((s = nvram_get("boardflags")))
180 + sprom->boardflags_lo = simple_strtoul(s, NULL, 0);
181 + sprom->boardflags_hi = 0;
182 + if ((s = nvram_get("boardflags2")))
183 + sprom->boardflags_hi = simple_strtoul(s, NULL, 0);
184 +}
185 +
186 +static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
187 +{
188 + char *s;
189
190 - /* Fill boardinfo structure */
191 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
192 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
193 + if ((s = nvram_get("boardtype")))
194 + iv->boardinfo.type = (u16)simple_strtoul(s, NULL, 0);
195 + if ((s = nvram_get("boardrev")))
196 + iv->boardinfo.rev = (u16)simple_strtoul(s, NULL, 0);
197
198 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0)
199 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
200 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
201 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
202 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
203 - iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
204 -
205 - /* Fill sprom structure */
206 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
207 - iv->sprom.revision = 3;
208 -
209 - if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
210 - str2eaddr(buf, iv->sprom.et0mac);
211 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
212 - str2eaddr(buf, iv->sprom.et1mac);
213 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
214 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 10);
215 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
216 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 10);
217 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
218 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
219 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
220 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
221 + bcm47xx_fill_sprom(&iv->sprom);
222 +
223 + if ((s = nvram_get("cardbus")))
224 + iv->has_cardbus_slot = !!simple_strtoul(s, NULL, 10);
225
226 return 0;
227 }
228
229 void __init plat_mem_setup(void)
230 {
231 - int err;
232 -
233 - err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
234 - bcm47xx_get_invariants);
235 - if (err)
236 - panic("Failed to initialize SSB bus (err %d)\n", err);
237 + int i, err;
238 + char *s;
239 + struct ssb_mipscore *mcore;
240 +
241 + err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, bcm47xx_get_invariants);
242 + if (err) {
243 + const char *msg = "Failed to initialize SSB bus (err %d)\n";
244 + printk(msg, err); /* Make sure the message gets out of the box. */
245 + panic(msg, err);
246 + }
247 + mcore = &ssb_bcm47xx.mipscore;
248 +
249 + s = nvram_get("kernel_args");
250 + if (s && !strncmp(s, "console=ttyS1", 13)) {
251 + struct ssb_serial_port port;
252 +
253 + printk("Swapping serial ports!\n");
254 + /* swap serial ports */
255 + memcpy(&port, &mcore->serial_ports[0], sizeof(port));
256 + memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1], sizeof(port));
257 + memcpy(&mcore->serial_ports[1], &port, sizeof(port));
258 + }
259 +
260 + for (i = 0; i < mcore->nr_serial_ports; i++) {
261 + struct ssb_serial_port *port = &(mcore->serial_ports[i]);
262 + struct uart_port s;
263 +
264 + memset(&s, 0, sizeof(s));
265 + s.line = i;
266 + s.mapbase = (unsigned int) port->regs;
267 + s.membase = port->regs;
268 + s.irq = port->irq + 2;
269 + s.uartclk = port->baud_base;
270 + s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
271 + s.iotype = SERIAL_IO_MEM;
272 + s.regshift = port->reg_shift;
273 +
274 + early_serial_setup(&s);
275 + }
276 + printk("Serial init done.\n");
277
278 _machine_restart = bcm47xx_machine_restart;
279 _machine_halt = bcm47xx_machine_halt;
280 pm_power_off = bcm47xx_machine_halt;
281 }
282 +
283 +static int __init bcm47xx_register_gpiodev(void)
284 +{
285 + static struct resource res = {
286 + .start = 0xFFFFFFFF,
287 + };
288 + struct platform_device *pdev;
289 +
290 + pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
291 + if (!pdev) {
292 + printk(KERN_ERR "bcm47xx: GPIODEV init failed\n");
293 + return -ENODEV;
294 + }
295 +
296 + return 0;
297 +}
298 +device_initcall(bcm47xx_register_gpiodev);
299 --- a/arch/mips/bcm47xx/time.c
300 +++ b/arch/mips/bcm47xx/time.c
301 @@ -22,11 +22,17 @@
302 * 675 Mass Ave, Cambridge, MA 02139, USA.
303 */
304
305 -
306 #include <linux/init.h>
307 +#include <linux/kernel.h>
308 +#include <linux/sched.h>
309 +#include <linux/serial_reg.h>
310 +#include <linux/interrupt.h>
311 #include <linux/ssb/ssb.h>
312 +#include <asm/addrspace.h>
313 +#include <asm/io.h>
314 #include <asm/time.h>
315 -#include <bcm47xx.h>
316 +
317 +extern struct ssb_bus ssb_bcm47xx;
318
319 void __init plat_time_init(void)
320 {
This page took 0.051118 seconds and 5 git commands to generate.