~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/mtd/rpxlite.c

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * $Id: rpxlite.c,v 1.8 2000/12/09 22:00:31 dwmw2 Exp $
  3  *
  4  * Handle mapping of the flash on the RPX Lite and CLLF boards
  5  */
  6 
  7 #include <linux/module.h>
  8 #include <linux/types.h>
  9 #include <linux/kernel.h>
 10 #include <asm/io.h>
 11 #include <linux/mtd/mtd.h>
 12 #include <linux/mtd/map.h>
 13 
 14 
 15 #define WINDOW_ADDR 0xfe000000
 16 #define WINDOW_SIZE 0x800000
 17 
 18 static struct mtd_info *mymtd;
 19 
 20 __u8 rpxlite_read8(struct map_info *map, unsigned long ofs)
 21 {
 22         return readb(map->map_priv_1 * ofs);
 23 }
 24 
 25 __u16 rpxlite_read16(struct map_info *map, unsigned long ofs)
 26 {
 27         return readw(map->map_priv_1 + ofs);
 28 }
 29 
 30 __u32 rpxlite_read32(struct map_info *map, unsigned long ofs)
 31 {
 32         return readl(map->map_priv_1 + ofs);
 33 }
 34 
 35 void rpxlite_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
 36 {
 37         memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
 38 }
 39 
 40 void rpxlite_write8(struct map_info *map, __u8 d, unsigned long adr)
 41 {
 42         writeb(d, map->map_priv_1 + adr);
 43 }
 44 
 45 void rpxlite_write16(struct map_info *map, __u16 d, unsigned long adr)
 46 {
 47         writew(d, map->map_priv_1 + adr);
 48 }
 49 
 50 void rpxlite_write32(struct map_info *map, __u32 d, unsigned long adr)
 51 {
 52         writel(d, map->map_priv_1 + adr);
 53 }
 54 
 55 void rpxlite_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
 56 {
 57         memcpy_toio((void *)(map->map_priv_1 + to), from, len);
 58 }
 59 
 60 struct map_info rpxlite_map = {
 61         name: "RPX",
 62         size: WINDOW_SIZE,
 63         buswidth: 4,
 64         read8: rpxlite_read8,
 65         read16: rpxlite_read16,
 66         read32: rpxlite_read32,
 67         copy_from: rpxlite_copy_from,
 68         write8: rpxlite_write8,
 69         write16: rpxlite_write16,
 70         write32: rpxlite_write32,
 71         copy_to: rpxlite_copy_to
 72 };
 73 
 74 #if LINUX_VERSION_CODE < 0x20212 && defined(MODULE)
 75 #define init_rpxlite init_module
 76 #define cleanup_rpxlite cleanup_module
 77 #endif
 78 
 79 int __init init_rpxlite(void)
 80 {
 81         printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
 82         rpxlite_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
 83 
 84         if (!rpxlite_map.map_priv_1) {
 85                 printk("Failed to ioremap\n");
 86                 return -EIO;
 87         }
 88         mymtd = do_cfi_probe(&rpxlite_map);
 89         if (mymtd) {
 90 #ifdef MODULE
 91                 mymtd->module = &__this_module;
 92 #endif
 93                 add_mtd_device(mymtd);
 94                 return 0;
 95         }
 96 
 97         return -ENXIO;
 98 }
 99 
100 static void __exit cleanup_rpxlite(void)
101 {
102         if (mymtd) {
103                 del_mtd_device(mymtd);
104                 map_destroy(mymtd);
105         }
106         if (rpxlite_map.map_priv_1) {
107                 iounmap((void *)rpxlite_map.map_priv_1);
108                 rpxlite_map.map_priv_1 = 0;
109         }
110 }
111 
112 module_init(init_rpxlite);
113 module_exit(cleanup_rpxlite);
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.