2 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based
5 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
6 * 2003 Thomas Gleixner <tglx@linutronix.de>
9 #include <linux/config.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/errno.h>
15 #include <linux/slab.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/map.h>
19 #include <linux/mtd/partitions.h>
20 #include <asm/hardware.h>
23 static struct mtd_info *mymtd;
25 static struct map_info h720x_map = {
32 static struct mtd_partition h720x_partitions[] = {
37 .mask_flags = MTD_WRITEABLE
42 .mask_flags = MTD_WRITEABLE
47 .mask_flags = MTD_WRITEABLE
52 .mask_flags = MTD_WRITEABLE
55 .size = MTDPART_SIZ_FULL,
56 .offset = MTDPART_OFS_APPEND
60 #define NUM_PARTITIONS (sizeof(h720x_partitions)/sizeof(h720x_partitions[0]))
62 static int nr_mtd_parts;
63 static struct mtd_partition *mtd_parts;
64 static const char *probes[] = { "cmdlinepart", NULL };
67 * Initialize FLASH support
69 int __init h720x_mtd_init(void)
72 char *part_type = NULL;
74 h720x_map.virt = (unsigned long)ioremap(FLASH_PHYS, FLASH_SIZE);
76 if (!h720x_map.virt) {
77 printk(KERN_ERR "H720x-MTD: ioremap failed\n");
81 simple_map_init(&h720x_map);
83 // Probe for flash buswidth 4
84 printk (KERN_INFO "H720x-MTD probing 32bit FLASH\n");
85 mymtd = do_map_probe("cfi_probe", &h720x_map);
87 printk (KERN_INFO "H720x-MTD probing 16bit FLASH\n");
88 // Probe for buswidth 2
89 h720x_map.buswidth = 2;
90 mymtd = do_map_probe("cfi_probe", &h720x_map);
94 mymtd->owner = THIS_MODULE;
96 #ifdef CONFIG_MTD_PARTITIONS
97 nr_mtd_parts = parse_mtd_partitions(mymtd, probes, &mtd_parts, 0);
99 part_type = "command line";
101 if (nr_mtd_parts <= 0) {
102 mtd_parts = h720x_partitions;
103 nr_mtd_parts = NUM_PARTITIONS;
104 part_type = "builtin";
106 printk(KERN_INFO "Using %s partition table\n", part_type);
107 add_mtd_partitions(mymtd, mtd_parts, nr_mtd_parts);
111 iounmap((void *)h720x_map.virt);
118 static void __exit h720x_mtd_cleanup(void)
122 del_mtd_partitions(mymtd);
126 /* Free partition info, if commandline partition was used */
127 if (mtd_parts && (mtd_parts != h720x_partitions))
130 if (h720x_map.virt) {
131 iounmap((void *)h720x_map.virt);
137 module_init(h720x_mtd_init);
138 module_exit(h720x_mtd_cleanup);
140 MODULE_LICENSE("GPL");
141 MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
142 MODULE_DESCRIPTION("MTD map driver for Hynix evaluation boards");