2 * Flash memory access on Hynix GMS30C7201/HMS30C7202 based
5 * $Id: h720x-flash.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $
7 * (C) 2002 Jungjun Kim <jungjun.kim@hynix.com>
8 * 2003 Thomas Gleixner <tglx@linutronix.de>
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/errno.h>
16 #include <linux/slab.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/mtd/partitions.h>
21 #include <asm/hardware.h>
24 static struct mtd_info
*mymtd
;
26 static struct map_info h720x_map
= {
33 static struct mtd_partition h720x_partitions
[] = {
38 .mask_flags
= MTD_WRITEABLE
43 .mask_flags
= MTD_WRITEABLE
48 .mask_flags
= MTD_WRITEABLE
53 .mask_flags
= MTD_WRITEABLE
56 .size
= MTDPART_SIZ_FULL
,
57 .offset
= MTDPART_OFS_APPEND
61 #define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions)
63 static int nr_mtd_parts
;
64 static struct mtd_partition
*mtd_parts
;
65 static const char *probes
[] = { "cmdlinepart", NULL
};
68 * Initialize FLASH support
70 int __init
h720x_mtd_init(void)
73 char *part_type
= NULL
;
75 h720x_map
.virt
= ioremap(FLASH_PHYS
, FLASH_SIZE
);
77 if (!h720x_map
.virt
) {
78 printk(KERN_ERR
"H720x-MTD: ioremap failed\n");
82 simple_map_init(&h720x_map
);
84 // Probe for flash bankwidth 4
85 printk (KERN_INFO
"H720x-MTD probing 32bit FLASH\n");
86 mymtd
= do_map_probe("cfi_probe", &h720x_map
);
88 printk (KERN_INFO
"H720x-MTD probing 16bit FLASH\n");
89 // Probe for bankwidth 2
90 h720x_map
.bankwidth
= 2;
91 mymtd
= do_map_probe("cfi_probe", &h720x_map
);
95 mymtd
->owner
= THIS_MODULE
;
97 #ifdef CONFIG_MTD_PARTITIONS
98 nr_mtd_parts
= parse_mtd_partitions(mymtd
, probes
, &mtd_parts
, 0);
100 part_type
= "command line";
102 if (nr_mtd_parts
<= 0) {
103 mtd_parts
= h720x_partitions
;
104 nr_mtd_parts
= NUM_PARTITIONS
;
105 part_type
= "builtin";
107 printk(KERN_INFO
"Using %s partition table\n", part_type
);
108 add_mtd_partitions(mymtd
, mtd_parts
, nr_mtd_parts
);
112 iounmap((void *)h720x_map
.virt
);
119 static void __exit
h720x_mtd_cleanup(void)
123 del_mtd_partitions(mymtd
);
127 /* Free partition info, if commandline partition was used */
128 if (mtd_parts
&& (mtd_parts
!= h720x_partitions
))
131 if (h720x_map
.virt
) {
132 iounmap((void *)h720x_map
.virt
);
138 module_init(h720x_mtd_init
);
139 module_exit(h720x_mtd_cleanup
);
141 MODULE_LICENSE("GPL");
142 MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
143 MODULE_DESCRIPTION("MTD map driver for Hynix evaluation boards");