| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Handle mapping of the flash on the RPX Lite and CLLF boards | 
|  | 3 | */ | 
|  | 4 |  | 
|  | 5 | #include <linux/module.h> | 
|  | 6 | #include <linux/types.h> | 
|  | 7 | #include <linux/kernel.h> | 
|  | 8 | #include <linux/init.h> | 
|  | 9 | #include <asm/io.h> | 
|  | 10 | #include <linux/mtd/mtd.h> | 
|  | 11 | #include <linux/mtd/map.h> | 
|  | 12 |  | 
|  | 13 |  | 
|  | 14 | #define WINDOW_ADDR 0xfe000000 | 
|  | 15 | #define WINDOW_SIZE 0x800000 | 
|  | 16 |  | 
|  | 17 | static struct mtd_info *mymtd; | 
|  | 18 |  | 
|  | 19 | static struct map_info rpxlite_map = { | 
|  | 20 | .name = "RPX", | 
|  | 21 | .size = WINDOW_SIZE, | 
|  | 22 | .bankwidth = 4, | 
|  | 23 | .phys = WINDOW_ADDR, | 
|  | 24 | }; | 
|  | 25 |  | 
| Dmitri Vorobiev | bc18540 | 2008-11-25 02:55:05 +0200 | [diff] [blame] | 26 | static int __init init_rpxlite(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | { | 
|  | 28 | printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR); | 
|  | 29 | rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); | 
|  | 30 |  | 
|  | 31 | if (!rpxlite_map.virt) { | 
|  | 32 | printk("Failed to ioremap\n"); | 
|  | 33 | return -EIO; | 
|  | 34 | } | 
|  | 35 | simple_map_init(&rpxlite_map); | 
|  | 36 | mymtd = do_map_probe("cfi_probe", &rpxlite_map); | 
|  | 37 | if (mymtd) { | 
|  | 38 | mymtd->owner = THIS_MODULE; | 
|  | 39 | add_mtd_device(mymtd); | 
|  | 40 | return 0; | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | iounmap((void *)rpxlite_map.virt); | 
|  | 44 | return -ENXIO; | 
|  | 45 | } | 
|  | 46 |  | 
|  | 47 | static void __exit cleanup_rpxlite(void) | 
|  | 48 | { | 
|  | 49 | if (mymtd) { | 
|  | 50 | del_mtd_device(mymtd); | 
|  | 51 | map_destroy(mymtd); | 
|  | 52 | } | 
|  | 53 | if (rpxlite_map.virt) { | 
|  | 54 | iounmap((void *)rpxlite_map.virt); | 
|  | 55 | rpxlite_map.virt = 0; | 
|  | 56 | } | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | module_init(init_rpxlite); | 
|  | 60 | module_exit(cleanup_rpxlite); | 
|  | 61 |  | 
|  | 62 | MODULE_LICENSE("GPL"); | 
|  | 63 | MODULE_AUTHOR("Arnold Christensen <AKC@pel.dk>"); | 
|  | 64 | MODULE_DESCRIPTION("MTD map driver for RPX Lite and CLLF boards"); |