MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / mtd / maps / dbox2-flash.c
blob7c4de43c0ef18be3dba3ee81fc41c75101cae36d
1 /*
2 * $Id: dbox2-flash.c,v 1.11 2004/07/12 21:59:43 dwmw2 Exp $
4 * D-Box 2 flash driver
5 */
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <asm/io.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/map.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/config.h>
16 #include <linux/errno.h>
18 /* partition_info gives details on the logical partitions that the split the
19 * single flash device into. If the size if zero we use up to the end of the
20 * device. */
21 static struct mtd_partition partition_info[]= {
23 .name = "BR bootloader",
24 .size = 128 * 1024,
25 .offset = 0,
26 .mask_flags = MTD_WRITEABLE
29 .name = "FLFS (U-Boot)",
30 .size = 128 * 1024,
31 .offset = MTDPART_OFS_APPEND,
32 .mask_flags = 0
35 .name = "Root (SquashFS)",
36 .size = 7040 * 1024,
37 .offset = MTDPART_OFS_APPEND,
38 .mask_flags = 0
41 .name = "var (JFFS2)",
42 .size = 896 * 1024,
43 .offset = MTDPART_OFS_APPEND,
44 .mask_flags = 0
47 .name = "Flash without bootloader",
48 .size = MTDPART_SIZ_FULL,
49 .offset = 128 * 1024,
50 .mask_flags = 0
53 .name = "Complete Flash",
54 .size = MTDPART_SIZ_FULL,
55 .offset = 0,
56 .mask_flags = MTD_WRITEABLE
60 #define NUM_PARTITIONS (sizeof(partition_info) / sizeof(partition_info[0]))
62 #define WINDOW_ADDR 0x10000000
63 #define WINDOW_SIZE 0x800000
65 static struct mtd_info *mymtd;
68 struct map_info dbox2_flash_map = {
69 .name = "D-Box 2 flash memory",
70 .size = WINDOW_SIZE,
71 .bankwidth = 4,
72 .phys = WINDOW_ADDR,
75 int __init init_dbox2_flash(void)
77 printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR);
78 dbox2_flash_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
80 if (!dbox2_flash_map.virt) {
81 printk("Failed to ioremap\n");
82 return -EIO;
84 simple_map_init(&dbox2_flash_map);
86 // Probe for dual Intel 28F320 or dual AMD
87 mymtd = do_map_probe("cfi_probe", &dbox2_flash_map);
88 if (!mymtd) {
89 // Probe for single Intel 28F640
90 dbox2_flash_map.bankwidth = 2;
92 mymtd = do_map_probe("cfi_probe", &dbox2_flash_map);
95 if (mymtd) {
96 mymtd->owner = THIS_MODULE;
98 /* Create MTD devices for each partition. */
99 add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
101 return 0;
104 iounmap((void *)dbox2_flash_map.virt);
105 return -ENXIO;
108 static void __exit cleanup_dbox2_flash(void)
110 if (mymtd) {
111 del_mtd_partitions(mymtd);
112 map_destroy(mymtd);
114 if (dbox2_flash_map.virt) {
115 iounmap((void *)dbox2_flash_map.virt);
116 dbox2_flash_map.virt = 0;
120 module_init(init_dbox2_flash);
121 module_exit(cleanup_dbox2_flash);
124 MODULE_LICENSE("GPL");
125 MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>, Bastian Blank <waldi@tuxbox.org>, Alexander Wild <wild@te-elektronik.com>");
126 MODULE_DESCRIPTION("MTD map driver for D-Box 2 board");