5 #include <linux/module.h>
6 #include <linux/types.h>
7 #include <linux/kernel.h>
8 #include <linux/init.h>
10 #include <linux/mtd/mtd.h>
11 #include <linux/mtd/map.h>
12 #include <linux/mtd/partitions.h>
13 #include <linux/errno.h>
15 /* partition_info gives details on the logical partitions that the split the
16 * single flash device into. If the size if zero we use up to the end of the
18 static struct mtd_partition partition_info
[]= {
20 .name
= "BR bootloader",
23 .mask_flags
= MTD_WRITEABLE
26 .name
= "FLFS (U-Boot)",
28 .offset
= MTDPART_OFS_APPEND
,
32 .name
= "Root (SquashFS)",
34 .offset
= MTDPART_OFS_APPEND
,
38 .name
= "var (JFFS2)",
40 .offset
= MTDPART_OFS_APPEND
,
44 .name
= "Flash without bootloader",
45 .size
= MTDPART_SIZ_FULL
,
50 .name
= "Complete Flash",
51 .size
= MTDPART_SIZ_FULL
,
53 .mask_flags
= MTD_WRITEABLE
57 #define NUM_PARTITIONS ARRAY_SIZE(partition_info)
59 #define WINDOW_ADDR 0x10000000
60 #define WINDOW_SIZE 0x800000
62 static struct mtd_info
*mymtd
;
65 struct map_info dbox2_flash_map
= {
66 .name
= "D-Box 2 flash memory",
72 static int __init
init_dbox2_flash(void)
74 printk(KERN_NOTICE
"D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE
, WINDOW_ADDR
);
75 dbox2_flash_map
.virt
= ioremap(WINDOW_ADDR
, WINDOW_SIZE
);
77 if (!dbox2_flash_map
.virt
) {
78 printk("Failed to ioremap\n");
81 simple_map_init(&dbox2_flash_map
);
83 // Probe for dual Intel 28F320 or dual AMD
84 mymtd
= do_map_probe("cfi_probe", &dbox2_flash_map
);
86 // Probe for single Intel 28F640
87 dbox2_flash_map
.bankwidth
= 2;
89 mymtd
= do_map_probe("cfi_probe", &dbox2_flash_map
);
93 mymtd
->owner
= THIS_MODULE
;
95 /* Create MTD devices for each partition. */
96 mtd_device_register(mymtd
, partition_info
, NUM_PARTITIONS
);
101 iounmap((void *)dbox2_flash_map
.virt
);
105 static void __exit
cleanup_dbox2_flash(void)
108 mtd_device_unregister(mymtd
);
111 if (dbox2_flash_map
.virt
) {
112 iounmap((void *)dbox2_flash_map
.virt
);
113 dbox2_flash_map
.virt
= 0;
117 module_init(init_dbox2_flash
);
118 module_exit(cleanup_dbox2_flash
);
121 MODULE_LICENSE("GPL");
122 MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>, Bastian Blank <waldi@tuxbox.org>, Alexander Wild <wild@te-elektronik.com>");
123 MODULE_DESCRIPTION("MTD map driver for D-Box 2 board");