ar71xx: fix random wireless mac address on the TEW-632BRP/DIR-615 boards
[openwrt.git] / target / linux / rdc / patches-2.6.28 / 002-platform_support.patch
1 Index: linux-2.6.28.10/arch/x86/mach-rdc321x/gpio.c
2 ===================================================================
3 --- linux-2.6.28.10.orig/arch/x86/mach-rdc321x/gpio.c 2009-11-03 21:01:29.800401126 -0800
4 +++ linux-2.6.28.10/arch/x86/mach-rdc321x/gpio.c 2009-11-03 21:01:32.164401226 -0800
5 @@ -26,7 +26,7 @@
6 #include <linux/types.h>
7 #include <linux/module.h>
8
9 -#include <asm/gpio.h>
10 +#include <asm/mach-rdc321x/gpio.h>
11 #include <asm/mach-rdc321x/rdc321x_defs.h>
12
13
14 @@ -74,8 +74,8 @@
15 }
16
17 /* initially setup the 2 copies of the gpio data registers.
18 - This function must be called by the platform setup code. */
19 -void __init rdc321x_gpio_setup()
20 + This function is called before the platform setup code. */
21 +static int __init rdc321x_gpio_setup(void)
22 {
23 /* this might not be, what others (BIOS, bootloader, etc.)
24 wrote to these registers before, but it's a good guess. Still
25 @@ -83,6 +83,8 @@
26
27 gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1);
28 gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2);
29 +
30 + return 0;
31 }
32
33 /* determine, if gpio number is valid */
34 @@ -192,3 +194,5 @@
35 return 0;
36 }
37 EXPORT_SYMBOL(rdc_gpio_direction_output);
38 +
39 +arch_initcall(rdc321x_gpio_setup);
40 Index: linux-2.6.28.10/arch/x86/mach-rdc321x/platform.c
41 ===================================================================
42 --- linux-2.6.28.10.orig/arch/x86/mach-rdc321x/platform.c 2009-11-03 21:01:29.836402559 -0800
43 +++ linux-2.6.28.10/arch/x86/mach-rdc321x/platform.c 2009-11-03 21:13:27.212398945 -0800
44 @@ -1,7 +1,9 @@
45 /*
46 * Generic RDC321x platform devices
47 *
48 + * Copyright (C) 2007-2008 OpenWrt.org
49 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
50 + * Copyright (C) 2008 Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
51 *
52 * This program is free software; you can redistribute it and/or
53 * modify it under the terms of the GNU General Public License
54 @@ -25,13 +27,59 @@
55 #include <linux/list.h>
56 #include <linux/device.h>
57 #include <linux/platform_device.h>
58 +#include <linux/version.h>
59 #include <linux/leds.h>
60 +#include <linux/gpio_keys.h>
61 +#include <linux/input.h>
62 +#include <linux/mtd/map.h>
63 +#include <linux/mtd/mtd.h>
64 +#include <linux/mtd/physmap.h>
65 +#include <linux/root_dev.h>
66
67 -#include <asm/gpio.h>
68 +#include <asm/mach-rdc321x/gpio.h>
69 +
70 +/* Flash */
71 +#ifdef CONFIG_MTD_R8610
72 +#define CONFIG_MTD_RDC3210 1
73 +#elif defined CONFIG_MTD_RDC3210
74 +static struct resource rdc_flash_resource[] = {
75 + [0] = {
76 + .start = (u32)-CONFIG_MTD_RDC3210_SIZE,
77 + .end = (u32)-1,
78 + .flags = IORESOURCE_MEM,
79 + },
80 +};
81 +
82 +static struct platform_device rdc_flash_device = {
83 + .name = "rdc321x-flash",
84 + .id = -1,
85 + .num_resources = ARRAY_SIZE(rdc_flash_resource),
86 + .resource = rdc_flash_resource,
87 +};
88 +#else
89 +static struct mtd_partition rdc_flash_parts[15];
90 +
91 +static struct resource rdc_flash_resource = {
92 + .end = (u32)-1,
93 + .flags = IORESOURCE_MEM,
94 +};
95 +
96 +static struct physmap_flash_data rdc_flash_data = {
97 + .parts = rdc_flash_parts,
98 +};
99 +
100 +static struct platform_device rdc_flash_device = {
101 + .name = "physmap-flash",
102 + .id = -1,
103 + .resource = &rdc_flash_resource,
104 + .num_resources = 1,
105 + .dev.platform_data = &rdc_flash_data,
106 +};
107 +#endif
108
109 /* LEDS */
110 static struct gpio_led default_leds[] = {
111 - { .name = "rdc:dmz", .gpio = 1, },
112 + { .name = "rdc321x:dmz", .gpio = 1, },
113 };
114
115 static struct gpio_led_platform_data rdc321x_led_data = {
116 @@ -54,16 +102,189 @@
117 .num_resources = 0,
118 };
119
120 +/* Button */
121 +static struct gpio_keys_button rdc321x_gpio_btn[] = {
122 + {
123 + .gpio = 0,
124 + .code = BTN_0,
125 + .desc = "Reset",
126 + .active_low = 1,
127 + }
128 +};
129 +
130 +static struct gpio_keys_platform_data rdc321x_gpio_btn_data = {
131 + .buttons = rdc321x_gpio_btn,
132 + .nbuttons = ARRAY_SIZE(rdc321x_gpio_btn),
133 +};
134 +
135 +static struct platform_device rdc321x_button = {
136 + .name = "gpio-keys",
137 + .id = -1,
138 + .dev = {
139 + .platform_data = &rdc321x_gpio_btn_data,
140 + }
141 +};
142 +
143 static struct platform_device *rdc321x_devs[] = {
144 + &rdc_flash_device,
145 &rdc321x_leds,
146 - &rdc321x_wdt
147 + &rdc321x_wdt,
148 + &rdc321x_button,
149 };
150
151 +static int probe_flash_start(struct map_info *the_map)
152 +{
153 + struct mtd_info *res;
154 +
155 + the_map->virt = ioremap(the_map->phys, the_map->size);
156 + if (the_map->virt == NULL)
157 + return 1;
158 + for (the_map->bankwidth = 32; the_map->bankwidth; the_map->bankwidth
159 + >>= 1) {
160 + res = do_map_probe("cfi_probe", the_map);
161 + if (res == NULL)
162 + res = do_map_probe("jedec_probe", the_map);
163 + if (res != NULL)
164 + break;
165 + }
166 + iounmap(the_map->virt);
167 + if (res != NULL)
168 + the_map->phys = (u32)-(s32)(the_map->size = res->size);
169 + return res == NULL;
170 +}
171 +
172 static int __init rdc_board_setup(void)
173 {
174 - rdc321x_gpio_setup();
175 +#ifndef CONFIG_MTD_RDC3210
176 + struct map_info rdc_map_info;
177 + u32 the_header[8];
178
179 + ROOT_DEV = 0;
180 + rdc_map_info.name = rdc_flash_device.name;
181 + rdc_map_info.phys = 0xff000000;
182 + rdc_map_info.size = 0x1000000;
183 + rdc_map_info.bankwidth = 2;
184 + rdc_map_info.set_vpp = NULL;
185 + simple_map_init(&rdc_map_info);
186 + while (probe_flash_start(&rdc_map_info)) {
187 + rdc_map_info.phys++;
188 + if (--rdc_map_info.size)
189 + panic("Could not find start of flash!");
190 + }
191 + rdc_flash_resource.start = rdc_map_info.phys;
192 + rdc_flash_data.width = rdc_map_info.bankwidth;
193 + rdc_map_info.virt = ioremap_nocache(rdc_map_info.phys, 0x10);
194 + if (rdc_map_info.virt == NULL)
195 + panic("Could not ioremap to read device magic!");
196 + the_header[0] = ((u32 *)rdc_map_info.virt)[0];
197 + the_header[1] = ((u32 *)rdc_map_info.virt)[1];
198 + the_header[2] = ((u32 *)rdc_map_info.virt)[2];
199 + the_header[3] = ((u32 *)rdc_map_info.virt)[3];
200 + iounmap(rdc_map_info.virt);
201 + rdc_map_info.virt = ioremap_nocache(rdc_map_info.phys + 0x8000, 0x10);
202 + if (rdc_map_info.virt == NULL)
203 + panic("Could not ioremap to read device magic!");
204 + the_header[4] = ((u32 *)rdc_map_info.virt)[0];
205 + the_header[5] = ((u32 *)rdc_map_info.virt)[1];
206 + the_header[6] = ((u32 *)rdc_map_info.virt)[2];
207 + the_header[7] = ((u32 *)rdc_map_info.virt)[3];
208 + iounmap(rdc_map_info.virt);
209 + if (!memcmp(the_header, "GMTK", 4)) { /* Gemtek */
210 + /* TODO */
211 + } else if (!memcmp(the_header + 4, "CSYS", 4)) { /* Sitecom */
212 + rdc_flash_parts[0].name = "system";
213 + rdc_flash_parts[0].offset = 0;
214 + rdc_flash_parts[0].size = rdc_map_info.size - 0x10000;
215 + rdc_flash_parts[1].name = "config";
216 + rdc_flash_parts[1].offset = 0;
217 + rdc_flash_parts[1].size = 0x8000;
218 + rdc_flash_parts[2].name = "magic";
219 + rdc_flash_parts[2].offset = 0x8000;
220 + rdc_flash_parts[2].size = 0x14;
221 + rdc_flash_parts[3].name = "kernel";
222 + rdc_flash_parts[3].offset = 0x8014;
223 + rdc_flash_parts[3].size = the_header[5];
224 + rdc_flash_parts[4].name = "rootfs";
225 + rdc_flash_parts[4].offset = 0x8014 + the_header[5];
226 + rdc_flash_parts[4].size = rdc_flash_parts[0].size - rdc_flash_parts[4].offset;
227 + rdc_flash_parts[5].name = "bootloader";
228 + rdc_flash_parts[5].offset = rdc_flash_parts[0].size;
229 + rdc_flash_parts[5].size = 0x10000;
230 + rdc_flash_data.nr_parts = 6;
231 + } else if (!memcmp(((u8 *)the_header) + 14, "Li", 2)) { /* AMIT */
232 + rdc_flash_parts[0].name = "kernel_parthdr";
233 + rdc_flash_parts[0].offset = 0;
234 + rdc_flash_parts[0].size = 0x10;
235 + rdc_flash_parts[1].name = "kernel";
236 + rdc_flash_parts[1].offset = 0x10;
237 + rdc_flash_parts[1].size = 0xffff0;
238 + rdc_flash_parts[2].name = "rootfs_parthdr";
239 + rdc_flash_parts[2].offset = 0x100000;
240 + rdc_flash_parts[2].size = 0x10;
241 + rdc_flash_parts[3].name = "rootfs";
242 + rdc_flash_parts[3].offset = 0x100010;
243 + rdc_flash_parts[3].size = rdc_map_info.size - 0x160010;
244 + rdc_flash_parts[4].name = "config_parthdr";
245 + rdc_flash_parts[4].offset = rdc_map_info.size - 0x60000;
246 + rdc_flash_parts[4].size = 0x10;
247 + rdc_flash_parts[5].name = "config";
248 + rdc_flash_parts[5].offset = rdc_map_info.size - 0x5fff0;
249 + rdc_flash_parts[5].size = 0xfff0;
250 + rdc_flash_parts[6].name = "recoveryfs_parthdr";
251 + rdc_flash_parts[6].offset = rdc_map_info.size - 0x50000;
252 + rdc_flash_parts[6].size = 0x10;
253 + rdc_flash_parts[7].name = "recoveryfs";
254 + rdc_flash_parts[7].offset = rdc_map_info.size - 0x4fff0;
255 + rdc_flash_parts[7].size = 0x3fff0;
256 + rdc_flash_parts[8].name = "recovery_parthdr";
257 + rdc_flash_parts[8].offset = rdc_map_info.size - 0x10000;
258 + rdc_flash_parts[8].size = 0x10;
259 + rdc_flash_parts[9].name = "recovery";
260 + rdc_flash_parts[9].offset = rdc_map_info.size - 0xfff0;
261 + rdc_flash_parts[9].size = 0x7ff0;
262 + rdc_flash_parts[10].name = "productinfo_parthdr";
263 + rdc_flash_parts[10].offset = rdc_map_info.size - 0x8000;
264 + rdc_flash_parts[10].size = 0x10;
265 + rdc_flash_parts[11].name = "productinfo";
266 + rdc_flash_parts[11].offset = rdc_map_info.size - 0x7ff0;
267 + rdc_flash_parts[11].size = 0x1ff0;
268 + rdc_flash_parts[12].name = "bootloader_parthdr";
269 + rdc_flash_parts[12].offset = rdc_map_info.size - 0x6000;
270 + rdc_flash_parts[12].size = 0x10;
271 + rdc_flash_parts[13].name = "bootloader";
272 + rdc_flash_parts[13].offset = rdc_map_info.size - 0x5ff0;
273 + rdc_flash_parts[13].size = 0x5ff0;
274 + rdc_flash_parts[14].name = "everything";
275 + rdc_flash_parts[14].offset = 0;
276 + rdc_flash_parts[14].size = rdc_map_info.size;
277 + rdc_flash_data.nr_parts = 15;
278 + } else { /* ZyXEL */
279 + rdc_flash_parts[0].name = "kernel";
280 + rdc_flash_parts[0].offset = 0;
281 + rdc_flash_parts[0].size = 0x100000;
282 + rdc_flash_parts[1].name = "rootfs";
283 + rdc_flash_parts[1].offset = 0x100000;
284 + rdc_flash_parts[1].size = rdc_map_info.size - 0x140000;
285 + rdc_flash_parts[2].name = "linux";
286 + rdc_flash_parts[2].offset = 0;
287 + rdc_flash_parts[2].size = rdc_map_info.size - 0x40000;
288 + rdc_flash_parts[3].name = "config";
289 + rdc_flash_parts[3].offset = rdc_map_info.size - 0x40000;
290 + rdc_flash_parts[3].size = 0x10000;
291 + rdc_flash_parts[4].name = "productinfo";
292 + rdc_flash_parts[4].offset = rdc_map_info.size - 0x30000;
293 + rdc_flash_parts[4].size = 0x10000;
294 + rdc_flash_parts[5].name = "bootloader";
295 + rdc_flash_parts[5].offset = rdc_map_info.size - 0x20000;
296 + rdc_flash_parts[5].size = 0x20000;
297 + rdc_flash_data.nr_parts = 6;
298 + }
299 +#endif
300 return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
301 }
302
303 +#ifdef CONFIG_MTD_RDC3210
304 arch_initcall(rdc_board_setup);
305 +#else
306 +late_initcall(rdc_board_setup);
307 +#endif
308 Index: linux-2.6.28.10/arch/x86/Makefile
309 ===================================================================
310 --- linux-2.6.28.10.orig/arch/x86/Makefile 2009-11-03 21:01:29.756400281 -0800
311 +++ linux-2.6.28.10/arch/x86/Makefile 2009-11-03 21:01:32.164401226 -0800
312 @@ -113,6 +113,10 @@
313 mflags-$(CONFIG_X86_VOYAGER) := -Iarch/x86/include/asm/mach-voyager
314 mcore-$(CONFIG_X86_VOYAGER) := arch/x86/mach-voyager/
315
316 +# RDC subarch support
317 +mflags-$(CONFIG_X86_RDC321X) := -Iarch/x86/include/asm/mach-rdc321x
318 +mcore-$(CONFIG_X86_RDC321X) += arch/x86/mach-rdc321x/
319 +
320 # generic subarchitecture
321 mflags-$(CONFIG_X86_GENERICARCH):= -Iarch/x86/include/asm/mach-generic
322 fcore-$(CONFIG_X86_GENERICARCH) += arch/x86/mach-generic/
323 Index: linux-2.6.28.10/arch/x86/include/asm/mach-rdc321x/gpio.h
324 ===================================================================
325 --- linux-2.6.28.10.orig/arch/x86/include/asm/mach-rdc321x/gpio.h 2009-11-03 21:01:29.784401606 -0800
326 +++ linux-2.6.28.10/arch/x86/include/asm/mach-rdc321x/gpio.h 2009-11-03 21:01:32.164401226 -0800
327 @@ -9,7 +9,6 @@
328 extern int rdc_gpio_direction_output(unsigned gpio, int value);
329 extern int rdc_gpio_request(unsigned gpio, const char *label);
330 extern void rdc_gpio_free(unsigned gpio);
331 -extern void __init rdc321x_gpio_setup(void);
332
333 /* Wrappers for the arch-neutral GPIO API */
334
This page took 0.059788 seconds and 5 git commands to generate.