2 * $Id: dbox2-flash.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/kernel.h>
10 #include <linux/init.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
21 static struct mtd_partition partition_info[]= {
23 .name = "BR bootloader",
26 .mask_flags = MTD_WRITEABLE
29 .name = "FLFS (U-Boot)",
31 .offset = MTDPART_OFS_APPEND,
35 .name = "Root (SquashFS)",
37 .offset = MTDPART_OFS_APPEND,
41 .name = "var (JFFS2)",
43 .offset = MTDPART_OFS_APPEND,
47 .name = "Flash without bootloader",
48 .size = MTDPART_SIZ_FULL,
53 .name = "Complete Flash",
54 .size = MTDPART_SIZ_FULL,
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",
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 = ioremap(WINDOW_ADDR, WINDOW_SIZE);
80 if (!dbox2_flash_map.virt) {
81 printk("Failed to ioremap\n");
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);
89 // Probe for single Intel 28F640
90 dbox2_flash_map.bankwidth = 2;
92 mymtd = do_map_probe("cfi_probe", &dbox2_flash_map);
96 mymtd->owner = THIS_MODULE;
98 /* Create MTD devices for each partition. */
99 add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
104 iounmap((void *)dbox2_flash_map.virt);
108 static void __exit cleanup_dbox2_flash(void)
111 del_mtd_partitions(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");