diff options
Diffstat (limited to 'linux-2.4.x/drivers/mtd/maps/vmax301.c')
-rw-r--r-- | linux-2.4.x/drivers/mtd/maps/vmax301.c | 127 |
1 files changed, 43 insertions, 84 deletions
diff --git a/linux-2.4.x/drivers/mtd/maps/vmax301.c b/linux-2.4.x/drivers/mtd/maps/vmax301.c index 4fd2f63..299aa9b 100644 --- a/linux-2.4.x/drivers/mtd/maps/vmax301.c +++ b/linux-2.4.x/drivers/mtd/maps/vmax301.c @@ -1,19 +1,19 @@ -// $Id: vmax301.c,v 1.24 2001/10/02 15:05:14 dwmw2 Exp $ +// $Id: vmax301.c,v 1.33 2006/03/29 08:44:35 dwmw2 Exp $ /* ###################################################################### Tempustech VMAX SBC301 MTD Driver. - + The VMAx 301 is a SBC based on . It comes with three builtin AMD 29F016B flash chips and a socket for SRAM or - more flash. Each unit has it's own 8k mapping into a settable region + more flash. Each unit has it's own 8k mapping into a settable region (0xD8000). There are two 8k mappings for each MTD, the first is always set to the lower 8k of the device the second is paged. Writing a 16 bit page value to anywhere in the first 8k will cause the second 8k to page around. - To boot the device a bios extension must be installed into the first 8k - of flash that is smart enough to copy itself down, page in the rest of + To boot the device a bios extension must be installed into the first 8k + of flash that is smart enough to copy itself down, page in the rest of itself and begin executing. - + ##################################################################### */ #include <linux/module.h> @@ -24,6 +24,7 @@ #include <asm/io.h> #include <linux/mtd/map.h> +#include <linux/mtd/mtd.h> #define WINDOW_START 0xd8000 @@ -34,10 +35,10 @@ /* Actually we could use two spinlocks, but we'd have to have more private space in the struct map_info. We lose a little performance like this, but we'd probably lose more by having - the extra indirection from having one of the map->map_priv + the extra indirection from having one of the map->map_priv fields pointing to yet another private struct. */ -static spinlock_t vmax301_spin = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(vmax301_spin); static void __vmax301_page(struct map_info *map, unsigned long page) { @@ -53,32 +54,12 @@ static inline void vmax301_page(struct map_info *map, __vmax301_page(map, page); } -static __u8 vmax301_read8(struct map_info *map, unsigned long ofs) -{ - __u8 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) +static map_word vmax301_read8(struct map_info *map, unsigned long ofs) { - __u32 ret; + map_word 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; } @@ -99,27 +80,11 @@ static void vmax301_copy_from(struct map_info *map, void *to, unsigned long from } } -static void vmax301_write8(struct map_info *map, __u8 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); - 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) -{ - 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); } @@ -133,7 +98,7 @@ static void vmax301_copy_to(struct map_info *map, unsigned long to, const void * spin_lock(&vmax301_spin); vmax301_page(map, to); memcpy_toio(map->map_priv_2 + to, from, thislen); - spin_unlock(&vmax301_spin); + spin_unlock(&vmax301_spin); to += thislen; from += thislen; len -= thislen; @@ -142,34 +107,28 @@ static void vmax301_copy_to(struct map_info *map, unsigned long to, const void * static struct map_info vmax_map[2] = { { - name: "VMAX301 Internal Flash", - size: 3*2*1024*1024, - buswidth: 1, - read8: vmax301_read8, - read16: vmax301_read16, - read32: vmax301_read32, - copy_from: vmax301_copy_from, - write8: vmax301_write8, - write16: vmax301_write16, - write32: vmax301_write32, - copy_to: vmax301_copy_to, - map_priv_1: WINDOW_START + WINDOW_LENGTH, - map_priv_2: 0xFFFFFFFF + .name = "VMAX301 Internal Flash", + .phys = NO_XIP, + .size = 3*2*1024*1024, + .bankwidth = 1, + .read = vmax301_read8, + .copy_from = vmax301_copy_from, + .write = vmax301_write8, + .copy_to = vmax301_copy_to, + .map_priv_1 = WINDOW_START + WINDOW_LENGTH, + .map_priv_2 = 0xFFFFFFFF }, { - name: "VMAX301 Socket", - size: 0, - buswidth: 1, - read8: vmax301_read8, - read16: vmax301_read16, - read32: vmax301_read32, - copy_from: vmax301_copy_from, - write8: vmax301_write8, - write16: vmax301_write16, - write32: vmax301_write32, - copy_to: vmax301_copy_to, - map_priv_1: WINDOW_START + (3*WINDOW_LENGTH), - map_priv_2: 0xFFFFFFFF + .name = "VMAX301 Socket", + .phys = NO_XIP, + .size = 0, + .bankwidth = 1, + .read = vmax301_read8, + .copy_from = vmax301_copy_from, + .write = vmax301_write8, + .copy_to = vmax301_copy_to, + .map_priv_1 = WINDOW_START + (3*WINDOW_LENGTH), + .map_priv_2 = 0xFFFFFFFF } }; @@ -178,7 +137,7 @@ static struct mtd_info *vmax_mtd[2] = {NULL, NULL}; static void __exit cleanup_vmax301(void) { int i; - + for (i=0; i<2; i++) { if (vmax_mtd[i]) { del_mtd_device(vmax_mtd[i]); @@ -202,13 +161,13 @@ int __init init_vmax301(void) return -EIO; } /* Put the address in the map's private data area. - We store the actual MTD IO address rather than the + We store the actual MTD IO address rather than the address of the first half, because it's used more - often. + often. */ - vmax_map[0].map_priv_1 = iomapadr + WINDOW_START; - vmax_map[1].map_priv_1 = iomapadr + (3*WINDOW_START); - + vmax_map[0].map_priv_2 = iomapadr + WINDOW_START; + vmax_map[1].map_priv_2 = iomapadr + (3*WINDOW_START); + for (i=0; i<2; i++) { vmax_mtd[i] = do_map_probe("cfi_probe", &vmax_map[i]); if (!vmax_mtd[i]) @@ -218,12 +177,12 @@ int __init init_vmax301(void) if (!vmax_mtd[i]) vmax_mtd[i] = do_map_probe("map_rom", &vmax_map[i]); if (vmax_mtd[i]) { - vmax_mtd[i]->module = THIS_MODULE; + vmax_mtd[i]->owner = THIS_MODULE; add_mtd_device(vmax_mtd[i]); } } - if (!vmax_mtd[1] && !vmax_mtd[2]) { + if (!vmax_mtd[0] && !vmax_mtd[1]) { iounmap((void *)iomapadr); return -ENXIO; } |