Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
0004  * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
0005  */
0006 
0007 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0008 
0009 #include <linux/init.h>
0010 #include <linux/kernel.h>
0011 #include <linux/string.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/ssb/ssb.h>
0014 #include <asm/addrspace.h>
0015 #include <bcm63xx_board.h>
0016 #include <bcm63xx_cpu.h>
0017 #include <bcm63xx_dev_uart.h>
0018 #include <bcm63xx_regs.h>
0019 #include <bcm63xx_io.h>
0020 #include <bcm63xx_nvram.h>
0021 #include <bcm63xx_dev_pci.h>
0022 #include <bcm63xx_dev_enet.h>
0023 #include <bcm63xx_dev_flash.h>
0024 #include <bcm63xx_dev_hsspi.h>
0025 #include <bcm63xx_dev_pcmcia.h>
0026 #include <bcm63xx_dev_spi.h>
0027 #include <bcm63xx_dev_usb_usbd.h>
0028 #include <board_bcm963xx.h>
0029 
0030 #include <uapi/linux/bcm933xx_hcs.h>
0031 
0032 #define HCS_OFFSET_128K         0x20000
0033 
0034 static struct board_info board;
0035 
0036 /*
0037  * known 3368 boards
0038  */
0039 #ifdef CONFIG_BCM63XX_CPU_3368
0040 static struct board_info __initdata board_cvg834g = {
0041     .name = "CVG834G_E15R3921",
0042     .expected_cpu_id = 0x3368,
0043 
0044     .ephy_reset_gpio = 36,
0045     .ephy_reset_gpio_flags = GPIOF_INIT_HIGH,
0046     .has_pci = 1,
0047     .has_uart0 = 1,
0048     .has_uart1 = 1,
0049 
0050     .has_enet0 = 1,
0051     .enet0 = {
0052         .has_phy = 1,
0053         .use_internal_phy = 1,
0054     },
0055 
0056     .leds = {
0057         {
0058             .name = "CVG834G:green:power",
0059             .gpio = 37,
0060             .default_trigger= "default-on",
0061         },
0062     },
0063 };
0064 #endif /* CONFIG_BCM63XX_CPU_3368 */
0065 
0066 /*
0067  * known 6328 boards
0068  */
0069 #ifdef CONFIG_BCM63XX_CPU_6328
0070 static struct board_info __initdata board_96328avng = {
0071     .name = "96328avng",
0072     .expected_cpu_id = 0x6328,
0073 
0074     .has_pci = 1,
0075     .has_uart0 = 1,
0076 
0077     .has_usbd = 0,
0078     .usbd = {
0079         .use_fullspeed = 0,
0080         .port_no = 0,
0081     },
0082 
0083     .leds = {
0084         {
0085             .name = "96328avng::ppp-fail",
0086             .gpio = 2,
0087             .active_low = 1,
0088         },
0089         {
0090             .name = "96328avng::power",
0091             .gpio = 4,
0092             .active_low = 1,
0093             .default_trigger = "default-on",
0094         },
0095         {
0096             .name = "96328avng::power-fail",
0097             .gpio = 8,
0098             .active_low = 1,
0099         },
0100         {
0101             .name = "96328avng::wps",
0102             .gpio = 9,
0103             .active_low = 1,
0104         },
0105         {
0106             .name = "96328avng::ppp",
0107             .gpio = 11,
0108             .active_low = 1,
0109         },
0110     },
0111 };
0112 #endif /* CONFIG_BCM63XX_CPU_6328 */
0113 
0114 /*
0115  * known 6338 boards
0116  */
0117 #ifdef CONFIG_BCM63XX_CPU_6338
0118 static struct board_info __initdata board_96338gw = {
0119     .name = "96338GW",
0120     .expected_cpu_id = 0x6338,
0121 
0122     .has_ohci0 = 1,
0123     .has_uart0 = 1,
0124 
0125     .has_enet0 = 1,
0126     .enet0 = {
0127         .force_speed_100 = 1,
0128         .force_duplex_full = 1,
0129     },
0130 
0131     .leds = {
0132         {
0133             .name = "adsl",
0134             .gpio = 3,
0135             .active_low = 1,
0136         },
0137         {
0138             .name = "ses",
0139             .gpio = 5,
0140             .active_low = 1,
0141         },
0142         {
0143             .name = "ppp-fail",
0144             .gpio = 4,
0145             .active_low = 1,
0146         },
0147         {
0148             .name = "power",
0149             .gpio = 0,
0150             .active_low = 1,
0151             .default_trigger = "default-on",
0152         },
0153         {
0154             .name = "stop",
0155             .gpio = 1,
0156             .active_low = 1,
0157         }
0158     },
0159 };
0160 
0161 static struct board_info __initdata board_96338w = {
0162     .name = "96338W",
0163     .expected_cpu_id = 0x6338,
0164 
0165     .has_uart0 = 1,
0166 
0167     .has_enet0 = 1,
0168     .enet0 = {
0169         .force_speed_100 = 1,
0170         .force_duplex_full = 1,
0171     },
0172 
0173     .leds = {
0174         {
0175             .name = "adsl",
0176             .gpio = 3,
0177             .active_low = 1,
0178         },
0179         {
0180             .name = "ses",
0181             .gpio = 5,
0182             .active_low = 1,
0183         },
0184         {
0185             .name = "ppp-fail",
0186             .gpio = 4,
0187             .active_low = 1,
0188         },
0189         {
0190             .name = "power",
0191             .gpio = 0,
0192             .active_low = 1,
0193             .default_trigger = "default-on",
0194         },
0195         {
0196             .name = "stop",
0197             .gpio = 1,
0198             .active_low = 1,
0199         },
0200     },
0201 };
0202 #endif /* CONFIG_BCM63XX_CPU_6338 */
0203 
0204 /*
0205  * known 6345 boards
0206  */
0207 #ifdef CONFIG_BCM63XX_CPU_6345
0208 static struct board_info __initdata board_96345gw2 = {
0209     .name = "96345GW2",
0210     .expected_cpu_id = 0x6345,
0211 
0212     .has_uart0 = 1,
0213 };
0214 #endif /* CONFIG_BCM63XX_CPU_6345 */
0215 
0216 /*
0217  * known 6348 boards
0218  */
0219 #ifdef CONFIG_BCM63XX_CPU_6348
0220 static struct board_info __initdata board_96348r = {
0221     .name = "96348R",
0222     .expected_cpu_id = 0x6348,
0223 
0224     .has_pci = 1,
0225     .has_uart0 = 1,
0226 
0227     .has_enet0 = 1,
0228     .enet0 = {
0229         .has_phy = 1,
0230         .use_internal_phy = 1,
0231     },
0232 
0233     .leds = {
0234         {
0235             .name = "adsl-fail",
0236             .gpio = 2,
0237             .active_low = 1,
0238         },
0239         {
0240             .name = "ppp",
0241             .gpio = 3,
0242             .active_low = 1,
0243         },
0244         {
0245             .name = "ppp-fail",
0246             .gpio = 4,
0247             .active_low = 1,
0248         },
0249         {
0250             .name = "power",
0251             .gpio = 0,
0252             .active_low = 1,
0253             .default_trigger = "default-on",
0254 
0255         },
0256         {
0257             .name = "stop",
0258             .gpio = 1,
0259             .active_low = 1,
0260         },
0261     },
0262 };
0263 
0264 static struct board_info __initdata board_96348gw_10 = {
0265     .name = "96348GW-10",
0266     .expected_cpu_id = 0x6348,
0267 
0268     .has_ohci0 = 1,
0269     .has_pccard = 1,
0270     .has_pci = 1,
0271     .has_uart0 = 1,
0272 
0273     .has_enet0 = 1,
0274     .enet0 = {
0275         .has_phy = 1,
0276         .use_internal_phy = 1,
0277     },
0278 
0279     .has_enet1 = 1,
0280     .enet1 = {
0281         .force_speed_100 = 1,
0282         .force_duplex_full = 1,
0283     },
0284 
0285     .leds = {
0286         {
0287             .name = "adsl-fail",
0288             .gpio = 2,
0289             .active_low = 1,
0290         },
0291         {
0292             .name = "ppp",
0293             .gpio = 3,
0294             .active_low = 1,
0295         },
0296         {
0297             .name = "ppp-fail",
0298             .gpio = 4,
0299             .active_low = 1,
0300         },
0301         {
0302             .name = "power",
0303             .gpio = 0,
0304             .active_low = 1,
0305             .default_trigger = "default-on",
0306         },
0307         {
0308             .name = "stop",
0309             .gpio = 1,
0310             .active_low = 1,
0311         },
0312     },
0313 };
0314 
0315 static struct board_info __initdata board_96348gw_11 = {
0316     .name = "96348GW-11",
0317     .expected_cpu_id = 0x6348,
0318 
0319     .has_ohci0 = 1,
0320     .has_pccard = 1,
0321     .has_pci = 1,
0322     .has_uart0 = 1,
0323 
0324     .has_enet0 = 1,
0325     .enet0 = {
0326         .has_phy = 1,
0327         .use_internal_phy = 1,
0328     },
0329 
0330     .has_enet1 = 1,
0331     .enet1 = {
0332         .force_speed_100 = 1,
0333         .force_duplex_full = 1,
0334     },
0335 
0336     .leds = {
0337         {
0338             .name = "adsl-fail",
0339             .gpio = 2,
0340             .active_low = 1,
0341         },
0342         {
0343             .name = "ppp",
0344             .gpio = 3,
0345             .active_low = 1,
0346         },
0347         {
0348             .name = "ppp-fail",
0349             .gpio = 4,
0350             .active_low = 1,
0351         },
0352         {
0353             .name = "power",
0354             .gpio = 0,
0355             .active_low = 1,
0356             .default_trigger = "default-on",
0357         },
0358         {
0359             .name = "stop",
0360             .gpio = 1,
0361             .active_low = 1,
0362         },
0363     },
0364 };
0365 
0366 static struct board_info __initdata board_96348gw = {
0367     .name = "96348GW",
0368     .expected_cpu_id = 0x6348,
0369 
0370     .has_ohci0 = 1,
0371     .has_pci = 1,
0372     .has_uart0 = 1,
0373 
0374     .has_enet0 = 1,
0375     .enet0 = {
0376         .has_phy = 1,
0377         .use_internal_phy = 1,
0378     },
0379 
0380     .has_enet1 = 1,
0381     .enet1 = {
0382         .force_speed_100 = 1,
0383         .force_duplex_full = 1,
0384     },
0385 
0386     .leds = {
0387         {
0388             .name = "adsl-fail",
0389             .gpio = 2,
0390             .active_low = 1,
0391         },
0392         {
0393             .name = "ppp",
0394             .gpio = 3,
0395             .active_low = 1,
0396         },
0397         {
0398             .name = "ppp-fail",
0399             .gpio = 4,
0400             .active_low = 1,
0401         },
0402         {
0403             .name = "power",
0404             .gpio = 0,
0405             .active_low = 1,
0406             .default_trigger = "default-on",
0407         },
0408         {
0409             .name = "stop",
0410             .gpio = 1,
0411             .active_low = 1,
0412         },
0413     },
0414 };
0415 
0416 static struct board_info __initdata board_FAST2404 = {
0417     .name = "F@ST2404",
0418     .expected_cpu_id = 0x6348,
0419 
0420     .has_ohci0 = 1,
0421     .has_pccard = 1,
0422     .has_pci = 1,
0423     .has_uart0 = 1,
0424 
0425     .has_enet0 = 1,
0426     .enet0 = {
0427         .has_phy = 1,
0428         .use_internal_phy = 1,
0429     },
0430 
0431     .has_enet1 = 1,
0432     .enet1 = {
0433         .force_speed_100 = 1,
0434         .force_duplex_full = 1,
0435     },
0436 };
0437 
0438 static struct board_info __initdata board_rta1025w_16 = {
0439     .name = "RTA1025W_16",
0440     .expected_cpu_id = 0x6348,
0441 
0442     .has_pci = 1,
0443 
0444     .has_enet0 = 1,
0445     .enet0 = {
0446         .has_phy = 1,
0447         .use_internal_phy = 1,
0448     },
0449 
0450     .has_enet1 = 1,
0451     .enet1 = {
0452         .force_speed_100 = 1,
0453         .force_duplex_full = 1,
0454     },
0455 };
0456 
0457 static struct board_info __initdata board_DV201AMR = {
0458     .name = "DV201AMR",
0459     .expected_cpu_id = 0x6348,
0460 
0461     .has_ohci0 = 1,
0462     .has_pci = 1,
0463     .has_uart0 = 1,
0464 
0465     .has_enet0 = 1,
0466     .enet0 = {
0467         .has_phy = 1,
0468         .use_internal_phy = 1,
0469     },
0470 
0471     .has_enet1 = 1,
0472     .enet1 = {
0473         .force_speed_100 = 1,
0474         .force_duplex_full = 1,
0475     },
0476 };
0477 
0478 static struct board_info __initdata board_96348gw_a = {
0479     .name = "96348GW-A",
0480     .expected_cpu_id = 0x6348,
0481 
0482     .has_ohci0 = 1,
0483     .has_pci = 1,
0484     .has_uart0 = 1,
0485 
0486     .has_enet0 = 1,
0487     .enet0 = {
0488         .has_phy = 1,
0489         .use_internal_phy = 1,
0490     },
0491 
0492     .has_enet1 = 1,
0493     .enet1 = {
0494         .force_speed_100 = 1,
0495         .force_duplex_full = 1,
0496     },
0497 };
0498 #endif /* CONFIG_BCM63XX_CPU_6348 */
0499 
0500 /*
0501  * known 6358 boards
0502  */
0503 #ifdef CONFIG_BCM63XX_CPU_6358
0504 static struct board_info __initdata board_96358vw = {
0505     .name = "96358VW",
0506     .expected_cpu_id = 0x6358,
0507 
0508     .has_ehci0 = 1,
0509     .has_ohci0 = 1,
0510     .has_pccard = 1,
0511     .has_pci = 1,
0512     .has_uart0 = 1,
0513 
0514     .has_enet0 = 1,
0515     .enet0 = {
0516         .has_phy = 1,
0517         .use_internal_phy = 1,
0518     },
0519 
0520     .has_enet1 = 1,
0521     .enet1 = {
0522         .force_speed_100 = 1,
0523         .force_duplex_full = 1,
0524     },
0525 
0526     .leds = {
0527         {
0528             .name = "adsl-fail",
0529             .gpio = 15,
0530             .active_low = 1,
0531         },
0532         {
0533             .name = "ppp",
0534             .gpio = 22,
0535             .active_low = 1,
0536         },
0537         {
0538             .name = "ppp-fail",
0539             .gpio = 23,
0540             .active_low = 1,
0541         },
0542         {
0543             .name = "power",
0544             .gpio = 4,
0545             .default_trigger = "default-on",
0546         },
0547         {
0548             .name = "stop",
0549             .gpio = 5,
0550         },
0551     },
0552 };
0553 
0554 static struct board_info __initdata board_96358vw2 = {
0555     .name = "96358VW2",
0556     .expected_cpu_id = 0x6358,
0557 
0558     .has_ehci0 = 1,
0559     .has_ohci0 = 1,
0560     .has_pccard = 1,
0561     .has_pci = 1,
0562     .has_uart0 = 1,
0563 
0564     .has_enet0 = 1,
0565     .enet0 = {
0566         .has_phy = 1,
0567         .use_internal_phy = 1,
0568     },
0569 
0570     .has_enet1 = 1,
0571     .enet1 = {
0572         .force_speed_100 = 1,
0573         .force_duplex_full = 1,
0574     },
0575 
0576     .leds = {
0577         {
0578             .name = "adsl",
0579             .gpio = 22,
0580             .active_low = 1,
0581         },
0582         {
0583             .name = "ppp-fail",
0584             .gpio = 23,
0585         },
0586         {
0587             .name = "power",
0588             .gpio = 5,
0589             .active_low = 1,
0590             .default_trigger = "default-on",
0591         },
0592         {
0593             .name = "stop",
0594             .gpio = 4,
0595             .active_low = 1,
0596         },
0597     },
0598 };
0599 
0600 static struct board_info __initdata board_AGPFS0 = {
0601     .name = "AGPF-S0",
0602     .expected_cpu_id = 0x6358,
0603 
0604     .has_ehci0 = 1,
0605     .has_ohci0 = 1,
0606     .has_pci = 1,
0607     .has_uart0 = 1,
0608 
0609     .has_enet0 = 1,
0610     .enet0 = {
0611         .has_phy = 1,
0612         .use_internal_phy = 1,
0613     },
0614 
0615     .has_enet1 = 1,
0616     .enet1 = {
0617         .force_speed_100 = 1,
0618         .force_duplex_full = 1,
0619     },
0620 };
0621 
0622 static struct board_info __initdata board_DWVS0 = {
0623     .name = "DWV-S0",
0624     .expected_cpu_id = 0x6358,
0625 
0626     .has_ehci0 = 1,
0627     .has_ohci0 = 1,
0628     .has_pci = 1,
0629 
0630     .has_enet0 = 1,
0631     .enet0 = {
0632         .has_phy = 1,
0633         .use_internal_phy = 1,
0634     },
0635 
0636     .has_enet1 = 1,
0637     .enet1 = {
0638         .force_speed_100 = 1,
0639         .force_duplex_full = 1,
0640     },
0641 };
0642 #endif /* CONFIG_BCM63XX_CPU_6358 */
0643 
0644 /*
0645  * all boards
0646  */
0647 static const struct board_info __initconst *bcm963xx_boards[] = {
0648 #ifdef CONFIG_BCM63XX_CPU_3368
0649     &board_cvg834g,
0650 #endif /* CONFIG_BCM63XX_CPU_3368 */
0651 #ifdef CONFIG_BCM63XX_CPU_6328
0652     &board_96328avng,
0653 #endif /* CONFIG_BCM63XX_CPU_6328 */
0654 #ifdef CONFIG_BCM63XX_CPU_6338
0655     &board_96338gw,
0656     &board_96338w,
0657 #endif /* CONFIG_BCM63XX_CPU_6338 */
0658 #ifdef CONFIG_BCM63XX_CPU_6345
0659     &board_96345gw2,
0660 #endif /* CONFIG_BCM63XX_CPU_6345 */
0661 #ifdef CONFIG_BCM63XX_CPU_6348
0662     &board_96348r,
0663     &board_96348gw,
0664     &board_96348gw_10,
0665     &board_96348gw_11,
0666     &board_FAST2404,
0667     &board_DV201AMR,
0668     &board_96348gw_a,
0669     &board_rta1025w_16,
0670 #endif /* CONFIG_BCM63XX_CPU_6348 */
0671 #ifdef CONFIG_BCM63XX_CPU_6358
0672     &board_96358vw,
0673     &board_96358vw2,
0674     &board_AGPFS0,
0675     &board_DWVS0,
0676 #endif /* CONFIG_BCM63XX_CPU_6358 */
0677 };
0678 
0679 /*
0680  * Register a sane SPROMv2 to make the on-board
0681  * bcm4318 WLAN work
0682  */
0683 #ifdef CONFIG_SSB_PCIHOST
0684 static struct ssb_sprom bcm63xx_sprom = {
0685     .revision       = 0x02,
0686     .board_rev      = 0x17,
0687     .country_code       = 0x0,
0688     .ant_available_bg   = 0x3,
0689     .pa0b0          = 0x15ae,
0690     .pa0b1          = 0xfa85,
0691     .pa0b2          = 0xfe8d,
0692     .pa1b0          = 0xffff,
0693     .pa1b1          = 0xffff,
0694     .pa1b2          = 0xffff,
0695     .gpio0          = 0xff,
0696     .gpio1          = 0xff,
0697     .gpio2          = 0xff,
0698     .gpio3          = 0xff,
0699     .maxpwr_bg      = 0x004c,
0700     .itssi_bg       = 0x00,
0701     .boardflags_lo      = 0x2848,
0702     .boardflags_hi      = 0x0000,
0703 };
0704 
0705 int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
0706 {
0707     if (bus->bustype == SSB_BUSTYPE_PCI) {
0708         memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
0709         return 0;
0710     } else {
0711         pr_err("unable to fill SPROM for given bustype\n");
0712         return -EINVAL;
0713     }
0714 }
0715 #endif /* CONFIG_SSB_PCIHOST */
0716 
0717 /*
0718  * return board name for /proc/cpuinfo
0719  */
0720 const char *board_get_name(void)
0721 {
0722     return board.name;
0723 }
0724 
0725 /*
0726  * early init callback, read nvram data from flash and checksum it
0727  */
0728 void __init board_prom_init(void)
0729 {
0730     unsigned int i;
0731     u8 *boot_addr, *cfe;
0732     char cfe_version[32];
0733     char *board_name = NULL;
0734     u32 val;
0735     struct bcm_hcs *hcs;
0736 
0737     /* read base address of boot chip select (0)
0738      * 6328/6362 do not have MPI but boot from a fixed address
0739      */
0740     if (BCMCPU_IS_6328() || BCMCPU_IS_6362()) {
0741         val = 0x18000000;
0742     } else {
0743         val = bcm_mpi_readl(MPI_CSBASE_REG(0));
0744         val &= MPI_CSBASE_BASE_MASK;
0745     }
0746     boot_addr = (u8 *)KSEG1ADDR(val);
0747 
0748     /* dump cfe version */
0749     cfe = boot_addr + BCM963XX_CFE_VERSION_OFFSET;
0750     if (strstarts(cfe, "cfe-")) {
0751         if(cfe[4] == 'v') {
0752             if(cfe[5] == 'd')
0753                 snprintf(cfe_version, 11, "%s",
0754                      (char *) &cfe[5]);
0755             else if (cfe[10] > 0)
0756                 snprintf(cfe_version, sizeof(cfe_version),
0757                      "%u.%u.%u-%u.%u-%u", cfe[5], cfe[6],
0758                      cfe[7], cfe[8], cfe[9], cfe[10]);
0759             else
0760                 snprintf(cfe_version, sizeof(cfe_version),
0761                      "%u.%u.%u-%u.%u", cfe[5], cfe[6],
0762                      cfe[7], cfe[8], cfe[9]);
0763         } else {
0764             snprintf(cfe_version, 12, "%s", (char *) &cfe[4]);
0765         }
0766     } else {
0767         strcpy(cfe_version, "unknown");
0768     }
0769     pr_info("CFE version: %s\n", cfe_version);
0770 
0771     bcm63xx_nvram_init(boot_addr + BCM963XX_NVRAM_OFFSET);
0772 
0773     if (BCMCPU_IS_3368()) {
0774         hcs = (struct bcm_hcs *)boot_addr;
0775         board_name = hcs->filename;
0776     } else {
0777         board_name = bcm63xx_nvram_get_name();
0778     }
0779     /* find board by name */
0780     for (i = 0; i < ARRAY_SIZE(bcm963xx_boards); i++) {
0781         if (strncmp(board_name, bcm963xx_boards[i]->name, 16))
0782             continue;
0783         /* copy, board desc array is marked initdata */
0784         memcpy(&board, bcm963xx_boards[i], sizeof(board));
0785         break;
0786     }
0787 
0788     /* bail out if board is not found, will complain later */
0789     if (!board.name[0]) {
0790         char name[17];
0791         memcpy(name, board_name, 16);
0792         name[16] = 0;
0793         pr_err("unknown bcm963xx board: %s\n", name);
0794         return;
0795     }
0796 
0797     /* setup pin multiplexing depending on board enabled device,
0798      * this has to be done this early since PCI init is done
0799      * inside arch_initcall */
0800     val = 0;
0801 
0802 #ifdef CONFIG_PCI
0803     if (board.has_pci) {
0804         bcm63xx_pci_enabled = 1;
0805         if (BCMCPU_IS_6348())
0806             val |= GPIO_MODE_6348_G2_PCI;
0807     }
0808 #endif /* CONFIG_PCI */
0809 
0810     if (board.has_pccard) {
0811         if (BCMCPU_IS_6348())
0812             val |= GPIO_MODE_6348_G1_MII_PCCARD;
0813     }
0814 
0815     if (board.has_enet0 && !board.enet0.use_internal_phy) {
0816         if (BCMCPU_IS_6348())
0817             val |= GPIO_MODE_6348_G3_EXT_MII |
0818                 GPIO_MODE_6348_G0_EXT_MII;
0819     }
0820 
0821     if (board.has_enet1 && !board.enet1.use_internal_phy) {
0822         if (BCMCPU_IS_6348())
0823             val |= GPIO_MODE_6348_G3_EXT_MII |
0824                 GPIO_MODE_6348_G0_EXT_MII;
0825     }
0826 
0827     bcm_gpio_writel(val, GPIO_MODE_REG);
0828 }
0829 
0830 /*
0831  * second stage init callback, good time to panic if we couldn't
0832  * identify on which board we're running since early printk is working
0833  */
0834 void __init board_setup(void)
0835 {
0836     if (!board.name[0])
0837         panic("unable to detect bcm963xx board");
0838     pr_info("board name: %s\n", board.name);
0839 
0840     /* make sure we're running on expected cpu */
0841     if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
0842         panic("unexpected CPU for bcm963xx board");
0843 }
0844 
0845 static struct gpio_led_platform_data bcm63xx_led_data;
0846 
0847 static struct platform_device bcm63xx_gpio_leds = {
0848     .name           = "leds-gpio",
0849     .id         = 0,
0850     .dev.platform_data  = &bcm63xx_led_data,
0851 };
0852 
0853 /*
0854  * third stage init callback, register all board devices.
0855  */
0856 int __init board_register_devices(void)
0857 {
0858     if (board.has_uart0)
0859         bcm63xx_uart_register(0);
0860 
0861     if (board.has_uart1)
0862         bcm63xx_uart_register(1);
0863 
0864     if (board.has_pccard)
0865         bcm63xx_pcmcia_register();
0866 
0867     if (board.has_enet0 &&
0868         !bcm63xx_nvram_get_mac_address(board.enet0.mac_addr))
0869         bcm63xx_enet_register(0, &board.enet0);
0870 
0871     if (board.has_enet1 &&
0872         !bcm63xx_nvram_get_mac_address(board.enet1.mac_addr))
0873         bcm63xx_enet_register(1, &board.enet1);
0874 
0875     if (board.has_enetsw &&
0876         !bcm63xx_nvram_get_mac_address(board.enetsw.mac_addr))
0877         bcm63xx_enetsw_register(&board.enetsw);
0878 
0879     if (board.has_usbd)
0880         bcm63xx_usbd_register(&board.usbd);
0881 
0882     /* Generate MAC address for WLAN and register our SPROM,
0883      * do this after registering enet devices
0884      */
0885 #ifdef CONFIG_SSB_PCIHOST
0886     if (!bcm63xx_nvram_get_mac_address(bcm63xx_sprom.il0mac)) {
0887         memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
0888         memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
0889         if (ssb_arch_register_fallback_sprom(
0890                 &bcm63xx_get_fallback_sprom) < 0)
0891             pr_err("failed to register fallback SPROM\n");
0892     }
0893 #endif /* CONFIG_SSB_PCIHOST */
0894 
0895     bcm63xx_spi_register();
0896 
0897     bcm63xx_hsspi_register();
0898 
0899     bcm63xx_flash_register();
0900 
0901     bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
0902     bcm63xx_led_data.leds = board.leds;
0903 
0904     platform_device_register(&bcm63xx_gpio_leds);
0905 
0906     if (board.ephy_reset_gpio && board.ephy_reset_gpio_flags)
0907         gpio_request_one(board.ephy_reset_gpio,
0908                 board.ephy_reset_gpio_flags, "ephy-reset");
0909 
0910     return 0;
0911 }