1 /*======================================================================
3 drivers/mtd/maps/integrator-flash.c: ARM Integrator flash map driver
5 Copyright (C) 2000 ARM Limited
6 Copyright (C) 2003 Deep Blue Solutions Ltd.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 This is access code for flashes using ARM's flash partitioning
25 $Id: integrator-flash.c,v 1.20 2005/11/07 11:14:27 gleixner Exp $
27 ======================================================================*/
29 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/kernel.h>
32 #include <linux/slab.h>
33 #include <linux/ioport.h>
34 #include <linux/platform_device.h>
35 #include <linux/init.h>
37 #include <linux/mtd/mtd.h>
38 #include <linux/mtd/map.h>
39 #include <linux/mtd/partitions.h>
41 #include <asm/mach/flash.h>
42 #include <asm/hardware.h>
44 #include <asm/system.h>
46 #ifdef CONFIG_ARCH_P720T
47 #define FLASH_BASE (0x04000000)
48 #define FLASH_SIZE (64*1024*1024)
51 struct armflash_info {
52 struct flash_platform_data *plat;
54 struct mtd_partition *parts;
59 static void armflash_set_vpp(struct map_info *map, int on)
61 struct armflash_info *info = container_of(map, struct armflash_info, map);
63 if (info->plat && info->plat->set_vpp)
64 info->plat->set_vpp(on);
67 static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL };
69 static int armflash_probe(struct platform_device *dev)
71 struct flash_platform_data *plat = dev->dev.platform_data;
72 struct resource *res = dev->resource;
73 unsigned int size = res->end - res->start + 1;
74 struct armflash_info *info;
78 info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);
84 memset(info, 0, sizeof(struct armflash_info));
87 if (plat && plat->init) {
93 info->res = request_mem_region(res->start, size, "armflash");
99 base = ioremap(res->start, size);
106 * look for CFI based flash parts fitted to this board
108 info->map.size = size;
109 info->map.bankwidth = plat->width;
110 info->map.phys = res->start;
111 info->map.virt = base;
112 info->map.name = dev->dev.bus_id;
113 info->map.set_vpp = armflash_set_vpp;
115 simple_map_init(&info->map);
118 * Also, the CFI layer automatically works out what size
119 * of chips we have, and does the necessary identification
120 * for us automatically.
122 info->mtd = do_map_probe(plat->map_name, &info->map);
128 info->mtd->owner = THIS_MODULE;
130 err = parse_mtd_partitions(info->mtd, probes, &info->parts, 0);
132 err = add_mtd_partitions(info->mtd, info->parts, err);
135 "mtd partition registration failed: %d\n", err);
139 platform_set_drvdata(dev, info);
142 * If we got an error, free all resources.
146 del_mtd_partitions(info->mtd);
147 map_destroy(info->mtd);
154 release_mem_region(res->start, size);
156 if (plat && plat->exit)
164 static int armflash_remove(struct platform_device *dev)
166 struct armflash_info *info = platform_get_drvdata(dev);
168 platform_set_drvdata(dev, NULL);
172 del_mtd_partitions(info->mtd);
173 map_destroy(info->mtd);
177 iounmap(info->map.virt);
178 release_resource(info->res);
181 if (info->plat && info->plat->exit)
190 static struct platform_driver armflash_driver = {
191 .probe = armflash_probe,
192 .remove = armflash_remove,
198 static int __init armflash_init(void)
200 return platform_driver_register(&armflash_driver);
203 static void __exit armflash_exit(void)
205 platform_driver_unregister(&armflash_driver);
208 module_init(armflash_init);
209 module_exit(armflash_exit);
211 MODULE_AUTHOR("ARM Ltd");
212 MODULE_DESCRIPTION("ARM Integrator CFI map driver");
213 MODULE_LICENSE("GPL");