MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / drivers / mtd / maps / avnet5282.c
blobbd077ca7b84f4793cb2d0eca0797bde6b970bcad
1 /*
3 * Normal mappings of chips in physical memory
4 */
5 #include <linux/module.h>
6 #include <linux/types.h>
7 #include <linux/kernel.h>
8 #include <linux/init.h>
9 #include <linux/errno.h>
11 #include <linux/mtd/cfi.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/partitions.h>
16 #include <asm/io.h>
18 #define WINDOW_ADDR 0xff800000 // Flash Start addr.
19 #define WINDOW_SIZE 0x00800000 // Flash Size: 8 MB
20 #define BUSWIDTH 2
22 #define NUM_PARTITIONS (sizeof(avnet5282_partitions) / sizeof (avnet5282_partitions[0]))
24 /*************************************************************************************/
26 static struct mtd_partition avnet5282_partitions[] = {
28 .name = "uboot (256 KB)",
29 .size = 0x40000,
30 .offset = 0x0,
31 .mask_flags = MTD_WRITEABLE
34 .name = "kernel (3 MB)",
35 .size = 0x300000,
36 .offset = 0x40000
39 .name = "rootfs (4,75 MB)",
40 .size = 0x4C0000,
41 .offset = 0x340000
45 /*************************************************************************************/
47 struct map_info avnet5282_map = {
48 .name = "MCF5282 flash",
49 .size = WINDOW_SIZE,
50 .phys = WINDOW_ADDR,
51 .bankwidth = BUSWIDTH
54 static struct mtd_info *mymtd;
56 /*************************************************************************************/
58 static int __init init_avnet5282(void)
60 avnet5282_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
62 if (avnet5282_map.virt == 0) {
63 printk(KERN_NOTICE "Failed to ioremap FLASH memory area.\n");
64 return -EIO;
66 simple_map_init(&avnet5282_map);
68 mymtd = do_map_probe("cfi_probe", &avnet5282_map);
70 if(!mymtd){
71 printk(KERN_NOTICE "Flash 5282 error, can't map");
72 iounmap((void *)avnet5282_map.virt);
73 return -ENXIO;
75 printk(KERN_NOTICE "MCF5282 flash device: %dMiB at 0x%08x\n", mymtd->size >> 20, WINDOW_ADDR);
77 mymtd->owner = THIS_MODULE;
78 mymtd->erasesize = 0x40000;
80 add_mtd_partitions(mymtd, avnet5282_partitions, NUM_PARTITIONS);
81 return 0;
84 /*************************************************************************************/
86 static void __exit cleanup_avnet5282(void)
88 if (mymtd) {
89 del_mtd_partitions(mymtd);
90 map_destroy(mymtd);
92 if (avnet5282_map.virt) {
93 iounmap((void *)avnet5282_map.virt);
94 avnet5282_map.virt = 0;
96 return;
99 /*************************************************************************************/
101 module_init(init_avnet5282);
102 module_exit(cleanup_avnet5282);
104 MODULE_AUTHOR("Daniel Alomar i Claramonte");
105 MODULE_DESCRIPTION("Mapejat Xip Flash 28F640JA");
106 MODULE_LICENSE("GPL");
108 /*************************************************************************************/