MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / mtd / maps / edb7312.c
blobb7fd849dc1fc2927608524eefb7acf09d9ec2443
1 /*
2 * $Id: edb7312.c,v 1.11 2004/07/14 09:52:55 dwmw2 Exp $
4 * Handle mapping of the NOR flash on Cogent EDB7312 boards
6 * Copyright 2002 SYSGO Real-Time Solutions GmbH
7 *
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>
17 #include <asm/io.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/config.h>
22 #ifdef CONFIG_MTD_PARTITIONS
23 #include <linux/mtd/partitions.h>
24 #endif
26 #define WINDOW_ADDR 0x00000000 /* physical properties of flash */
27 #define WINDOW_SIZE 0x01000000
28 #define BUSWIDTH 2
29 #define FLASH_BLOCKSIZE_MAIN 0x20000
30 #define FLASH_NUMBLOCKS_MAIN 128
31 /* can be "cfi_probe", "jedec_probe", "map_rom", NULL }; */
32 #define PROBETYPES { "cfi_probe", NULL }
34 #define MSG_PREFIX "EDB7312-NOR:" /* prefix for our printk()'s */
35 #define MTDID "edb7312-nor" /* for mtdparts= partitioning */
37 static struct mtd_info *mymtd;
39 struct map_info edb7312nor_map = {
40 .name = "NOR flash on EDB7312",
41 .size = WINDOW_SIZE,
42 .bankwidth = BUSWIDTH,
43 .phys = WINDOW_ADDR,
46 #ifdef CONFIG_MTD_PARTITIONS
49 * MTD partitioning stuff
51 static struct mtd_partition static_partitions[3] =
54 .name = "ARMboot",
55 .size = 0x40000,
56 .offset = 0
59 .name = "Kernel",
60 .size = 0x200000,
61 .offset = 0x40000
64 .name = "RootFS",
65 .size = 0xDC0000,
66 .offset = 0x240000
70 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
72 #endif
74 static int mtd_parts_nb;
75 static struct mtd_partition *mtd_parts;
77 int __init init_edb7312nor(void)
79 static const char *rom_probe_types[] = PROBETYPES;
80 const char **type;
81 const char *part_type = NULL;
83 printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n",
84 WINDOW_SIZE, WINDOW_ADDR);
85 edb7312nor_map.virt = (unsigned long)
86 ioremap(WINDOW_ADDR, WINDOW_SIZE);
88 if (!edb7312nor_map.virt) {
89 printk(MSG_PREFIX "failed to ioremap\n");
90 return -EIO;
93 simple_map_init(&edb7312nor_map);
95 mymtd = NULL;
96 type = rom_probe_types;
97 for(; !mymtd && *type; type++) {
98 mymtd = do_map_probe(*type, &edb7312nor_map);
100 if (mymtd) {
101 mymtd->owner = THIS_MODULE;
103 #ifdef CONFIG_MTD_PARTITIONS
104 mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, MTDID);
105 if (mtd_parts_nb > 0)
106 part_type = "detected";
108 if (mtd_parts_nb == 0)
110 mtd_parts = static_partitions;
111 mtd_parts_nb = ARRAY_SIZE(static_partitions);
112 part_type = "static";
114 #endif
115 add_mtd_device(mymtd);
116 if (mtd_parts_nb == 0)
117 printk(KERN_NOTICE MSG_PREFIX "no partition info available\n");
118 else
120 printk(KERN_NOTICE MSG_PREFIX
121 "using %s partition definition\n", part_type);
122 add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);
124 return 0;
127 iounmap((void *)edb7312nor_map.virt);
128 return -ENXIO;
131 static void __exit cleanup_edb7312nor(void)
133 if (mymtd) {
134 del_mtd_device(mymtd);
135 map_destroy(mymtd);
137 if (edb7312nor_map.virt) {
138 iounmap((void *)edb7312nor_map.virt);
139 edb7312nor_map.virt = 0;
143 module_init(init_edb7312nor);
144 module_exit(cleanup_edb7312nor);
146 MODULE_LICENSE("GPL");
147 MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
148 MODULE_DESCRIPTION("Generic configurable MTD map driver");