diff options
Diffstat (limited to 'linux-2.4.x/drivers/mtd/maps/sun_uflash.c')
-rw-r--r-- | linux-2.4.x/drivers/mtd/maps/sun_uflash.c | 91 |
1 files changed, 20 insertions, 71 deletions
diff --git a/linux-2.4.x/drivers/mtd/maps/sun_uflash.c b/linux-2.4.x/drivers/mtd/maps/sun_uflash.c index b431bf2..f64fae9 100644 --- a/linux-2.4.x/drivers/mtd/maps/sun_uflash.c +++ b/linux-2.4.x/drivers/mtd/maps/sun_uflash.c @@ -1,4 +1,4 @@ -/* $Id: sun_uflash.c,v 1.4 2001/10/02 15:05:14 dwmw2 Exp $ +/* $Id: sun_uflash.c,v 1.14 2005/11/29 20:01:28 gleixner Exp $ * * sun_uflash - Driver implementation for user-programmable flash * present on many Sun Microsystems SME boardsets. @@ -12,7 +12,6 @@ #include <linux/kernel.h> #include <linux/module.h> -#include <linux/version.h> #include <linux/fs.h> #include <linux/errno.h> #include <linux/init.h> @@ -48,60 +47,11 @@ struct uflash_dev { struct list_head list; }; -__u8 uflash_read8(struct map_info *map, unsigned long ofs) -{ - return(__raw_readb(map->map_priv_1 + ofs)); -} - -__u16 uflash_read16(struct map_info *map, unsigned long ofs) -{ - return(__raw_readw(map->map_priv_1 + ofs)); -} - -__u32 uflash_read32(struct map_info *map, unsigned long ofs) -{ - return(__raw_readl(map->map_priv_1 + ofs)); -} - -void uflash_copy_from(struct map_info *map, void *to, unsigned long from, - ssize_t len) -{ - memcpy_fromio(to, map->map_priv_1 + from, len); -} - -void uflash_write8(struct map_info *map, __u8 d, unsigned long adr) -{ - __raw_writeb(d, map->map_priv_1 + adr); -} - -void uflash_write16(struct map_info *map, __u16 d, unsigned long adr) -{ - __raw_writew(d, map->map_priv_1 + adr); -} - -void uflash_write32(struct map_info *map, __u32 d, unsigned long adr) -{ - __raw_writel(d, map->map_priv_1 + adr); -} - -void uflash_copy_to(struct map_info *map, unsigned long to, const void *from, - ssize_t len) -{ - memcpy_toio(map->map_priv_1 + to, from, len); -} struct map_info uflash_map_templ = { - name: "SUNW,???-????", - size: UFLASH_WINDOW_SIZE, - buswidth: UFLASH_BUSWIDTH, - read8: uflash_read8, - read16: uflash_read16, - read32: uflash_read32, - copy_from: uflash_copy_from, - write8: uflash_write8, - write16: uflash_write16, - write32: uflash_write32, - copy_to: uflash_copy_to + .name = "SUNW,???-????", + .size = UFLASH_WINDOW_SIZE, + .bankwidth = UFLASH_BUSWIDTH, }; int uflash_devinit(struct linux_ebus_device* edev) @@ -113,7 +63,7 @@ int uflash_devinit(struct linux_ebus_device* edev) iTmp = prom_getproperty( edev->prom_node, "reg", (void *)regs, sizeof(regs)); if ((iTmp % sizeof(regs[0])) != 0) { - printk("%s: Strange reg property size %d\n", + printk("%s: Strange reg property size %d\n", UFLASH_DEVNAME, iTmp); return -ENODEV; } @@ -125,7 +75,7 @@ int uflash_devinit(struct linux_ebus_device* edev) * can work on supporting it. */ printk("%s: unsupported device at 0x%lx (%d regs): " \ - "email ebrower@usa.net\n", + "email ebrower@usa.net\n", UFLASH_DEVNAME, edev->resource[0].start, nregs); return -ENODEV; } @@ -134,7 +84,7 @@ int uflash_devinit(struct linux_ebus_device* edev) printk("%s: unable to kmalloc new device\n", UFLASH_DEVNAME); return(-ENOMEM); } - + /* copy defaults and tweak parameters */ memcpy(&pdev->map, &uflash_map_templ, sizeof(uflash_map_templ)); pdev->map.size = regs[0].reg_size; @@ -145,20 +95,21 @@ int uflash_devinit(struct linux_ebus_device* edev) if(0 != pdev->name && 0 < strlen(pdev->name)) { pdev->map.name = pdev->name; } - - pdev->map.map_priv_1 = - (unsigned long)ioremap_nocache(edev->resource[0].start, pdev->map.size); - if(0 == pdev->map.map_priv_1) { + pdev->map.phys = edev->resource[0].start; + pdev->map.virt = ioremap_nocache(edev->resource[0].start, pdev->map.size); + if(0 == pdev->map.virt) { printk("%s: failed to map device\n", __FUNCTION__); kfree(pdev->name); kfree(pdev); return(-1); } + simple_map_init(&pdev->map); + /* MTD registration */ pdev->mtd = do_map_probe("cfi_probe", &pdev->map); if(0 == pdev->mtd) { - iounmap((void *)pdev->map.map_priv_1); + iounmap(pdev->map.virt); kfree(pdev->name); kfree(pdev); return(-ENXIO); @@ -166,7 +117,7 @@ int uflash_devinit(struct linux_ebus_device* edev) list_add(&pdev->list, &device_list); - pdev->mtd->module = THIS_MODULE; + pdev->mtd->owner = THIS_MODULE; add_mtd_device(pdev->mtd); return(0); @@ -204,22 +155,20 @@ static void __exit uflash_cleanup(void) list_for_each(udevlist, &device_list) { udev = list_entry(udevlist, struct uflash_dev, list); - DEBUG(2, "%s: removing device %s\n", + DEBUG(2, "%s: removing device %s\n", UFLASH_DEVNAME, udev->name); if(0 != udev->mtd) { del_mtd_device(udev->mtd); map_destroy(udev->mtd); } - if(0 != udev->map.map_priv_1) { - iounmap((void*)udev->map.map_priv_1); - udev->map.map_priv_1 = 0; - } - if(0 != udev->name) { - kfree(udev->name); + if(0 != udev->map.virt) { + iounmap(udev->map.virt); + udev->map.virt = NULL; } + kfree(udev->name); kfree(udev); - } + } } module_init(uflash_init); |