[generic-2.6] Remove files now present upstream in files-2.6.25
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-2.6.25 / 400-arch-bcm47xx.patch
1 Index: linux-2.6.25.1/arch/mips/bcm47xx/irq.c
2 ===================================================================
3 --- linux-2.6.25.1.orig/arch/mips/bcm47xx/irq.c 2008-05-14 14:36:58.000000000 +0100
4 +++ linux-2.6.25.1/arch/mips/bcm47xx/irq.c 2008-05-14 14:37:06.000000000 +0100
5 @@ -1,5 +1,6 @@
6 /*
7 * Copyright (C) 2004 Florian Schirmer <jolt@tuxbox.org>
8 + * Copyright (C) 2008 Michael Buesch <mb@bu3sch.de>
9 *
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
12 @@ -23,10 +24,19 @@
13 */
14
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>
22 +
23 #include <asm/irq_cpu.h>
24
25 +
26 +extern struct ssb_bus ssb_bcm47xx;
27 +
28 +
29 void plat_irq_dispatch(void)
30 {
31 u32 cause;
32 @@ -53,3 +63,19 @@ void __init arch_init_irq(void)
33 {
34 mips_cpu_irq_init();
35 }
36 +
37 +int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
38 +{
39 + int res;
40 +
41 + res = ssb_pcibios_map_irq(dev, slot, pin);
42 + if (res < 0) {
43 + printk(KERN_ALERT "PCI: Failed to map IRQ of device %s\n",
44 + dev->dev.bus_id);
45 + return 0;
46 + }
47 + /* IRQ-0 and IRQ-1 are software interrupts. */
48 + WARN_ON((res == 0) || (res == 1));
49 +
50 + return res;
51 +}
52 Index: linux-2.6.25.1/arch/mips/bcm47xx/setup.c
53 ===================================================================
54 --- linux-2.6.25.1.orig/arch/mips/bcm47xx/setup.c 2008-05-14 14:36:58.000000000 +0100
55 +++ linux-2.6.25.1/arch/mips/bcm47xx/setup.c 2008-05-14 14:37:06.000000000 +0100
56 @@ -2,7 +2,7 @@
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>
62 *
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
65 @@ -25,23 +25,52 @@
66 * 675 Mass Ave, Cambridge, MA 02139, USA.
67 */
68
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>
79 #include <asm/time.h>
80 -#include <bcm47xx.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>
86 +
87 +#include "include/nvram.h"
88
89 struct ssb_bus ssb_bcm47xx;
90 EXPORT_SYMBOL(ssb_bcm47xx);
91
92 +extern void bcm47xx_pci_init(void);
93 +
94 +int pcibios_plat_dev_init(struct pci_dev *dev)
95 +{
96 + int err;
97 +
98 + err = ssb_pcibios_plat_dev_init(dev);
99 + if (err) {
100 + printk(KERN_ALERT "PCI: Failed to init device %s\n",
101 + pci_name(dev));
102 + }
103 +
104 + return err;
105 +}
106 +
107 static void bcm47xx_machine_restart(char *command)
108 {
109 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
110 local_irq_disable();
111 + /* CFE has a reboot callback, but that does not work.
112 + * Oopses with: Reserved instruction in kernel code.
113 + */
114 +
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");
119 while (1)
120 cpu_relax();
121 }
122 @@ -50,12 +79,13 @@ static void bcm47xx_machine_halt(void)
123 {
124 /* Disable interrupts and watchdog and spin forever */
125 local_irq_disable();
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");
129 while (1)
130 cpu_relax();
131 }
132
133 -static void str2eaddr(char *str, char *dest)
134 +static void e_aton(char *str, char *dest)
135 {
136 int i = 0;
137
138 @@ -72,52 +102,141 @@ static void str2eaddr(char *str, char *d
139 }
140 }
141
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)
145 {
146 - char buf[100];
147 + char *s;
148
149 - /* Fill boardinfo structure */
150 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
151 + memset(sprom, 0xFF, sizeof(struct ssb_sprom));
152
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);
159 -
160 - /* Fill sprom structure */
161 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
162 - iv->sprom.revision = 3;
163 -
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);
225 +}
226 +
227 +static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
228 +{
229 + char *s;
230 +
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);
236 +
237 + bcm47xx_fill_sprom(&iv->sprom);
238 +
239 + if ((s = nvram_get("cardbus")))
240 + iv->has_cardbus_slot = !!simple_strtoul(s, NULL, 10);
241
242 return 0;
243 }
244
245 void __init plat_mem_setup(void)
246 {
247 - int err;
248 + int i, err;
249 + char *s;
250 + struct ssb_mipscore *mcore;
251 +
252 + err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, bcm47xx_get_invariants);
253 + if (err) {
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. */
256 + panic(msg, err);
257 + }
258 + mcore = &ssb_bcm47xx.mipscore;
259 +
260 + s = nvram_get("kernel_args");
261 + if (s && !strncmp(s, "console=ttyS1", 13)) {
262 + struct ssb_serial_port port;
263 +
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));
269 + }
270
271 - err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
272 - bcm47xx_get_invariants);
273 - if (err)
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;
278 +
279 + memset(&s, 0, sizeof(s));
280 + s.line = i;
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;
287 +
288 + early_serial_setup(&s);
289 + }
290 + printk("Serial init done.\n");
291
292 _machine_restart = bcm47xx_machine_restart;
293 _machine_halt = bcm47xx_machine_halt;
294 pm_power_off = bcm47xx_machine_halt;
295 }
296
297 +static int __init bcm47xx_register_gpiodev(void)
298 +{
299 + static struct resource res = {
300 + .start = 0xFFFFFFFF,
301 + };
302 + struct platform_device *pdev;
303 +
304 + pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
305 + if (!pdev) {
306 + printk(KERN_ERR "bcm47xx: GPIODEV init failed\n");
307 + return -ENODEV;
308 + }
309 +
310 + return 0;
311 +}
312 +device_initcall(bcm47xx_register_gpiodev);
313 Index: linux-2.6.25.1/arch/mips/bcm47xx/time.c
314 ===================================================================
315 --- linux-2.6.25.1.orig/arch/mips/bcm47xx/time.c 2008-05-14 14:36:58.000000000 +0100
316 +++ linux-2.6.25.1/arch/mips/bcm47xx/time.c 2008-05-14 14:37:06.000000000 +0100
317 @@ -22,11 +22,17 @@
318 * 675 Mass Ave, Cambridge, MA 02139, USA.
319 */
320
321 -
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>
329 +#include <asm/io.h>
330 #include <asm/time.h>
331 -#include <bcm47xx.h>
332 +
333 +extern struct ssb_bus ssb_bcm47xx;
334
335 void __init plat_time_init(void)
336 {
337 Index: linux-2.6.25.1/arch/mips/bcm47xx/nvram.c
338 ===================================================================
339 --- linux-2.6.25.1.orig/arch/mips/bcm47xx/nvram.c 2008-05-14 14:36:58.000000000 +0100
340 +++ linux-2.6.25.1/arch/mips/bcm47xx/nvram.c 2008-05-14 14:37:06.000000000 +0100
341 @@ -24,10 +24,10 @@
342 #include <asm/io.h>
343 #include <asm/uaccess.h>
344
345 -#include <nvram.h>
346 +#include "include/nvram.h"
347
348 #define MB * 1048576
349 -extern struct ssb_bus ssb;
350 +extern struct ssb_bus ssb_bcm47xx;
351
352 static char nvram_buf[NVRAM_SPACE];
353 static int cfe_env;
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)
357 {
358 - struct ssb_mipscore *mcore = &ssb.mipscore;
359 + struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
360 struct nvram_header *header;
361 int i;
362 u32 base, lim, off;
363 Index: linux-2.6.25.1/arch/mips/bcm47xx/Makefile
364 ===================================================================
365 --- linux-2.6.25.1.orig/arch/mips/bcm47xx/Makefile 2008-05-14 14:36:58.000000000 +0100
366 +++ linux-2.6.25.1/arch/mips/bcm47xx/Makefile 2008-05-14 14:37:06.000000000 +0100
367 @@ -3,4 +3,4 @@
368 # under Linux.
369 #
370
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.1/arch/mips/Kconfig
374 ===================================================================
375 --- linux-2.6.25.1.orig/arch/mips/Kconfig 2008-05-14 14:47:43.000000000 +0100
376 +++ linux-2.6.25.1/arch/mips/Kconfig 2008-05-14 14:48:15.000000000 +0100
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
383 select GENERIC_GPIO
384 select SYS_HAS_EARLY_PRINTK