[rdc] generate bifferboard images, patch from bifferos
[openwrt.git] / target / linux / brcm47xx / patches-2.6.30 / 400-arch-bcm47xx.patch
1 --- a/arch/mips/Kconfig
2 +++ b/arch/mips/Kconfig
3 @@ -53,6 +53,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,52 +83,142 @@ 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 - /* Fill boardinfo structure */
134 - memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
135 + memset(sprom, 0xFF, sizeof(struct ssb_sprom));
136
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);
143 -
144 - /* Fill sprom structure */
145 - memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
146 - iv->sprom.revision = 3;
147 -
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);
209 +}
210 +
211 +static int bcm47xx_get_invariants(struct ssb_bus *bus, struct ssb_init_invariants *iv)
212 +{
213 + char *s;
214 +
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);
220 +
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 + int i, err;
233 + char *s;
234 + struct ssb_mipscore *mcore;
235 +
236 + err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE, bcm47xx_get_invariants);
237 + if (err) {
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. */
240 + panic(msg, err);
241 + }
242 + mcore = &ssb_bcm47xx.mipscore;
243
244 - err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
245 - bcm47xx_get_invariants);
246 - if (err)
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;
251 +
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));
257 + }
258 +
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;
262 +
263 + memset(&s, 0, sizeof(s));
264 + s.line = i;
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;
272 +
273 + early_serial_setup(&s);
274 + }
275 + printk("Serial init done.\n");
276
277 _machine_restart = bcm47xx_machine_restart;
278 _machine_halt = bcm47xx_machine_halt;
279 pm_power_off = bcm47xx_machine_halt;
280 }
281
282 +static int __init bcm47xx_register_gpiodev(void)
283 +{
284 + static struct resource res = {
285 + .start = 0xFFFFFFFF,
286 + };
287 + struct platform_device *pdev;
288 +
289 + pdev = platform_device_register_simple("GPIODEV", 0, &res, 1);
290 + if (!pdev) {
291 + printk(KERN_ERR "bcm47xx: GPIODEV init failed\n");
292 + return -ENODEV;
293 + }
294 +
295 + return 0;
296 +}
297 +device_initcall(bcm47xx_register_gpiodev);
298 --- a/arch/mips/bcm47xx/time.c
299 +++ b/arch/mips/bcm47xx/time.c
300 @@ -22,11 +22,17 @@
301 * 675 Mass Ave, Cambridge, MA 02139, USA.
302 */
303
304 -
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>
312 +#include <asm/io.h>
313 #include <asm/time.h>
314 -#include <bcm47xx.h>
315 +
316 +extern struct ssb_bus ssb_bcm47xx;
317
318 void __init plat_time_init(void)
319 {
This page took 0.069104 seconds and 5 git commands to generate.