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