f59e31d9a22a341ef0d6f4c9426b186ac89eabfb
[openembedded.git] / packages / linux / linux-ezx-2.6.20.7 / ezx-mtd-map.patch
1 Index: linux-2.6.20.7/drivers/mtd/maps/Kconfig
2 ===================================================================
3 --- linux-2.6.20.7.orig/drivers/mtd/maps/Kconfig        2007-04-21 12:47:04.000000000 -0300
4 +++ linux-2.6.20.7/drivers/mtd/maps/Kconfig     2007-04-21 13:01:08.000000000 -0300
5 @@ -595,6 +595,28 @@
6         help
7           This enables access to the flash chip on the Sharp SL Series of PDAs.
8  
9 +config MTD_EZX
10 +       bool "Map driver for Motorola EZX Platform"
11 +       depends on MTD && PXA_EZX
12 +
13 +if MTD_EZX
14 +
15 +choice
16 +       prompt "Select partition mapping for EZX platform"
17 +
18 +config MTD_EZX_A780
19 +       bool "A780/E680 Original Mapping"
20 +
21 +config MTD_EZX_A780_ALTERNATE
22 +       bool "A780/E680 Alternate Mapping for BLOB2"
23 +
24 +config MTD_EZX_E2
25 +       bool "E2 Original Mapping"
26 +
27 +endchoice
28 +
29 +endif
30 +
31  config MTD_PLATRAM
32         tristate "Map driver for platform device RAM (mtd-ram)"
33         depends on MTD
34 Index: linux-2.6.20.7/drivers/mtd/maps/Makefile
35 ===================================================================
36 --- linux-2.6.20.7.orig/drivers/mtd/maps/Makefile       2007-04-21 12:55:09.000000000 -0300
37 +++ linux-2.6.20.7/drivers/mtd/maps/Makefile    2007-04-21 12:55:45.000000000 -0300
38 @@ -72,3 +72,4 @@
39  obj-$(CONFIG_MTD_OMAP_NOR)     += omap_nor.o
40  obj-$(CONFIG_MTD_MTX1)         += mtx-1_flash.o
41  obj-$(CONFIG_MTD_TQM834x)      += tqm834x.o
42 +obj-$(CONFIG_MTD_EZX)          += ezx-flash.o
43 Index: linux-2.6.20.7/drivers/mtd/maps/ezx-flash.c
44 ===================================================================
45 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
46 +++ linux-2.6.20.7/drivers/mtd/maps/ezx-flash.c 2007-04-21 13:07:14.000000000 -0300
47 @@ -0,0 +1,227 @@
48 +/*
49 + * $Id:  $
50 + *
51 + * Map driver for the PXA27x
52 + *
53 + * Author:     Harald Welte
54 + * Copyright:  (C) 2001 MontaVista Software Inc.
55 + *
56 + * This program is free software; you can redistribute it and/or modify
57 + * it under the terms of the GNU General Public License version 2 as
58 + * published by the Free Software Foundation.
59 + *
60 + * Mar 3, 2007 - (Daniel Ribeiro) Alternate partition table
61 + *
62 + */
63 +
64 +#include <linux/module.h>
65 +#include <linux/types.h>
66 +#include <linux/kernel.h>
67 +#include <linux/init.h>
68 +#include <linux/dma-mapping.h>
69 +#include <linux/slab.h>
70 +
71 +#include <linux/mtd/mtd.h>
72 +#include <linux/mtd/map.h>
73 +#include <linux/mtd/partitions.h>
74 +
75 +#include <asm/io.h>
76 +#include <asm/hardware.h>
77 +#include <asm/arch/pxa-regs.h>
78 +#include <asm/arch/mainstone.h>
79 +
80 +#define WINDOW_ADDR            0x0
81 +#define WINDOW_SIZE            (32*1024*1024)
82 +#define WINDOW_CACHE_ADDR      0x0
83 +#define WINDOW_CACHE_SIZE      0x1a00000
84 +
85 +static void pxa27x_map_inval_cache(struct map_info *map, unsigned long from,
86 +                                  ssize_t len)
87 +{
88 +#if 0
89 +       unsigned long endaddress, i, j;
90 +       endaddress = from + len -1;
91 +       from &= ~(32-1);
92 +       endaddress &= ~(32-1);
93 +       for (i = from; i <= endaddress; i += 32)
94 +               asm("mcr        p15, 0, %0, c7, c6, 1"::"r"(i));
95 +
96 +       asm(    "mrc p15, 0, %0, c2, c0, 0\n"
97 +               "mov %0, %0\n"
98 +               "sub pc, pc #4"
99 +               :"=r"(j));
100 +#else
101 +       consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
102 +#endif
103 +}
104 +
105 +
106 +struct map_info pxa27x_map = {
107 +       .name           = "PXA27x flash",
108 +       .size           = WINDOW_SIZE,
109 +       .phys           = WINDOW_ADDR,
110 +       .inval_cache    = &pxa27x_map_inval_cache,
111 +};
112 +
113 +#if defined CONFIG_MTD_EZX_A780_ALTERNATE
114 +static struct mtd_partition pxa27x_partitions[] = {
115 +       {
116 +               .name           = "Bootloader (RO)",
117 +               .size           = 0x00020000,
118 +               .offset         = 0,
119 +               .mask_flags     = MTD_WRITEABLE,
120 +       }, {
121 +               .name           = "Bootloader 2",
122 +               .size           = 0x00020000,
123 +               .offset         = 0x00020000,
124 +       } , {
125 +               .name           = "Kernel 1",
126 +               .size           = 0x000e0000, // 896KB
127 +               .offset         = 0x00040000,
128 +       } , {
129 +               .name           = "rootfs",
130 +               .size           = 0x01760000,
131 +               .offset         = 0x00120000,
132 +       } , {
133 +               .name           = "Kernel 2",
134 +               .size           = 0x00180000, // 1.5MB
135 +               .offset         = 0x01880000,
136 +       } , {
137 +               .name           = "VFM_Filesystem",
138 +               .size           = 0x005a0000,
139 +               .offset         = 0x01a00000,
140 +       } , {
141 +               .name           = "setup",
142 +               .size           = 0x00020000,
143 +               .offset         = 0x01fa0000,
144 +       } , {
145 +               .name           = "Logo",
146 +               .size           = 0x00020000,
147 +               .offset         = 0x01fc0000,
148 +       },
149 +};
150 +#elif defined CONFIG_MTD_EZX_A780
151 +static struct mtd_partition pxa27x_partitions[] = {
152 +       {
153 +               .name           = "Bootloader",
154 +               .size           = 0x00020000,
155 +               .offset         = 0,
156 +               .mask_flags     = MTD_WRITEABLE,
157 +       }, {
158 +               .name           = "Kernel",
159 +               .size           = 0x000e0000,
160 +               .offset         = 0x00020000,
161 +       } , {
162 +               .name           = "rootfs",
163 +               .size           = 0x018e0000,
164 +               .offset         = 0x00120000,
165 +       } , {
166 +               .name           = "VFM_Filesystem",
167 +               .size           = 0x00580000,
168 +               .offset         = 0x01a00000,
169 +       } , {
170 +               .name           = "setup",
171 +               .size           = 0x00020000,
172 +               .offset         = 0x01fa0000,
173 +       } , {
174 +               .name           = "Logo",
175 +               .size           = 0x00020000,
176 +               .offset         = 0x01fc0000,
177 +       },
178 +};
179 +#else
180 +#error "please define partition for this PXA27x implementation"
181 +#endif
182 +
183 +
184 +static struct mtd_info *mymtd;
185 +static struct mtd_partition *parsed_parts;
186 +
187 +static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
188 +
189 +static int __init init_pxa27x(void)
190 +{
191 +       struct mtd_partition *parts;
192 +       int nb_parts = 0;
193 +       int parsed_nr_parts = 0;
194 +       char *part_type = "static";
195 +
196 +       pxa27x_map.bankwidth = (BOOT_DEF & 1) ? 2 : 4;
197 +
198 +       printk("Probing PXA27x flash at physical address 0x%08x (%d-bit bankwidth)\n",
199 +               WINDOW_ADDR, pxa27x_map.bankwidth * 8);
200 +       pxa27x_map.virt = ioremap(pxa27x_map.phys, pxa27x_map.size);
201 +
202 +       if (!pxa27x_map.virt) {
203 +               printk("Failed to ioremap\n");
204 +               return -EIO;
205 +       }
206 +
207 +       mymtd = do_map_probe("cfi_probe", &pxa27x_map);
208 +       if (!mymtd) {
209 +               iounmap((void *)pxa27x_map.virt);
210 +               return -ENXIO;
211 +       }
212 +       mymtd->owner = THIS_MODULE;
213 +
214 +#if 0
215 +       /* ioremap the first flash chip as cacheable */
216 +       pxa27x_map.cached = ioremap_cached(pxa27x_map.phys, pxa27x_map.size);
217 +       if (!pxa27x_map.cached) {
218 +               printk("Failed to do cacheable-ioremap\n");
219 +               iounmap((void *)pxa27x_map.virt);
220 +               return -EIO;
221 +       }
222 +#endif
223 +       simple_map_init(&pxa27x_map);
224 +
225 +       if (parsed_nr_parts == 0) {
226 +               int ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0);
227 +
228 +               if (ret > 0) {
229 +                       part_type = "RedBoot";
230 +                       parsed_nr_parts = ret;
231 +               }
232 +       }
233 +
234 +       if (parsed_nr_parts > 0) {
235 +               parts = parsed_parts;
236 +               nb_parts = parsed_nr_parts;
237 +       } else {
238 +               parts = pxa27x_partitions;
239 +               nb_parts = ARRAY_SIZE(pxa27x_partitions);
240 +       }
241 +
242 +       if (nb_parts) {
243 +               printk(KERN_NOTICE "Using %s partition definition\n", part_type);
244 +               add_mtd_partitions(mymtd, parts, nb_parts);
245 +       } else {
246 +               add_mtd_device(mymtd);
247 +       }
248 +#if 0
249 +       if (ret = ezx_partition_init())
250 +#endif
251 +       return 0;
252 +}
253 +
254 +static void __exit cleanup_pxa27x(void)
255 +{
256 +       if (mymtd) {
257 +               del_mtd_partitions(mymtd);
258 +               map_destroy(mymtd);
259 +               if (parsed_parts)
260 +                       kfree(parsed_parts);
261 +       }
262 +       if (pxa27x_map.virt)
263 +               iounmap((void *)pxa27x_map.virt);
264 +       if (pxa27x_map.cached)
265 +               iounmap((void *)pxa27x_map.cached);
266 +       return;
267 +}
268 +
269 +module_init(init_pxa27x);
270 +module_exit(cleanup_pxa27x);
271 +
272 +MODULE_LICENSE("GPL");
273 +MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
274 +MODULE_DESCRIPTION("MTD map driver for Motorola EZX platform");