summaryrefslogtreecommitdiff
path: root/packages/linux/linux-ezx-2.6.23/patches/ezx-mtd-map.patch
blob: 2dd45d2a17199624c3b086bb4917a3b98d3fa8e6 (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
Index: linux-2.6.23/drivers/mtd/maps/Kconfig
===================================================================
--- linux-2.6.23.orig/drivers/mtd/maps/Kconfig	2007-10-10 09:38:44.000000000 +0200
+++ linux-2.6.23/drivers/mtd/maps/Kconfig	2007-10-22 22:19:57.000000000 +0200
@@ -605,6 +605,34 @@
 	help
 	  This enables access to the flash chip on the Sharp SL Series of PDAs.
 
+config MTD_EZX
+	tristate "Map driver for Motorola EZX Platform"
+	depends on MTD && PXA_EZX
+
+if MTD_EZX
+
+choice
+	prompt "Select partition mapping for EZX platform"
+
+config MTD_EZX_A780
+	bool "A780/E680 Original Mapping"
+
+config MTD_EZX_A780_ALTERNATE
+	bool "A780/E680 Alternate Mapping for BLOB2"
+
+config MTD_EZX_A1200
+	bool "A1200 Original Mapping"
+
+config MTD_EZX_E2
+	bool "E2 Original Mapping"
+
+config MTD_EZX_E6
+	bool "E6 Original Mapping"
+
+endchoice
+
+endif
+
 config MTD_PLATRAM
 	tristate "Map driver for platform device RAM (mtd-ram)"
 	select MTD_RAM
Index: linux-2.6.23/drivers/mtd/maps/Makefile
===================================================================
--- linux-2.6.23.orig/drivers/mtd/maps/Makefile	2007-10-10 09:38:44.000000000 +0200
+++ linux-2.6.23/drivers/mtd/maps/Makefile	2007-10-22 22:19:57.000000000 +0200
@@ -71,3 +71,4 @@
 obj-$(CONFIG_MTD_OMAP_NOR)	+= omap_nor.o
 obj-$(CONFIG_MTD_MTX1)		+= mtx-1_flash.o
 obj-$(CONFIG_MTD_TQM834x)	+= tqm834x.o
+obj-$(CONFIG_MTD_EZX)		+= ezx-flash.o
Index: linux-2.6.23/drivers/mtd/maps/ezx-flash.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.23/drivers/mtd/maps/ezx-flash.c	2007-10-22 22:19:57.000000000 +0200
@@ -0,0 +1,256 @@
+/*
+ * Map driver for the PXA27x
+ *
+ * Author:	Harald Welte
+ * Copyright:	(C) 2001 MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/cacheflush.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/arch/mainstone.h>
+
+#define WINDOW_ADDR		0x0
+#define WINDOW_SIZE		(32*1024*1024)
+#define WINDOW_CACHE_ADDR	0x0
+#define WINDOW_CACHE_SIZE	0x1a00000
+
+static void pxa27x_map_inval_cache(struct map_info *map, unsigned long from,
+				   ssize_t len)
+{
+	flush_ioremap_region(map->phys, map->cached, from, len);
+}
+
+
+struct map_info pxa27x_map = {
+	.name		= "PXA27x flash",
+	.size		= WINDOW_SIZE,
+	.phys		= WINDOW_ADDR,
+	.inval_cache	= &pxa27x_map_inval_cache,
+};
+
+#if defined CONFIG_MTD_EZX_A780_ALTERNATE
+static struct mtd_partition pxa27x_partitions[] = {
+	{
+		.name		= "Bootloader (RO)",
+		.size		= 0x00020000,
+		.offset		= 0,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "Bootloader 2",
+		.size		= 0x00020000,
+		.offset		= 0x00020000,
+	} , {
+		.name		= "Moto Kernel",
+		.size		= 0x000e0000, // 896KB
+		.offset		= 0x00040000,
+	} , {
+		.name		= "rootfs",
+		.size		= 0x01760000,
+		.offset		= 0x00120000,
+	} , {
+		.name		= "OpenEZX Kernel",
+		.size		= 0x00180000, // 1.5MB
+		.offset		= 0x01880000,
+	} , {
+		.name		= "ezxlocal",
+		.size		= 0x005a0000,
+		.offset		= 0x01a00000,
+	} , {
+		.name		= "setup",
+		.size		= 0x00020000,
+		.offset		= 0x01fa0000,
+	} , {
+		.name		= "Logo",
+		.size		= 0x00020000,
+		.offset		= 0x01fc0000,
+	},
+};
+#elif defined CONFIG_MTD_EZX_A780
+static struct mtd_partition pxa27x_partitions[] = {
+	{
+		.name		= "Bootloader",
+		.size		= 0x00020000,
+		.offset		= 0,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "Kernel",
+		.size		= 0x000e0000,
+		.offset		= 0x00020000,
+	} , {
+		.name		= "rootfs",
+		.size		= 0x018e0000,
+		.offset		= 0x00120000,
+	} , {
+		.name		= "VFM_Filesystem",
+		.size		= 0x00580000,
+		.offset		= 0x01a00000,
+	} , {
+		.name		= "setup",
+		.size		= 0x00020000,
+		.offset		= 0x01fa0000,
+	} , {
+		.name		= "Logo",
+		.size		= 0x00020000,
+		.offset		= 0x01fc0000,
+	},
+};
+#elif defined CONFIG_MTD_EZX_A1200
+static struct mtd_partition pxa27x_partitions[] = {
+	{
+		.name		= "Caddo 2",
+		.size		= 0x00008000,
+		.offset		= 0,
+	}, {
+		.name		= "Itunes",
+		.size		= 0x00008000,
+		.offset		= 0x00008000,
+	}, {
+		.name		= "Caddo 1",
+		.size		= 0x00008000,
+		.offset		= 0x00010000,
+	}, {
+		.name		= "Fota rev",
+		.size		= 0x00008000,
+		.offset		= 0x00018000,
+	}, {
+		.name		= "MBM",
+		.size		= 0x00040000,
+		.offset		= 0x00020000,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "Blob",
+		.size		= 0x00020000,
+		.offset		= 0x00080000,
+		.mask_flags	= MTD_WRITEABLE,
+	}, {
+		.name		= "Kernel",
+		.size		= 0x00100000,
+		.offset		= 0x000A0000,
+	} , {
+		.name		= "UserFS DB",
+		.size		= 0x00600000,
+		.offset		= 0x00AA0000,
+	}, {
+		.name		= "UserFS",
+		.size		= 0x007E0000,
+		.offset		= 0x010A0000,
+	}, {
+		.name		= "Test cmd",
+		.size		= 0x00020000,
+		.offset		= 0x018C0000,
+	} , {
+		.name		= "Logo",
+		.size		= 0x00020000,
+		.offset		= 0x018E0000,
+	} , {
+		.name		= "Fota",
+		.size		= 0x000c0000,
+		.offset		= 0x01900000,
+	}, {
+		.name		= "Reserve",
+		.size		= 0x00020000,
+		.offset		= 0x019c0000,
+	}
+};
+#else
+#error "please define partition for this PXA27x implementation"
+#endif
+
+
+static struct mtd_info *mymtd;
+static struct mtd_partition *parsed_parts;
+
+static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
+
+static int __init init_pxa27x(void)
+{
+	struct mtd_partition *parts;
+	int nb_parts = 0;
+	int parsed_nr_parts = 0;
+	char *part_type = "static";
+
+	pxa27x_map.bankwidth = (BOOT_DEF & 1) ? 2 : 4;
+
+	printk("Probing PXA27x flash at physical address 0x%08x (%d-bit bankwidth)\n",
+		WINDOW_ADDR, pxa27x_map.bankwidth * 8);
+	pxa27x_map.virt = ioremap(pxa27x_map.phys, pxa27x_map.size);
+
+	if (!pxa27x_map.virt) {
+		printk("Failed to ioremap\n");
+		return -EIO;
+	}
+
+	mymtd = do_map_probe("cfi_probe", &pxa27x_map);
+	if (!mymtd) {
+		iounmap((void *)pxa27x_map.virt);
+		return -ENXIO;
+	}
+	mymtd->owner = THIS_MODULE;
+
+	simple_map_init(&pxa27x_map);
+
+	if (parsed_nr_parts == 0) {
+		int ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0);
+
+		if (ret > 0) {
+			part_type = "RedBoot";
+			parsed_nr_parts = ret;
+		}
+	}
+
+	if (parsed_nr_parts > 0) {
+		parts = parsed_parts;
+		nb_parts = parsed_nr_parts;
+	} else {
+		parts = pxa27x_partitions;
+		nb_parts = ARRAY_SIZE(pxa27x_partitions);
+	}
+
+	if (nb_parts) {
+		printk(KERN_NOTICE "Using %s partition definition\n", part_type);
+		add_mtd_partitions(mymtd, parts, nb_parts);
+	} else {
+		add_mtd_device(mymtd);
+	}
+	return 0;
+}
+
+static void __exit cleanup_pxa27x(void)
+{
+	if (mymtd) {
+		del_mtd_partitions(mymtd);
+		map_destroy(mymtd);
+		if (parsed_parts)
+			kfree(parsed_parts);
+	}
+	if (pxa27x_map.virt)
+		iounmap((void *)pxa27x_map.virt);
+	if (pxa27x_map.cached)
+		iounmap((void *)pxa27x_map.cached);
+	return;
+}
+
+module_init(init_pxa27x);
+module_exit(cleanup_pxa27x);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
+MODULE_DESCRIPTION("MTD map driver for Motorola EZX platform");