Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mtd / maps / omap-toto-flash.c
blob496109071cb10dc86bb828a0654ff295660f1ac0
1 /*
2 * NOR Flash memory access on TI Toto board
4 * jzhang@ti.com (C) 2003 Texas Instruments.
6 * (C) 2002 MontVista Software, Inc.
8 * $Id: omap-toto-flash.c,v 1.3 2004/09/16 23:27:13 gleixner Exp $
9 */
11 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/init.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
23 #include <asm/hardware.h>
24 #include <asm/io.h>
27 #ifndef CONFIG_ARCH_OMAP
28 #error This is for OMAP architecture only
29 #endif
31 //these lines need be moved to a hardware header file
32 #define OMAP_TOTO_FLASH_BASE 0xd8000000
33 #define OMAP_TOTO_FLASH_SIZE 0x80000
35 static struct map_info omap_toto_map_flash = {
36 .name = "OMAP Toto flash",
37 .bankwidth = 2,
38 .virt = (void __iomem *)OMAP_TOTO_FLASH_BASE,
42 static struct mtd_partition toto_flash_partitions[] = {
44 .name = "BootLoader",
45 .size = 0x00040000, /* hopefully u-boot will stay 128k + 128*/
46 .offset = 0,
47 .mask_flags = MTD_WRITEABLE, /* force read-only */
48 }, {
49 .name = "ReservedSpace",
50 .size = 0x00030000,
51 .offset = MTDPART_OFS_APPEND,
52 //mask_flags: MTD_WRITEABLE, /* force read-only */
53 }, {
54 .name = "EnvArea", /* bottom 64KiB for env vars */
55 .size = MTDPART_SIZ_FULL,
56 .offset = MTDPART_OFS_APPEND,
60 static struct mtd_partition *parsed_parts;
62 static struct mtd_info *flash_mtd;
64 static int __init init_flash (void)
67 struct mtd_partition *parts;
68 int nb_parts = 0;
69 int parsed_nr_parts = 0;
70 const char *part_type;
73 * Static partition definition selection
75 part_type = "static";
77 parts = toto_flash_partitions;
78 nb_parts = ARRAY_SIZE(toto_flash_partitions);
79 omap_toto_map_flash.size = OMAP_TOTO_FLASH_SIZE;
80 omap_toto_map_flash.phys = virt_to_phys(OMAP_TOTO_FLASH_BASE);
82 simple_map_init(&omap_toto_map_flash);
84 * Now let's probe for the actual flash. Do it here since
85 * specific machine settings might have been set above.
87 printk(KERN_NOTICE "OMAP toto flash: probing %d-bit flash bus\n",
88 omap_toto_map_flash.bankwidth*8);
89 flash_mtd = do_map_probe("jedec_probe", &omap_toto_map_flash);
90 if (!flash_mtd)
91 return -ENXIO;
93 if (parsed_nr_parts > 0) {
94 parts = parsed_parts;
95 nb_parts = parsed_nr_parts;
98 if (nb_parts == 0) {
99 printk(KERN_NOTICE "OMAP toto flash: no partition info available,"
100 "registering whole flash at once\n");
101 if (add_mtd_device(flash_mtd)){
102 return -ENXIO;
104 } else {
105 printk(KERN_NOTICE "Using %s partition definition\n",
106 part_type);
107 return add_mtd_partitions(flash_mtd, parts, nb_parts);
109 return 0;
112 int __init omap_toto_mtd_init(void)
114 int status;
116 if (status = init_flash()) {
117 printk(KERN_ERR "OMAP Toto Flash: unable to init map for toto flash\n");
119 return status;
122 static void __exit omap_toto_mtd_cleanup(void)
124 if (flash_mtd) {
125 del_mtd_partitions(flash_mtd);
126 map_destroy(flash_mtd);
127 if (parsed_parts)
128 kfree(parsed_parts);
132 module_init(omap_toto_mtd_init);
133 module_exit(omap_toto_mtd_cleanup);
135 MODULE_AUTHOR("Jian Zhang");
136 MODULE_DESCRIPTION("OMAP Toto board map driver");
137 MODULE_LICENSE("GPL");