1 Index: linux-2.6.28.7/arch/mips/Kconfig
2 ===================================================================
3 --- linux-2.6.28.7.orig/arch/mips/Kconfig 2009-03-17 17:26:23.000000000 +0100
4 +++ linux-2.6.28.7/arch/mips/Kconfig 2009-03-17 17:27:33.000000000 +0100
5 @@ -53,6 +53,7 @@ config BCM47XX
7 select SSB_DRIVER_EXTIF
9 + select SSB_B43_PCI_BRIDGE if PCI
10 select SSB_PCICORE_HOSTMODE if PCI
12 select SYS_HAS_EARLY_PRINTK
13 Index: linux-2.6.28.7/arch/mips/bcm47xx/Makefile
14 ===================================================================
15 --- linux-2.6.28.7.orig/arch/mips/bcm47xx/Makefile 2009-03-17 17:26:19.000000000 +0100
16 +++ linux-2.6.28.7/arch/mips/bcm47xx/Makefile 2009-03-17 17:26:56.000000000 +0100
21 -obj-y := gpio.o irq.o prom.o serial.o setup.o time.o wgt634u.o
22 +obj-y := cfe_env.o gpio.o irq.o nvram.o prom.o serial.o setup.o time.o wgt634u.o
23 Index: linux-2.6.28.7/arch/mips/bcm47xx/irq.c
24 ===================================================================
25 --- linux-2.6.28.7.orig/arch/mips/bcm47xx/irq.c 2009-03-17 17:26:19.000000000 +0100
26 +++ linux-2.6.28.7/arch/mips/bcm47xx/irq.c 2009-03-17 17:26:23.000000000 +0100
29 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
30 + * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
32 * This program is free software; you can redistribute it and/or modify it
33 * under the terms of the GNU General Public License as published by the
37 #include <linux/types.h>
38 +#include <linux/errno.h>
39 +#include <linux/init.h>
40 #include <linux/interrupt.h>
41 #include <linux/irq.h>
42 +#include <linux/pci.h>
43 +#include <linux/ssb/ssb.h>
45 #include <asm/irq_cpu.h>
48 +extern struct ssb_bus ssb_bcm47xx;
51 void plat_irq_dispatch(void)
54 Index: linux-2.6.28.7/arch/mips/bcm47xx/nvram.c
55 ===================================================================
56 --- linux-2.6.28.7.orig/arch/mips/bcm47xx/nvram.c 2009-03-17 17:26:19.000000000 +0100
57 +++ linux-2.6.28.7/arch/mips/bcm47xx/nvram.c 2009-03-17 17:26:23.000000000 +0100
60 #include <asm/uaccess.h>
63 +#include "include/nvram.h"
66 -extern struct ssb_bus ssb;
67 +extern struct ssb_bus ssb_bcm47xx;
69 static char nvram_buf[NVRAM_SPACE];
71 @@ -36,7 +36,7 @@ extern char *cfe_env_get(char *nv_buf, c
72 /* Probe for NVRAM header */
73 static void __init early_nvram_init(void)
75 - struct ssb_mipscore *mcore = &ssb.mipscore;
76 + struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
77 struct nvram_header *header;
80 Index: linux-2.6.28.7/arch/mips/bcm47xx/setup.c
81 ===================================================================
82 --- linux-2.6.28.7.orig/arch/mips/bcm47xx/setup.c 2009-03-17 17:26:19.000000000 +0100
83 +++ linux-2.6.28.7/arch/mips/bcm47xx/setup.c 2009-03-17 17:26:23.000000000 +0100
85 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
86 * Copyright (C) 2005 Waldemar Brodkorb <wbx@openwrt.org>
87 * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
88 - * Copyright (C) 2006 Michael Buesch <mb@bu3sch.de>
89 + * Copyright (C) 2006-2008 Michael Buesch <mb@bu3sch.de>
91 * This program is free software; you can redistribute it and/or modify it
92 * under the terms of the GNU General Public License as published by the
94 * 675 Mass Ave, Cambridge, MA 02139, USA.
97 +#include <linux/init.h>
98 #include <linux/types.h>
99 #include <linux/ssb/ssb.h>
100 #include <linux/ssb/ssb_embedded.h>
101 +#include <linux/tty.h>
102 +#include <linux/serial.h>
103 +#include <linux/serial_core.h>
104 +#include <linux/serial_reg.h>
105 +#include <linux/serial_8250.h>
106 #include <asm/bootinfo.h>
107 #include <asm/reboot.h>
108 #include <asm/time.h>
109 -#include <bcm47xx.h>
110 #include <asm/fw/cfe/cfe_api.h>
111 +#include <linux/pm.h>
113 +#include "include/nvram.h"
115 struct ssb_bus ssb_bcm47xx;
116 EXPORT_SYMBOL(ssb_bcm47xx);
118 +extern void bcm47xx_pci_init(void);
120 static void bcm47xx_machine_restart(char *command)
122 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
123 @@ -56,7 +66,7 @@ static void bcm47xx_machine_halt(void)
127 -static void str2eaddr(char *str, char *dest)
128 +static void e_aton(char *str, char *dest)
132 @@ -73,52 +83,141 @@ static void str2eaddr(char *str, char *d
136 -static int bcm47xx_get_invariants(struct ssb_bus *bus,
137 - struct ssb_init_invariants *iv)
138 +static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
143 - /* Fill boardinfo structure */
144 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
145 + memset(sprom, 0xFF, sizeof(struct ssb_sprom));
147 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0)
148 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
149 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
150 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
151 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
152 - iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
154 - /* Fill sprom structure */
155 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
156 - iv->sprom.revision = 3;
158 - if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
159 - str2eaddr(buf, iv->sprom.et0mac);
160 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
161 - str2eaddr(buf, iv->sprom.et1mac);
162 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
163 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 10);
164 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
165 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 10);
166 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
167 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
168 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
169 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
170 + sprom->revision = 1;
171 + if ((s = nvram_get("il0macaddr")))
172 + e_aton(s, sprom->il0mac);
173 + if ((s = nvram_get("et0macaddr")))
174 + e_aton(s, sprom->et0mac);
175 + if ((s = nvram_get("et1macaddr")))
176 + e_aton(s, sprom->et1mac);
177 + if ((s = nvram_get("et0phyaddr")))
178 + sprom->et0phyaddr = simple_strtoul(s, NULL, 0);
179 + if ((s = nvram_get("et1phyaddr")))
180 + sprom->et1phyaddr = simple_strtoul(s, NULL, 0);
181 + if ((s = nvram_get("et0mdcport")))
182 + sprom->et0mdcport = !!simple_strtoul(s, NULL, 10);
183 + if ((s = nvram_get("et1mdcport")))
184 + sprom->et1mdcport = !!simple_strtoul(s, NULL, 10);
185 + if ((s = nvram_get("pa0b0")))
186 + sprom->pa0b0 = simple_strtoul(s, NULL, 0);
187 + if ((s = nvram_get("pa0b1")))
188 + sprom->pa0b1 = simple_strtoul(s, NULL, 0);
189 + if ((s = nvram_get("pa0b2")))
190 + sprom->pa0b2 = simple_strtoul(s, NULL, 0);
191 + if ((s = nvram_get("pa1b0")))
192 + sprom->pa1b0 = simple_strtoul(s, NULL, 0);
193 + if ((s = nvram_get("pa1b1")))
194 + sprom->pa1b1 = simple_strtoul(s, NULL, 0);
195 + if ((s = nvram_get("pa1b2")))
196 + sprom->pa1b2 = simple_strtoul(s, NULL, 0);
197 + if ((s = nvram_get("wl0gpio0")))
198 + sprom->gpio0 = simple_strtoul(s, NULL, 0);
199 + if ((s = nvram_get("wl0gpio1")))
200 + sprom->gpio1 = simple_strtoul(s, NULL, 0);
201 + if ((s = nvram_get("wl0gpio2")))
202 + sprom->gpio2 = simple_strtoul(s, NULL, 0);
203 + if ((s = nvram_get("wl0gpio3")))
204 + sprom->gpio3 = simple_strtoul(s, NULL, 0);
205 + if ((s = nvram_get("pa0maxpwr")))
206 + sprom->maxpwr_bg = simple_strtoul(s, NULL, 0);
207 + if ((s = nvram_get("pa1maxpwr")))
208 + sprom->maxpwr_a = simple_strtoul(s, NULL, 0);
209 + if ((s = nvram_get("pa0itssit")))
210 + sprom->itssi_bg = simple_strtoul(s, NULL, 0);
211 + if ((s = nvram_get("pa1itssit")))
212 + sprom->itssi_a = simple_strtoul(s, NULL, 0);
213 + sprom->boardflags_lo = 0;
214 + if ((s = nvram_get("boardflags")))
215 + sprom->boardflags_lo = simple_strtoul(s, NULL, 0);
216 + sprom->boardflags_hi = 0;
217 + if ((s = nvram_get("boardflags2")))
218 + sprom->boardflags_hi = simple_strtoul(s, NULL, 0);
221 +static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
225 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
226 + if ((s = nvram_get("boardtype")))
227 + iv->boardinfo.type = (u16)simple_strtoul(s, NULL, 0);
228 + if ((s = nvram_get("boardrev")))
229 + iv->boardinfo.rev = (u16)simple_strtoul(s, NULL, 0);
231 + bcm47xx_fill_sprom(&iv->sprom);
233 + if ((s = nvram_get("cardbus")))
234 + iv->has_cardbus_slot = !!simple_strtoul(s, NULL, 10);
239 void __init plat_mem_setup(void)
244 + struct ssb_mipscore *mcore;
246 + err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, bcm47xx_get_invariants);
248 + const char *msg = "Failed to initialize SSB bus (err %d)\n";
249 + printk(msg, err); /* Make sure the message gets out of the box. */
252 + mcore = &ssb_bcm47xx.mipscore;
254 - err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
255 - bcm47xx_get_invariants);
257 - panic("Failed to initialize SSB bus (err %d)\n", err);
258 + s = nvram_get("kernel_args");
259 + if (s && !strncmp(s, "console=ttyS1", 13)) {
260 + struct ssb_serial_port port;
262 + printk("Swapping serial ports!\n");
263 + /* swap serial ports */
264 + memcpy(&port, &mcore->serial_ports[0], sizeof(port));
265 + memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1], sizeof(port));
266 + memcpy(&mcore->serial_ports[1], &port, sizeof(port));
269 + for (i = 0; i < mcore->nr_serial_ports; i++) {
270 + struct ssb_serial_port *port = &(mcore->serial_ports[i]);
271 + struct uart_port s;
273 + memset(&s, 0, sizeof(s));
275 + s.membase = port->regs;
276 + s.irq = port->irq + 2;
277 + s.uartclk = port->baud_base;
278 + s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
279 + s.iotype = SERIAL_IO_MEM;
280 + s.regshift = port->reg_shift;
282 + early_serial_setup(&s);
284 + printk("Serial init done.\n");
286 _machine_restart = bcm47xx_machine_restart;
287 _machine_halt = bcm47xx_machine_halt;
288 pm_power_off = bcm47xx_machine_halt;
291 +static int __init bcm47xx_register_gpiodev(void)
293 + static struct resource res = {
294 + .start = 0xFFFFFFFF,
296 + struct platform_device *pdev;
298 + pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
300 + printk(KERN_ERR "bcm47xx: GPIODEV init failed\n");
306 +device_initcall(bcm47xx_register_gpiodev);
307 Index: linux-2.6.28.7/arch/mips/bcm47xx/time.c
308 ===================================================================
309 --- linux-2.6.28.7.orig/arch/mips/bcm47xx/time.c 2009-03-17 17:26:19.000000000 +0100
310 +++ linux-2.6.28.7/arch/mips/bcm47xx/time.c 2009-03-17 17:26:23.000000000 +0100
312 * 675 Mass Ave, Cambridge, MA 02139, USA.
316 #include <linux/init.h>
317 +#include <linux/kernel.h>
318 +#include <linux/sched.h>
319 +#include <linux/serial_reg.h>
320 +#include <linux/interrupt.h>
321 #include <linux/ssb/ssb.h>
322 +#include <asm/addrspace.h>
324 #include <asm/time.h>
325 -#include <bcm47xx.h>
327 +extern struct ssb_bus ssb_bcm47xx;
329 void __init plat_time_init(void)