[brcm63xx] bcm63xx MTD driver cleanup and fixes:
[openwrt.git] / target / linux / brcm63xx / files / arch / mips / bcm63xx / boards / board_livebox.c
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.
5 *
6 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
7 */
8
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>
29
30 #define PFX "board_livebox: "
31
32 static unsigned int mac_addr_used = 0;
33 static struct board_info board;
34
35 /*
36 * known 6348 boards
37 */
38 #ifdef CONFIG_BCM63XX_CPU_6348
39 static struct board_info __initdata board_livebox = {
40 .name = "Livebox",
41 .expected_cpu_id = 0x6348,
42
43 .has_enet0 = 1,
44 .has_pci = 1,
45
46 .enet0 = {
47 .has_phy = 1,
48 .use_internal_phy = 1,
49 },
50 };
51 #endif
52
53 /*
54 * all boards
55 */
56 static const struct board_info __initdata *bcm963xx_boards[] = {
57 #ifdef CONFIG_BCM63XX_CPU_6348
58 &board_livebox
59 #endif
60 };
61
62 /*
63 * early init callback
64 */
65 void __init board_prom_init(void)
66 {
67 u32 val;
68
69 /* read base address of boot chip select (0) */
70 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
71 val &= MPI_CSBASE_BASE_MASK;
72
73 /* assume board is a Livebox */
74 memcpy(&board, bcm963xx_boards[0], sizeof(board));
75
76 /* setup pin multiplexing depending on board enabled device,
77 * this has to be done this early since PCI init is done
78 * inside arch_initcall */
79 val = 0;
80
81 if (board.has_pci) {
82 bcm63xx_pci_enabled = 1;
83 if (BCMCPU_IS_6348())
84 val |= GPIO_MODE_6348_G2_PCI;
85 }
86
87 if (board.has_pccard) {
88 if (BCMCPU_IS_6348())
89 val |= GPIO_MODE_6348_G1_MII_PCCARD;
90 }
91
92 if (board.has_enet0 && !board.enet0.use_internal_phy) {
93 if (BCMCPU_IS_6348())
94 val |= GPIO_MODE_6348_G3_EXT_MII |
95 GPIO_MODE_6348_G0_EXT_MII;
96 }
97
98 if (board.has_enet1 && !board.enet1.use_internal_phy) {
99 if (BCMCPU_IS_6348())
100 val |= GPIO_MODE_6348_G3_EXT_MII |
101 GPIO_MODE_6348_G0_EXT_MII;
102 }
103
104 bcm_gpio_writel(val, GPIO_MODE_REG);
105 }
106
107 /*
108 * second stage init callback, good time to panic if we couldn't
109 * identify on which board we're running since early printk is working
110 */
111 void __init board_setup(void)
112 {
113 if (!board.name[0])
114 panic("unable to detect bcm963xx board");
115 printk(KERN_INFO PFX "board name: %s\n", board.name);
116
117 /* make sure we're running on expected cpu */
118 if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
119 panic("unexpected CPU for bcm963xx board");
120 }
121
122 /*
123 * return board name for /proc/cpuinfo
124 */
125 const char *board_get_name(void)
126 {
127 return board.name;
128 }
129
130 /*
131 * register & return a new board mac address
132 */
133 static int board_get_mac_address(u8 *mac)
134 {
135 /* Not yet implemented */
136 return 0;
137 }
138
139 /*
140 * third stage init callback, register all board devices.
141 */
142 int __init board_register_devices(void)
143 {
144 u32 val;
145
146 bcm63xx_uart_register();
147
148 if (board.has_pccard)
149 bcm63xx_pcmcia_register();
150
151 if (board.has_enet0 &&
152 !board_get_mac_address(board.enet0.mac_addr))
153 bcm63xx_enet_register(0, &board.enet0);
154
155 if (board.has_enet1 &&
156 !board_get_mac_address(board.enet1.mac_addr))
157 bcm63xx_enet_register(1, &board.enet1);
158
159 if (board.has_ohci0)
160 bcm63xx_ohci_register();
161
162 if (board.has_ehci0)
163 bcm63xx_ehci_register();
164
165
166 /* read base address of boot chip select (0) */
167 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
168 val &= MPI_CSBASE_BASE_MASK;
169
170 return 0;
171 }
172
This page took 0.08713 seconds and 5 git commands to generate.