2 * NOR Flash memory access on TI Toto board
4 * jzhang@ti.com (C) 2003 Texas Instruments.
6 * (C) 2002 MontVista Software, Inc.
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/errno.h>
13 #include <linux/init.h>
14 #include <linux/slab.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
20 #include <asm/hardware.h>
24 #ifndef CONFIG_ARCH_OMAP
25 #error This is for OMAP architecture only
28 //these lines need be moved to a hardware header file
29 #define OMAP_TOTO_FLASH_BASE 0xd8000000
30 #define OMAP_TOTO_FLASH_SIZE 0x80000
32 static struct map_info omap_toto_map_flash = {
33 .name = "OMAP Toto flash",
35 .virt = (void __iomem *)OMAP_TOTO_FLASH_BASE,
39 static struct mtd_partition toto_flash_partitions[] = {
42 .size = 0x00040000, /* hopefully u-boot will stay 128k + 128*/
44 .mask_flags = MTD_WRITEABLE, /* force read-only */
46 .name = "ReservedSpace",
48 .offset = MTDPART_OFS_APPEND,
49 //mask_flags: MTD_WRITEABLE, /* force read-only */
51 .name = "EnvArea", /* bottom 64KiB for env vars */
52 .size = MTDPART_SIZ_FULL,
53 .offset = MTDPART_OFS_APPEND,
57 static struct mtd_partition *parsed_parts;
59 static struct mtd_info *flash_mtd;
61 static int __init init_flash (void)
64 struct mtd_partition *parts;
66 int parsed_nr_parts = 0;
67 const char *part_type;
70 * Static partition definition selection
74 parts = toto_flash_partitions;
75 nb_parts = ARRAY_SIZE(toto_flash_partitions);
76 omap_toto_map_flash.size = OMAP_TOTO_FLASH_SIZE;
77 omap_toto_map_flash.phys = virt_to_phys(OMAP_TOTO_FLASH_BASE);
79 simple_map_init(&omap_toto_map_flash);
81 * Now let's probe for the actual flash. Do it here since
82 * specific machine settings might have been set above.
84 printk(KERN_NOTICE "OMAP toto flash: probing %d-bit flash bus\n",
85 omap_toto_map_flash.bankwidth*8);
86 flash_mtd = do_map_probe("jedec_probe", &omap_toto_map_flash);
90 if (parsed_nr_parts > 0) {
92 nb_parts = parsed_nr_parts;
96 printk(KERN_NOTICE "OMAP toto flash: no partition info available,"
97 "registering whole flash at once\n");
98 if (add_mtd_device(flash_mtd)){
102 printk(KERN_NOTICE "Using %s partition definition\n",
104 return add_mtd_partitions(flash_mtd, parts, nb_parts);
109 int __init omap_toto_mtd_init(void)
113 if (status = init_flash()) {
114 printk(KERN_ERR "OMAP Toto Flash: unable to init map for toto flash\n");
119 static void __exit omap_toto_mtd_cleanup(void)
122 del_mtd_partitions(flash_mtd);
123 map_destroy(flash_mtd);
128 module_init(omap_toto_mtd_init);
129 module_exit(omap_toto_mtd_cleanup);
131 MODULE_AUTHOR("Jian Zhang");
132 MODULE_DESCRIPTION("OMAP Toto board map driver");
133 MODULE_LICENSE("GPL");