[brcm63xx] fix SPI driver, move register out of driver code
[openwrt.git] / target / linux / brcm63xx / patches-2.6.32 / 170-board_livebox.patch
1 --- a/arch/mips/bcm63xx/boards/Kconfig
2 +++ b/arch/mips/bcm63xx/boards/Kconfig
3 @@ -8,4 +8,10 @@ config BOARD_BCM963XX
4 select SSB
5 help
6
7 +config BOARD_LIVEBOX
8 + bool "Inventel Livebox(es) boards"
9 + select SSB
10 + help
11 + Inventel Livebox boards using the RedBoot bootloader.
12 +
13 endchoice
14 --- a/arch/mips/bcm63xx/boards/Makefile
15 +++ b/arch/mips/bcm63xx/boards/Makefile
16 @@ -1,3 +1,4 @@
17 obj-$(CONFIG_BOARD_BCM963XX) += board_bcm963xx.o
18 +obj-$(CONFIG_BOARD_LIVEBOX) += board_livebox.o
19
20 EXTRA_CFLAGS += -Werror
21 --- /dev/null
22 +++ b/arch/mips/bcm63xx/boards/board_livebox.c
23 @@ -0,0 +1,223 @@
24 +/*
25 + * This file is subject to the terms and conditions of the GNU General Public
26 + * License. See the file "COPYING" in the main directory of this archive
27 + * for more details.
28 + *
29 + * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
30 + */
31 +
32 +#include <linux/init.h>
33 +#include <linux/kernel.h>
34 +#include <linux/string.h>
35 +#include <linux/platform_device.h>
36 +#include <linux/mtd/mtd.h>
37 +#include <linux/mtd/partitions.h>
38 +#include <linux/mtd/physmap.h>
39 +#include <linux/input.h>
40 +#include <linux/gpio_buttons.h>
41 +#include <asm/addrspace.h>
42 +#include <bcm63xx_board.h>
43 +#include <bcm63xx_cpu.h>
44 +#include <bcm63xx_regs.h>
45 +#include <bcm63xx_io.h>
46 +#include <bcm63xx_dev_pci.h>
47 +#include <bcm63xx_dev_enet.h>
48 +#include <bcm63xx_dev_pcmcia.h>
49 +#include <bcm63xx_dev_usb_ohci.h>
50 +#include <bcm63xx_dev_usb_ehci.h>
51 +#include <board_bcm963xx.h>
52 +
53 +#define PFX "board_livebox: "
54 +
55 +static unsigned int mac_addr_used = 0;
56 +static struct board_info board;
57 +
58 +/*
59 + * known 6348 boards
60 + */
61 +#ifdef CONFIG_BCM63XX_CPU_6348
62 +static struct board_info __initdata board_livebox = {
63 + .name = "Livebox",
64 + .expected_cpu_id = 0x6348,
65 +
66 + .has_enet0 = 1,
67 + .has_enet1 = 1,
68 + .has_pci = 1,
69 +
70 + .enet0 = {
71 + .has_phy = 1,
72 + .use_internal_phy = 1,
73 + },
74 +
75 + .enet1 = {
76 + .force_speed_100 = 1,
77 + .force_duplex_full = 1,
78 + },
79 +
80 + .has_ohci0 = 1,
81 + .has_pccard = 1,
82 + .has_ehci0 = 1,
83 +};
84 +#endif
85 +
86 +/*
87 + * all boards
88 + */
89 +static const struct board_info __initdata *bcm963xx_boards[] = {
90 +#ifdef CONFIG_BCM63XX_CPU_6348
91 + &board_livebox
92 +#endif
93 +};
94 +
95 +/*
96 + * early init callback
97 + */
98 +void __init board_prom_init(void)
99 +{
100 + u32 val;
101 +
102 + /* read base address of boot chip select (0) */
103 + val = bcm_mpi_readl(MPI_CSBASE_REG(0));
104 + val &= MPI_CSBASE_BASE_MASK;
105 +
106 + /* assume board is a Livebox */
107 + memcpy(&board, bcm963xx_boards[0], sizeof(board));
108 +
109 + /* setup pin multiplexing depending on board enabled device,
110 + * this has to be done this early since PCI init is done
111 + * inside arch_initcall */
112 + val = 0;
113 +
114 + if (board.has_pci) {
115 + bcm63xx_pci_enabled = 1;
116 + if (BCMCPU_IS_6348())
117 + val |= GPIO_MODE_6348_G2_PCI;
118 + }
119 +
120 + if (board.has_pccard) {
121 + if (BCMCPU_IS_6348())
122 + val |= GPIO_MODE_6348_G1_MII_PCCARD;
123 + }
124 +
125 + if (board.has_enet0 && !board.enet0.use_internal_phy) {
126 + if (BCMCPU_IS_6348())
127 + val |= GPIO_MODE_6348_G3_EXT_MII |
128 + GPIO_MODE_6348_G0_EXT_MII;
129 + }
130 +
131 + if (board.has_enet1 && !board.enet1.use_internal_phy) {
132 + if (BCMCPU_IS_6348())
133 + val |= GPIO_MODE_6348_G3_EXT_MII |
134 + GPIO_MODE_6348_G0_EXT_MII;
135 + }
136 +
137 + bcm_gpio_writel(val, GPIO_MODE_REG);
138 +}
139 +
140 +/*
141 + * second stage init callback, good time to panic if we couldn't
142 + * identify on which board we're running since early printk is working
143 + */
144 +void __init board_setup(void)
145 +{
146 + if (!board.name[0])
147 + panic("unable to detect bcm963xx board");
148 + printk(KERN_INFO PFX "board name: %s\n", board.name);
149 +
150 + /* make sure we're running on expected cpu */
151 + if (bcm63xx_get_cpu_id() != board.expected_cpu_id)
152 + panic("unexpected CPU for bcm963xx board");
153 +}
154 +
155 +/*
156 + * return board name for /proc/cpuinfo
157 + */
158 +const char *board_get_name(void)
159 +{
160 + return board.name;
161 +}
162 +
163 +/*
164 + * register & return a new board mac address
165 + */
166 +
167 +static int board_get_mac_address(u8 *mac)
168 +{
169 + u8 default_mac[ETH_ALEN] = {0x00, 0x07, 0x3A, 0x00, 0x00, 0x00};
170 + u8 *p;
171 + int count;
172 +
173 + memcpy(mac, default_mac, ETH_ALEN);
174 +
175 + p = mac + ETH_ALEN - 1;
176 + count = mac_addr_used;
177 +
178 + while (count--) {
179 + do {
180 + (*p)++;
181 + if (*p != 0)
182 + break;
183 + p--;
184 + } while (p != mac);
185 + }
186 +
187 + if (p == mac) {
188 + printk(KERN_ERR PFX "unable to fetch mac address\n");
189 + return -ENODEV;
190 + }
191 + mac_addr_used++;
192 +
193 + return 0;
194 +}
195 +
196 +static struct resource mtd_resources[] = {
197 + {
198 + .start = 0, /* filled at runtime */
199 + .end = 0, /* filled at runtime */
200 + .flags = IORESOURCE_MEM,
201 + }
202 +};
203 +
204 +static struct platform_device mtd_dev = {
205 + .name = "bcm963xx-flash",
206 + .resource = mtd_resources,
207 + .num_resources = ARRAY_SIZE(mtd_resources),
208 +};
209 +
210 +
211 +/*
212 + * third stage init callback, register all board devices.
213 + */
214 +int __init board_register_devices(void)
215 +{
216 + u32 val;
217 +
218 + if (board.has_pccard)
219 + bcm63xx_pcmcia_register();
220 +
221 + if (board.has_enet0 &&
222 + !board_get_mac_address(board.enet0.mac_addr))
223 + bcm63xx_enet_register(0, &board.enet0);
224 +
225 + if (board.has_enet1 &&
226 + !board_get_mac_address(board.enet1.mac_addr))
227 + bcm63xx_enet_register(1, &board.enet1);
228 +
229 + if (board.has_ohci0)
230 + bcm63xx_ohci_register();
231 +
232 + if (board.has_ehci0)
233 + bcm63xx_ehci_register();
234 +
235 +
236 + /* read base address of boot chip select (0) */
237 + val = bcm_mpi_readl(MPI_CSBASE_REG(0));
238 + val &= MPI_CSBASE_BASE_MASK;
239 + mtd_resources[0].start = val;
240 + mtd_resources[0].end = 0x1FFFFFFF;
241 +
242 + platform_device_register(&mtd_dev);
243 +
244 + return 0;
245 +}
246 +
This page took 0.049794 seconds and 5 git commands to generate.