2 * Flash and EPROM on Hitachi Solution Engine and similar boards.
4 * (C) 2001 Red Hat, Inc.
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/map.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/errno.h>
19 static struct mtd_info
*flash_mtd
;
20 static struct mtd_info
*eprom_mtd
;
22 static struct mtd_partition
*parsed_parts
;
24 struct map_info soleng_eprom_map
= {
25 .name
= "Solution Engine EPROM",
30 struct map_info soleng_flash_map
= {
31 .name
= "Solution Engine FLASH",
36 static const char *probes
[] = { "RedBoot", "cmdlinepart", NULL
};
38 #ifdef CONFIG_MTD_SUPERH_RESERVE
39 static struct mtd_partition superh_se_partitions
[] = {
40 /* Reserved for boot code, read-only */
44 .size
= CONFIG_MTD_SUPERH_RESERVE
,
45 .mask_flags
= MTD_WRITEABLE
,
47 /* All else is writable (e.g. JFFS) */
50 .offset
= MTDPART_OFS_NXTBLK
,
51 .size
= MTDPART_SIZ_FULL
,
54 #endif /* CONFIG_MTD_SUPERH_RESERVE */
56 static int __init
init_soleng_maps(void)
60 /* First probe at offset 0 */
61 soleng_flash_map
.phys
= 0;
62 soleng_flash_map
.virt
= (void __iomem
*)P2SEGADDR(0);
63 soleng_eprom_map
.phys
= 0x01000000;
64 soleng_eprom_map
.virt
= (void __iomem
*)P1SEGADDR(0x01000000);
65 simple_map_init(&soleng_eprom_map
);
66 simple_map_init(&soleng_flash_map
);
68 printk(KERN_NOTICE
"Probing for flash chips at 0x00000000:\n");
69 flash_mtd
= do_map_probe("cfi_probe", &soleng_flash_map
);
71 /* Not there. Try swapping */
72 printk(KERN_NOTICE
"Probing for flash chips at 0x01000000:\n");
73 soleng_flash_map
.phys
= 0x01000000;
74 soleng_flash_map
.virt
= P2SEGADDR(0x01000000);
75 soleng_eprom_map
.phys
= 0;
76 soleng_eprom_map
.virt
= P1SEGADDR(0);
77 flash_mtd
= do_map_probe("cfi_probe", &soleng_flash_map
);
80 printk(KERN_NOTICE
"Flash chips not detected at either possible location.\n");
84 printk(KERN_NOTICE
"Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
85 soleng_flash_map
.phys
& 0x1fffffff,
86 soleng_eprom_map
.phys
& 0x1fffffff);
87 flash_mtd
->owner
= THIS_MODULE
;
89 eprom_mtd
= do_map_probe("map_rom", &soleng_eprom_map
);
91 eprom_mtd
->owner
= THIS_MODULE
;
92 add_mtd_device(eprom_mtd
);
95 nr_parts
= parse_mtd_partitions(flash_mtd
, probes
, &parsed_parts
, 0);
97 #ifdef CONFIG_MTD_SUPERH_RESERVE
99 printk(KERN_NOTICE
"Using configured partition at 0x%08x.\n",
100 CONFIG_MTD_SUPERH_RESERVE
);
101 parsed_parts
= superh_se_partitions
;
102 nr_parts
= sizeof(superh_se_partitions
)/sizeof(*parsed_parts
);
104 #endif /* CONFIG_MTD_SUPERH_RESERVE */
107 add_mtd_partitions(flash_mtd
, parsed_parts
, nr_parts
);
109 add_mtd_device(flash_mtd
);
114 static void __exit
cleanup_soleng_maps(void)
117 del_mtd_device(eprom_mtd
);
118 map_destroy(eprom_mtd
);
122 del_mtd_partitions(flash_mtd
);
124 del_mtd_device(flash_mtd
);
125 map_destroy(flash_mtd
);
128 module_init(init_soleng_maps
);
129 module_exit(cleanup_soleng_maps
);
131 MODULE_LICENSE("GPL");
132 MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
133 MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");