aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTodd Poynor <tpoynor@mvista.com>2005-11-07 16:47:48 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2007-09-23 13:40:14 -0400
commite644f7d6289456657996df4192de76c5d0a9f9c7 (patch)
tree0c34302a7b43bc84ffd02acef5d11493e049eb31 /drivers
parentb38178ee712e8608f20c8e741adf97f75f1aea39 (diff)
[MTD] MAPS: Merge Lubbock and Mainstone drivers into common PXA2xx driver
Replace Lubbock and Mainstone board drivers with common PXA2xx driver, convert to platform driver (corresponding platform device changes merged to kernel.org for 2.6.15), add power management callbacks. Signed-off-by: Todd Poynor <tpoynor@mvista.com> Signed-off-by: Nicolas Pitre <npitre@mvista.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/maps/Kconfig16
-rw-r--r--drivers/mtd/maps/Makefile3
-rw-r--r--drivers/mtd/maps/lubbock-flash.c170
-rw-r--r--drivers/mtd/maps/mainstone-flash.c181
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c200
5 files changed, 205 insertions, 365 deletions
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 1c9716381fe9..7559950e42d0 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -163,20 +163,12 @@ config MTD_SBC_GXX
163 More info at 163 More info at
164 <http://www.arcomcontrols.com/products/icp/pc104/processors/SBC_GX1.htm>. 164 <http://www.arcomcontrols.com/products/icp/pc104/processors/SBC_GX1.htm>.
165 165
166config MTD_LUBBOCK 166config MTD_PXA2XX
167 tristate "CFI Flash device mapped on Intel Lubbock XScale eval board" 167 tristate "CFI Flash device mapped on Intel XScale PXA2xx based boards"
168 depends on ARCH_LUBBOCK && MTD_CFI_INTELEXT && MTD_PARTITIONS 168 depends on (PXA25x || PXA27x) && MTD_CFI_INTELEXT
169 help
170 This provides a driver for the on-board flash of the Intel
171 'Lubbock' XScale evaluation board.
172
173config MTD_MAINSTONE
174 tristate "CFI Flash device mapped on Intel Mainstone XScale eval board"
175 depends on MACH_MAINSTONE && MTD_CFI_INTELEXT
176 select MTD_PARTITIONS 169 select MTD_PARTITIONS
177 help 170 help
178 This provides a driver for the on-board flash of the Intel 171 This provides a driver for the NOR flash attached to a PXA2xx chip.
179 'Mainstone PXA27x evaluation board.
180 172
181config MTD_OCTAGON 173config MTD_OCTAGON
182 tristate "JEDEC Flash device mapped on Octagon 5066 SBC" 174 tristate "JEDEC Flash device mapped on Octagon 5066 SBC"
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 53fa2b55b494..1313eee61afc 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -20,8 +20,7 @@ obj-$(CONFIG_MTD_ESB2ROM) += esb2rom.o
20obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o 20obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o
21obj-$(CONFIG_MTD_CK804XROM) += ck804xrom.o 21obj-$(CONFIG_MTD_CK804XROM) += ck804xrom.o
22obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o 22obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o
23obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o 23obj-$(CONFIG_MTD_PXA2XX) += pxa2xx-flash.o
24obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o
25obj-$(CONFIG_MTD_MBX860) += mbx860.o 24obj-$(CONFIG_MTD_MBX860) += mbx860.o
26obj-$(CONFIG_MTD_CEIVA) += ceiva.o 25obj-$(CONFIG_MTD_CEIVA) += ceiva.o
27obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o 26obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o
diff --git a/drivers/mtd/maps/lubbock-flash.c b/drivers/mtd/maps/lubbock-flash.c
deleted file mode 100644
index 1aa0447c5e66..000000000000
--- a/drivers/mtd/maps/lubbock-flash.c
+++ /dev/null
@@ -1,170 +0,0 @@
1/*
2 * $Id: lubbock-flash.c,v 1.21 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Map driver for the Lubbock 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/slab.h>
19
20#include <linux/dma-mapping.h>
21#include <linux/mtd/mtd.h>
22#include <linux/mtd/map.h>
23#include <linux/mtd/partitions.h>
24
25#include <asm/io.h>
26#include <asm/hardware.h>
27#include <asm/arch/pxa-regs.h>
28#include <asm/arch/lubbock.h>
29
30
31#define ROM_ADDR 0x00000000
32#define FLASH_ADDR 0x04000000
33
34#define WINDOW_SIZE 64*1024*1024
35
36static void lubbock_map_inval_cache(struct map_info *map, unsigned long from, ssize_t len)
37{
38 consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
39}
40
41static struct map_info lubbock_maps[2] = { {
42 .size = WINDOW_SIZE,
43 .phys = 0x00000000,
44 .inval_cache = lubbock_map_inval_cache,
45}, {
46 .size = WINDOW_SIZE,
47 .phys = 0x04000000,
48 .inval_cache = lubbock_map_inval_cache,
49} };
50
51static struct mtd_partition lubbock_partitions[] = {
52 {
53 .name = "Bootloader",
54 .size = 0x00040000,
55 .offset = 0,
56 .mask_flags = MTD_WRITEABLE /* force read-only */
57 },{
58 .name = "Kernel",
59 .size = 0x00100000,
60 .offset = 0x00040000,
61 },{
62 .name = "Filesystem",
63 .size = MTDPART_SIZ_FULL,
64 .offset = 0x00140000
65 }
66};
67
68static struct mtd_info *mymtds[2];
69static struct mtd_partition *parsed_parts[2];
70static int nr_parsed_parts[2];
71
72static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
73
74static int __init init_lubbock(void)
75{
76 int flashboot = (LUB_CONF_SWITCHES & 1);
77 int ret = 0, i;
78
79 lubbock_maps[0].bankwidth = lubbock_maps[1].bankwidth =
80 (BOOT_DEF & 1) ? 2 : 4;
81
82 /* Compensate for the nROMBT switch which swaps the flash banks */
83 printk(KERN_NOTICE "Lubbock configured to boot from %s (bank %d)\n",
84 flashboot?"Flash":"ROM", flashboot);
85
86 lubbock_maps[flashboot^1].name = "Lubbock Application Flash";
87 lubbock_maps[flashboot].name = "Lubbock Boot ROM";
88
89 for (i = 0; i < 2; i++) {
90 lubbock_maps[i].virt = ioremap(lubbock_maps[i].phys, WINDOW_SIZE);
91 if (!lubbock_maps[i].virt) {
92 printk(KERN_WARNING "Failed to ioremap %s\n", lubbock_maps[i].name);
93 if (!ret)
94 ret = -ENOMEM;
95 continue;
96 }
97 lubbock_maps[i].cached = ioremap_cached(lubbock_maps[i].phys, WINDOW_SIZE);
98 if (!lubbock_maps[i].cached)
99 printk(KERN_WARNING "Failed to ioremap cached %s\n", lubbock_maps[i].name);
100 simple_map_init(&lubbock_maps[i]);
101
102 printk(KERN_NOTICE "Probing %s at physical address 0x%08lx (%d-bit bankwidth)\n",
103 lubbock_maps[i].name, lubbock_maps[i].phys,
104 lubbock_maps[i].bankwidth * 8);
105
106 mymtds[i] = do_map_probe("cfi_probe", &lubbock_maps[i]);
107
108 if (!mymtds[i]) {
109 iounmap((void *)lubbock_maps[i].virt);
110 if (lubbock_maps[i].cached)
111 iounmap(lubbock_maps[i].cached);
112 if (!ret)
113 ret = -EIO;
114 continue;
115 }
116 mymtds[i]->owner = THIS_MODULE;
117
118 ret = parse_mtd_partitions(mymtds[i], probes,
119 &parsed_parts[i], 0);
120
121 if (ret > 0)
122 nr_parsed_parts[i] = ret;
123 }
124
125 if (!mymtds[0] && !mymtds[1])
126 return ret;
127
128 for (i = 0; i < 2; i++) {
129 if (!mymtds[i]) {
130 printk(KERN_WARNING "%s is absent. Skipping\n", lubbock_maps[i].name);
131 } else if (nr_parsed_parts[i]) {
132 add_mtd_partitions(mymtds[i], parsed_parts[i], nr_parsed_parts[i]);
133 } else if (!i) {
134 printk("Using static partitions on %s\n", lubbock_maps[i].name);
135 add_mtd_partitions(mymtds[i], lubbock_partitions, ARRAY_SIZE(lubbock_partitions));
136 } else {
137 printk("Registering %s as whole device\n", lubbock_maps[i].name);
138 add_mtd_device(mymtds[i]);
139 }
140 }
141 return 0;
142}
143
144static void __exit cleanup_lubbock(void)
145{
146 int i;
147 for (i = 0; i < 2; i++) {
148 if (!mymtds[i])
149 continue;
150
151 if (nr_parsed_parts[i] || !i)
152 del_mtd_partitions(mymtds[i]);
153 else
154 del_mtd_device(mymtds[i]);
155
156 map_destroy(mymtds[i]);
157 iounmap((void *)lubbock_maps[i].virt);
158 if (lubbock_maps[i].cached)
159 iounmap(lubbock_maps[i].cached);
160
161 kfree(parsed_parts[i]);
162 }
163}
164
165module_init(init_lubbock);
166module_exit(cleanup_lubbock);
167
168MODULE_LICENSE("GPL");
169MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
170MODULE_DESCRIPTION("MTD map driver for Intel Lubbock");
diff --git a/drivers/mtd/maps/mainstone-flash.c b/drivers/mtd/maps/mainstone-flash.c
deleted file mode 100644
index eaa4bbb868a3..000000000000
--- a/drivers/mtd/maps/mainstone-flash.c
+++ /dev/null
@@ -1,181 +0,0 @@
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/slab.h>
20
21#include <linux/mtd/mtd.h>
22#include <linux/mtd/map.h>
23#include <linux/mtd/partitions.h>
24
25#include <asm/io.h>
26#include <asm/hardware.h>
27#include <asm/arch/pxa-regs.h>
28#include <asm/arch/mainstone.h>
29
30
31#define ROM_ADDR 0x00000000
32#define FLASH_ADDR 0x04000000
33
34#define WINDOW_SIZE 0x04000000
35
36static void mainstone_map_inval_cache(struct map_info *map, unsigned long from,
37 ssize_t len)
38{
39 consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
40}
41
42static struct map_info mainstone_maps[2] = { {
43 .size = WINDOW_SIZE,
44 .phys = PXA_CS0_PHYS,
45 .inval_cache = mainstone_map_inval_cache,
46}, {
47 .size = WINDOW_SIZE,
48 .phys = PXA_CS1_PHYS,
49 .inval_cache = mainstone_map_inval_cache,
50} };
51
52static struct mtd_partition mainstone_partitions[] = {
53 {
54 .name = "Bootloader",
55 .size = 0x00040000,
56 .offset = 0,
57 .mask_flags = MTD_WRITEABLE /* force read-only */
58 },{
59 .name = "Kernel",
60 .size = 0x00400000,
61 .offset = 0x00040000,
62 },{
63 .name = "Filesystem",
64 .size = MTDPART_SIZ_FULL,
65 .offset = 0x00440000
66 }
67};
68
69static struct mtd_info *mymtds[2];
70static struct mtd_partition *parsed_parts[2];
71static int nr_parsed_parts[2];
72
73static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
74
75static int __init init_mainstone(void)
76{
77 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
78 int ret = 0, i;
79
80 mainstone_maps[0].bankwidth = (BOOT_DEF & 1) ? 2 : 4;
81 mainstone_maps[1].bankwidth = 4;
82
83 /* Compensate for SW7 which swaps the flash banks */
84 mainstone_maps[SW7].name = "processor flash";
85 mainstone_maps[SW7 ^ 1].name = "main board flash";
86
87 printk(KERN_NOTICE "Mainstone configured to boot from %s\n",
88 mainstone_maps[0].name);
89
90 for (i = 0; i < 2; i++) {
91 mainstone_maps[i].virt = ioremap(mainstone_maps[i].phys,
92 WINDOW_SIZE);
93 if (!mainstone_maps[i].virt) {
94 printk(KERN_WARNING "Failed to ioremap %s\n",
95 mainstone_maps[i].name);
96 if (!ret)
97 ret = -ENOMEM;
98 continue;
99 }
100 mainstone_maps[i].cached =
101 ioremap_cached(mainstone_maps[i].phys, WINDOW_SIZE);
102 if (!mainstone_maps[i].cached)
103 printk(KERN_WARNING "Failed to ioremap cached %s\n",
104 mainstone_maps[i].name);
105 simple_map_init(&mainstone_maps[i]);
106
107 printk(KERN_NOTICE
108 "Probing %s at physical address 0x%08lx"
109 " (%d-bit bankwidth)\n",
110 mainstone_maps[i].name, mainstone_maps[i].phys,
111 mainstone_maps[i].bankwidth * 8);
112
113 mymtds[i] = do_map_probe("cfi_probe", &mainstone_maps[i]);
114
115 if (!mymtds[i]) {
116 iounmap((void *)mainstone_maps[i].virt);
117 if (mainstone_maps[i].cached)
118 iounmap(mainstone_maps[i].cached);
119 if (!ret)
120 ret = -EIO;
121 continue;
122 }
123 mymtds[i]->owner = THIS_MODULE;
124
125 ret = parse_mtd_partitions(mymtds[i], probes,
126 &parsed_parts[i], 0);
127
128 if (ret > 0)
129 nr_parsed_parts[i] = ret;
130 }
131
132 if (!mymtds[0] && !mymtds[1])
133 return ret;
134
135 for (i = 0; i < 2; i++) {
136 if (!mymtds[i]) {
137 printk(KERN_WARNING "%s is absent. Skipping\n",
138 mainstone_maps[i].name);
139 } else if (nr_parsed_parts[i]) {
140 add_mtd_partitions(mymtds[i], parsed_parts[i],
141 nr_parsed_parts[i]);
142 } else if (!i) {
143 printk("Using static partitions on %s\n",
144 mainstone_maps[i].name);
145 add_mtd_partitions(mymtds[i], mainstone_partitions,
146 ARRAY_SIZE(mainstone_partitions));
147 } else {
148 printk("Registering %s as whole device\n",
149 mainstone_maps[i].name);
150 add_mtd_device(mymtds[i]);
151 }
152 }
153 return 0;
154}
155
156static void __exit cleanup_mainstone(void)
157{
158 int i;
159 for (i = 0; i < 2; i++) {
160 if (!mymtds[i])
161 continue;
162
163 if (nr_parsed_parts[i] || !i)
164 del_mtd_partitions(mymtds[i]);
165 else
166 del_mtd_device(mymtds[i]);
167
168 map_destroy(mymtds[i]);
169 iounmap((void *)mainstone_maps[i].virt);
170 if (mainstone_maps[i].cached)
171 iounmap(mainstone_maps[i].cached);
172 kfree(parsed_parts[i]);
173 }
174}
175
176module_init(init_mainstone);
177module_exit(cleanup_mainstone);
178
179MODULE_LICENSE("GPL");
180MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
181MODULE_DESCRIPTION("MTD map driver for Intel Mainstone");
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
new file mode 100644
index 000000000000..cb933ac475d5
--- /dev/null
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -0,0 +1,200 @@
1/*
2 * Map driver for Intel XScale PXA2xx platforms.
3 *
4 * Author: Nicolas Pitre
5 * Copyright: (C) 2001 MontaVista Software Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/dma-mapping.h>
18#include <linux/mtd/mtd.h>
19#include <linux/mtd/map.h>
20#include <linux/mtd/partitions.h>
21
22#include <asm/io.h>
23#include <asm/hardware.h>
24
25#include <asm/mach/flash.h>
26
27static void pxa2xx_map_inval_cache(struct map_info *map, unsigned long from,
28 ssize_t len)
29{
30 consistent_sync((char *)map->cached + from, len, DMA_FROM_DEVICE);
31}
32
33struct pxa2xx_flash_info {
34 struct mtd_partition *parts;
35 int nr_parts;
36 struct mtd_info *mtd;
37 struct map_info map;
38};
39
40
41static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
42
43
44static int __init pxa2xx_flash_probe(struct device *dev)
45{
46 struct platform_device *pdev = to_platform_device(dev);
47 struct flash_platform_data *flash = pdev->dev.platform_data;
48 struct pxa2xx_flash_info *info;
49 struct mtd_partition *parts;
50 struct resource *res;
51 int ret = 0;
52
53 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
54 if (!res)
55 return -ENODEV;
56
57 info = kmalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL);
58 if (!info)
59 return -ENOMEM;
60
61 memset(info, 0, sizeof(struct pxa2xx_flash_info));
62 info->map.name = (char *) flash->name;
63 info->map.bankwidth = flash->width;
64 info->map.phys = res->start;
65 info->map.size = res->end - res->start + 1;
66 info->parts = flash->parts;
67 info->nr_parts = flash->nr_parts;
68
69 info->map.virt = ioremap(info->map.phys, info->map.size);
70 if (!info->map.virt) {
71 printk(KERN_WARNING "Failed to ioremap %s\n",
72 info->map.name);
73 return -ENOMEM;
74 }
75 info->map.cached =
76 ioremap_cached(info->map.phys, info->map.size);
77 if (!info->map.cached)
78 printk(KERN_WARNING "Failed to ioremap cached %s\n",
79 info->map.name);
80 info->map.inval_cache = pxa2xx_map_inval_cache;
81 simple_map_init(&info->map);
82
83 printk(KERN_NOTICE
84 "Probing %s at physical address 0x%08lx"
85 " (%d-bit bankwidth)\n",
86 info->map.name, (unsigned long)info->map.phys,
87 info->map.bankwidth * 8);
88
89 info->mtd = do_map_probe(flash->map_name, &info->map);
90
91 if (!info->mtd) {
92 iounmap((void *)info->map.virt);
93 if (info->map.cached)
94 iounmap(info->map.cached);
95 return -EIO;
96 }
97 info->mtd->owner = THIS_MODULE;
98
99#ifdef CONFIG_MTD_PARTITIONS
100 ret = parse_mtd_partitions(info->mtd, probes, &parts, 0);
101
102 if (ret > 0) {
103 info->nr_parts = ret;
104 info->parts = parts;
105 }
106#endif
107
108 if (info->nr_parts) {
109 add_mtd_partitions(info->mtd, info->parts,
110 info->nr_parts);
111 } else {
112 printk("Registering %s as whole device\n",
113 info->map.name);
114 add_mtd_device(info->mtd);
115 }
116
117 dev_set_drvdata(dev, info);
118 return 0;
119}
120
121static int __exit pxa2xx_flash_remove(struct device *dev)
122{
123 struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
124
125 dev_set_drvdata(dev, NULL);
126
127#ifdef CONFIG_MTD_PARTITIONS
128 if (info->nr_parts)
129 del_mtd_partitions(info->mtd);
130 else
131#endif
132 del_mtd_device(info->mtd);
133
134 map_destroy(info->mtd);
135 iounmap(info->map.virt);
136 if (info->map.cached)
137 iounmap(info->map.cached);
138 kfree(info->parts);
139 kfree(info);
140 return 0;
141}
142
143#ifdef CONFIG_PM
144static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state)
145{
146 struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
147 int ret = 0;
148
149 if (info->mtd && info->mtd->suspend)
150 ret = info->mtd->suspend(info->mtd);
151 return ret;
152}
153
154static int pxa2xx_flash_resume(struct device *dev)
155{
156 struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
157
158 if (info->mtd && info->mtd->resume)
159 info->mtd->resume(info->mtd);
160 return 0;
161}
162static void pxa2xx_flash_shutdown(struct device *dev)
163{
164 struct pxa2xx_flash_info *info = dev_get_drvdata(dev);
165
166 if (info && info->mtd->suspend(info->mtd) == 0)
167 info->mtd->resume(info->mtd);
168}
169#else
170#define pxa2xx_flash_suspend NULL
171#define pxa2xx_flash_resume NULL
172#define pxa2xx_flash_shutdown NULL
173#endif
174
175static struct device_driver pxa2xx_flash_driver = {
176 .name = "pxa2xx-flash",
177 .bus = &platform_bus_type,
178 .probe = pxa2xx_flash_probe,
179 .remove = __exit_p(pxa2xx_flash_remove),
180 .suspend = pxa2xx_flash_suspend,
181 .resume = pxa2xx_flash_resume,
182 .shutdown = pxa2xx_flash_shutdown,
183};
184
185static int __init init_pxa2xx_flash(void)
186{
187 return driver_register(&pxa2xx_flash_driver);
188}
189
190static void __exit cleanup_pxa2xx_flash(void)
191{
192 driver_unregister(&pxa2xx_flash_driver);
193}
194
195module_init(init_pxa2xx_flash);
196module_exit(cleanup_pxa2xx_flash);
197
198MODULE_LICENSE("GPL");
199MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
200MODULE_DESCRIPTION("MTD map driver for Intel XScale PXA2xx");