beb8f33b696bc3d168a0adf2c159968c1b1873f5
[openwrt/svn-archive/archive.git] / target / linux / brcm63xx / patches-3.3 / 501-board-NB4.patch
1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -15,6 +15,8 @@
4 #include <linux/gpio_keys.h>
5 #include <linux/input.h>
6 #include <linux/spi/spi.h>
7 +#include <linux/spi/spi_gpio.h>
8 +#include <linux/spi/74x164.h>
9 #include <asm/addrspace.h>
10 #include <bcm63xx_board.h>
11 #include <bcm63xx_cpu.h>
12 @@ -43,6 +45,12 @@
13 #define CFE_OFFSET_64K 0x10000
14 #define CFE_OFFSET_128K 0x20000
15
16 +#define NB4_PID_OFFSET 0xff80
17 +#define NB4_74X164_GPIO_BASE 64
18 +#define NB4_SPI_GPIO_MOSI 7
19 +#define NB4_SPI_GPIO_CLK 6
20 +#define NB4_74HC64_GPIO(X) (NB4_74X164_GPIO_BASE + (X))
21 +
22 static struct board_info board;
23
24 /*
25 @@ -666,6 +674,496 @@ static struct board_info __initdata boar
26
27 .has_ohci0 = 1,
28 };
29 +
30 +struct spi_gpio_platform_data nb4_spi_gpio_data = {
31 + .sck = NB4_SPI_GPIO_CLK,
32 + .mosi = NB4_SPI_GPIO_MOSI,
33 + .miso = SPI_GPIO_NO_MISO,
34 + .num_chipselect = 1,
35 +};
36 +
37 +
38 +static struct platform_device nb4_spi_gpio = {
39 + .name = "spi_gpio",
40 + .id = 1,
41 + .dev = {
42 + .platform_data = &nb4_spi_gpio_data,
43 + },
44 +};
45 +
46 +static struct platform_device * __initdata nb4_devices[] = {
47 + &nb4_spi_gpio,
48 +};
49 +
50 +const struct gen_74x164_chip_platform_data nb4_74x164_platform_data = {
51 + .base = NB4_74X164_GPIO_BASE
52 +};
53 +
54 +static struct spi_board_info nb4_spi_devices[] = {
55 + {
56 + .modalias = "74x164",
57 + .max_speed_hz = 781000,
58 + .bus_num = 1,
59 + .controller_data = (void *) SPI_GPIO_NO_CHIPSELECT,
60 + .mode = SPI_MODE_0,
61 + .platform_data = &nb4_74x164_platform_data
62 + }
63 +};
64 +
65 +static struct board_info __initdata board_nb4_ser_r0 = {
66 + .name = "NB4-SER-r0",
67 + .expected_cpu_id = 0x6358,
68 +
69 + .has_uart0 = 1,
70 + .has_enet0 = 1,
71 + .has_enet1 = 1,
72 + .has_pci = 1,
73 +
74 + .enet0 = {
75 + .has_phy = 1,
76 + .use_internal_phy = 1,
77 + },
78 +
79 + .enet1 = {
80 + .force_speed_100 = 1,
81 + .force_duplex_full = 1,
82 + },
83 +
84 +
85 + .has_ohci0 = 1,
86 + .has_pccard = 1,
87 + .has_ehci0 = 1,
88 +
89 + .leds = {
90 + {
91 + .name = "NB4-SER-r0:white:adsl",
92 + .gpio = NB4_74HC64_GPIO(4),
93 + .active_low = 1,
94 + },
95 + {
96 + .name = "NB4-SER-r0:white:traffic",
97 + .gpio = 2,
98 + .active_low = 1,
99 + },
100 + {
101 + .name = "NB4-SER-r0:white:tel",
102 + .gpio = NB4_74HC64_GPIO(3),
103 + .active_low = 1,
104 + },
105 + {
106 + .name = "NB4-SER-r0:white:tv",
107 + .gpio = NB4_74HC64_GPIO(2),
108 + .active_low = 1,
109 + },
110 + {
111 + .name = "NB4-SER-r0:white:wifi",
112 + .gpio = 15,
113 + .active_low = 1,
114 + },
115 + {
116 + .name = "NB4-SER-r0:white:alarm",
117 + .gpio = NB4_74HC64_GPIO(0),
118 + .active_low = 1,
119 + },
120 + {
121 + .name = "NB4-SER-r0:red:service",
122 + .gpio = 29,
123 + .active_low = 1,
124 + },
125 + {
126 + .name = "NB4-SER-r0:green:service",
127 + .gpio = 30,
128 + .active_low = 1,
129 + },
130 + {
131 + .name = "NB4-SER-r0:blue:service",
132 + .gpio = 4,
133 + .active_low = 1,
134 + },
135 + },
136 + .buttons = {
137 + {
138 + .desc = "reset",
139 + .gpio = 34,
140 + .type = EV_KEY,
141 + .code = KEY_RESTART,
142 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
143 + },
144 + {
145 + .desc = "wps",
146 + .gpio = 37,
147 + .type = EV_KEY,
148 + .code = KEY_WPS_BUTTON,
149 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
150 + },
151 + },
152 + .devs = nb4_devices,
153 + .num_devs = ARRAY_SIZE(nb4_devices),
154 + .spis = nb4_spi_devices,
155 + .num_spis = ARRAY_SIZE(nb4_spi_devices),
156 +};
157 +
158 +static struct board_info __initdata board_nb4_ser_r1 = {
159 + .name = "NB4-SER-r1",
160 + .expected_cpu_id = 0x6358,
161 +
162 + .has_uart0 = 1,
163 + .has_enet0 = 1,
164 + .has_enet1 = 1,
165 + .has_pci = 1,
166 +
167 + .enet0 = {
168 + .has_phy = 1,
169 + .use_internal_phy = 1,
170 + },
171 +
172 + .enet1 = {
173 + .force_speed_100 = 1,
174 + .force_duplex_full = 1,
175 + },
176 +
177 +
178 + .has_ohci0 = 1,
179 + .has_pccard = 1,
180 + .has_ehci0 = 1,
181 +
182 + .leds = {
183 + {
184 + .name = "NB4-SER-r1:white:adsl",
185 + .gpio = NB4_74HC64_GPIO(4),
186 + .active_low = 1,
187 + },
188 + {
189 + .name = "NB4-SER-r1:white:traffic",
190 + .gpio = 2,
191 + .active_low = 1,
192 + },
193 + {
194 + .name = "NB4-SER-r1:white:tel",
195 + .gpio = NB4_74HC64_GPIO(3),
196 + .active_low = 1,
197 + },
198 + {
199 + .name = "NB4-SER-r1:white:tv",
200 + .gpio = NB4_74HC64_GPIO(2),
201 + .active_low = 1,
202 + },
203 + {
204 + .name = "NB4-SER-r1:white:wifi",
205 + .gpio = 15,
206 + .active_low = 1,
207 + },
208 + {
209 + .name = "NB4-SER-r1:white:alarm",
210 + .gpio = NB4_74HC64_GPIO(0),
211 + .active_low = 1,
212 + },
213 + {
214 + .name = "NB4-SER-r1:red:service",
215 + .gpio = 29,
216 + .active_low = 1,
217 + },
218 + {
219 + .name = "NB4-SER-r1:green:service",
220 + .gpio = 30,
221 + .active_low = 1,
222 + },
223 + {
224 + .name = "NB4-SER-r1:blue:service",
225 + .gpio = 4,
226 + .active_low = 1,
227 + },
228 + },
229 + .buttons = {
230 + {
231 + .desc = "reset",
232 + .gpio = 34,
233 + .type = EV_KEY,
234 + .code = KEY_RESTART,
235 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
236 + },
237 + {
238 + .desc = "wps",
239 + .gpio = 37,
240 + .type = EV_KEY,
241 + .code = KEY_WPS_BUTTON,
242 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
243 + },
244 + },
245 + .devs = nb4_devices,
246 + .num_devs = ARRAY_SIZE(nb4_devices),
247 + .spis = nb4_spi_devices,
248 + .num_spis = ARRAY_SIZE(nb4_spi_devices),
249 +};
250 +
251 +static struct board_info __initdata board_nb4_ser_r2 = {
252 + .name = "NB4-SER-r2",
253 + .expected_cpu_id = 0x6358,
254 +
255 + .has_uart0 = 1,
256 + .has_enet0 = 1,
257 + .has_enet1 = 1,
258 + .has_pci = 1,
259 +
260 + .enet0 = {
261 + .has_phy = 1,
262 + .use_internal_phy = 1,
263 + },
264 +
265 + .enet1 = {
266 + .force_speed_100 = 1,
267 + .force_duplex_full = 1,
268 + },
269 +
270 +
271 + .has_ohci0 = 1,
272 + .has_pccard = 1,
273 + .has_ehci0 = 1,
274 +
275 + .leds = {
276 + {
277 + .name = "NB4-SER-r2:white:adsl",
278 + .gpio = NB4_74HC64_GPIO(4),
279 + .active_low = 1,
280 + },
281 + {
282 + .name = "NB4-SER-r2:white:traffic",
283 + .gpio = 2,
284 + .active_low = 1,
285 + },
286 + {
287 + .name = "NB4-SER-r2:white:tel",
288 + .gpio = NB4_74HC64_GPIO(3),
289 + .active_low = 1,
290 + },
291 + {
292 + .name = "NB4-SER-r2:white:tv",
293 + .gpio = NB4_74HC64_GPIO(2),
294 + .active_low = 1,
295 + },
296 + {
297 + .name = "NB4-SER-r2:white:wifi",
298 + .gpio = 15,
299 + .active_low = 1,
300 + },
301 + {
302 + .name = "NB4-SER-r2:white:alarm",
303 + .gpio = NB4_74HC64_GPIO(0),
304 + .active_low = 1,
305 + },
306 + {
307 + .name = "NB4-SER-r2:red:service",
308 + .gpio = 29,
309 + .active_low = 1,
310 + },
311 + {
312 + .name = "NB4-SER-r2:green:service",
313 + .gpio = 30,
314 + .active_low = 1,
315 + },
316 + {
317 + .name = "NB4-SER-r2:blue:service",
318 + .gpio = 4,
319 + .active_low = 1,
320 + },
321 + },
322 + .buttons = {
323 + {
324 + .desc = "reset",
325 + .gpio = 34,
326 + .type = EV_KEY,
327 + .code = KEY_RESTART,
328 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
329 + },
330 + {
331 + .desc = "wps",
332 + .gpio = 37,
333 + .type = EV_KEY,
334 + .code = KEY_WPS_BUTTON,
335 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
336 + },
337 + },
338 + .devs = nb4_devices,
339 + .num_devs = ARRAY_SIZE(nb4_devices),
340 + .spis = nb4_spi_devices,
341 + .num_spis = ARRAY_SIZE(nb4_spi_devices),
342 +};
343 +
344 +static struct board_info __initdata board_nb4_fxc_r1 = {
345 + .name = "NB4-FXC-r1",
346 + .expected_cpu_id = 0x6358,
347 +
348 + .has_uart0 = 1,
349 + .has_enet0 = 1,
350 + .has_enet1 = 1,
351 + .has_pci = 1,
352 +
353 + .enet0 = {
354 + .has_phy = 1,
355 + .use_internal_phy = 1,
356 + },
357 +
358 + .enet1 = {
359 + .force_speed_100 = 1,
360 + .force_duplex_full = 1,
361 + },
362 +
363 +
364 + .has_ohci0 = 1,
365 + .has_pccard = 1,
366 + .has_ehci0 = 1,
367 +
368 + .leds = {
369 + {
370 + .name = "NB4-FXC-r1:white:adsl",
371 + .gpio = NB4_74HC64_GPIO(4),
372 + .active_low = 1,
373 + },
374 + {
375 + .name = "NB4-FXC-r1:white:traffic",
376 + .gpio = 2,
377 + },
378 + {
379 + .name = "NB4-FXC-r1:white:tel",
380 + .gpio = NB4_74HC64_GPIO(3),
381 + .active_low = 1,
382 + },
383 + {
384 + .name = "NB4-FXC-r1:white:tv",
385 + .gpio = NB4_74HC64_GPIO(2),
386 + .active_low = 1,
387 + },
388 + {
389 + .name = "NB4-FXC-r1:white:wifi",
390 + .gpio = 15,
391 + },
392 + {
393 + .name = "NB4-FXC-r1:white:alarm",
394 + .gpio = NB4_74HC64_GPIO(0),
395 + .active_low = 1,
396 + },
397 + {
398 + .name = "NB4-FXC-r1:red:service",
399 + .gpio = 29,
400 + },
401 + {
402 + .name = "NB4-FXC-r1:green:service",
403 + .gpio = 30,
404 + },
405 + {
406 + .name = "NB4-FXC-r1:blue:service",
407 + .gpio = 4,
408 + },
409 + },
410 + .buttons = {
411 + {
412 + .desc = "reset",
413 + .gpio = 34,
414 + .type = EV_KEY,
415 + .code = KEY_RESTART,
416 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
417 + },
418 + {
419 + .desc = "wps",
420 + .gpio = 37,
421 + .type = EV_KEY,
422 + .code = KEY_WPS_BUTTON,
423 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
424 + },
425 + },
426 + .devs = nb4_devices,
427 + .num_devs = ARRAY_SIZE(nb4_devices),
428 + .spis = nb4_spi_devices,
429 + .num_spis = ARRAY_SIZE(nb4_spi_devices),
430 +};
431 +
432 +static struct board_info __initdata board_nb4_fxc_r2 = {
433 + .name = "NB4-FXC-r2",
434 + .expected_cpu_id = 0x6358,
435 +
436 + .has_uart0 = 1,
437 + .has_enet0 = 1,
438 + .has_enet1 = 1,
439 + .has_pci = 1,
440 +
441 + .enet0 = {
442 + .has_phy = 1,
443 + .use_internal_phy = 1,
444 + },
445 +
446 + .enet1 = {
447 + .force_speed_100 = 1,
448 + .force_duplex_full = 1,
449 + },
450 +
451 +
452 + .has_ohci0 = 1,
453 + .has_pccard = 1,
454 + .has_ehci0 = 1,
455 +
456 + .leds = {
457 + {
458 + .name = "NB4-FXC-r2:white:adsl",
459 + .gpio = NB4_74HC64_GPIO(4),
460 + .active_low = 1,
461 + },
462 + {
463 + .name = "NB4-FXC-r2:white:traffic",
464 + .gpio = 2,
465 + },
466 + {
467 + .name = "NB4-FXC-r2:white:tel",
468 + .gpio = NB4_74HC64_GPIO(3),
469 + .active_low = 1,
470 + },
471 + {
472 + .name = "NB4-FXC-r2:white:tv",
473 + .gpio = NB4_74HC64_GPIO(2),
474 + .active_low = 1,
475 + },
476 + {
477 + .name = "NB4-FXC-r2:white:wifi",
478 + .gpio = 15,
479 + },
480 + {
481 + .name = "NB4-FXC-r2:white:alarm",
482 + .gpio = NB4_74HC64_GPIO(0),
483 + .active_low = 1,
484 + },
485 + {
486 + .name = "NB4-FXC-r2:red:service",
487 + .gpio = 29,
488 + },
489 + {
490 + .name = "NB4-FXC-r2:green:service",
491 + .gpio = 30,
492 + },
493 + {
494 + .name = "NB4-FXC-r2:blue:service",
495 + .gpio = 4,
496 + },
497 + },
498 + .buttons = {
499 + {
500 + .desc = "reset",
501 + .gpio = 34,
502 + .type = EV_KEY,
503 + .code = KEY_RESTART,
504 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
505 + },
506 + {
507 + .desc = "wps",
508 + .gpio = 37,
509 + .type = EV_KEY,
510 + .code = KEY_WPS_BUTTON,
511 + .debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
512 + },
513 + },
514 + .devs = nb4_devices,
515 + .num_devs = ARRAY_SIZE(nb4_devices),
516 + .spis = nb4_spi_devices,
517 + .num_spis = ARRAY_SIZE(nb4_spi_devices),
518 +};
519 #endif
520
521 /*
522 @@ -696,9 +1194,31 @@ static const struct board_info __initdat
523 &board_96358vw2,
524 &board_AGPFS0,
525 &board_DWVS0,
526 + &board_nb4_ser_r0,
527 + &board_nb4_ser_r1,
528 + &board_nb4_ser_r2,
529 + &board_nb4_fxc_r1,
530 + &board_nb4_fxc_r2,
531 #endif
532 };
533
534 +static void __init nb4_nvram_fixup(void)
535 +{
536 + u8 *boot_addr, *p;
537 + u32 val;
538 + char *board_name = (char *)bcm63xx_nvram_get_name();
539 +
540 + if (BCMCPU_IS_6358() && (!strcmp(board_name, "96358VW"))) {
541 + val = bcm_mpi_readl(MPI_CSBASE_REG(0));
542 + val &= MPI_CSBASE_BASE_MASK;
543 + boot_addr = (u8 *)KSEG1ADDR(val);
544 + /* Extract nb4 PID */
545 + p = boot_addr + NB4_PID_OFFSET;
546 + if (!memcmp(p, "NB4-", 4))
547 + memcpy(board_name, p, sizeof("NB4-XXX-rX"));
548 + }
549 +}
550 +
551 /*
552 * Register a sane SPROMv2 to make the on-board
553 * bcm4318 WLAN work
554 @@ -810,6 +1330,9 @@ void __init board_prom_init(void)
555 boardid_fixup(boot_addr);
556 }
557
558 + /* Fixup broken nb4 board name */
559 + nb4_nvram_fixup();
560 +
561 board_name = bcm63xx_nvram_get_name();
562 /* find board by name */
563 for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {