1 Index: linux-2.6.25.4/arch/mips/bcm47xx/irq.c
2 ===================================================================
3 --- linux-2.6.25.4.orig/arch/mips/bcm47xx/irq.c
4 +++ linux-2.6.25.4/arch/mips/bcm47xx/irq.c
7 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
8 + * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
15 #include <linux/types.h>
16 +#include <linux/errno.h>
17 +#include <linux/init.h>
18 #include <linux/interrupt.h>
19 #include <linux/irq.h>
20 +#include <linux/pci.h>
21 +#include <linux/ssb/ssb.h>
23 #include <asm/irq_cpu.h>
26 +extern struct ssb_bus ssb_bcm47xx;
29 void plat_irq_dispatch(void)
32 @@ -53,3 +63,19 @@ void __init arch_init_irq(void)
37 +int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
41 + res = ssb_pcibios_map_irq(dev, slot, pin);
43 + printk(KERN_ALERT "PCI: Failed to map IRQ of device %s\n",
47 + /* IRQ-0 and IRQ-1 are software interrupts. */
48 + WARN_ON((res == 0) || (res == 1));
52 Index: linux-2.6.25.4/arch/mips/bcm47xx/setup.c
53 ===================================================================
54 --- linux-2.6.25.4.orig/arch/mips/bcm47xx/setup.c
55 +++ linux-2.6.25.4/arch/mips/bcm47xx/setup.c
57 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
58 * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
59 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
60 - * Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
61 + * Copyright (C) 2006-2008 Michael Buesch <mb@bu3sch.de>
63 * This program is free software; you can redistribute it and/or modify it
64 * under the terms of the GNU General Public License as published by the
66 * 675 Mass Ave, Cambridge, MA 02139, USA.
69 +#include <linux/init.h>
70 #include <linux/types.h>
71 -#include <linux/ssb/ssb.h>
72 +#include <linux/tty.h>
73 +#include <linux/serial.h>
74 +#include <linux/serial_core.h>
75 +#include <linux/serial_reg.h>
76 +#include <linux/serial_8250.h>
77 #include <asm/bootinfo.h>
78 -#include <asm/reboot.h>
81 +#include <asm/reboot.h>
82 #include <asm/fw/cfe/cfe_api.h>
83 +#include <linux/pm.h>
84 +#include <linux/ssb/ssb.h>
85 +#include <linux/ssb/ssb_embedded.h>
87 +#include "include/nvram.h"
89 struct ssb_bus ssb_bcm47xx;
90 EXPORT_SYMBOL(ssb_bcm47xx);
92 +extern void bcm47xx_pci_init(void);
94 +int pcibios_plat_dev_init(struct pci_dev *dev)
98 + err = ssb_pcibios_plat_dev_init(dev);
100 + printk(KERN_ALERT "PCI: Failed to init device %s\n",
107 static void bcm47xx_machine_restart(char *command)
109 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
111 + /* CFE has a reboot callback, but that does not work.
112 + * Oopses with: Reserved instruction in kernel code.
115 /* Set the watchdog timer to reset immediately */
116 - ssb_chipco_watchdog_timer_set(&ssb_bcm47xx.chipco, 1);
117 + if (ssb_watchdog_timer_set(&ssb_bcm47xx, 1))
118 + printk(KERN_EMERG "SSB watchdog-triggered reboot failed!\n");
122 @@ -50,12 +79,13 @@ static void bcm47xx_machine_halt(void)
124 /* Disable interrupts and watchdog and spin forever */
126 - ssb_chipco_watchdog_timer_set(&ssb_bcm47xx.chipco, 0);
127 + if (ssb_watchdog_timer_set(&ssb_bcm47xx, 0))
128 + printk(KERN_EMERG "Failed to disable SSB watchdog!\n");
133 -static void str2eaddr(char *str, char *dest)
134 +static void e_aton(char *str, char *dest)
138 @@ -72,52 +102,141 @@ static void str2eaddr(char *str, char *d
142 -static int bcm47xx_get_invariants(struct ssb_bus *bus,
143 - struct ssb_init_invariants *iv)
144 +static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
149 - /* Fill boardinfo structure */
150 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
151 + memset(sprom, 0xFF, sizeof(struct ssb_sprom));
153 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0)
154 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
155 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
156 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
157 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
158 - iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
160 - /* Fill sprom structure */
161 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
162 - iv->sprom.revision = 3;
164 - if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
165 - str2eaddr(buf, iv->sprom.et0mac);
166 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
167 - str2eaddr(buf, iv->sprom.et1mac);
168 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
169 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 10);
170 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
171 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 10);
172 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
173 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
174 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
175 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
176 + sprom->revision = 1;
177 + if ((s = nvram_get("il0macaddr")))
178 + e_aton(s, sprom->il0mac);
179 + if ((s = nvram_get("et0macaddr")))
180 + e_aton(s, sprom->et0mac);
181 + if ((s = nvram_get("et1macaddr")))
182 + e_aton(s, sprom->et1mac);
183 + if ((s = nvram_get("et0phyaddr")))
184 + sprom->et0phyaddr = simple_strtoul(s, NULL, 0);
185 + if ((s = nvram_get("et1phyaddr")))
186 + sprom->et1phyaddr = simple_strtoul(s, NULL, 0);
187 + if ((s = nvram_get("et0mdcport")))
188 + sprom->et0mdcport = !!simple_strtoul(s, NULL, 10);
189 + if ((s = nvram_get("et1mdcport")))
190 + sprom->et1mdcport = !!simple_strtoul(s, NULL, 10);
191 + if ((s = nvram_get("pa0b0")))
192 + sprom->pa0b0 = simple_strtoul(s, NULL, 0);
193 + if ((s = nvram_get("pa0b1")))
194 + sprom->pa0b1 = simple_strtoul(s, NULL, 0);
195 + if ((s = nvram_get("pa0b2")))
196 + sprom->pa0b2 = simple_strtoul(s, NULL, 0);
197 + if ((s = nvram_get("pa1b0")))
198 + sprom->pa1b0 = simple_strtoul(s, NULL, 0);
199 + if ((s = nvram_get("pa1b1")))
200 + sprom->pa1b1 = simple_strtoul(s, NULL, 0);
201 + if ((s = nvram_get("pa1b2")))
202 + sprom->pa1b2 = simple_strtoul(s, NULL, 0);
203 + if ((s = nvram_get("wl0gpio0")))
204 + sprom->gpio0 = simple_strtoul(s, NULL, 0);
205 + if ((s = nvram_get("wl0gpio1")))
206 + sprom->gpio1 = simple_strtoul(s, NULL, 0);
207 + if ((s = nvram_get("wl0gpio2")))
208 + sprom->gpio2 = simple_strtoul(s, NULL, 0);
209 + if ((s = nvram_get("wl0gpio3")))
210 + sprom->gpio3 = simple_strtoul(s, NULL, 0);
211 + if ((s = nvram_get("pa0maxpwr")))
212 + sprom->maxpwr_bg = simple_strtoul(s, NULL, 0);
213 + if ((s = nvram_get("pa1maxpwr")))
214 + sprom->maxpwr_a = simple_strtoul(s, NULL, 0);
215 + if ((s = nvram_get("pa0itssit")))
216 + sprom->itssi_bg = simple_strtoul(s, NULL, 0);
217 + if ((s = nvram_get("pa1itssit")))
218 + sprom->itssi_a = simple_strtoul(s, NULL, 0);
219 + sprom->boardflags_lo = 0;
220 + if ((s = nvram_get("boardflags")))
221 + sprom->boardflags_lo = simple_strtoul(s, NULL, 0);
222 + sprom->boardflags_hi = 0;
223 + if ((s = nvram_get("boardflags2")))
224 + sprom->boardflags_hi = simple_strtoul(s, NULL, 0);
227 +static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
231 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
232 + if ((s = nvram_get("boardtype")))
233 + iv->boardinfo.type = (u16)simple_strtoul(s, NULL, 0);
234 + if ((s = nvram_get("boardrev")))
235 + iv->boardinfo.rev = (u16)simple_strtoul(s, NULL, 0);
237 + bcm47xx_fill_sprom(&iv->sprom);
239 + if ((s = nvram_get("cardbus")))
240 + iv->has_cardbus_slot = !!simple_strtoul(s, NULL, 10);
245 void __init plat_mem_setup(void)
250 + struct ssb_mipscore *mcore;
252 + err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, bcm47xx_get_invariants);
254 + const char *msg = "Failed to initialize SSB bus (err %d)\n";
255 + printk(msg, err); /* Make sure the message gets out of the box. */
258 + mcore = &ssb_bcm47xx.mipscore;
260 + s = nvram_get("kernel_args");
261 + if (s && !strncmp(s, "console=ttyS1", 13)) {
262 + struct ssb_serial_port port;
264 + printk("Swapping serial ports!\n");
265 + /* swap serial ports */
266 + memcpy(&port, &mcore->serial_ports[0], sizeof(port));
267 + memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1], sizeof(port));
268 + memcpy(&mcore->serial_ports[1], &port, sizeof(port));
271 - err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
272 - bcm47xx_get_invariants);
274 - panic("Failed to initialize SSB bus (err %d)\n", err);
275 + for (i = 0; i < mcore->nr_serial_ports; i++) {
276 + struct ssb_serial_port *port = &(mcore->serial_ports[i]);
277 + struct uart_port s;
279 + memset(&s, 0, sizeof(s));
281 + s.membase = port->regs;
282 + s.irq = port->irq + 2;
283 + s.uartclk = port->baud_base;
284 + s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
285 + s.iotype = SERIAL_IO_MEM;
286 + s.regshift = port->reg_shift;
288 + early_serial_setup(&s);
290 + printk("Serial init done.\n");
292 _machine_restart = bcm47xx_machine_restart;
293 _machine_halt = bcm47xx_machine_halt;
294 pm_power_off = bcm47xx_machine_halt;
297 +static int __init bcm47xx_register_gpiodev(void)
299 + static struct resource res = {
300 + .start = 0xFFFFFFFF,
302 + struct platform_device *pdev;
304 + pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
306 + printk(KERN_ERR "bcm47xx: GPIODEV init failed\n");
312 +device_initcall(bcm47xx_register_gpiodev);
313 Index: linux-2.6.25.4/arch/mips/bcm47xx/time.c
314 ===================================================================
315 --- linux-2.6.25.4.orig/arch/mips/bcm47xx/time.c
316 +++ linux-2.6.25.4/arch/mips/bcm47xx/time.c
318 * 675 Mass Ave, Cambridge, MA 02139, USA.
322 #include <linux/init.h>
323 +#include <linux/kernel.h>
324 +#include <linux/sched.h>
325 +#include <linux/serial_reg.h>
326 +#include <linux/interrupt.h>
327 #include <linux/ssb/ssb.h>
328 +#include <asm/addrspace.h>
330 #include <asm/time.h>
331 -#include <bcm47xx.h>
333 +extern struct ssb_bus ssb_bcm47xx;
335 void __init plat_time_init(void)
337 Index: linux-2.6.25.4/arch/mips/bcm47xx/nvram.c
338 ===================================================================
339 --- linux-2.6.25.4.orig/arch/mips/bcm47xx/nvram.c
340 +++ linux-2.6.25.4/arch/mips/bcm47xx/nvram.c
343 #include <asm/uaccess.h>
346 +#include "include/nvram.h"
349 -extern struct ssb_bus ssb;
350 +extern struct ssb_bus ssb_bcm47xx;
352 static char nvram_buf[NVRAM_SPACE];
354 @@ -36,7 +36,7 @@ extern char *cfe_env_get(char *nv_buf, c
355 /* Probe for NVRAM header */
356 static void __init early_nvram_init(void)
358 - struct ssb_mipscore *mcore = &ssb.mipscore;
359 + struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
360 struct nvram_header *header;
363 Index: linux-2.6.25.4/arch/mips/bcm47xx/Makefile
364 ===================================================================
365 --- linux-2.6.25.4.orig/arch/mips/bcm47xx/Makefile
366 +++ linux-2.6.25.4/arch/mips/bcm47xx/Makefile
371 -obj-y := gpio.o irq.o prom.o serial.o setup.o time.o wgt634u.o
372 +obj-y := cfe_env.o gpio.o irq.o nvram.o prom.o serial.o setup.o time.o wgt634u.o
373 Index: linux-2.6.25.4/arch/mips/Kconfig
374 ===================================================================
375 --- linux-2.6.25.4.orig/arch/mips/Kconfig
376 +++ linux-2.6.25.4/arch/mips/Kconfig
377 @@ -54,6 +54,7 @@ config BCM47XX
378 select SSB_DRIVER_MIPS
379 select SSB_DRIVER_EXTIF
380 select SSB_DRIVER_PCICORE
381 + select SSB_B43_PCI_BRIDGE
382 select SSB_PCICORE_HOSTMODE if PCI
384 select SYS_HAS_EARLY_PRINTK