2 * drivers/mtd/maps/dm270-flash.c
4 * Flash memory access on TI TMS320DM270 based devices
6 * Derived from drivers/mtd/maps/omap-toto-flash.c
8 * Copyright (C) 2004 Chee Tim Loh <lohct@pacific.net.sg>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <linux/module.h>
32 #include <linux/types.h>
33 #include <linux/kernel.h>
35 #include <linux/errno.h>
36 #include <linux/init.h>
38 #include <linux/mtd/mtd.h>
39 #include <linux/mtd/map.h>
40 #include <linux/mtd/partitions.h>
42 #include <asm/hardware.h>
45 #ifndef CONFIG_MACH_DM270
46 # error This is for DM270 architecture only!
49 #define DM270_FLASH_BUSWIDTH 2
51 static const char *dm270_partition_types
[] = {
52 #ifdef CONFIG_MTD_CMDLINE_PARTS
55 #ifdef CONFIG_MTD_REDBOOT_PARTS
61 static struct map_info dm270_map_flash
= {
62 .name
= "DM270 flash",
63 .size
= CONFIG_FLASH_SIZE
,
64 .phys
= CONFIG_FLASH_MEM_BASE
,
65 .bankwidth
= DM270_FLASH_BUSWIDTH
,
69 * Here are partition information for all known DM270-based devices.
70 * See include/linux/mtd/partitions.h for definition of the mtd_partition
73 * The *_max_flash_size is the maximum possible mapped flash size which
74 * is not necessarily the actual flash size. It must be no more than
75 * the value specified in the "struct map_desc *_io_desc" mapping
76 * definition for the corresponding machine.
80 * 1xToshiba TC58FVB160AFT-70 16-MBIT (2Mx8 bits/1Mx16 bits) CMOS FLASH MEMORY
81 * Block erase architecture:
82 * 1x16 Kbytes / 2x8 Kbytes / 1x32 Kbytes / 31x64 Kbytes
84 #ifdef CONFIG_BOARD_XEVMDM270GHK
85 static struct mtd_partition dm270_partitions
[] = {
90 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
94 .offset
= MTDPART_OFS_APPEND
,
95 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
99 .offset
= MTDPART_OFS_APPEND
,
100 .mask_flags
= 0, /* read-write */
102 .name
= "bootloader params",
104 .offset
= MTDPART_OFS_APPEND
,
105 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
108 #elif defined(CONFIG_BOARD_IMPLDM270VP4)
109 static struct mtd_partition dm270_partitions
[] = {
111 .name
= "bootloader",
114 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
118 .offset
= MTDPART_OFS_APPEND
,
119 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
123 .offset
= MTDPART_OFS_APPEND
,
124 .mask_flags
= 0, /* read-write */
128 .offset
= MTDPART_OFS_APPEND
,
129 .mask_flags
= 0, /* read-write */
131 .name
= "bootloader params",
133 .offset
= MTDPART_OFS_APPEND
,
134 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
138 # error You have not specified your target board!
141 static struct mtd_partition
*parsed_parts
;
143 static struct mtd_info
*dm270_flash_mtd
;
146 dm270_init_flash (void)
148 struct mtd_partition
*parts
;
150 int parsed_nr_parts
= 0;
151 const char *part_type
;
154 * Static partition definition selection
156 part_type
= "static";
158 parts
= dm270_partitions
;
159 nb_parts
= ARRAY_SIZE(dm270_partitions
);
160 dm270_map_flash
.virt
= phys_to_virt(dm270_map_flash
.phys
);
162 simple_map_init(&dm270_map_flash
);
164 * Now let's probe for the actual flash. Do it here since
165 * specific machine settings might have been set above.
167 printk(KERN_NOTICE
"DM270 flash: probing %d-bit flash bus\n",
168 dm270_map_flash
.bankwidth
*8);
169 dm270_flash_mtd
= do_map_probe("cfi_probe", &dm270_map_flash
);
170 if (!dm270_flash_mtd
) {
173 dm270_flash_mtd
->owner
= THIS_MODULE
;
176 * Dynamic partition selection stuff (might override the static ones)
178 if (dm270_partition_types
[0]) {
179 parsed_nr_parts
= parse_mtd_partitions(dm270_flash_mtd
,
180 dm270_partition_types
, &parsed_parts
,
181 CONFIG_FLASH_MEM_BASE
);
183 if (parsed_nr_parts
> 0) {
184 part_type
= "dynamic";
185 parts
= parsed_parts
;
186 nb_parts
= parsed_nr_parts
;
190 printk(KERN_NOTICE
"DM270 flash: no partition info available,"
191 "registering whole flash at once\n");
192 if (add_mtd_device(dm270_flash_mtd
)) {
196 printk(KERN_NOTICE
"Using %s partition definition\n",
198 return add_mtd_partitions(dm270_flash_mtd
, parts
, nb_parts
);
208 if ((status
= dm270_init_flash())) {
209 printk(KERN_ERR
"DM270 Flash: unable to init map for DM270 flash\n");
215 dm270_mtd_cleanup(void)
217 if (dm270_flash_mtd
) {
218 del_mtd_partitions(dm270_flash_mtd
);
219 map_destroy(dm270_flash_mtd
);
225 module_init(dm270_mtd_init
);
226 module_exit(dm270_mtd_cleanup
);
228 MODULE_AUTHOR("Chee Tim Loh <lohct@pacific.net.sg>");
229 MODULE_DESCRIPTION("DM270 CFI map driver");
230 MODULE_LICENSE("GPL");