mtd/drivers/mtd/maps dc21285.c, 1.19, 1.20 elan-104nc.c, 1.20,
1.21 ichxrom.c, 1.3, 1.4 ixp4xx.c, 1.2, 1.3 octagon-5066.c,
1.25, 1.26 pci.c, 1.7, 1.8 pcmciamtd.c, 1.50, 1.51 sbc8240.c,
1.3, 1.4 sbc_gxx.c, 1.28, 1.29 tsunami_flash.c, 1.7,
1.8 vmax301.c, 1.29, 1.30
David Woodhouse
dwmw2 at infradead.org
Mon Jul 12 18:38:32 EDT 2004
Update of /home/cvs/mtd/drivers/mtd/maps
In directory phoenix.infradead.org:/tmp/cvs-serv26871
Modified Files:
dc21285.c elan-104nc.c ichxrom.c ixp4xx.c octagon-5066.c pci.c
pcmciamtd.c sbc8240.c sbc_gxx.c tsunami_flash.c vmax301.c
Log Message:
fix out-of-line map drivers for new map access
Index: dc21285.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/dc21285.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- dc21285.c 12 Jul 2004 21:59:44 -0000 1.19
+++ dc21285.c 12 Jul 2004 22:38:29 -0000 1.20
@@ -53,93 +53,84 @@
#define nw_en_write() do { } while (0)
#endif
-__u8 dc21285_read8(struct map_info *map, unsigned long ofs)
+static map_word dc21285_read8(struct map_info *map, unsigned long ofs)
{
- return *(__u8*)(map->map_priv_1 + ofs);
+ return *(uint8_t*)(map->map_priv_1 + ofs);
}
-__u16 dc21285_read16(struct map_info *map, unsigned long ofs)
+static map_word dc21285_read16(struct map_info *map, unsigned long ofs)
{
- return *(__u16*)(map->map_priv_1 + ofs);
+ return *(uint16_t*)(map->map_priv_1 + ofs);
}
-__u32 dc21285_read32(struct map_info *map, unsigned long ofs)
+static map_word dc21285_read32(struct map_info *map, unsigned long ofs)
{
- return *(__u32*)(map->map_priv_1 + ofs);
+ return *(uint32_t*)(map->map_priv_1 + ofs);
}
-void dc21285_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+static void dc21285_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
memcpy(to, (void*)(map->map_priv_1 + from), len);
}
-void dc21285_write8(struct map_info *map, __u8 d, unsigned long adr)
+static void dc21285_write(struct map_info *map, map_word d, unsigned long adr)
{
if (machine_is_netwinder())
nw_en_write();
*CSR_ROMWRITEREG = adr & 3;
adr &= ~3;
- *(__u8*)(map->map_priv_1 + adr) = d;
+ *(uint8_t*)(map->map_priv_1 + adr) = d.x[0];
}
-void dc21285_write16(struct map_info *map, __u16 d, unsigned long adr)
+static void dc21285_write16(struct map_info *map, map_word d, unsigned long adr)
{
if (machine_is_netwinder())
nw_en_write();
*CSR_ROMWRITEREG = adr & 3;
adr &= ~3;
- *(__u16*)(map->map_priv_1 + adr) = d;
+ *(uint16_t*)(map->map_priv_1 + adr) = d.x[0];
}
-void dc21285_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void dc21285_write32(struct map_info *map, map_word d, unsigned long adr)
{
if (machine_is_netwinder())
nw_en_write();
- *(__u32*)(map->map_priv_1 + adr) = d;
+ *(uint32_t*)(map->map_priv_1 + adr) = d.x[0];
}
-void dc21285_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+static void dc21285_copy_to_32(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
- switch (map->bankwidth) {
- case 4:
- while (len > 0) {
- __u32 d = *((__u32*)from)++;
- dc21285_write32(map, d, to);
- to += 4;
- len -= 4;
- }
- break;
- case 2:
- while (len > 0) {
- __u16 d = *((__u16*)from)++;
- dc21285_write16(map, d, to);
- to += 2;
- len -= 2;
- }
- break;
- case 1:
- while (len > 0) {
- __u8 d = *((__u8*)from)++;
- dc21285_write8(map, d, to);
- to++;
- len--;
- }
- break;
+ while (len > 0) {
+ uint32_t d = *((uint32_t*)from)++;
+ dc21285_write32(map, d, to);
+ to += 4;
+ len -= 4;
+ }
+}
+
+static void dc21285_copy_to_16(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+{
+ while (len > 0) {
+ uint16_t d = *((uint16_t*)from)++;
+ dc21285_write16(map, d, to);
+ to += 2;
+ len -= 2;
}
}
-struct map_info dc21285_map = {
+static void dc21285_copy_to_8(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+{
+ uint8_t d = *((uint8_t*)from)++;
+ dc21285_write8(map, d, to);
+ to++;
+ len--;
+}
+
+static struct map_info dc21285_map = {
.name = "DC21285 flash",
.phys = NO_XIP,
.size = 16*1024*1024,
- .read8 = dc21285_read8,
- .read16 = dc21285_read16,
- .read32 = dc21285_read32,
.copy_from = dc21285_copy_from,
- .write8 = dc21285_write8,
- .write16 = dc21285_write16,
- .write32 = dc21285_write32,
- .copy_to = dc21285_copy_to
};
@@ -149,7 +140,7 @@
static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
#endif
-int __init init_dc21285(void)
+static int __init init_dc21285(void)
{
#ifdef CONFIG_MTD_PARTITIONS
@@ -160,13 +151,22 @@
switch (*CSR_SA110_CNTL & (3<<14)) {
case SA110_CNTL_ROMWIDTH_8:
dc21285_map.bankwidth = 1;
+ dc21285_map.read = dc21285_read8;
+ dc21285_map.write = dc21285_write8;
+ dc21285_map.copy_to = dc21285_copy_to_8;
break;
case SA110_CNTL_ROMWIDTH_16:
dc21285_map.bankwidth = 2;
+ dc21285_map.read = dc21285_read16;
+ dc21285_map.write = dc21285_write16;
+ dc21285_map.copy_to = dc21285_copy_to_16;
break;
case SA110_CNTL_ROMWIDTH_32:
dc21285_map.bankwidth = 4;
break;
+ dc21285_map.read = dc21285_read32;
+ dc21285_map.write = dc21285_write32;
+ dc21285_map.copy_to = dc21285_copy_to_32;
default:
printk (KERN_ERR "DC21285 flash: undefined bankwidth\n");
return -ENXIO;
Index: elan-104nc.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/elan-104nc.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- elan-104nc.c 12 Jul 2004 21:59:44 -0000 1.20
+++ elan-104nc.c 12 Jul 2004 22:38:29 -0000 1.21
@@ -107,32 +107,12 @@
}
-static __u8 elan_104nc_read8(struct map_info *map, unsigned long ofs)
+static map_word elan_104nc_read16(struct map_info *map, unsigned long ofs)
{
- __u8 ret;
+ map_word ret;
spin_lock(&elan_104nc_spin);
elan_104nc_page(map, ofs);
- ret = readb(iomapadr + (ofs & WINDOW_MASK));
- spin_unlock(&elan_104nc_spin);
- return ret;
-}
-
-static __u16 elan_104nc_read16(struct map_info *map, unsigned long ofs)
-{
- __u16 ret;
- spin_lock(&elan_104nc_spin);
- elan_104nc_page(map, ofs);
- ret = readw(iomapadr + (ofs & WINDOW_MASK));
- spin_unlock(&elan_104nc_spin);
- return ret;
-}
-
-static __u32 elan_104nc_read32(struct map_info *map, unsigned long ofs)
-{
- __u32 ret;
- spin_lock(&elan_104nc_spin);
- elan_104nc_page(map, ofs);
- ret = readl(iomapadr + (ofs & WINDOW_MASK));
+ ret.x[0] = readw(iomapadr + (ofs & WINDOW_MASK));
spin_unlock(&elan_104nc_spin);
return ret;
}
@@ -154,27 +134,11 @@
}
}
-static void elan_104nc_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
- spin_lock(&elan_104nc_spin);
- elan_104nc_page(map, adr);
- writeb(d, iomapadr + (adr & WINDOW_MASK));
- spin_unlock(&elan_104nc_spin);
-}
-
-static void elan_104nc_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
- spin_lock(&elan_104nc_spin);
- elan_104nc_page(map, adr);
- writew(d, iomapadr + (adr & WINDOW_MASK));
- spin_unlock(&elan_104nc_spin);
-}
-
-static void elan_104nc_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void elan_104nc_write16(struct map_info *map, map_word d, unsigned long adr)
{
spin_lock(&elan_104nc_spin);
elan_104nc_page(map, adr);
- writel(d, iomapadr + (adr & WINDOW_MASK));
+ writew(d.x[0], iomapadr + (adr & WINDOW_MASK));
spin_unlock(&elan_104nc_spin);
}
@@ -202,13 +166,9 @@
of flash so the cfi probe routines find all
the chips */
.bankwidth = 2,
- .read8 = elan_104nc_read8,
- .read16 = elan_104nc_read16,
- .read32 = elan_104nc_read32,
+ .read = elan_104nc_read16,
.copy_from = elan_104nc_copy_from,
- .write8 = elan_104nc_write8,
- .write16 = elan_104nc_write16,
- .write32 = elan_104nc_write32,
+ .write = elan_104nc_write16,
.copy_to = elan_104nc_copy_to
};
Index: ichxrom.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/ichxrom.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ichxrom.c 12 Jul 2004 21:59:44 -0000 1.3
+++ ichxrom.c 12 Jul 2004 22:38:29 -0000 1.4
@@ -57,19 +57,11 @@
return addr - map->map_priv_1 + ICHX_FWH_REGION_START;
}
-static __u8 ichxrom_read8(struct map_info *map, unsigned long ofs)
+static map_word ichxrom_read8(struct map_info *map, unsigned long ofs)
{
- return __raw_readb(addr(map, ofs));
-}
-
-static __u16 ichxrom_read16(struct map_info *map, unsigned long ofs)
-{
- return __raw_readw(addr(map, ofs));
-}
-
-static __u32 ichxrom_read32(struct map_info *map, unsigned long ofs)
-{
- return __raw_readl(addr(map, ofs));
+ map_word val;
+ val.x[0] = __raw_readb(addr(map, ofs));
+ return val;
}
static void ichxrom_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
@@ -77,21 +69,9 @@
memcpy_fromio(to, addr(map, from), len);
}
-static void ichxrom_write8(struct map_info *map, __u8 d, unsigned long ofs)
-{
- __raw_writeb(d, addr(map,ofs));
- mb();
-}
-
-static void ichxrom_write16(struct map_info *map, __u16 d, unsigned long ofs)
-{
- __raw_writew(d, addr(map, ofs));
- mb();
-}
-
-static void ichxrom_write32(struct map_info *map, __u32 d, unsigned long ofs)
+static void ichxrom_write8(struct map_info *map, map_word d, unsigned long ofs)
{
- __raw_writel(d, addr(map, ofs));
+ __raw_writeb(d.x[0], addr(map,ofs));
mb();
}
@@ -106,13 +86,9 @@
.phys = NO_XIP,
.size = 0,
.bankwidth = 1,
- .read8 = ichxrom_read8,
- .read16 = ichxrom_read16,
- .read32 = ichxrom_read32,
+ .read = ichxrom_read8,
.copy_from = ichxrom_copy_from,
- .write8 = ichxrom_write8,
- .write16 = ichxrom_write16,
- .write32 = ichxrom_write32,
+ .write = ichxrom_write8,
.copy_to = ichxrom_copy_to,
/* Firmware hubs only use vpp when being programmed
* in a factory setting. So in-place programming
Index: ixp4xx.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/ixp4xx.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ixp4xx.c 12 Jul 2004 21:59:44 -0000 1.2
+++ ixp4xx.c 12 Jul 2004 22:38:29 -0000 1.3
@@ -39,10 +39,11 @@
#define BYTE1(h) ((h) & 0xFF)
#endif
-static __u16
-ixp4xx_read16(struct map_info *map, unsigned long ofs)
+static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
{
- return *(__u16 *) (map->map_priv_1 + ofs);
+ map_word val;
+ val.x[0] = *(__u16 *) (map->map_priv_1 + ofs);
+ return val;
}
/*
@@ -50,9 +51,8 @@
* when attached to a 16-bit wide device (such as the 28F128J3A),
* so we can't just memcpy_fromio().
*/
-static void
-ixp4xx_copy_from(struct map_info *map, void *to,
- unsigned long from, ssize_t len)
+static void ixp4xx_copy_from(struct map_info *map, void *to,
+ unsigned long from, ssize_t len)
{
int i;
u8 *dest = (u8 *) to;
@@ -69,10 +69,9 @@
dest[len - 1] = BYTE0(src[i]);
}
-static void
-ixp4xx_write16(struct map_info *map, __u16 d, unsigned long adr)
+static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
{
- *(__u16 *) (map->map_priv_1 + adr) = d;
+ *(__u16 *) (map->map_priv_1 + adr) = d.x[0];
}
struct ixp4xx_flash_info {
@@ -84,8 +83,7 @@
static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
-static int
-ixp4xx_flash_remove(struct device *_dev)
+static int ixp4xx_flash_remove(struct device *_dev)
{
struct platform_device *dev = to_platform_device(_dev);
struct flash_platform_data *plat = dev->dev.platform_data;
@@ -170,8 +168,8 @@
*/
info->map.bankwidth = 2;
info->map.name = dev->dev.bus_id;
- info->map.read16 = ixp4xx_read16,
- info->map.write16 = ixp4xx_write16,
+ info->map.read = ixp4xx_read16,
+ info->map.write = ixp4xx_write16,
info->map.copy_from = ixp4xx_copy_from,
info->res = request_mem_region(dev->resource->start,
Index: octagon-5066.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/octagon-5066.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- octagon-5066.c 12 Jul 2004 21:59:44 -0000 1.25
+++ octagon-5066.c 12 Jul 2004 22:38:29 -0000 1.26
@@ -62,32 +62,12 @@
}
-static __u8 oct5066_read8(struct map_info *map, unsigned long ofs)
+static map_word oct5066_read8(struct map_info *map, unsigned long ofs)
{
- __u8 ret;
+ map_word ret;
spin_lock(&oct5066_spin);
oct5066_page(map, ofs);
- ret = readb(iomapadr + (ofs & WINDOW_MASK));
- spin_unlock(&oct5066_spin);
- return ret;
-}
-
-static __u16 oct5066_read16(struct map_info *map, unsigned long ofs)
-{
- __u16 ret;
- spin_lock(&oct5066_spin);
- oct5066_page(map, ofs);
- ret = readw(iomapadr + (ofs & WINDOW_MASK));
- spin_unlock(&oct5066_spin);
- return ret;
-}
-
-static __u32 oct5066_read32(struct map_info *map, unsigned long ofs)
-{
- __u32 ret;
- spin_lock(&oct5066_spin);
- oct5066_page(map, ofs);
- ret = readl(iomapadr + (ofs & WINDOW_MASK));
+ ret.x[0] = readb(iomapadr + (ofs & WINDOW_MASK));
spin_unlock(&oct5066_spin);
return ret;
}
@@ -109,27 +89,11 @@
}
}
-static void oct5066_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
- spin_lock(&oct5066_spin);
- oct5066_page(map, adr);
- writeb(d, iomapadr + (adr & WINDOW_MASK));
- spin_unlock(&oct5066_spin);
-}
-
-static void oct5066_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
- spin_lock(&oct5066_spin);
- oct5066_page(map, adr);
- writew(d, iomapadr + (adr & WINDOW_MASK));
- spin_unlock(&oct5066_spin);
-}
-
-static void oct5066_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void oct5066_write8(struct map_info *map, map_word d, unsigned long adr)
{
spin_lock(&oct5066_spin);
oct5066_page(map, adr);
- writel(d, iomapadr + (adr & WINDOW_MASK));
+ writeb(d.x[0], iomapadr + (adr & WINDOW_MASK));
spin_unlock(&oct5066_spin);
}
@@ -156,13 +120,9 @@
.phys = NO_XIP,
.size = 512 * 1024,
.bankwidth = 1,
- .read8 = oct5066_read8,
- .read16 = oct5066_read16,
- .read32 = oct5066_read32,
+ .read = oct5066_read8,
.copy_from = oct5066_copy_from,
- .write8 = oct5066_write8,
- .write16 = oct5066_write16,
- .write32 = oct5066_write32,
+ .write = oct5066_write8,
.copy_to = oct5066_copy_to,
.map_priv_1 = 1<<6
},
@@ -171,13 +131,9 @@
.phys = NO_XIP,
.size = 2 * 1024 * 1024,
.bankwidth = 1,
- .read8 = oct5066_read8,
- .read16 = oct5066_read16,
- .read32 = oct5066_read32,
+ .read = oct5066_read8,
.copy_from = oct5066_copy_from,
- .write8 = oct5066_write8,
- .write16 = oct5066_write16,
- .write32 = oct5066_write32,
+ .write = oct5066_write8,
.copy_to = oct5066_copy_to,
.map_priv_1 = 2<<6
}
Index: pci.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/pci.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- pci.c 12 Jul 2004 21:59:44 -0000 1.7
+++ pci.c 12 Jul 2004 22:38:29 -0000 1.8
@@ -39,6 +39,74 @@
struct pci_dev *dev;
};
+static map_word mtd_pci_read8(struct map_info *_map, unsigned long ofs)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+ map_word val;
+ val.x[0]= readb(map->base + map->translate(map, ofs));
+// printk("read8 : %08lx => %02x\n", ofs, val.x[0]);
+ return val;
+}
+
+#if 0
+static map_word mtd_pci_read16(struct map_info *_map, unsigned long ofs)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+ map_word val;
+ val.x[0] = readw(map->base + map->translate(map, ofs));
+// printk("read16: %08lx => %04x\n", ofs, val.x[0]);
+ return val;
+}
+#endif
+static map_word mtd_pci_read32(struct map_info *_map, unsigned long ofs)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+ map_word val;
+ val.x[0] = readl(map->base + map->translate(map, ofs));
+// printk("read32: %08lx => %08x\n", ofs, val.x[0]);
+ return val;
+}
+
+static void mtd_pci_copyfrom(struct map_info *_map, void *to, unsigned long from, ssize_t len)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+ memcpy_fromio(to, map->base + map->translate(map, from), len);
+}
+
+static void mtd_pci_write8(struct map_info *_map, map_word val, unsigned long ofs)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+// printk("write8 : %08lx <= %02x\n", ofs, val.x[0]);
+ writeb(val.x[0], map->base + map->translate(map, ofs));
+}
+
+#if 0
+static void mtd_pci_write16(struct map_info *_map, map_word val, unsigned long ofs)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+// printk("write16: %08lx <= %04x\n", ofs, val.x[0]);
+ writew(val.x[0], map->base + map->translate(map, ofs));
+}
+#endif
+static void mtd_pci_write32(struct map_info *_map, map_word val, unsigned long ofs)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+// printk("write32: %08lx <= %08x\n", ofs, val.x[0]);
+ writel(val.x[0], map->base + map->translate(map, ofs));
+}
+
+static void mtd_pci_copyto(struct map_info *_map, unsigned long to, const void *from, ssize_t len)
+{
+ struct map_pci_info *map = (struct map_pci_info *)_map;
+ memcpy_toio(map->base + map->translate(map, to), from, len);
+}
+
+static struct map_info mtd_pci_map = {
+ .phys = NO_XIP,
+ .copy_from = mtd_pci_copyfrom,
+ .copy_to = mtd_pci_copyto,
+};
+
/*
* Intel IOP80310 Flash driver
*/
@@ -49,6 +117,9 @@
u32 win_base;
map->map.bankwidth = 1;
+ map->map.read = mtd_pci_read8,
+ map->map.write = mtd_pci_write8,
+
map->map.size = 0x00800000;
map->base = ioremap_nocache(pci_resource_start(dev, 0),
pci_resource_len(dev, 0));
@@ -148,6 +219,8 @@
return -ENXIO;
map->map.bankwidth = 4;
+ map->map.read = mtd_pci_read32,
+ map->map.write = mtd_pci_write32,
map->map.size = len;
map->base = ioremap_nocache(base, len);
@@ -215,75 +288,6 @@
* Generic code follows.
*/
-static u8 mtd_pci_read8(struct map_info *_map, unsigned long ofs)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
- u8 val = readb(map->base + map->translate(map, ofs));
-// printk("read8 : %08lx => %02x\n", ofs, val);
- return val;
-}
-
-static u16 mtd_pci_read16(struct map_info *_map, unsigned long ofs)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
- u16 val = readw(map->base + map->translate(map, ofs));
-// printk("read16: %08lx => %04x\n", ofs, val);
- return val;
-}
-
-static u32 mtd_pci_read32(struct map_info *_map, unsigned long ofs)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
- u32 val = readl(map->base + map->translate(map, ofs));
-// printk("read32: %08lx => %08x\n", ofs, val);
- return val;
-}
-
-static void mtd_pci_copyfrom(struct map_info *_map, void *to, unsigned long from, ssize_t len)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
- memcpy_fromio(to, map->base + map->translate(map, from), len);
-}
-
-static void mtd_pci_write8(struct map_info *_map, u8 val, unsigned long ofs)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
-// printk("write8 : %08lx <= %02x\n", ofs, val);
- writeb(val, map->base + map->translate(map, ofs));
-}
-
-static void mtd_pci_write16(struct map_info *_map, u16 val, unsigned long ofs)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
-// printk("write16: %08lx <= %04x\n", ofs, val);
- writew(val, map->base + map->translate(map, ofs));
-}
-
-static void mtd_pci_write32(struct map_info *_map, u32 val, unsigned long ofs)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
-// printk("write32: %08lx <= %08x\n", ofs, val);
- writel(val, map->base + map->translate(map, ofs));
-}
-
-static void mtd_pci_copyto(struct map_info *_map, unsigned long to, const void *from, ssize_t len)
-{
- struct map_pci_info *map = (struct map_pci_info *)_map;
- memcpy_toio(map->base + map->translate(map, to), from, len);
-}
-
-static struct map_info mtd_pci_map = {
- .phys = NO_XIP,
- .read8 = mtd_pci_read8,
- .read16 = mtd_pci_read16,
- .read32 = mtd_pci_read32,
- .copy_from = mtd_pci_copyfrom,
- .write8 = mtd_pci_write8,
- .write16 = mtd_pci_write16,
- .write32 = mtd_pci_write32,
- .copy_to = mtd_pci_copyto,
-};
-
static int __devinit
mtd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
Index: pcmciamtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/pcmciamtd.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- pcmciamtd.c 12 Jul 2004 21:59:44 -0000 1.50
+++ pcmciamtd.c 12 Jul 2004 22:38:29 -0000 1.51
@@ -135,32 +135,32 @@
}
-static u8 pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
+static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
{
caddr_t addr;
- u8 d;
+ map_word d = {{0}};
addr = remap_window(map, ofs);
if(!addr)
- return 0;
+ return d;
- d = readb(addr);
- DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, addr, d);
+ d.x[0] = readb(addr);
+ DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, addr, d.x[0]);
return d;
}
-static u16 pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
+static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
{
caddr_t addr;
- u16 d;
+ map_word d = {{0}};
addr = remap_window(map, ofs);
if(!addr)
- return 0;
+ return d;
- d = readw(addr);
- DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, addr, d);
+ d.x[0] = readw(addr);
+ DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, addr, d.x[0]);
return d;
}
@@ -191,26 +191,26 @@
}
-static void pcmcia_write8_remap(struct map_info *map, u8 d, unsigned long adr)
+static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long adr)
{
caddr_t addr = remap_window(map, adr);
if(!addr)
return;
- DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, addr, d);
- writeb(d, addr);
+ DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, addr, d.x[0]);
+ writeb(d.x[0], addr);
}
-static void pcmcia_write16_remap(struct map_info *map, u16 d, unsigned long adr)
+static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long adr)
{
caddr_t addr = remap_window(map, adr);
if(!addr)
return;
- DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, addr, d);
- writew(d, addr);
+ DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, addr, d.x[0]);
+ writew(d.x[0], addr);
}
@@ -244,30 +244,30 @@
#define DEV_REMOVED(x) (!(*(u_int *)x->map_priv_1 & DEV_PRESENT))
-static u8 pcmcia_read8(struct map_info *map, unsigned long ofs)
+static map_word pcmcia_read8(struct map_info *map, unsigned long ofs)
{
caddr_t win_base = (caddr_t)map->map_priv_2;
- u8 d;
+ map_word d = {{0}};
if(DEV_REMOVED(map))
- return 0;
+ return d;
- d = readb(win_base + ofs);
- DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d);
+ d.x[0] = readb(win_base + ofs);
+ DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d.x[0]);
return d;
}
-static u16 pcmcia_read16(struct map_info *map, unsigned long ofs)
+static map_word pcmcia_read16(struct map_info *map, unsigned long ofs)
{
caddr_t win_base = (caddr_t)map->map_priv_2;
- u16 d;
+ map_word d = {{0}};
if(DEV_REMOVED(map))
- return 0;
+ return d;
- d = readw(win_base + ofs);
- DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d);
+ d.x[0] = readw(win_base + ofs);
+ DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d.x[0]);
return d;
}
@@ -439,9 +439,9 @@
case CISTPL_DEVICE_GEO: {
cistpl_device_geo_t *t = &parse.device_geo;
int i;
- dev->pcmcia_map.bankwidth = t->geo[0].bankwidth;
+ dev->pcmcia_map.bankwidth = t->geo[0].buswidth;
for(i = 0; i < t->ngeo; i++) {
- DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].bankwidth);
+ DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth);
DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block);
DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block);
DEBUG(2, "region: %d write_block = %u", i, t->geo[i].write_block);
@@ -522,12 +522,15 @@
card_settings(dev, link, &new_name);
dev->pcmcia_map.phys = NO_XIP;
- dev->pcmcia_map.read8 = pcmcia_read8_remap;
- dev->pcmcia_map.read16 = pcmcia_read16_remap;
dev->pcmcia_map.copy_from = pcmcia_copy_from_remap;
- dev->pcmcia_map.write8 = pcmcia_write8_remap;
- dev->pcmcia_map.write16 = pcmcia_write16_remap;
dev->pcmcia_map.copy_to = pcmcia_copy_to_remap;
+ if (dev->pcmcia_map.bankwidth == 1) {
+ dev->pcmcia_map.read = pcmcia_read8_remap;
+ dev->pcmcia_map.write = pcmcia_write8_remap;
+ } else {
+ dev->pcmcia_map.read = pcmcia_read16_remap;
+ dev->pcmcia_map.write = pcmcia_write16_remap;
+ }
if(setvpp == 1)
dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp;
@@ -657,11 +660,14 @@
DEBUG(1, "Using non remapping memory functions");
dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->link.state);
dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base;
- dev->pcmcia_map.read8 = pcmcia_read8;
- dev->pcmcia_map.read16 = pcmcia_read16;
+ if (dev->pcmcia_map.bankwidth == 1) {
+ dev->pcmcia_map.read = pcmcia_read8;
+ dev->pcmcia_map.write = pcmcia_write8;
+ } else {
+ dev->pcmcia_map.read = pcmcia_read16;
+ dev->pcmcia_map.write = pcmcia_write16;
+ }
dev->pcmcia_map.copy_from = pcmcia_copy_from;
- dev->pcmcia_map.write8 = pcmcia_write8;
- dev->pcmcia_map.write16 = pcmcia_write16;
dev->pcmcia_map.copy_to = pcmcia_copy_to;
}
Index: sbc8240.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/sbc8240.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sbc8240.c 12 Jul 2004 21:59:45 -0000 1.3
+++ sbc8240.c 12 Jul 2004 22:38:29 -0000 1.4
@@ -53,187 +53,16 @@
#define MTDID "sbc8240-%d" /* for mtdparts= partitioning */
-static __u8 sbc8240_read8 (struct map_info *map, unsigned long ofs)
-{
- return __raw_readb(map->map_priv_1 + ofs);
-}
-
-static __u16 sbc8240_read16 (struct map_info *map, unsigned long ofs)
-{
- return __raw_readw(map->map_priv_1 + ofs);
-}
-
-static __u32 sbc8240_read32 (struct map_info *map, unsigned long ofs)
-{
- return __raw_readl(map->map_priv_1 + ofs);
-}
-
-unsigned long long result64;
-
-static __u64 sbc8240_read64 (struct map_info *map, unsigned long ofs)
-{
- unsigned long flags, msr, saved_msr;
- volatile long saved_fr[2];
- volatile unsigned long long result;
- volatile unsigned long *p;
-
- save_flags(flags);
- cli();
-
- /* turn off floating point unavailable exceptions */
-
- __asm__ __volatile__ (
- "mfmsr %0"
- : "=r" (msr) :);
-
- saved_msr = msr;
- msr |= MSR_FP;
- msr &= ~(MSR_FE0 | MSR_FE1);
-
- __asm__ __volatile__ (
- "mtmsr %0\n"
- "isync\n"
- : : "r" (msr));
-
- /* read the data via a floating point register */
-
- ofs = map->map_priv_1 + ofs;
- p = (unsigned long *) &result64;
-
- __asm__ __volatile__ (
- "lfd 1,0(%1)\n"
- "stfd 1,0(%0)\n"
- : : "r" (p), "r" (ofs)
- );
-
- /* restore state */
-
- __asm__ __volatile__ (
- "mtmsr %0\n"
- "isync\n"
- : : "r" (saved_msr));
-
- restore_flags(flags);
-
- p = (unsigned long *) &result64;
- debugk("sbc8240_read64 ofs 0x%x result 0x%08x%08x\n", ofs, *p, *(p+1));
-
- return result64;
-}
-
-static void sbc8240_copy_from (struct map_info *map,
- void *to, unsigned long from, ssize_t len)
-{
- memcpy_fromio (to, (void *) (map->map_priv_1 + from), len);
-}
-
-static void sbc8240_write8 (struct map_info *map, __u8 d, unsigned long adr)
-{
- __raw_writeb(d, map->map_priv_1 + adr);
- mb();
-}
-
-static void sbc8240_write16 (struct map_info *map, __u16 d,
- unsigned long adr)
-{
- __raw_writew(d, map->map_priv_1 + adr);
- mb();
-}
-
-static void sbc8240_write32 (struct map_info *map, __u32 d,
- unsigned long adr)
-{
- __raw_writel(d, map->map_priv_1 + adr);
- mb();
-}
-
-static void sbc8240_write64 (struct map_info *map, __u64 data,
- unsigned long adr)
-{
- unsigned long long tmp;
- unsigned long flags, msr, saved_msr, *p;
- volatile long saved_fr[2];
-
- save_flags(flags);
- cli();
-
- /* turn off floating point unavailable exceptions */
-
- __asm__ __volatile__ (
- "mfmsr %0"
- : "=r" (msr) :);
-
- saved_msr = msr;
- msr |= MSR_FP;
- msr &= ~(MSR_FE0 | MSR_FE1);
-
- __asm__ __volatile__ (
- "mtmsr %0\n"
- "isync\n"
- : : "r" (msr));
-
-
- /* write the data via a floating point register */
-
- tmp = data;
- p = (unsigned long *) &tmp;
- adr = map->map_priv_1 + adr;
- debugk("sbc8240_write64 adr 0x%x data 0x%08x%08x\n", adr, *p, *(p+1));
-
- __asm__ __volatile__ (
- "stfd 1,0(%2)\n"
- "lfd 1,0(%0)\n"
- "stfd 1,0(%1)\n"
- "lfd 1,0(%2)\n"
- : : "r" (p), "r" (adr), "b" (saved_fr)
- );
-
- /* restore state */
-
- __asm__ __volatile__ (
- "mtmsr %0\n"
- "isync\n"
- : : "r" (saved_msr));
-
- restore_flags(flags);
-}
-
-static void sbc8240_copy_to (struct map_info *map,
- unsigned long to, const void *from, ssize_t len)
-{
- memcpy_toio ((void *) (map->map_priv_1 + to), from, len);
-}
-
static struct map_info sbc8240_map[2] = {
{
.name = "sbc8240 Flash Bank #0",
.size = WINDOW_SIZE0,
.bankwidth = BUSWIDTH0,
- .read8 = sbc8240_read8,
- .read16 = sbc8240_read16,
- .read32 = sbc8240_read32,
- .read64 = sbc8240_read64,
- .copy_from = sbc8240_copy_from,
- .write8 = sbc8240_write8,
- .write16 = sbc8240_write16,
- .write32 = sbc8240_write32,
- .write64 = sbc8240_write64,
- .copy_to = sbc8240_copy_to
},
{
.name = "sbc8240 Flash Bank #1",
.size = WINDOW_SIZE1,
.bankwidth = BUSWIDTH1,
- .read8 = sbc8240_read8,
- .read16 = sbc8240_read16,
- .read32 = sbc8240_read32,
- .read64 = sbc8240_read64,
- .copy_from = sbc8240_copy_from,
- .write8 = sbc8240_write8,
- .write16 = sbc8240_write16,
- .write32 = sbc8240_write32,
- .write64 = sbc8240_write64,
- .copy_to = sbc8240_copy_to
}
};
@@ -342,6 +171,7 @@
printk (MSG_PREFIX "failed to ioremap\n");
return -EIO;
}
+ simple_map_init(&sbc8240_mtd[i]);
sbc8240_mtd[i] = do_map_probe("jedec_probe", &sbc8240_map[i]);
Index: sbc_gxx.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/sbc_gxx.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- sbc_gxx.c 12 Jul 2004 21:59:45 -0000 1.28
+++ sbc_gxx.c 12 Jul 2004 22:38:29 -0000 1.29
@@ -114,32 +114,12 @@
}
-static __u8 sbc_gxx_read8(struct map_info *map, unsigned long ofs)
+static map_word sbc_gxx_read8(struct map_info *map, unsigned long ofs)
{
- __u8 ret;
+ map_word ret;
spin_lock(&sbc_gxx_spin);
sbc_gxx_page(map, ofs);
- ret = readb(iomapadr + (ofs & WINDOW_MASK));
- spin_unlock(&sbc_gxx_spin);
- return ret;
-}
-
-static __u16 sbc_gxx_read16(struct map_info *map, unsigned long ofs)
-{
- __u16 ret;
- spin_lock(&sbc_gxx_spin);
- sbc_gxx_page(map, ofs);
- ret = readw(iomapadr + (ofs & WINDOW_MASK));
- spin_unlock(&sbc_gxx_spin);
- return ret;
-}
-
-static __u32 sbc_gxx_read32(struct map_info *map, unsigned long ofs)
-{
- __u32 ret;
- spin_lock(&sbc_gxx_spin);
- sbc_gxx_page(map, ofs);
- ret = readl(iomapadr + (ofs & WINDOW_MASK));
+ ret.x[0] = readb(iomapadr + (ofs & WINDOW_MASK));
spin_unlock(&sbc_gxx_spin);
return ret;
}
@@ -161,27 +141,11 @@
}
}
-static void sbc_gxx_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
- spin_lock(&sbc_gxx_spin);
- sbc_gxx_page(map, adr);
- writeb(d, iomapadr + (adr & WINDOW_MASK));
- spin_unlock(&sbc_gxx_spin);
-}
-
-static void sbc_gxx_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
- spin_lock(&sbc_gxx_spin);
- sbc_gxx_page(map, adr);
- writew(d, iomapadr + (adr & WINDOW_MASK));
- spin_unlock(&sbc_gxx_spin);
-}
-
-static void sbc_gxx_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void sbc_gxx_write8(struct map_info *map, map_word d, unsigned long adr)
{
spin_lock(&sbc_gxx_spin);
sbc_gxx_page(map, adr);
- writel(d, iomapadr + (adr & WINDOW_MASK));
+ writeb(d.x[0], iomapadr + (adr & WINDOW_MASK));
spin_unlock(&sbc_gxx_spin);
}
@@ -209,13 +173,9 @@
of flash so the cfi probe routines find all
the chips */
.bankwidth = 1,
- .read8 = sbc_gxx_read8,
- .read16 = sbc_gxx_read16,
- .read32 = sbc_gxx_read32,
+ .read = sbc_gxx_read8,
.copy_from = sbc_gxx_copy_from,
- .write8 = sbc_gxx_write8,
- .write16 = sbc_gxx_write16,
- .write32 = sbc_gxx_write32,
+ .write = sbc_gxx_write8,
.copy_to = sbc_gxx_copy_to
};
Index: tsunami_flash.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/tsunami_flash.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- tsunami_flash.c 12 Jul 2004 21:59:45 -0000 1.7
+++ tsunami_flash.c 12 Jul 2004 22:38:29 -0000 1.8
@@ -15,14 +15,16 @@
#define FLASH_DISABLE_BYTE 0x00
#define MAX_TIG_FLASH_SIZE (12*1024*1024)
-static inline __u8 tsunami_flash_read8(struct map_info *map, unsigned long offset)
+static inline map_word tsunami_flash_read8(struct map_info *map, unsigned long offset)
{
- return tsunami_tig_readb(offset);
+ map_word val;
+ val.x[0] = tsunami_tig_readb(offset);
+ return val;
}
-static void tsunami_flash_write8(struct map_info *map, __u8 value, unsigned long offset)
+static void tsunami_flash_write8(struct map_info *map, map_word value, unsigned long offset)
{
- tsunami_tig_writeb(value, offset);
+ tsunami_tig_writeb(value.x[0], offset);
}
static void tsunami_flash_copy_from(
@@ -62,9 +64,9 @@
.size = MAX_TIG_FLASH_SIZE,
.phys = NO_XIP;
.bankwidth = 1,
- .read8 = tsunami_flash_read8,
+ .read = tsunami_flash_read8,
.copy_from = tsunami_flash_copy_from,
- .write8 = tsunami_flash_write8,
+ .write = tsunami_flash_write8,
.copy_to = tsunami_flash_copy_to,
};
Index: vmax301.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/maps/vmax301.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- vmax301.c 12 Jul 2004 21:59:45 -0000 1.29
+++ vmax301.c 12 Jul 2004 22:38:29 -0000 1.30
@@ -54,32 +54,12 @@
__vmax301_page(map, page);
}
-static __u8 vmax301_read8(struct map_info *map, unsigned long ofs)
+static map_word vmax301_read8(struct map_info *map, unsigned long ofs)
{
- __u8 ret;
+ map_word ret;
spin_lock(&vmax301_spin);
vmax301_page(map, ofs);
- ret = readb(map->map_priv_2 + (ofs & WINDOW_MASK));
- spin_unlock(&vmax301_spin);
- return ret;
-}
-
-static __u16 vmax301_read16(struct map_info *map, unsigned long ofs)
-{
- __u16 ret;
- spin_lock(&vmax301_spin);
- vmax301_page(map, ofs);
- ret = readw(map->map_priv_2 + (ofs & WINDOW_MASK));
- spin_unlock(&vmax301_spin);
- return ret;
-}
-
-static __u32 vmax301_read32(struct map_info *map, unsigned long ofs)
-{
- __u32 ret;
- spin_lock(&vmax301_spin);
- vmax301_page(map, ofs);
- ret = readl(map->map_priv_2 + (ofs & WINDOW_MASK));
+ ret.x[0] = readb(map->map_priv_2 + (ofs & WINDOW_MASK));
spin_unlock(&vmax301_spin);
return ret;
}
@@ -100,27 +80,11 @@
}
}
-static void vmax301_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
- spin_lock(&vmax301_spin);
- vmax301_page(map, adr);
- writeb(d, map->map_priv_2 + (adr & WINDOW_MASK));
- spin_unlock(&vmax301_spin);
-}
-
-static void vmax301_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
- spin_lock(&vmax301_spin);
- vmax301_page(map, adr);
- writew(d, map->map_priv_2 + (adr & WINDOW_MASK));
- spin_unlock(&vmax301_spin);
-}
-
-static void vmax301_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void vmax301_write8(struct map_info *map, map_word d, unsigned long adr)
{
spin_lock(&vmax301_spin);
vmax301_page(map, adr);
- writel(d, map->map_priv_2 + (adr & WINDOW_MASK));
+ writeb(d.x[0], map->map_priv_2 + (adr & WINDOW_MASK));
spin_unlock(&vmax301_spin);
}
@@ -147,13 +111,9 @@
.phys = NO_XIP,
.size = 3*2*1024*1024,
.bankwidth = 1,
- .read8 = vmax301_read8,
- .read16 = vmax301_read16,
- .read32 = vmax301_read32,
+ .read = vmax301_read8,
.copy_from = vmax301_copy_from,
- .write8 = vmax301_write8,
- .write16 = vmax301_write16,
- .write32 = vmax301_write32,
+ .write = vmax301_write8,
.copy_to = vmax301_copy_to,
.map_priv_1 = WINDOW_START + WINDOW_LENGTH,
.map_priv_2 = 0xFFFFFFFF
@@ -163,13 +123,9 @@
.phys = NO_XIP,
.size = 0,
.bankwidth = 1,
- .read8 = vmax301_read8,
- .read16 = vmax301_read16,
- .read32 = vmax301_read32,
+ .read = vmax301_read8,
.copy_from = vmax301_copy_from,
- .write8 = vmax301_write8,
- .write16 = vmax301_write16,
- .write32 = vmax301_write32,
+ .write = vmax301_write8,
.copy_to = vmax301_copy_to,
.map_priv_1 = WINDOW_START + (3*WINDOW_LENGTH),
.map_priv_2 = 0xFFFFFFFF
More information about the linux-mtd-cvs
mailing list