1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7  * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
8  */
9 
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11 
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/platform_device.h>
16 #include <linux/ssb/ssb.h>
17 #include <asm/addrspace.h>
18 #include <bcm63xx_board.h>
19 #include <bcm63xx_cpu.h>
20 #include <bcm63xx_dev_uart.h>
21 #include <bcm63xx_regs.h>
22 #include <bcm63xx_io.h>
23 #include <bcm63xx_nvram.h>
24 #include <bcm63xx_dev_pci.h>
25 #include <bcm63xx_dev_enet.h>
26 #include <bcm63xx_dev_flash.h>
27 #include <bcm63xx_dev_hsspi.h>
28 #include <bcm63xx_dev_pcmcia.h>
29 #include <bcm63xx_dev_spi.h>
30 #include <bcm63xx_dev_usb_usbd.h>
31 #include <board_bcm963xx.h>
32 
33 #include <uapi/linux/bcm933xx_hcs.h>
34 
35 
36 #define HCS_OFFSET_128K			0x20000
37 
38 static struct board_info board;
39 
40 /*
41  * known 3368 boards
42  */
43 #ifdef CONFIG_BCM63XX_CPU_3368
44 static struct board_info __initdata board_cvg834g = {
45 	.name				= "CVG834G_E15R3921",
46 	.expected_cpu_id		= 0x3368,
47 
48 	.has_uart0			= 1,
49 	.has_uart1			= 1,
50 
51 	.has_enet0			= 1,
52 	.has_pci			= 1,
53 
54 	.enet0 = {
55 		.has_phy		= 1,
56 		.use_internal_phy	= 1,
57 	},
58 
59 	.leds = {
60 		{
61 			.name		= "CVG834G:green:power",
62 			.gpio		= 37,
63 			.default_trigger= "default-on",
64 		},
65 	},
66 
67 	.ephy_reset_gpio		= 36,
68 	.ephy_reset_gpio_flags		= GPIOF_INIT_HIGH,
69 };
70 #endif /* CONFIG_BCM63XX_CPU_3368 */
71 
72 /*
73  * known 6328 boards
74  */
75 #ifdef CONFIG_BCM63XX_CPU_6328
76 static struct board_info __initdata board_96328avng = {
77 	.name				= "96328avng",
78 	.expected_cpu_id		= 0x6328,
79 
80 	.has_uart0			= 1,
81 	.has_pci			= 1,
82 	.has_usbd			= 0,
83 
84 	.usbd = {
85 		.use_fullspeed		= 0,
86 		.port_no		= 0,
87 	},
88 
89 	.leds = {
90 		{
91 			.name		= "96328avng::ppp-fail",
92 			.gpio		= 2,
93 			.active_low	= 1,
94 		},
95 		{
96 			.name		= "96328avng::power",
97 			.gpio		= 4,
98 			.active_low	= 1,
99 			.default_trigger = "default-on",
100 		},
101 		{
102 			.name		= "96328avng::power-fail",
103 			.gpio		= 8,
104 			.active_low	= 1,
105 		},
106 		{
107 			.name		= "96328avng::wps",
108 			.gpio		= 9,
109 			.active_low	= 1,
110 		},
111 		{
112 			.name		= "96328avng::ppp",
113 			.gpio		= 11,
114 			.active_low	= 1,
115 		},
116 	},
117 };
118 #endif /* CONFIG_BCM63XX_CPU_6328 */
119 
120 /*
121  * known 6338 boards
122  */
123 #ifdef CONFIG_BCM63XX_CPU_6338
124 static struct board_info __initdata board_96338gw = {
125 	.name				= "96338GW",
126 	.expected_cpu_id		= 0x6338,
127 
128 	.has_uart0			= 1,
129 	.has_enet0			= 1,
130 	.enet0 = {
131 		.force_speed_100	= 1,
132 		.force_duplex_full	= 1,
133 	},
134 
135 	.has_ohci0			= 1,
136 
137 	.leds = {
138 		{
139 			.name		= "adsl",
140 			.gpio		= 3,
141 			.active_low	= 1,
142 		},
143 		{
144 			.name		= "ses",
145 			.gpio		= 5,
146 			.active_low	= 1,
147 		},
148 		{
149 			.name		= "ppp-fail",
150 			.gpio		= 4,
151 			.active_low	= 1,
152 		},
153 		{
154 			.name		= "power",
155 			.gpio		= 0,
156 			.active_low	= 1,
157 			.default_trigger = "default-on",
158 		},
159 		{
160 			.name		= "stop",
161 			.gpio		= 1,
162 			.active_low	= 1,
163 		}
164 	},
165 };
166 
167 static struct board_info __initdata board_96338w = {
168 	.name				= "96338W",
169 	.expected_cpu_id		= 0x6338,
170 
171 	.has_uart0			= 1,
172 	.has_enet0			= 1,
173 	.enet0 = {
174 		.force_speed_100	= 1,
175 		.force_duplex_full	= 1,
176 	},
177 
178 	.leds = {
179 		{
180 			.name		= "adsl",
181 			.gpio		= 3,
182 			.active_low	= 1,
183 		},
184 		{
185 			.name		= "ses",
186 			.gpio		= 5,
187 			.active_low	= 1,
188 		},
189 		{
190 			.name		= "ppp-fail",
191 			.gpio		= 4,
192 			.active_low	= 1,
193 		},
194 		{
195 			.name		= "power",
196 			.gpio		= 0,
197 			.active_low	= 1,
198 			.default_trigger = "default-on",
199 		},
200 		{
201 			.name		= "stop",
202 			.gpio		= 1,
203 			.active_low	= 1,
204 		},
205 	},
206 };
207 #endif /* CONFIG_BCM63XX_CPU_6338 */
208 
209 /*
210  * known 6345 boards
211  */
212 #ifdef CONFIG_BCM63XX_CPU_6345
213 static struct board_info __initdata board_96345gw2 = {
214 	.name				= "96345GW2",
215 	.expected_cpu_id		= 0x6345,
216 
217 	.has_uart0			= 1,
218 };
219 #endif /* CONFIG_BCM63XX_CPU_6345 */
220 
221 /*
222  * known 6348 boards
223  */
224 #ifdef CONFIG_BCM63XX_CPU_6348
225 static struct board_info __initdata board_96348r = {
226 	.name				= "96348R",
227 	.expected_cpu_id		= 0x6348,
228 
229 	.has_uart0			= 1,
230 	.has_enet0			= 1,
231 	.has_pci			= 1,
232 
233 	.enet0 = {
234 		.has_phy		= 1,
235 		.use_internal_phy	= 1,
236 	},
237 
238 	.leds = {
239 		{
240 			.name		= "adsl-fail",
241 			.gpio		= 2,
242 			.active_low	= 1,
243 		},
244 		{
245 			.name		= "ppp",
246 			.gpio		= 3,
247 			.active_low	= 1,
248 		},
249 		{
250 			.name		= "ppp-fail",
251 			.gpio		= 4,
252 			.active_low	= 1,
253 		},
254 		{
255 			.name		= "power",
256 			.gpio		= 0,
257 			.active_low	= 1,
258 			.default_trigger = "default-on",
259 
260 		},
261 		{
262 			.name		= "stop",
263 			.gpio		= 1,
264 			.active_low	= 1,
265 		},
266 	},
267 };
268 
269 static struct board_info __initdata board_96348gw_10 = {
270 	.name				= "96348GW-10",
271 	.expected_cpu_id		= 0x6348,
272 
273 	.has_uart0			= 1,
274 	.has_enet0			= 1,
275 	.has_enet1			= 1,
276 	.has_pci			= 1,
277 
278 	.enet0 = {
279 		.has_phy		= 1,
280 		.use_internal_phy	= 1,
281 	},
282 	.enet1 = {
283 		.force_speed_100	= 1,
284 		.force_duplex_full	= 1,
285 	},
286 
287 	.has_ohci0			= 1,
288 	.has_pccard			= 1,
289 	.has_ehci0			= 1,
290 
291 	.leds = {
292 		{
293 			.name		= "adsl-fail",
294 			.gpio		= 2,
295 			.active_low	= 1,
296 		},
297 		{
298 			.name		= "ppp",
299 			.gpio		= 3,
300 			.active_low	= 1,
301 		},
302 		{
303 			.name		= "ppp-fail",
304 			.gpio		= 4,
305 			.active_low	= 1,
306 		},
307 		{
308 			.name		= "power",
309 			.gpio		= 0,
310 			.active_low	= 1,
311 			.default_trigger = "default-on",
312 		},
313 		{
314 			.name		= "stop",
315 			.gpio		= 1,
316 			.active_low	= 1,
317 		},
318 	},
319 };
320 
321 static struct board_info __initdata board_96348gw_11 = {
322 	.name				= "96348GW-11",
323 	.expected_cpu_id		= 0x6348,
324 
325 	.has_uart0			= 1,
326 	.has_enet0			= 1,
327 	.has_enet1			= 1,
328 	.has_pci			= 1,
329 
330 	.enet0 = {
331 		.has_phy		= 1,
332 		.use_internal_phy	= 1,
333 	},
334 
335 	.enet1 = {
336 		.force_speed_100	= 1,
337 		.force_duplex_full	= 1,
338 	},
339 
340 
341 	.has_ohci0 = 1,
342 	.has_pccard = 1,
343 	.has_ehci0 = 1,
344 
345 	.leds = {
346 		{
347 			.name		= "adsl-fail",
348 			.gpio		= 2,
349 			.active_low	= 1,
350 		},
351 		{
352 			.name		= "ppp",
353 			.gpio		= 3,
354 			.active_low	= 1,
355 		},
356 		{
357 			.name		= "ppp-fail",
358 			.gpio		= 4,
359 			.active_low	= 1,
360 		},
361 		{
362 			.name		= "power",
363 			.gpio		= 0,
364 			.active_low	= 1,
365 			.default_trigger = "default-on",
366 		},
367 		{
368 			.name		= "stop",
369 			.gpio		= 1,
370 			.active_low	= 1,
371 		},
372 	},
373 };
374 
375 static struct board_info __initdata board_96348gw = {
376 	.name				= "96348GW",
377 	.expected_cpu_id		= 0x6348,
378 
379 	.has_uart0			= 1,
380 	.has_enet0			= 1,
381 	.has_enet1			= 1,
382 	.has_pci			= 1,
383 
384 	.enet0 = {
385 		.has_phy		= 1,
386 		.use_internal_phy	= 1,
387 	},
388 	.enet1 = {
389 		.force_speed_100	= 1,
390 		.force_duplex_full	= 1,
391 	},
392 
393 	.has_ohci0 = 1,
394 
395 	.leds = {
396 		{
397 			.name		= "adsl-fail",
398 			.gpio		= 2,
399 			.active_low	= 1,
400 		},
401 		{
402 			.name		= "ppp",
403 			.gpio		= 3,
404 			.active_low	= 1,
405 		},
406 		{
407 			.name		= "ppp-fail",
408 			.gpio		= 4,
409 			.active_low	= 1,
410 		},
411 		{
412 			.name		= "power",
413 			.gpio		= 0,
414 			.active_low	= 1,
415 			.default_trigger = "default-on",
416 		},
417 		{
418 			.name		= "stop",
419 			.gpio		= 1,
420 			.active_low	= 1,
421 		},
422 	},
423 };
424 
425 static struct board_info __initdata board_FAST2404 = {
426 	.name				= "F@ST2404",
427 	.expected_cpu_id		= 0x6348,
428 
429 	.has_uart0			= 1,
430 	.has_enet0			= 1,
431 	.has_enet1			= 1,
432 	.has_pci			= 1,
433 
434 	.enet0 = {
435 		.has_phy		= 1,
436 		.use_internal_phy	= 1,
437 	},
438 
439 	.enet1 = {
440 		.force_speed_100	= 1,
441 		.force_duplex_full	= 1,
442 	},
443 
444 	.has_ohci0			= 1,
445 	.has_pccard			= 1,
446 	.has_ehci0			= 1,
447 };
448 
449 static struct board_info __initdata board_rta1025w_16 = {
450 	.name				= "RTA1025W_16",
451 	.expected_cpu_id		= 0x6348,
452 
453 	.has_enet0			= 1,
454 	.has_enet1			= 1,
455 	.has_pci			= 1,
456 
457 	.enet0 = {
458 		.has_phy		= 1,
459 		.use_internal_phy	= 1,
460 	},
461 	.enet1 = {
462 		.force_speed_100	= 1,
463 		.force_duplex_full	= 1,
464 	},
465 };
466 
467 static struct board_info __initdata board_DV201AMR = {
468 	.name				= "DV201AMR",
469 	.expected_cpu_id		= 0x6348,
470 
471 	.has_uart0			= 1,
472 	.has_pci			= 1,
473 	.has_ohci0			= 1,
474 
475 	.has_enet0			= 1,
476 	.has_enet1			= 1,
477 	.enet0 = {
478 		.has_phy		= 1,
479 		.use_internal_phy	= 1,
480 	},
481 	.enet1 = {
482 		.force_speed_100	= 1,
483 		.force_duplex_full	= 1,
484 	},
485 };
486 
487 static struct board_info __initdata board_96348gw_a = {
488 	.name				= "96348GW-A",
489 	.expected_cpu_id		= 0x6348,
490 
491 	.has_uart0			= 1,
492 	.has_enet0			= 1,
493 	.has_enet1			= 1,
494 	.has_pci			= 1,
495 
496 	.enet0 = {
497 		.has_phy		= 1,
498 		.use_internal_phy	= 1,
499 	},
500 	.enet1 = {
501 		.force_speed_100	= 1,
502 		.force_duplex_full	= 1,
503 	},
504 
505 	.has_ohci0 = 1,
506 };
507 #endif /* CONFIG_BCM63XX_CPU_6348 */
508 
509 /*
510  * known 6358 boards
511  */
512 #ifdef CONFIG_BCM63XX_CPU_6358
513 static struct board_info __initdata board_96358vw = {
514 	.name				= "96358VW",
515 	.expected_cpu_id		= 0x6358,
516 
517 	.has_uart0			= 1,
518 	.has_enet0			= 1,
519 	.has_enet1			= 1,
520 	.has_pci			= 1,
521 
522 	.enet0 = {
523 		.has_phy		= 1,
524 		.use_internal_phy	= 1,
525 	},
526 
527 	.enet1 = {
528 		.force_speed_100	= 1,
529 		.force_duplex_full	= 1,
530 	},
531 
532 	.has_ohci0 = 1,
533 	.has_pccard = 1,
534 	.has_ehci0 = 1,
535 
536 	.leds = {
537 		{
538 			.name		= "adsl-fail",
539 			.gpio		= 15,
540 			.active_low	= 1,
541 		},
542 		{
543 			.name		= "ppp",
544 			.gpio		= 22,
545 			.active_low	= 1,
546 		},
547 		{
548 			.name		= "ppp-fail",
549 			.gpio		= 23,
550 			.active_low	= 1,
551 		},
552 		{
553 			.name		= "power",
554 			.gpio		= 4,
555 			.default_trigger = "default-on",
556 		},
557 		{
558 			.name		= "stop",
559 			.gpio		= 5,
560 		},
561 	},
562 };
563 
564 static struct board_info __initdata board_96358vw2 = {
565 	.name				= "96358VW2",
566 	.expected_cpu_id		= 0x6358,
567 
568 	.has_uart0			= 1,
569 	.has_enet0			= 1,
570 	.has_enet1			= 1,
571 	.has_pci			= 1,
572 
573 	.enet0 = {
574 		.has_phy		= 1,
575 		.use_internal_phy	= 1,
576 	},
577 
578 	.enet1 = {
579 		.force_speed_100	= 1,
580 		.force_duplex_full	= 1,
581 	},
582 
583 
584 	.has_ohci0 = 1,
585 	.has_pccard = 1,
586 	.has_ehci0 = 1,
587 
588 	.leds = {
589 		{
590 			.name		= "adsl",
591 			.gpio		= 22,
592 			.active_low	= 1,
593 		},
594 		{
595 			.name		= "ppp-fail",
596 			.gpio		= 23,
597 		},
598 		{
599 			.name		= "power",
600 			.gpio		= 5,
601 			.active_low	= 1,
602 			.default_trigger = "default-on",
603 		},
604 		{
605 			.name		= "stop",
606 			.gpio		= 4,
607 			.active_low	= 1,
608 		},
609 	},
610 };
611 
612 static struct board_info __initdata board_AGPFS0 = {
613 	.name				= "AGPF-S0",
614 	.expected_cpu_id		= 0x6358,
615 
616 	.has_uart0			= 1,
617 	.has_enet0			= 1,
618 	.has_enet1			= 1,
619 	.has_pci			= 1,
620 
621 	.enet0 = {
622 		.has_phy		= 1,
623 		.use_internal_phy	= 1,
624 	},
625 
626 	.enet1 = {
627 		.force_speed_100	= 1,
628 		.force_duplex_full	= 1,
629 	},
630 
631 	.has_ohci0 = 1,
632 	.has_ehci0 = 1,
633 };
634 
635 static struct board_info __initdata board_DWVS0 = {
636 	.name				= "DWV-S0",
637 	.expected_cpu_id		= 0x6358,
638 
639 	.has_enet0			= 1,
640 	.has_enet1			= 1,
641 	.has_pci			= 1,
642 
643 	.enet0 = {
644 		.has_phy		= 1,
645 		.use_internal_phy	= 1,
646 	},
647 
648 	.enet1 = {
649 		.force_speed_100	= 1,
650 		.force_duplex_full	= 1,
651 	},
652 
653 	.has_ohci0			= 1,
654 };
655 #endif /* CONFIG_BCM63XX_CPU_6358 */
656 
657 /*
658  * all boards
659  */
660 static const struct board_info __initconst *bcm963xx_boards[] = {
661 #ifdef CONFIG_BCM63XX_CPU_3368
662 	&board_cvg834g,
663 #endif /* CONFIG_BCM63XX_CPU_3368 */
664 #ifdef CONFIG_BCM63XX_CPU_6328
665 	&board_96328avng,
666 #endif /* CONFIG_BCM63XX_CPU_6328 */
667 #ifdef CONFIG_BCM63XX_CPU_6338
668 	&board_96338gw,
669 	&board_96338w,
670 #endif /* CONFIG_BCM63XX_CPU_6338 */
671 #ifdef CONFIG_BCM63XX_CPU_6345
672 	&board_96345gw2,
673 #endif /* CONFIG_BCM63XX_CPU_6345 */
674 #ifdef CONFIG_BCM63XX_CPU_6348
675 	&board_96348r,
676 	&board_96348gw,
677 	&board_96348gw_10,
678 	&board_96348gw_11,
679 	&board_FAST2404,
680 	&board_DV201AMR,
681 	&board_96348gw_a,
682 	&board_rta1025w_16,
683 #endif /* CONFIG_BCM63XX_CPU_6348 */
684 #ifdef CONFIG_BCM63XX_CPU_6358
685 	&board_96358vw,
686 	&board_96358vw2,
687 	&board_AGPFS0,
688 	&board_DWVS0,
689 #endif /* CONFIG_BCM63XX_CPU_6358 */
690 };
691 
692 /*
693  * Register a sane SPROMv2 to make the on-board
694  * bcm4318 WLAN work
695  */
696 #ifdef CONFIG_SSB_PCIHOST
697 static struct ssb_sprom bcm63xx_sprom = {
698 	.revision		= 0x02,
699 	.board_rev		= 0x17,
700 	.country_code		= 0x0,
701 	.ant_available_bg	= 0x3,
702 	.pa0b0			= 0x15ae,
703 	.pa0b1			= 0xfa85,
704 	.pa0b2			= 0xfe8d,
705 	.pa1b0			= 0xffff,
706 	.pa1b1			= 0xffff,
707 	.pa1b2			= 0xffff,
708 	.gpio0			= 0xff,
709 	.gpio1			= 0xff,
710 	.gpio2			= 0xff,
711 	.gpio3			= 0xff,
712 	.maxpwr_bg		= 0x004c,
713 	.itssi_bg		= 0x00,
714 	.boardflags_lo		= 0x2848,
715 	.boardflags_hi		= 0x0000,
716 };
717 
718 int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
719 {
720 	if (bus->bustype == SSB_BUSTYPE_PCI) {
721 		memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
722 		return 0;
723 	} else {
724 		pr_err("unable to fill SPROM for given bustype\n");
725 		return -EINVAL;
726 	}
727 }
728 #endif /* CONFIG_SSB_PCIHOST */
729 
730 /*
731  * return board name for /proc/cpuinfo
732  */
733 const char *board_get_name(void)
734 {
735 	return board.name;
736 }
737 
738 /*
739  * early init callback, read nvram data from flash and checksum it
740  */
741 void __init board_prom_init(void)
742 {
743 	unsigned int i;
744 	u8 *boot_addr, *cfe;
745 	char cfe_version[32];
746 	char *board_name = NULL;
747 	u32 val;
748 	struct bcm_hcs *hcs;
749 
750 	/* read base address of boot chip select (0)
751 	 * 6328/6362 do not have MPI but boot from a fixed address
752 	 */
753 	if (BCMCPU_IS_6328() || BCMCPU_IS_6362()) {
754 		val = 0x18000000;
755 	} else {
756 		val = bcm_mpi_readl(MPI_CSBASE_REG(0));
757 		val &= MPI_CSBASE_BASE_MASK;
758 	}
759 	boot_addr = (u8 *)KSEG1ADDR(val);
760 
761 	/* dump cfe version */
762 	cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
763 	if (strstarts(cfe, "cfe-")) {
764 		if(cfe[4] == 'v') {
765 			if(cfe[5] == 'd')
766 				snprintf(cfe_version, 11, "%s",
767 					 (char *) &cfe[5]);
768 			else if (cfe[10] > 0)
769 				snprintf(cfe_version, sizeof(cfe_version),
770 					 "%u.%u.%u-%u.%u-%u", cfe[5], cfe[6],
771 					 cfe[7], cfe[8], cfe[9], cfe[10]);
772 			else
773 				snprintf(cfe_version, sizeof(cfe_version),
774 					 "%u.%u.%u-%u.%u", cfe[5], cfe[6],
775 					 cfe[7], cfe[8], cfe[9]);
776 		} else {
777 			snprintf(cfe_version, 12, "%s", (char *) &cfe[4]);
778 		}
779 	} else {
780 		strcpy(cfe_version, "unknown");
781 	}
782 	pr_info("CFE version: %s\n", cfe_version);
783 
784 	bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
785 
786 	if (BCMCPU_IS_3368()) {
787 		hcs = (struct bcm_hcs *)boot_addr;
788 		board_name = hcs->filename;
789 	} else {
790 		board_name = bcm63xx_nvram_get_name();
791 	}
792 	/* find board by name */
793 	for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
794 		if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
795 			continue;
796 		/* copy, board desc array is marked initdata */
797 		memcpy(&board, bcm963xx_boards[i], sizeof(board));
798 		break;
799 	}
800 
801 	/* bail out if board is not found, will complain later */
802 	if (!board.name[0]) {
803 		char name[17];
804 		memcpy(name, board_name, 16);
805 		name[16] = 0;
806 		pr_err("unknown bcm963xx board: %s\n", name);
807 		return;
808 	}
809 
810 	/* setup pin multiplexing depending on board enabled device,
811 	 * this has to be done this early since PCI init is done
812 	 * inside arch_initcall */
813 	val = 0;
814 
815 #ifdef CONFIG_PCI
816 	if (board.has_pci) {
817 		bcm63xx_pci_enabled = 1;
818 		if (BCMCPU_IS_6348())
819 			val |= GPIO_MODE_6348_G2_PCI;
820 	}
821 #endif /* CONFIG_PCI */
822 
823 	if (board.has_pccard) {
824 		if (BCMCPU_IS_6348())
825 			val |= GPIO_MODE_6348_G1_MII_PCCARD;
826 	}
827 
828 	if (board.has_enet0 && !board.enet0.use_internal_phy) {
829 		if (BCMCPU_IS_6348())
830 			val |= GPIO_MODE_6348_G3_EXT_MII |
831 				GPIO_MODE_6348_G0_EXT_MII;
832 	}
833 
834 	if (board.has_enet1 && !board.enet1.use_internal_phy) {
835 		if (BCMCPU_IS_6348())
836 			val |= GPIO_MODE_6348_G3_EXT_MII |
837 				GPIO_MODE_6348_G0_EXT_MII;
838 	}
839 
840 	bcm_gpio_writel(val, GPIO_MODE_REG);
841 }
842 
843 /*
844  * second stage init callback, good time to panic if we couldn't
845  * identify on which board we're running since early printk is working
846  */
847 void __init board_setup(void)
848 {
849 	if (!board.name[0])
850 		panic("unable to detect bcm963xx board");
851 	pr_info("board name: %s\n", board.name);
852 
853 	/* make sure we're running on expected cpu */
854 	if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
855 		panic("unexpected CPU for bcm963xx board");
856 }
857 
858 static struct gpio_led_platform_data bcm63xx_led_data;
859 
860 static struct platform_device bcm63xx_gpio_leds = {
861 	.name			= "leds-gpio",
862 	.id			= 0,
863 	.dev.platform_data	= &bcm63xx_led_data,
864 };
865 
866 /*
867  * third stage init callback, register all board devices.
868  */
869 int __init board_register_devices(void)
870 {
871 	if (board.has_uart0)
872 		bcm63xx_uart_register(0);
873 
874 	if (board.has_uart1)
875 		bcm63xx_uart_register(1);
876 
877 	if (board.has_pccard)
878 		bcm63xx_pcmcia_register();
879 
880 	if (board.has_enet0 &&
881 	    !bcm63xx_nvram_get_mac_address(board.enet0.mac_addr))
882 		bcm63xx_enet_register(0, &board.enet0);
883 
884 	if (board.has_enet1 &&
885 	    !bcm63xx_nvram_get_mac_address(board.enet1.mac_addr))
886 		bcm63xx_enet_register(1, &board.enet1);
887 
888 	if (board.has_enetsw &&
889 	    !bcm63xx_nvram_get_mac_address(board.enetsw.mac_addr))
890 		bcm63xx_enetsw_register(&board.enetsw);
891 
892 	if (board.has_usbd)
893 		bcm63xx_usbd_register(&board.usbd);
894 
895 	/* Generate MAC address for WLAN and register our SPROM,
896 	 * do this after registering enet devices
897 	 */
898 #ifdef CONFIG_SSB_PCIHOST
899 	if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) {
900 		memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
901 		memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
902 		if (ssb_arch_register_fallback_sprom(
903 				&bcm63xx_get_fallback_sprom) < 0)
904 			pr_err("failed to register fallback SPROM\n");
905 	}
906 #endif /* CONFIG_SSB_PCIHOST */
907 
908 	bcm63xx_spi_register();
909 
910 	bcm63xx_hsspi_register();
911 
912 	bcm63xx_flash_register();
913 
914 	bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
915 	bcm63xx_led_data.leds = board.leds;
916 
917 	platform_device_register(&bcm63xx_gpio_leds);
918 
919 	if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
920 		gpio_request_one(board.ephy_reset_gpio,
921 				board.ephy_reset_gpio_flags, "ephy-reset");
922 
923 	return 0;
924 }
925