2 * $Id: edb7312.c,v 1.14 2005/11/07 11:14:27 gleixner Exp $
4 * Handle mapping of the NOR flash on Cogent EDB7312 boards
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
21 #ifdef CONFIG_MTD_PARTITIONS
22 #include <linux/mtd/partitions.h>
25 #define WINDOW_ADDR 0x00000000 /* physical properties of flash */
26 #define WINDOW_SIZE 0x01000000
28 #define FLASH_BLOCKSIZE_MAIN 0x20000
29 #define FLASH_NUMBLOCKS_MAIN 128
30 /* can be "cfi_probe", "jedec_probe", "map_rom", NULL }; */
31 #define PROBETYPES { "cfi_probe", NULL }
33 #define MSG_PREFIX "EDB7312-NOR:" /* prefix for our printk()'s */
34 #define MTDID "edb7312-nor" /* for mtdparts= partitioning */
36 static struct mtd_info
*mymtd
;
38 struct map_info edb7312nor_map
= {
39 .name
= "NOR flash on EDB7312",
41 .bankwidth
= BUSWIDTH
,
45 #ifdef CONFIG_MTD_PARTITIONS
48 * MTD partitioning stuff
50 static struct mtd_partition static_partitions
[3] =
69 static const char *probes
[] = { "RedBoot", "cmdlinepart", NULL
};
73 static int mtd_parts_nb
= 0;
74 static struct mtd_partition
*mtd_parts
= 0;
76 int __init
init_edb7312nor(void)
78 static const char *rom_probe_types
[] = PROBETYPES
;
80 const char *part_type
= 0;
82 printk(KERN_NOTICE MSG_PREFIX
"0x%08x at 0x%08x\n",
83 WINDOW_SIZE
, WINDOW_ADDR
);
84 edb7312nor_map
.virt
= ioremap(WINDOW_ADDR
, WINDOW_SIZE
);
86 if (!edb7312nor_map
.virt
) {
87 printk(MSG_PREFIX
"failed to ioremap\n");
91 simple_map_init(&edb7312nor_map
);
94 type
= rom_probe_types
;
95 for(; !mymtd
&& *type
; type
++) {
96 mymtd
= do_map_probe(*type
, &edb7312nor_map
);
99 mymtd
->owner
= THIS_MODULE
;
101 #ifdef CONFIG_MTD_PARTITIONS
102 mtd_parts_nb
= parse_mtd_partitions(mymtd
, probes
, &mtd_parts
, MTDID
);
103 if (mtd_parts_nb
> 0)
104 part_type
= "detected";
106 if (mtd_parts_nb
== 0)
108 mtd_parts
= static_partitions
;
109 mtd_parts_nb
= ARRAY_SIZE(static_partitions
);
110 part_type
= "static";
113 add_mtd_device(mymtd
);
114 if (mtd_parts_nb
== 0)
115 printk(KERN_NOTICE MSG_PREFIX
"no partition info available\n");
118 printk(KERN_NOTICE MSG_PREFIX
119 "using %s partition definition\n", part_type
);
120 add_mtd_partitions(mymtd
, mtd_parts
, mtd_parts_nb
);
125 iounmap((void *)edb7312nor_map
.virt
);
129 static void __exit
cleanup_edb7312nor(void)
132 del_mtd_device(mymtd
);
135 if (edb7312nor_map
.virt
) {
136 iounmap((void *)edb7312nor_map
.virt
);
137 edb7312nor_map
.virt
= 0;
141 module_init(init_edb7312nor
);
142 module_exit(cleanup_edb7312nor
);
144 MODULE_LICENSE("GPL");
145 MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
146 MODULE_DESCRIPTION("Generic configurable MTD map driver");