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 Florian Fainelli <florian@openwrt.org>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/string.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16 #include <asm/addrspace.h>
17 #include <bcm63xx_board.h>
18 #include <bcm63xx_cpu.h>
19 #include <bcm63xx_regs.h>
20 #include <bcm63xx_io.h>
21 #include <bcm63xx_board.h>
22 #include <bcm63xx_dev_pci.h>
23 #include <bcm63xx_dev_uart.h>
24 #include <bcm63xx_dev_wdt.h>
25 #include <bcm63xx_dev_enet.h>
26 #include <bcm63xx_dev_pcmcia.h>
27 #include <bcm63xx_dev_usb_ohci.h>
28 #include <bcm63xx_dev_usb_ehci.h>
29 #include <board_bcm963xx.h>
31 #define PFX "board_livebox: "
33 static unsigned int mac_addr_used = 0;
34 static struct board_info board;
39 #ifdef CONFIG_BCM63XX_CPU_6348
40 static struct board_info __initdata board_livebox = {
42 .expected_cpu_id = 0x6348,
50 .use_internal_phy = 1,
55 .force_duplex_full = 1,
67 static const struct board_info __initdata *bcm963xx_boards[] = {
68 #ifdef CONFIG_BCM63XX_CPU_6348
76 void __init board_prom_init(void)
80 /* read base address of boot chip select (0) */
81 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
82 val &= MPI_CSBASE_BASE_MASK;
84 /* assume board is a Livebox */
85 memcpy(&board, bcm963xx_boards[0], sizeof(board));
87 /* setup pin multiplexing depending on board enabled device,
88 * this has to be done this early since PCI init is done
89 * inside arch_initcall */
93 bcm63xx_pci_enabled = 1;
95 val |= GPIO_MODE_6348_G2_PCI;
98 if (board.has_pccard) {
100 val |= GPIO_MODE_6348_G1_MII_PCCARD;
103 if (board.has_enet0 && !board.enet0.use_internal_phy) {
104 if (BCMCPU_IS_6348())
105 val |= GPIO_MODE_6348_G3_EXT_MII |
106 GPIO_MODE_6348_G0_EXT_MII;
109 if (board.has_enet1 && !board.enet1.use_internal_phy) {
110 if (BCMCPU_IS_6348())
111 val |= GPIO_MODE_6348_G3_EXT_MII |
112 GPIO_MODE_6348_G0_EXT_MII;
115 bcm_gpio_writel(val, GPIO_MODE_REG);
119 * second stage init callback, good time to panic if we couldn't
120 * identify on which board we're running since early printk is working
122 void __init board_setup(void)
125 panic("unable to detect bcm963xx board");
126 printk(KERN_INFO PFX "board name: %s\n", board.name);
128 /* make sure we're running on expected cpu */
129 if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
130 panic("unexpected CPU for bcm963xx board");
134 * return board name for /proc/cpuinfo
136 const char *board_get_name(void)
142 * register & return a new board mac address
145 static int board_get_mac_address(u8 *mac)
147 u8 default_mac[ETH_ALEN] = {0x00, 0x07, 0x3A, 0x00, 0x00, 0x00};
151 memcpy(mac, default_mac, ETH_ALEN);
153 p = mac + ETH_ALEN - 1;
154 count = mac_addr_used;
166 printk(KERN_ERR PFX "unable to fetch mac address\n");
174 static struct resource mtd_resources[] = {
176 .start = 0, /* filled at runtime */
177 .end = 0, /* filled at runtime */
178 .flags = IORESOURCE_MEM,
182 static struct platform_device mtd_dev = {
183 .name = "bcm963xx-flash",
184 .resource = mtd_resources,
185 .num_resources = ARRAY_SIZE(mtd_resources),
190 * third stage init callback, register all board devices.
192 int __init board_register_devices(void)
196 bcm63xx_uart_register();
197 bcm63xx_wdt_register();
199 if (board.has_pccard)
200 bcm63xx_pcmcia_register();
202 if (board.has_enet0 &&
203 !board_get_mac_address(board.enet0.mac_addr))
204 bcm63xx_enet_register(0, &board.enet0);
206 if (board.has_enet1 &&
207 !board_get_mac_address(board.enet1.mac_addr))
208 bcm63xx_enet_register(1, &board.enet1);
211 bcm63xx_ohci_register();
214 bcm63xx_ehci_register();
217 /* read base address of boot chip select (0) */
218 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
219 val &= MPI_CSBASE_BASE_MASK;
220 mtd_resources[0].start = val;
221 mtd_resources[0].end = 0x1FFFFFFF;
223 platform_device_register(&mtd_dev);