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
6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/string.h>
13 #include <linux/platform_device.h>
14 #include <linux/ssb/ssb.h>
15 #include <asm/addrspace.h>
16 #include <bcm63xx_board.h>
17 #include <bcm63xx_cpu.h>
18 #include <bcm63xx_dev_uart.h>
19 #include <bcm63xx_regs.h>
20 #include <bcm63xx_io.h>
21 #include <bcm63xx_nvram.h>
22 #include <bcm63xx_dev_pci.h>
23 #include <bcm63xx_dev_enet.h>
24 #include <bcm63xx_dev_dsp.h>
25 #include <bcm63xx_dev_flash.h>
26 #include <bcm63xx_dev_pcmcia.h>
27 #include <bcm63xx_dev_spi.h>
28 #include <bcm63xx_dev_usb_usbd.h>
29 #include <board_bcm963xx.h>
31 #define PFX "board_bcm963xx: "
33 static struct board_info board
;
38 #ifdef CONFIG_BCM63XX_CPU_6328
39 static struct board_info __initdata board_96328avng
= {
41 .expected_cpu_id
= 0x6328,
54 .name
= "96328avng::ppp-fail",
59 .name
= "96328avng::power",
62 .default_trigger
= "default-on",
65 .name
= "96328avng::power-fail",
70 .name
= "96328avng::wps",
75 .name
= "96328avng::ppp",
86 #ifdef CONFIG_BCM63XX_CPU_6338
87 static struct board_info __initdata board_96338gw
= {
89 .expected_cpu_id
= 0x6338,
95 .force_duplex_full
= 1,
120 .default_trigger
= "default-on",
130 static struct board_info __initdata board_96338w
= {
132 .expected_cpu_id
= 0x6338,
137 .force_speed_100
= 1,
138 .force_duplex_full
= 1,
161 .default_trigger
= "default-on",
175 #ifdef CONFIG_BCM63XX_CPU_6345
176 static struct board_info __initdata board_96345gw2
= {
178 .expected_cpu_id
= 0x6345,
187 #ifdef CONFIG_BCM63XX_CPU_6348
188 static struct board_info __initdata board_96348r
= {
190 .expected_cpu_id
= 0x6348,
198 .use_internal_phy
= 1,
221 .default_trigger
= "default-on",
232 static struct board_info __initdata board_96348gw_10
= {
233 .name
= "96348GW-10",
234 .expected_cpu_id
= 0x6348,
243 .use_internal_phy
= 1,
246 .force_speed_100
= 1,
247 .force_duplex_full
= 1,
282 .default_trigger
= "default-on",
292 static struct board_info __initdata board_96348gw_11
= {
293 .name
= "96348GW-11",
294 .expected_cpu_id
= 0x6348,
303 .use_internal_phy
= 1,
307 .force_speed_100
= 1,
308 .force_duplex_full
= 1,
336 .default_trigger
= "default-on",
346 static struct board_info __initdata board_96348gw
= {
348 .expected_cpu_id
= 0x6348,
357 .use_internal_phy
= 1,
360 .force_speed_100
= 1,
361 .force_duplex_full
= 1,
394 .default_trigger
= "default-on",
404 static struct board_info __initdata board_FAST2404
= {
406 .expected_cpu_id
= 0x6348,
415 .use_internal_phy
= 1,
419 .force_speed_100
= 1,
420 .force_duplex_full
= 1,
428 static struct board_info __initdata board_rta1025w_16
= {
429 .name
= "RTA1025W_16",
430 .expected_cpu_id
= 0x6348,
438 .use_internal_phy
= 1,
441 .force_speed_100
= 1,
442 .force_duplex_full
= 1,
447 static struct board_info __initdata board_DV201AMR
= {
449 .expected_cpu_id
= 0x6348,
459 .use_internal_phy
= 1,
462 .force_speed_100
= 1,
463 .force_duplex_full
= 1,
467 static struct board_info __initdata board_96348gw_a
= {
469 .expected_cpu_id
= 0x6348,
478 .use_internal_phy
= 1,
481 .force_speed_100
= 1,
482 .force_duplex_full
= 1,
492 #ifdef CONFIG_BCM63XX_CPU_6358
493 static struct board_info __initdata board_96358vw
= {
495 .expected_cpu_id
= 0x6358,
504 .use_internal_phy
= 1,
508 .force_speed_100
= 1,
509 .force_duplex_full
= 1,
536 .default_trigger
= "default-on",
545 static struct board_info __initdata board_96358vw2
= {
547 .expected_cpu_id
= 0x6358,
556 .use_internal_phy
= 1,
560 .force_speed_100
= 1,
561 .force_duplex_full
= 1,
583 .default_trigger
= "default-on",
593 static struct board_info __initdata board_AGPFS0
= {
595 .expected_cpu_id
= 0x6358,
604 .use_internal_phy
= 1,
608 .force_speed_100
= 1,
609 .force_duplex_full
= 1,
616 static struct board_info __initdata board_DWVS0
= {
618 .expected_cpu_id
= 0x6358,
626 .use_internal_phy
= 1,
630 .force_speed_100
= 1,
631 .force_duplex_full
= 1,
641 static const struct board_info __initconst
*bcm963xx_boards
[] = {
642 #ifdef CONFIG_BCM63XX_CPU_6328
645 #ifdef CONFIG_BCM63XX_CPU_6338
649 #ifdef CONFIG_BCM63XX_CPU_6345
652 #ifdef CONFIG_BCM63XX_CPU_6348
663 #ifdef CONFIG_BCM63XX_CPU_6358
672 * Register a sane SPROMv2 to make the on-board
675 #ifdef CONFIG_SSB_PCIHOST
676 static struct ssb_sprom bcm63xx_sprom
= {
680 .ant_available_bg
= 0x3,
693 .boardflags_lo
= 0x2848,
694 .boardflags_hi
= 0x0000,
697 int bcm63xx_get_fallback_sprom(struct ssb_bus
*bus
, struct ssb_sprom
*out
)
699 if (bus
->bustype
== SSB_BUSTYPE_PCI
) {
700 memcpy(out
, &bcm63xx_sprom
, sizeof(struct ssb_sprom
));
703 printk(KERN_ERR PFX
"unable to fill SPROM for given bustype.\n");
710 * return board name for /proc/cpuinfo
712 const char *board_get_name(void)
718 * early init callback, read nvram data from flash and checksum it
720 void __init
board_prom_init(void)
724 char cfe_version
[32];
728 /* read base address of boot chip select (0)
729 * 6328 does not have MPI but boots from a fixed address
731 if (BCMCPU_IS_6328())
734 val
= bcm_mpi_readl(MPI_CSBASE_REG(0));
735 val
&= MPI_CSBASE_BASE_MASK
;
737 boot_addr
= (u8
*)KSEG1ADDR(val
);
739 /* dump cfe version */
740 cfe
= boot_addr
+ BCM963XX_CFE_VERSION_OFFSET
;
741 if (!memcmp(cfe
, "cfe-v", 5))
742 snprintf(cfe_version
, sizeof(cfe_version
), "%u.%u.%u-%u.%u",
743 cfe
[5], cfe
[6], cfe
[7], cfe
[8], cfe
[9]);
745 strcpy(cfe_version
, "unknown");
746 printk(KERN_INFO PFX
"CFE version: %s\n", cfe_version
);
748 if (bcm63xx_nvram_init(boot_addr
+ BCM963XX_NVRAM_OFFSET
)) {
749 printk(KERN_ERR PFX
"invalid nvram checksum\n");
753 board_name
= bcm63xx_nvram_get_name();
754 /* find board by name */
755 for (i
= 0; i
< ARRAY_SIZE(bcm963xx_boards
); i
++) {
756 if (strncmp(board_name
, bcm963xx_boards
[i
]->name
, 16))
758 /* copy, board desc array is marked initdata */
759 memcpy(&board
, bcm963xx_boards
[i
], sizeof(board
));
763 /* bail out if board is not found, will complain later */
764 if (!board
.name
[0]) {
766 memcpy(name
, board_name
, 16);
768 printk(KERN_ERR PFX
"unknown bcm963xx board: %s\n",
773 /* setup pin multiplexing depending on board enabled device,
774 * this has to be done this early since PCI init is done
775 * inside arch_initcall */
780 bcm63xx_pci_enabled
= 1;
781 if (BCMCPU_IS_6348())
782 val
|= GPIO_MODE_6348_G2_PCI
;
786 if (board
.has_pccard
) {
787 if (BCMCPU_IS_6348())
788 val
|= GPIO_MODE_6348_G1_MII_PCCARD
;
791 if (board
.has_enet0
&& !board
.enet0
.use_internal_phy
) {
792 if (BCMCPU_IS_6348())
793 val
|= GPIO_MODE_6348_G3_EXT_MII
|
794 GPIO_MODE_6348_G0_EXT_MII
;
797 if (board
.has_enet1
&& !board
.enet1
.use_internal_phy
) {
798 if (BCMCPU_IS_6348())
799 val
|= GPIO_MODE_6348_G3_EXT_MII
|
800 GPIO_MODE_6348_G0_EXT_MII
;
803 bcm_gpio_writel(val
, GPIO_MODE_REG
);
807 * second stage init callback, good time to panic if we couldn't
808 * identify on which board we're running since early printk is working
810 void __init
board_setup(void)
813 panic("unable to detect bcm963xx board");
814 printk(KERN_INFO PFX
"board name: %s\n", board
.name
);
816 /* make sure we're running on expected cpu */
817 if (bcm63xx_get_cpu_id() != board
.expected_cpu_id
)
818 panic("unexpected CPU for bcm963xx board");
821 static struct gpio_led_platform_data bcm63xx_led_data
;
823 static struct platform_device bcm63xx_gpio_leds
= {
826 .dev
.platform_data
= &bcm63xx_led_data
,
830 * third stage init callback, register all board devices.
832 int __init
board_register_devices(void)
835 bcm63xx_uart_register(0);
838 bcm63xx_uart_register(1);
840 if (board
.has_pccard
)
841 bcm63xx_pcmcia_register();
843 if (board
.has_enet0
&&
844 !bcm63xx_nvram_get_mac_address(board
.enet0
.mac_addr
))
845 bcm63xx_enet_register(0, &board
.enet0
);
847 if (board
.has_enet1
&&
848 !bcm63xx_nvram_get_mac_address(board
.enet1
.mac_addr
))
849 bcm63xx_enet_register(1, &board
.enet1
);
852 bcm63xx_usbd_register(&board
.usbd
);
855 bcm63xx_dsp_register(&board
.dsp
);
857 /* Generate MAC address for WLAN and register our SPROM,
858 * do this after registering enet devices
860 #ifdef CONFIG_SSB_PCIHOST
861 if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom
.il0mac
)) {
862 memcpy(bcm63xx_sprom
.et0mac
, bcm63xx_sprom
.il0mac
, ETH_ALEN
);
863 memcpy(bcm63xx_sprom
.et1mac
, bcm63xx_sprom
.il0mac
, ETH_ALEN
);
864 if (ssb_arch_register_fallback_sprom(
865 &bcm63xx_get_fallback_sprom
) < 0)
866 pr_err(PFX
"failed to register fallback SPROM\n");
870 bcm63xx_spi_register();
872 bcm63xx_flash_register();
874 bcm63xx_led_data
.num_leds
= ARRAY_SIZE(board
.leds
);
875 bcm63xx_led_data
.leds
= board
.leds
;
877 platform_device_register(&bcm63xx_gpio_leds
);