2 * Handle mapping of the NOR flash on Cogent EDB7312 boards
4 * Copyright 2002 SYSGO Real-Time Solutions GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/map.h>
18 #include <linux/mtd/partitions.h>
20 #define WINDOW_ADDR 0x00000000 /* physical properties of flash */
21 #define WINDOW_SIZE 0x01000000
23 #define FLASH_BLOCKSIZE_MAIN 0x20000
24 #define FLASH_NUMBLOCKS_MAIN 128
25 /* can be "cfi_probe", "jedec_probe", "map_rom", NULL }; */
26 #define PROBETYPES { "cfi_probe", NULL }
28 #define MSG_PREFIX "EDB7312-NOR:" /* prefix for our printk()'s */
29 #define MTDID "edb7312-nor" /* for mtdparts= partitioning */
31 static struct mtd_info
*mymtd
;
33 struct map_info edb7312nor_map
= {
34 .name
= "NOR flash on EDB7312",
36 .bankwidth
= BUSWIDTH
,
41 * MTD partitioning stuff
43 static struct mtd_partition static_partitions
[3] =
62 static const char *probes
[] = { "RedBoot", "cmdlinepart", NULL
};
64 static int mtd_parts_nb
= 0;
65 static struct mtd_partition
*mtd_parts
= 0;
67 static int __init
init_edb7312nor(void)
69 static const char *rom_probe_types
[] = PROBETYPES
;
71 const char *part_type
= 0;
73 printk(KERN_NOTICE MSG_PREFIX
"0x%08x at 0x%08x\n",
74 WINDOW_SIZE
, WINDOW_ADDR
);
75 edb7312nor_map
.virt
= ioremap(WINDOW_ADDR
, WINDOW_SIZE
);
77 if (!edb7312nor_map
.virt
) {
78 printk(MSG_PREFIX
"failed to ioremap\n");
82 simple_map_init(&edb7312nor_map
);
85 type
= rom_probe_types
;
86 for(; !mymtd
&& *type
; type
++) {
87 mymtd
= do_map_probe(*type
, &edb7312nor_map
);
90 mymtd
->owner
= THIS_MODULE
;
92 mtd_parts_nb
= parse_mtd_partitions(mymtd
, probes
, &mtd_parts
, MTDID
);
94 part_type
= "detected";
96 if (mtd_parts_nb
== 0) {
97 mtd_parts
= static_partitions
;
98 mtd_parts_nb
= ARRAY_SIZE(static_partitions
);
102 if (mtd_parts_nb
== 0)
103 printk(KERN_NOTICE MSG_PREFIX
"no partition info available\n");
105 printk(KERN_NOTICE MSG_PREFIX
106 "using %s partition definition\n", part_type
);
107 /* Register the whole device first. */
108 mtd_device_register(mymtd
, NULL
, 0);
109 mtd_device_register(mymtd
, mtd_parts
, mtd_parts_nb
);
113 iounmap((void *)edb7312nor_map
.virt
);
117 static void __exit
cleanup_edb7312nor(void)
120 mtd_device_unregister(mymtd
);
123 if (edb7312nor_map
.virt
) {
124 iounmap((void *)edb7312nor_map
.virt
);
125 edb7312nor_map
.virt
= 0;
129 module_init(init_edb7312nor
);
130 module_exit(cleanup_edb7312nor
);
132 MODULE_LICENSE("GPL");
133 MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
134 MODULE_DESCRIPTION("Generic configurable MTD map driver");