1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -62,6 +62,7 @@ config BCM47XX
5 select SSB_DRIVER_EXTIF
7 + select SSB_B43_PCI_BRIDGE if PCI
8 select SSB_PCICORE_HOSTMODE if PCI
10 select SYS_HAS_EARLY_PRINTK
11 --- a/arch/mips/bcm47xx/Makefile
12 +++ b/arch/mips/bcm47xx/Makefile
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
23 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
24 + * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
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
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>
39 #include <asm/irq_cpu.h>
42 +extern struct ssb_bus ssb_bcm47xx;
45 void plat_irq_dispatch(void)
48 --- a/arch/mips/bcm47xx/nvram.c
49 +++ b/arch/mips/bcm47xx/nvram.c
52 #include <asm/uaccess.h>
55 +#include "include/nvram.h"
58 -extern struct ssb_bus ssb;
59 +extern struct ssb_bus ssb_bcm47xx;
61 static char nvram_buf[NVRAM_SPACE];
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)
67 - struct ssb_mipscore *mcore = &ssb.mipscore;
68 + struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
69 struct nvram_header *header;
72 --- a/arch/mips/bcm47xx/setup.c
73 +++ b/arch/mips/bcm47xx/setup.c
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>
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
84 * 675 Mass Ave, Cambridge, MA 02139, USA.
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>
100 #include <asm/fw/cfe/cfe_api.h>
101 +#include <linux/pm.h>
103 +#include "include/nvram.h"
105 struct ssb_bus ssb_bcm47xx;
106 EXPORT_SYMBOL(ssb_bcm47xx);
108 +extern void bcm47xx_pci_init(void);
110 static void bcm47xx_machine_restart(char *command)
112 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
113 @@ -56,7 +66,7 @@ static void bcm47xx_machine_halt(void)
117 -static void str2eaddr(char *str, char *dest)
118 +static void e_aton(char *str, char *dest)
122 @@ -73,52 +83,142 @@ static void str2eaddr(char *str, char *d
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)
133 - /* Fill boardinfo structure */
134 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
135 + memset(sprom, 0xFF, sizeof(struct ssb_sprom));
137 - if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0)
138 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
139 - if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
140 - iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
141 - if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
142 - iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
144 - /* Fill sprom structure */
145 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
146 - iv->sprom.revision = 3;
148 - if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
149 - str2eaddr(buf, iv->sprom.et0mac);
150 - if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
151 - str2eaddr(buf, iv->sprom.et1mac);
152 - if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
153 - iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 10);
154 - if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
155 - iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 10);
156 - if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
157 - iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
158 - if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
159 - iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
160 + sprom->revision = 1;
161 + if ((s = nvram_get("il0macaddr")))
162 + e_aton(s, sprom->il0mac);
163 + if ((s = nvram_get("et0macaddr")))
164 + e_aton(s, sprom->et0mac);
165 + if ((s = nvram_get("et1macaddr")))
166 + e_aton(s, sprom->et1mac);
167 + if ((s = nvram_get("et0phyaddr")))
168 + sprom->et0phyaddr = simple_strtoul(s, NULL, 0);
169 + if ((s = nvram_get("et1phyaddr")))
170 + sprom->et1phyaddr = simple_strtoul(s, NULL, 0);
171 + if ((s = nvram_get("et0mdcport")))
172 + sprom->et0mdcport = !!simple_strtoul(s, NULL, 10);
173 + if ((s = nvram_get("et1mdcport")))
174 + sprom->et1mdcport = !!simple_strtoul(s, NULL, 10);
175 + if ((s = nvram_get("pa0b0")))
176 + sprom->pa0b0 = simple_strtoul(s, NULL, 0);
177 + if ((s = nvram_get("pa0b1")))
178 + sprom->pa0b1 = simple_strtoul(s, NULL, 0);
179 + if ((s = nvram_get("pa0b2")))
180 + sprom->pa0b2 = simple_strtoul(s, NULL, 0);
181 + if ((s = nvram_get("pa1b0")))
182 + sprom->pa1b0 = simple_strtoul(s, NULL, 0);
183 + if ((s = nvram_get("pa1b1")))
184 + sprom->pa1b1 = simple_strtoul(s, NULL, 0);
185 + if ((s = nvram_get("pa1b2")))
186 + sprom->pa1b2 = simple_strtoul(s, NULL, 0);
187 + if ((s = nvram_get("wl0gpio0")))
188 + sprom->gpio0 = simple_strtoul(s, NULL, 0);
189 + if ((s = nvram_get("wl0gpio1")))
190 + sprom->gpio1 = simple_strtoul(s, NULL, 0);
191 + if ((s = nvram_get("wl0gpio2")))
192 + sprom->gpio2 = simple_strtoul(s, NULL, 0);
193 + if ((s = nvram_get("wl0gpio3")))
194 + sprom->gpio3 = simple_strtoul(s, NULL, 0);
195 + if ((s = nvram_get("pa0maxpwr")))
196 + sprom->maxpwr_bg = simple_strtoul(s, NULL, 0);
197 + if ((s = nvram_get("pa1maxpwr")))
198 + sprom->maxpwr_a = simple_strtoul(s, NULL, 0);
199 + if ((s = nvram_get("pa0itssit")))
200 + sprom->itssi_bg = simple_strtoul(s, NULL, 0);
201 + if ((s = nvram_get("pa1itssit")))
202 + sprom->itssi_a = simple_strtoul(s, NULL, 0);
203 + sprom->boardflags_lo = 0;
204 + if ((s = nvram_get("boardflags")))
205 + sprom->boardflags_lo = simple_strtoul(s, NULL, 0);
206 + sprom->boardflags_hi = 0;
207 + if ((s = nvram_get("boardflags2")))
208 + sprom->boardflags_hi = simple_strtoul(s, NULL, 0);
211 +static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
215 + iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
216 + if ((s = nvram_get("boardtype")))
217 + iv->boardinfo.type = (u16)simple_strtoul(s, NULL, 0);
218 + if ((s = nvram_get("boardrev")))
219 + iv->boardinfo.rev = (u16)simple_strtoul(s, NULL, 0);
221 + bcm47xx_fill_sprom(&iv->sprom);
223 + if ((s = nvram_get("cardbus")))
224 + iv->has_cardbus_slot = !!simple_strtoul(s, NULL, 10);
229 void __init plat_mem_setup(void)
234 + struct ssb_mipscore *mcore;
236 + err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, bcm47xx_get_invariants);
238 + const char *msg = "Failed to initialize SSB bus (err %d)\n";
239 + printk(msg, err); /* Make sure the message gets out of the box. */
242 + mcore = &ssb_bcm47xx.mipscore;
244 - err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
245 - bcm47xx_get_invariants);
247 - panic("Failed to initialize SSB bus (err %d)\n", err);
248 + s = nvram_get("kernel_args");
249 + if (s && !strncmp(s, "console=ttyS1", 13)) {
250 + struct ssb_serial_port port;
252 + printk("Swapping serial ports!\n");
253 + /* swap serial ports */
254 + memcpy(&port, &mcore->serial_ports[0], sizeof(port));
255 + memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1], sizeof(port));
256 + memcpy(&mcore->serial_ports[1], &port, sizeof(port));
259 + for (i = 0; i < mcore->nr_serial_ports; i++) {
260 + struct ssb_serial_port *port = &(mcore->serial_ports[i]);
261 + struct uart_port s;
263 + memset(&s, 0, sizeof(s));
265 + s.mapbase = (unsigned int) port->regs;
266 + s.membase = port->regs;
267 + s.irq = port->irq + 2;
268 + s.uartclk = port->baud_base;
269 + s.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
270 + s.iotype = SERIAL_IO_MEM;
271 + s.regshift = port->reg_shift;
273 + early_serial_setup(&s);
275 + printk("Serial init done.\n");
277 _machine_restart = bcm47xx_machine_restart;
278 _machine_halt = bcm47xx_machine_halt;
279 pm_power_off = bcm47xx_machine_halt;
282 +static int __init bcm47xx_register_gpiodev(void)
284 + static struct resource res = {
285 + .start = 0xFFFFFFFF,
287 + struct platform_device *pdev;
289 + pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
291 + printk(KERN_ERR "bcm47xx: GPIODEV init failed\n");
297 +device_initcall(bcm47xx_register_gpiodev);
298 --- a/arch/mips/bcm47xx/time.c
299 +++ b/arch/mips/bcm47xx/time.c
301 * 675 Mass Ave, Cambridge, MA 02139, USA.
305 #include <linux/init.h>
306 +#include <linux/kernel.h>
307 +#include <linux/sched.h>
308 +#include <linux/serial_reg.h>
309 +#include <linux/interrupt.h>
310 #include <linux/ssb/ssb.h>
311 +#include <asm/addrspace.h>
313 #include <asm/time.h>
314 -#include <bcm47xx.h>
316 +extern struct ssb_bus ssb_bcm47xx;
318 void __init plat_time_init(void)