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_enet.h>
25 #include <bcm63xx_dev_pcmcia.h>
26 #include <bcm63xx_dev_usb_ohci.h>
27 #include <bcm63xx_dev_usb_ehci.h>
28 #include <board_bcm963xx.h>
30 #define PFX "board_livebox: "
32 static unsigned int mac_addr_used
= 0;
33 static struct board_info board
;
38 #ifdef CONFIG_BCM63XX_CPU_6348
39 static struct board_info __initdata board_livebox
= {
41 .expected_cpu_id
= 0x6348,
49 .use_internal_phy
= 1,
54 .force_duplex_full
= 1,
66 static const struct board_info __initdata
*bcm963xx_boards
[] = {
67 #ifdef CONFIG_BCM63XX_CPU_6348
75 void __init
board_prom_init(void)
79 /* read base address of boot chip select (0) */
80 val
= bcm_mpi_readl(MPI_CSBASE_REG(0));
81 val
&= MPI_CSBASE_BASE_MASK
;
83 /* assume board is a Livebox */
84 memcpy(&board
, bcm963xx_boards
[0], sizeof(board
));
86 /* setup pin multiplexing depending on board enabled device,
87 * this has to be done this early since PCI init is done
88 * inside arch_initcall */
92 bcm63xx_pci_enabled
= 1;
94 val
|= GPIO_MODE_6348_G2_PCI
;
97 if (board
.has_pccard
) {
99 val
|= GPIO_MODE_6348_G1_MII_PCCARD
;
102 if (board
.has_enet0
&& !board
.enet0
.use_internal_phy
) {
103 if (BCMCPU_IS_6348())
104 val
|= GPIO_MODE_6348_G3_EXT_MII
|
105 GPIO_MODE_6348_G0_EXT_MII
;
108 if (board
.has_enet1
&& !board
.enet1
.use_internal_phy
) {
109 if (BCMCPU_IS_6348())
110 val
|= GPIO_MODE_6348_G3_EXT_MII
|
111 GPIO_MODE_6348_G0_EXT_MII
;
114 bcm_gpio_writel(val
, GPIO_MODE_REG
);
118 * second stage init callback, good time to panic if we couldn't
119 * identify on which board we're running since early printk is working
121 void __init
board_setup(void)
124 panic("unable to detect bcm963xx board");
125 printk(KERN_INFO PFX
"board name: %s\n", board
.name
);
127 /* make sure we're running on expected cpu */
128 if (bcm63xx_get_cpu_id() != board
.expected_cpu_id
)
129 panic("unexpected CPU for bcm963xx board");
133 * return board name for /proc/cpuinfo
135 const char *board_get_name(void)
141 * register & return a new board mac address
144 static int board_get_mac_address(u8
*mac
)
146 u8 default_mac
[ETH_ALEN
] = {0x00, 0x07, 0x3A, 0x00, 0x00, 0x00};
150 memcpy(mac
, default_mac
, ETH_ALEN
);
152 p
= mac
+ ETH_ALEN
- 1;
153 count
= mac_addr_used
;
165 printk(KERN_ERR PFX
"unable to fetch mac address\n");
173 static struct resource mtd_resources
[] = {
175 .start
= 0, /* filled at runtime */
176 .end
= 0, /* filled at runtime */
177 .flags
= IORESOURCE_MEM
,
181 static struct platform_device mtd_dev
= {
182 .name
= "bcm963xx-flash",
183 .resource
= mtd_resources
,
184 .num_resources
= ARRAY_SIZE(mtd_resources
),
189 * third stage init callback, register all board devices.
191 int __init
board_register_devices(void)
195 bcm63xx_uart_register();
197 if (board
.has_pccard
)
198 bcm63xx_pcmcia_register();
200 if (board
.has_enet0
&&
201 !board_get_mac_address(board
.enet0
.mac_addr
))
202 bcm63xx_enet_register(0, &board
.enet0
);
204 if (board
.has_enet1
&&
205 !board_get_mac_address(board
.enet1
.mac_addr
))
206 bcm63xx_enet_register(1, &board
.enet1
);
209 bcm63xx_ohci_register();
212 bcm63xx_ehci_register();
215 /* read base address of boot chip select (0) */
216 val
= bcm_mpi_readl(MPI_CSBASE_REG(0));
217 val
&= MPI_CSBASE_BASE_MASK
;
218 mtd_resources
[0].start
= val
;
219 mtd_resources
[0].end
= 0x1FFFFFFF;
221 platform_device_register(&mtd_dev
);