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