aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/maps')
-rw-r--r--drivers/mtd/maps/Kconfig10
-rw-r--r--drivers/mtd/maps/Makefile3
-rw-r--r--drivers/mtd/maps/mainstone-flash.c178
3 files changed, 189 insertions, 2 deletions
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 8d27dbf3fa8e..dbe1716c9724 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -1,5 +1,5 @@
1# drivers/mtd/maps/Kconfig 1# drivers/mtd/maps/Kconfig
2# $Id: Kconfig,v 1.51 2005/03/18 02:07:22 gleixner Exp $ 2# $Id: Kconfig,v 1.54 2005/06/30 22:41:36 tpoynor Exp $
3 3
4menu "Mapping drivers for chip access" 4menu "Mapping drivers for chip access"
5 depends on MTD!=n 5 depends on MTD!=n
@@ -129,6 +129,14 @@ config MTD_LUBBOCK
129 This provides a driver for the on-board flash of the Intel 129 This provides a driver for the on-board flash of the Intel
130 'Lubbock' XScale evaluation board. 130 'Lubbock' XScale evaluation board.
131 131
132config MTD_MAINSTONE
133 tristate "CFI Flash device mapped on Intel Mainstone XScale eval board"
134 depends on MACH_MAINSTONE && MTD_CFI_INTELEXT
135 select MTD_PARTITIONS
136 help
137 This provides a driver for the on-board flash of the Intel
138 'Mainstone PXA27x evaluation board.
139
132config MTD_OCTAGON 140config MTD_OCTAGON
133 tristate "JEDEC Flash device mapped on Octagon 5066 SBC" 141 tristate "JEDEC Flash device mapped on Octagon 5066 SBC"
134 depends on X86 && MTD_JEDEC && MTD_COMPLEX_MAPPINGS 142 depends on X86 && MTD_JEDEC && MTD_COMPLEX_MAPPINGS
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 164cafc101ca..789a4b76890d 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# linux/drivers/maps/Makefile 2# linux/drivers/maps/Makefile
3# 3#
4# $Id: Makefile.common,v 1.26 2005/03/02 14:51:04 dvrabel Exp $ 4# $Id: Makefile.common,v 1.29 2005/06/30 22:41:36 tpoynor Exp $
5 5
6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y) 6ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y)
7obj-$(CONFIG_MTD) += map_funcs.o 7obj-$(CONFIG_MTD) += map_funcs.o
@@ -22,6 +22,7 @@ obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o
22obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o 22obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o
23obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o 23obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o
24obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o 24obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o
25obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o
25obj-$(CONFIG_MTD_MBX860) += mbx860.o 26obj-$(CONFIG_MTD_MBX860) += mbx860.o
26obj-$(CONFIG_MTD_CEIVA) += ceiva.o 27obj-$(CONFIG_MTD_CEIVA) += ceiva.o
27obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o 28obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o
diff --git a/drivers/mtd/maps/mainstone-flash.c b/drivers/mtd/maps/mainstone-flash.c
new file mode 100644
index 000000000000..87e93fa60588
--- /dev/null
+++ b/drivers/mtd/maps/mainstone-flash.c
@@ -0,0 +1,178 @@
1/*
2 * $Id: $
3 *
4 * Map driver for the Mainstone developer platform.
5 *
6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/dma-mapping.h>
19#include <linux/mtd/mtd.h>
20#include <linux/mtd/map.h>
21#include <linux/mtd/partitions.h>
22#include <asm/io.h>
23#include <asm/hardware.h>
24#include <asm/arch/pxa-regs.h>
25#include <asm/arch/mainstone.h>
26
27
28#define ROM_ADDR 0x00000000
29#define FLASH_ADDR 0x04000000
30
31#define WINDOW_SIZE 0x04000000
32
33static void mainstone_map_inval_cache(struct map_info *map, unsigned long from,
34 ssize_t len)
35{
36 consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
37}
38
39static struct map_info mainstone_maps[2] = { {
40 .size = WINDOW_SIZE,
41 .phys = PXA_CS0_PHYS,
42 .inval_cache = mainstone_map_inval_cache,
43}, {
44 .size = WINDOW_SIZE,
45 .phys = PXA_CS1_PHYS,
46 .inval_cache = mainstone_map_inval_cache,
47} };
48
49static struct mtd_partition mainstone_partitions[] = {
50 {
51 .name = "Bootloader",
52 .size = 0x00040000,
53 .offset = 0,
54 .mask_flags = MTD_WRITEABLE /* force read-only */
55 },{
56 .name = "Kernel",
57 .size = 0x00400000,
58 .offset = 0x00040000,
59 },{
60 .name = "Filesystem",
61 .size = MTDPART_SIZ_FULL,
62 .offset = 0x00440000
63 }
64};
65
66static struct mtd_info *mymtds[2];
67static struct mtd_partition *parsed_parts[2];
68static int nr_parsed_parts[2];
69
70static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
71
72static int __init init_mainstone(void)
73{
74 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
75 int ret = 0, i;
76
77 mainstone_maps[0].bankwidth = (BOOT_DEF & 1) ? 2 : 4;
78 mainstone_maps[1].bankwidth = 4;
79
80 /* Compensate for SW7 which swaps the flash banks */
81 mainstone_maps[SW7].name = "processor flash";
82 mainstone_maps[SW7 ^ 1].name = "main board flash";
83
84 printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
85 mainstone_maps[0].name);
86
87 for (i = 0; i < 2; i++) {
88 mainstone_maps[i].virt = ioremap(mainstone_maps[i].phys,
89 WINDOW_SIZE);
90 if (!mainstone_maps[i].virt) {
91 printk(KERN_WARNING "Failed to ioremap %s\n",
92 mainstone_maps[i].name);
93 if (!ret)
94 ret = -ENOMEM;
95 continue;
96 }
97 mainstone_maps[i].cached =
98 ioremap_cached(mainstone_maps[i].phys, WINDOW_SIZE);
99 if (!mainstone_maps[i].cached)
100 printk(KERN_WARNING "Failed to ioremap cached %s\n",
101 mainstone_maps[i].name);
102 simple_map_init(&mainstone_maps[i]);
103
104 printk(KERN_NOTICE
105 "Probing %s at physical address 0x%08lx"
106 " (%d-bit bankwidth)\n",
107 mainstone_maps[i].name, mainstone_maps[i].phys,
108 mainstone_maps[i].bankwidth * 8);
109
110 mymtds[i] = do_map_probe("cfi_probe", &mainstone_maps[i]);
111
112 if (!mymtds[i]) {
113 iounmap((void *)mainstone_maps[i].virt);
114 if (mainstone_maps[i].cached)
115 iounmap(mainstone_maps[i].cached);
116 if (!ret)
117 ret = -EIO;
118 continue;
119 }
120 mymtds[i]->owner = THIS_MODULE;
121
122 ret = parse_mtd_partitions(mymtds[i], probes,
123 &parsed_parts[i], 0);
124
125 if (ret > 0)
126 nr_parsed_parts[i] = ret;
127 }
128
129 if (!mymtds[0] && !mymtds[1])
130 return ret;
131
132 for (i = 0; i < 2; i++) {
133 if (!mymtds[i]) {
134 printk(KERN_WARNING "%s is absent. Skipping\n",
135 mainstone_maps[i].name);
136 } else if (nr_parsed_parts[i]) {
137 add_mtd_partitions(mymtds[i], parsed_parts[i],
138 nr_parsed_parts[i]);
139 } else if (!i) {
140 printk("Using static partitions on %s\n",
141 mainstone_maps[i].name);
142 add_mtd_partitions(mymtds[i], mainstone_partitions,
143 ARRAY_SIZE(mainstone_partitions));
144 } else {
145 printk("Registering %s as whole device\n",
146 mainstone_maps[i].name);
147 add_mtd_device(mymtds[i]);
148 }
149 }
150 return 0;
151}
152
153static void __exit cleanup_mainstone(void)
154{
155 int i;
156 for (i = 0; i < 2; i++) {
157 if (!mymtds[i])
158 continue;
159
160 if (nr_parsed_parts[i] || !i)
161 del_mtd_partitions(mymtds[i]);
162 else
163 del_mtd_device(mymtds[i]);
164
165 map_destroy(mymtds[i]);
166 iounmap((void *)mainstone_maps[i].virt);
167 if (mainstone_maps[i].cached)
168 iounmap(mainstone_maps[i].cached);
169 kfree(parsed_parts[i]);
170 }
171}
172
173module_init(init_mainstone);
174module_exit(cleanup_mainstone);
175
176MODULE_LICENSE("GPL");
177MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
178MODULE_DESCRIPTION("MTD map driver for Intel Mainstone");