aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps/edb7312.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/mtd/maps/edb7312.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/mtd/maps/edb7312.c')
-rw-r--r--drivers/mtd/maps/edb7312.c147
1 files changed, 147 insertions, 0 deletions
diff --git a/drivers/mtd/maps/edb7312.c b/drivers/mtd/maps/edb7312.c
new file mode 100644
index 000000000000..8b0da394f3fa
--- /dev/null
+++ b/drivers/mtd/maps/edb7312.c
@@ -0,0 +1,147 @@
1/*
2 * $Id: edb7312.c,v 1.13 2004/11/04 13:24:14 gleixner Exp $
3 *
4 * Handle mapping of the NOR flash on Cogent EDB7312 boards
5 *
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.
11 */
12
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>
21
22#ifdef CONFIG_MTD_PARTITIONS
23#include <linux/mtd/partitions.h>
24#endif
25
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 }
33
34#define MSG_PREFIX "EDB7312-NOR:" /* prefix for our printk()'s */
35#define MTDID "edb7312-nor" /* for mtdparts= partitioning */
36
37static struct mtd_info *mymtd;
38
39struct map_info edb7312nor_map = {
40 .name = "NOR flash on EDB7312",
41 .size = WINDOW_SIZE,
42 .bankwidth = BUSWIDTH,
43 .phys = WINDOW_ADDR,
44};
45
46#ifdef CONFIG_MTD_PARTITIONS
47
48/*
49 * MTD partitioning stuff
50 */
51static struct mtd_partition static_partitions[3] =
52{
53 {
54 .name = "ARMboot",
55 .size = 0x40000,
56 .offset = 0
57 },
58 {
59 .name = "Kernel",
60 .size = 0x200000,
61 .offset = 0x40000
62 },
63 {
64 .name = "RootFS",
65 .size = 0xDC0000,
66 .offset = 0x240000
67 },
68};
69
70static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
71
72#endif
73
74static int mtd_parts_nb = 0;
75static struct mtd_partition *mtd_parts = 0;
76
77int __init init_edb7312nor(void)
78{
79 static const char *rom_probe_types[] = PROBETYPES;
80 const char **type;
81 const char *part_type = 0;
82
83 printk(KERN_NOTICE MSG_PREFIX "0x%08x at 0x%08x\n",
84 WINDOW_SIZE, WINDOW_ADDR);
85 edb7312nor_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
86
87 if (!edb7312nor_map.virt) {
88 printk(MSG_PREFIX "failed to ioremap\n");
89 return -EIO;
90 }
91
92 simple_map_init(&edb7312nor_map);
93
94 mymtd = 0;
95 type = rom_probe_types;
96 for(; !mymtd && *type; type++) {
97 mymtd = do_map_probe(*type, &edb7312nor_map);
98 }
99 if (mymtd) {
100 mymtd->owner = THIS_MODULE;
101
102#ifdef CONFIG_MTD_PARTITIONS
103 mtd_parts_nb = parse_mtd_partitions(mymtd, probes, &mtd_parts, MTDID);
104 if (mtd_parts_nb > 0)
105 part_type = "detected";
106
107 if (mtd_parts_nb == 0)
108 {
109 mtd_parts = static_partitions;
110 mtd_parts_nb = ARRAY_SIZE(static_partitions);
111 part_type = "static";
112 }
113#endif
114 add_mtd_device(mymtd);
115 if (mtd_parts_nb == 0)
116 printk(KERN_NOTICE MSG_PREFIX "no partition info available\n");
117 else
118 {
119 printk(KERN_NOTICE MSG_PREFIX
120 "using %s partition definition\n", part_type);
121 add_mtd_partitions(mymtd, mtd_parts, mtd_parts_nb);
122 }
123 return 0;
124 }
125
126 iounmap((void *)edb7312nor_map.virt);
127 return -ENXIO;
128}
129
130static void __exit cleanup_edb7312nor(void)
131{
132 if (mymtd) {
133 del_mtd_device(mymtd);
134 map_destroy(mymtd);
135 }
136 if (edb7312nor_map.virt) {
137 iounmap((void *)edb7312nor_map.virt);
138 edb7312nor_map.virt = 0;
139 }
140}
141
142module_init(init_edb7312nor);
143module_exit(cleanup_edb7312nor);
144
145MODULE_LICENSE("GPL");
146MODULE_AUTHOR("Marius Groeger <mag@sysgo.de>");
147MODULE_DESCRIPTION("Generic configurable MTD map driver");