usb: gadget: udc: pch_udc: Fix a plethora of function documentation related issues
[linux/fpc-iii.git] / arch / mips / bcm63xx / boards / board_bcm963xx.c
blob36ec3dc2c999a94c9771408f3efc5e3c72972f22
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.
6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
8 */
10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
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>
33 #include <uapi/linux/bcm933xx_hcs.h>
36 #define HCS_OFFSET_128K 0x20000
38 static struct board_info board;
41 * known 3368 boards
43 #ifdef CONFIG_BCM63XX_CPU_3368
44 static struct board_info __initdata board_cvg834g = {
45 .name = "CVG834G_E15R3921",
46 .expected_cpu_id = 0x3368,
48 .has_uart0 = 1,
49 .has_uart1 = 1,
51 .has_enet0 = 1,
52 .has_pci = 1,
54 .enet0 = {
55 .has_phy = 1,
56 .use_internal_phy = 1,
59 .leds = {
61 .name = "CVG834G:green:power",
62 .gpio = 37,
63 .default_trigger= "default-on",
67 .ephy_reset_gpio = 36,
68 .ephy_reset_gpio_flags = GPIOF_INIT_HIGH,
70 #endif
73 * known 6328 boards
75 #ifdef CONFIG_BCM63XX_CPU_6328
76 static struct board_info __initdata board_96328avng = {
77 .name = "96328avng",
78 .expected_cpu_id = 0x6328,
80 .has_uart0 = 1,
81 .has_pci = 1,
82 .has_usbd = 0,
84 .usbd = {
85 .use_fullspeed = 0,
86 .port_no = 0,
89 .leds = {
91 .name = "96328avng::ppp-fail",
92 .gpio = 2,
93 .active_low = 1,
96 .name = "96328avng::power",
97 .gpio = 4,
98 .active_low = 1,
99 .default_trigger = "default-on",
102 .name = "96328avng::power-fail",
103 .gpio = 8,
104 .active_low = 1,
107 .name = "96328avng::wps",
108 .gpio = 9,
109 .active_low = 1,
112 .name = "96328avng::ppp",
113 .gpio = 11,
114 .active_low = 1,
118 #endif
121 * known 6338 boards
123 #ifdef CONFIG_BCM63XX_CPU_6338
124 static struct board_info __initdata board_96338gw = {
125 .name = "96338GW",
126 .expected_cpu_id = 0x6338,
128 .has_uart0 = 1,
129 .has_enet0 = 1,
130 .enet0 = {
131 .force_speed_100 = 1,
132 .force_duplex_full = 1,
135 .has_ohci0 = 1,
137 .leds = {
139 .name = "adsl",
140 .gpio = 3,
141 .active_low = 1,
144 .name = "ses",
145 .gpio = 5,
146 .active_low = 1,
149 .name = "ppp-fail",
150 .gpio = 4,
151 .active_low = 1,
154 .name = "power",
155 .gpio = 0,
156 .active_low = 1,
157 .default_trigger = "default-on",
160 .name = "stop",
161 .gpio = 1,
162 .active_low = 1,
167 static struct board_info __initdata board_96338w = {
168 .name = "96338W",
169 .expected_cpu_id = 0x6338,
171 .has_uart0 = 1,
172 .has_enet0 = 1,
173 .enet0 = {
174 .force_speed_100 = 1,
175 .force_duplex_full = 1,
178 .leds = {
180 .name = "adsl",
181 .gpio = 3,
182 .active_low = 1,
185 .name = "ses",
186 .gpio = 5,
187 .active_low = 1,
190 .name = "ppp-fail",
191 .gpio = 4,
192 .active_low = 1,
195 .name = "power",
196 .gpio = 0,
197 .active_low = 1,
198 .default_trigger = "default-on",
201 .name = "stop",
202 .gpio = 1,
203 .active_low = 1,
207 #endif
210 * known 6345 boards
212 #ifdef CONFIG_BCM63XX_CPU_6345
213 static struct board_info __initdata board_96345gw2 = {
214 .name = "96345GW2",
215 .expected_cpu_id = 0x6345,
217 .has_uart0 = 1,
219 #endif
222 * known 6348 boards
224 #ifdef CONFIG_BCM63XX_CPU_6348
225 static struct board_info __initdata board_96348r = {
226 .name = "96348R",
227 .expected_cpu_id = 0x6348,
229 .has_uart0 = 1,
230 .has_enet0 = 1,
231 .has_pci = 1,
233 .enet0 = {
234 .has_phy = 1,
235 .use_internal_phy = 1,
238 .leds = {
240 .name = "adsl-fail",
241 .gpio = 2,
242 .active_low = 1,
245 .name = "ppp",
246 .gpio = 3,
247 .active_low = 1,
250 .name = "ppp-fail",
251 .gpio = 4,
252 .active_low = 1,
255 .name = "power",
256 .gpio = 0,
257 .active_low = 1,
258 .default_trigger = "default-on",
262 .name = "stop",
263 .gpio = 1,
264 .active_low = 1,
269 static struct board_info __initdata board_96348gw_10 = {
270 .name = "96348GW-10",
271 .expected_cpu_id = 0x6348,
273 .has_uart0 = 1,
274 .has_enet0 = 1,
275 .has_enet1 = 1,
276 .has_pci = 1,
278 .enet0 = {
279 .has_phy = 1,
280 .use_internal_phy = 1,
282 .enet1 = {
283 .force_speed_100 = 1,
284 .force_duplex_full = 1,
287 .has_ohci0 = 1,
288 .has_pccard = 1,
289 .has_ehci0 = 1,
291 .leds = {
293 .name = "adsl-fail",
294 .gpio = 2,
295 .active_low = 1,
298 .name = "ppp",
299 .gpio = 3,
300 .active_low = 1,
303 .name = "ppp-fail",
304 .gpio = 4,
305 .active_low = 1,
308 .name = "power",
309 .gpio = 0,
310 .active_low = 1,
311 .default_trigger = "default-on",
314 .name = "stop",
315 .gpio = 1,
316 .active_low = 1,
321 static struct board_info __initdata board_96348gw_11 = {
322 .name = "96348GW-11",
323 .expected_cpu_id = 0x6348,
325 .has_uart0 = 1,
326 .has_enet0 = 1,
327 .has_enet1 = 1,
328 .has_pci = 1,
330 .enet0 = {
331 .has_phy = 1,
332 .use_internal_phy = 1,
335 .enet1 = {
336 .force_speed_100 = 1,
337 .force_duplex_full = 1,
341 .has_ohci0 = 1,
342 .has_pccard = 1,
343 .has_ehci0 = 1,
345 .leds = {
347 .name = "adsl-fail",
348 .gpio = 2,
349 .active_low = 1,
352 .name = "ppp",
353 .gpio = 3,
354 .active_low = 1,
357 .name = "ppp-fail",
358 .gpio = 4,
359 .active_low = 1,
362 .name = "power",
363 .gpio = 0,
364 .active_low = 1,
365 .default_trigger = "default-on",
368 .name = "stop",
369 .gpio = 1,
370 .active_low = 1,
375 static struct board_info __initdata board_96348gw = {
376 .name = "96348GW",
377 .expected_cpu_id = 0x6348,
379 .has_uart0 = 1,
380 .has_enet0 = 1,
381 .has_enet1 = 1,
382 .has_pci = 1,
384 .enet0 = {
385 .has_phy = 1,
386 .use_internal_phy = 1,
388 .enet1 = {
389 .force_speed_100 = 1,
390 .force_duplex_full = 1,
393 .has_ohci0 = 1,
395 .leds = {
397 .name = "adsl-fail",
398 .gpio = 2,
399 .active_low = 1,
402 .name = "ppp",
403 .gpio = 3,
404 .active_low = 1,
407 .name = "ppp-fail",
408 .gpio = 4,
409 .active_low = 1,
412 .name = "power",
413 .gpio = 0,
414 .active_low = 1,
415 .default_trigger = "default-on",
418 .name = "stop",
419 .gpio = 1,
420 .active_low = 1,
425 static struct board_info __initdata board_FAST2404 = {
426 .name = "F@ST2404",
427 .expected_cpu_id = 0x6348,
429 .has_uart0 = 1,
430 .has_enet0 = 1,
431 .has_enet1 = 1,
432 .has_pci = 1,
434 .enet0 = {
435 .has_phy = 1,
436 .use_internal_phy = 1,
439 .enet1 = {
440 .force_speed_100 = 1,
441 .force_duplex_full = 1,
444 .has_ohci0 = 1,
445 .has_pccard = 1,
446 .has_ehci0 = 1,
449 static struct board_info __initdata board_rta1025w_16 = {
450 .name = "RTA1025W_16",
451 .expected_cpu_id = 0x6348,
453 .has_enet0 = 1,
454 .has_enet1 = 1,
455 .has_pci = 1,
457 .enet0 = {
458 .has_phy = 1,
459 .use_internal_phy = 1,
461 .enet1 = {
462 .force_speed_100 = 1,
463 .force_duplex_full = 1,
468 static struct board_info __initdata board_DV201AMR = {
469 .name = "DV201AMR",
470 .expected_cpu_id = 0x6348,
472 .has_uart0 = 1,
473 .has_pci = 1,
474 .has_ohci0 = 1,
476 .has_enet0 = 1,
477 .has_enet1 = 1,
478 .enet0 = {
479 .has_phy = 1,
480 .use_internal_phy = 1,
482 .enet1 = {
483 .force_speed_100 = 1,
484 .force_duplex_full = 1,
488 static struct board_info __initdata board_96348gw_a = {
489 .name = "96348GW-A",
490 .expected_cpu_id = 0x6348,
492 .has_uart0 = 1,
493 .has_enet0 = 1,
494 .has_enet1 = 1,
495 .has_pci = 1,
497 .enet0 = {
498 .has_phy = 1,
499 .use_internal_phy = 1,
501 .enet1 = {
502 .force_speed_100 = 1,
503 .force_duplex_full = 1,
506 .has_ohci0 = 1,
508 #endif
511 * known 6358 boards
513 #ifdef CONFIG_BCM63XX_CPU_6358
514 static struct board_info __initdata board_96358vw = {
515 .name = "96358VW",
516 .expected_cpu_id = 0x6358,
518 .has_uart0 = 1,
519 .has_enet0 = 1,
520 .has_enet1 = 1,
521 .has_pci = 1,
523 .enet0 = {
524 .has_phy = 1,
525 .use_internal_phy = 1,
528 .enet1 = {
529 .force_speed_100 = 1,
530 .force_duplex_full = 1,
534 .has_ohci0 = 1,
535 .has_pccard = 1,
536 .has_ehci0 = 1,
538 .leds = {
540 .name = "adsl-fail",
541 .gpio = 15,
542 .active_low = 1,
545 .name = "ppp",
546 .gpio = 22,
547 .active_low = 1,
550 .name = "ppp-fail",
551 .gpio = 23,
552 .active_low = 1,
555 .name = "power",
556 .gpio = 4,
557 .default_trigger = "default-on",
560 .name = "stop",
561 .gpio = 5,
566 static struct board_info __initdata board_96358vw2 = {
567 .name = "96358VW2",
568 .expected_cpu_id = 0x6358,
570 .has_uart0 = 1,
571 .has_enet0 = 1,
572 .has_enet1 = 1,
573 .has_pci = 1,
575 .enet0 = {
576 .has_phy = 1,
577 .use_internal_phy = 1,
580 .enet1 = {
581 .force_speed_100 = 1,
582 .force_duplex_full = 1,
586 .has_ohci0 = 1,
587 .has_pccard = 1,
588 .has_ehci0 = 1,
590 .leds = {
592 .name = "adsl",
593 .gpio = 22,
594 .active_low = 1,
597 .name = "ppp-fail",
598 .gpio = 23,
601 .name = "power",
602 .gpio = 5,
603 .active_low = 1,
604 .default_trigger = "default-on",
607 .name = "stop",
608 .gpio = 4,
609 .active_low = 1,
614 static struct board_info __initdata board_AGPFS0 = {
615 .name = "AGPF-S0",
616 .expected_cpu_id = 0x6358,
618 .has_uart0 = 1,
619 .has_enet0 = 1,
620 .has_enet1 = 1,
621 .has_pci = 1,
623 .enet0 = {
624 .has_phy = 1,
625 .use_internal_phy = 1,
628 .enet1 = {
629 .force_speed_100 = 1,
630 .force_duplex_full = 1,
633 .has_ohci0 = 1,
634 .has_ehci0 = 1,
637 static struct board_info __initdata board_DWVS0 = {
638 .name = "DWV-S0",
639 .expected_cpu_id = 0x6358,
641 .has_enet0 = 1,
642 .has_enet1 = 1,
643 .has_pci = 1,
645 .enet0 = {
646 .has_phy = 1,
647 .use_internal_phy = 1,
650 .enet1 = {
651 .force_speed_100 = 1,
652 .force_duplex_full = 1,
655 .has_ohci0 = 1,
657 #endif
660 * all boards
662 static const struct board_info __initconst *bcm963xx_boards[] = {
663 #ifdef CONFIG_BCM63XX_CPU_3368
664 &board_cvg834g,
665 #endif
666 #ifdef CONFIG_BCM63XX_CPU_6328
667 &board_96328avng,
668 #endif
669 #ifdef CONFIG_BCM63XX_CPU_6338
670 &board_96338gw,
671 &board_96338w,
672 #endif
673 #ifdef CONFIG_BCM63XX_CPU_6345
674 &board_96345gw2,
675 #endif
676 #ifdef CONFIG_BCM63XX_CPU_6348
677 &board_96348r,
678 &board_96348gw,
679 &board_96348gw_10,
680 &board_96348gw_11,
681 &board_FAST2404,
682 &board_DV201AMR,
683 &board_96348gw_a,
684 &board_rta1025w_16,
685 #endif
687 #ifdef CONFIG_BCM63XX_CPU_6358
688 &board_96358vw,
689 &board_96358vw2,
690 &board_AGPFS0,
691 &board_DWVS0,
692 #endif
696 * Register a sane SPROMv2 to make the on-board
697 * bcm4318 WLAN work
699 #ifdef CONFIG_SSB_PCIHOST
700 static struct ssb_sprom bcm63xx_sprom = {
701 .revision = 0x02,
702 .board_rev = 0x17,
703 .country_code = 0x0,
704 .ant_available_bg = 0x3,
705 .pa0b0 = 0x15ae,
706 .pa0b1 = 0xfa85,
707 .pa0b2 = 0xfe8d,
708 .pa1b0 = 0xffff,
709 .pa1b1 = 0xffff,
710 .pa1b2 = 0xffff,
711 .gpio0 = 0xff,
712 .gpio1 = 0xff,
713 .gpio2 = 0xff,
714 .gpio3 = 0xff,
715 .maxpwr_bg = 0x004c,
716 .itssi_bg = 0x00,
717 .boardflags_lo = 0x2848,
718 .boardflags_hi = 0x0000,
721 int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
723 if (bus->bustype == SSB_BUSTYPE_PCI) {
724 memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
725 return 0;
726 } else {
727 pr_err("unable to fill SPROM for given bustype\n");
728 return -EINVAL;
731 #endif
734 * return board name for /proc/cpuinfo
736 const char *board_get_name(void)
738 return board.name;
742 * early init callback, read nvram data from flash and checksum it
744 void __init board_prom_init(void)
746 unsigned int i;
747 u8 *boot_addr, *cfe;
748 char cfe_version[32];
749 char *board_name = NULL;
750 u32 val;
751 struct bcm_hcs *hcs;
753 /* read base address of boot chip select (0)
754 * 6328/6362 do not have MPI but boot from a fixed address
756 if (BCMCPU_IS_6328() || BCMCPU_IS_6362()) {
757 val = 0x18000000;
758 } else {
759 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
760 val &= MPI_CSBASE_BASE_MASK;
762 boot_addr = (u8 *)KSEG1ADDR(val);
764 /* dump cfe version */
765 cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
766 if (!memcmp(cfe, "cfe-v", 5))
767 snprintf(cfe_version, sizeof(cfe_version), "%u.%u.%u-%u.%u",
768 cfe[5], cfe[6], cfe[7], cfe[8], cfe[9]);
769 else
770 strcpy(cfe_version, "unknown");
771 pr_info("CFE version: %s\n", cfe_version);
773 bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
775 if (BCMCPU_IS_3368()) {
776 hcs = (struct bcm_hcs *)boot_addr;
777 board_name = hcs->filename;
778 } else {
779 board_name = bcm63xx_nvram_get_name();
781 /* find board by name */
782 for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
783 if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
784 continue;
785 /* copy, board desc array is marked initdata */
786 memcpy(&board, bcm963xx_boards[i], sizeof(board));
787 break;
790 /* bail out if board is not found, will complain later */
791 if (!board.name[0]) {
792 char name[17];
793 memcpy(name, board_name, 16);
794 name[16] = 0;
795 pr_err("unknown bcm963xx board: %s\n", name);
796 return;
799 /* setup pin multiplexing depending on board enabled device,
800 * this has to be done this early since PCI init is done
801 * inside arch_initcall */
802 val = 0;
804 #ifdef CONFIG_PCI
805 if (board.has_pci) {
806 bcm63xx_pci_enabled = 1;
807 if (BCMCPU_IS_6348())
808 val |= GPIO_MODE_6348_G2_PCI;
810 #endif
812 if (board.has_pccard) {
813 if (BCMCPU_IS_6348())
814 val |= GPIO_MODE_6348_G1_MII_PCCARD;
817 if (board.has_enet0 && !board.enet0.use_internal_phy) {
818 if (BCMCPU_IS_6348())
819 val |= GPIO_MODE_6348_G3_EXT_MII |
820 GPIO_MODE_6348_G0_EXT_MII;
823 if (board.has_enet1 && !board.enet1.use_internal_phy) {
824 if (BCMCPU_IS_6348())
825 val |= GPIO_MODE_6348_G3_EXT_MII |
826 GPIO_MODE_6348_G0_EXT_MII;
829 bcm_gpio_writel(val, GPIO_MODE_REG);
833 * second stage init callback, good time to panic if we couldn't
834 * identify on which board we're running since early printk is working
836 void __init board_setup(void)
838 if (!board.name[0])
839 panic("unable to detect bcm963xx board");
840 pr_info("board name: %s\n", board.name);
842 /* make sure we're running on expected cpu */
843 if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
844 panic("unexpected CPU for bcm963xx board");
847 static struct gpio_led_platform_data bcm63xx_led_data;
849 static struct platform_device bcm63xx_gpio_leds = {
850 .name = "leds-gpio",
851 .id = 0,
852 .dev.platform_data = &bcm63xx_led_data,
856 * third stage init callback, register all board devices.
858 int __init board_register_devices(void)
860 if (board.has_uart0)
861 bcm63xx_uart_register(0);
863 if (board.has_uart1)
864 bcm63xx_uart_register(1);
866 if (board.has_pccard)
867 bcm63xx_pcmcia_register();
869 if (board.has_enet0 &&
870 !bcm63xx_nvram_get_mac_address(board.enet0.mac_addr))
871 bcm63xx_enet_register(0, &board.enet0);
873 if (board.has_enet1 &&
874 !bcm63xx_nvram_get_mac_address(board.enet1.mac_addr))
875 bcm63xx_enet_register(1, &board.enet1);
877 if (board.has_enetsw &&
878 !bcm63xx_nvram_get_mac_address(board.enetsw.mac_addr))
879 bcm63xx_enetsw_register(&board.enetsw);
881 if (board.has_usbd)
882 bcm63xx_usbd_register(&board.usbd);
884 /* Generate MAC address for WLAN and register our SPROM,
885 * do this after registering enet devices
887 #ifdef CONFIG_SSB_PCIHOST
888 if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) {
889 memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
890 memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
891 if (ssb_arch_register_fallback_sprom(
892 &bcm63xx_get_fallback_sprom) < 0)
893 pr_err("failed to register fallback SPROM\n");
895 #endif
897 bcm63xx_spi_register();
899 bcm63xx_hsspi_register();
901 bcm63xx_flash_register();
903 bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
904 bcm63xx_led_data.leds = board.leds;
906 platform_device_register(&bcm63xx_gpio_leds);
908 if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
909 gpio_request_one(board.ephy_reset_gpio,
910 board.ephy_reset_gpio_flags, "ephy-reset");
912 return 0;