18 #include <linux/module.h>
19 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/string.h>
23 #include <linux/slab.h>
25 #include <linux/device.h>
33 #include <mach/hardware.h>
36 #include <linux/reboot.h>
44 static inline unsigned long flash_bank_setup(
struct map_info *
map,
unsigned long ofs)
46 unsigned long (*set_bank)(
unsigned long) =
49 return (set_bank ? set_bank(ofs) : ofs);
58 static int erratum44_workaround = 0;
62 if (erratum44_workaround) {
69 #define address_fix8_write(x) (x)
76 val.
x[0] = *((
u8 *)(map->
map_priv_1 + flash_bank_setup(map, ofs)));
85 static void ixp2000_flash_copy_from(
struct map_info *
map,
void *to,
88 from = flash_bank_setup(map, from);
93 static void ixp2000_flash_write8(
struct map_info *map,
map_word d,
unsigned long ofs)
96 flash_bank_setup(map, ofs))) = d.
x[0];
99 static void ixp2000_flash_copy_to(
struct map_info *map,
unsigned long to,
102 to = flash_bank_setup(map, to);
115 platform_set_drvdata(dev,
NULL);
124 if (info->
map.map_priv_1)
141 static const char *probes[] = {
"RedBoot",
"cmdlinepart",
NULL };
142 struct ixp2000_flash_data *ixp_data = dev->
dev.platform_data;
145 unsigned long window_size;
151 plat = ixp_data->platform_data;
155 window_size = resource_size(dev->
resource);
156 dev_info(&dev->
dev,
"Probe of IXP2000 flash(%d banks x %dMiB)\n",
157 ixp_data->nr_banks, ((
u32)window_size >> 20));
159 if (plat->
width != 1) {
160 dev_err(&dev->
dev,
"IXP2000 MTD map only supports 8-bit mode, asking for %d\n",
171 platform_set_drvdata(dev, info);
179 info->
map.size = ixp_data->nr_banks * window_size;
180 info->
map.bankwidth = 1;
185 info->
map.map_priv_2 = (
unsigned long) ixp_data->bank_setup;
187 info->
map.name = dev_name(&dev->
dev);
188 info->
map.read = ixp2000_flash_read8;
189 info->
map.write = ixp2000_flash_write8;
190 info->
map.copy_from = ixp2000_flash_copy_from;
191 info->
map.copy_to = ixp2000_flash_copy_to;
195 dev_name(&dev->
dev));
197 dev_err(&dev->
dev,
"Could not reserve memory region\n");
202 info->
map.map_priv_1 =
205 if (!info->
map.map_priv_1) {
206 dev_err(&dev->
dev,
"Failed to ioremap flash region\n");
211 #if defined(__ARMEB__)
216 erratum44_workaround = ixp2000_has_broken_slowport();
218 erratum44_workaround ?
"enabled" :
"disabled");
236 ixp2000_flash_remove(dev);
241 .probe = ixp2000_flash_probe,
242 .remove = ixp2000_flash_remove,
244 .name =
"IXP2000-Flash",