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 $
11 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
15 #include <linux/errno.h>
16 #include <linux/init.h>
17 #include <linux/slab.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/map.h>
21 #include <linux/mtd/partitions.h>
23 #include <asm/hardware.h>
27 #ifndef CONFIG_ARCH_OMAP
28 #error This is for OMAP architecture only
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",
38 .virt
= (void __iomem
*)OMAP_TOTO_FLASH_BASE
,
42 static struct mtd_partition toto_flash_partitions
[] = {
45 .size
= 0x00040000, /* hopefully u-boot will stay 128k + 128*/
47 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
49 .name
= "ReservedSpace",
51 .offset
= MTDPART_OFS_APPEND
,
52 //mask_flags: MTD_WRITEABLE, /* force read-only */
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
;
69 int parsed_nr_parts
= 0;
70 const char *part_type
;
73 * Static partition definition selection
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
);
93 if (parsed_nr_parts
> 0) {
95 nb_parts
= parsed_nr_parts
;
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
)){
105 printk(KERN_NOTICE
"Using %s partition definition\n",
107 return add_mtd_partitions(flash_mtd
, parts
, nb_parts
);
112 int __init
omap_toto_mtd_init(void)
116 if (status
= init_flash()) {
117 printk(KERN_ERR
"OMAP Toto Flash: unable to init map for toto flash\n");
122 static void __exit
omap_toto_mtd_cleanup(void)
125 del_mtd_partitions(flash_mtd
);
126 map_destroy(flash_mtd
);
131 module_init(omap_toto_mtd_init
);
132 module_exit(omap_toto_mtd_cleanup
);
134 MODULE_AUTHOR("Jian Zhang");
135 MODULE_DESCRIPTION("OMAP Toto board map driver");
136 MODULE_LICENSE("GPL");