diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/maps/Kconfig | 11 | ||||
-rw-r--r-- | drivers/mtd/maps/Makefile | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/omap_nor.c | 179 |
3 files changed, 191 insertions, 2 deletions
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index dbe1716c9724..ac853d4d1668 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.54 2005/06/30 22:41:36 tpoynor Exp $ | 2 | # $Id: Kconfig,v 1.55 2005/07/02 01:53:24 tpoynor Exp $ |
3 | 3 | ||
4 | menu "Mapping drivers for chip access" | 4 | menu "Mapping drivers for chip access" |
5 | depends on MTD!=n | 5 | depends on MTD!=n |
@@ -523,6 +523,15 @@ config MTD_MPC1211 | |||
523 | This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02). | 523 | This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02). |
524 | If you have such a board, say 'Y'. | 524 | If you have such a board, say 'Y'. |
525 | 525 | ||
526 | config MTD_OMAP_NOR | ||
527 | tristate "TI OMAP board mappings" | ||
528 | depends on MTD_CFI && ARCH_OMAP | ||
529 | help | ||
530 | This enables access to the NOR flash chips on TI OMAP-based | ||
531 | boards defining flash platform devices and flash platform data. | ||
532 | These boards include the Innovator, H2, H3, OSK, Perseus2, and | ||
533 | more. If you have such a board, say 'Y'. | ||
534 | |||
526 | # This needs CFI or JEDEC, depending on the cards found. | 535 | # This needs CFI or JEDEC, depending on the cards found. |
527 | config MTD_PCI | 536 | config MTD_PCI |
528 | tristate "PCI MTD driver" | 537 | tristate "PCI MTD driver" |
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index 789a4b76890d..7bcbc49e329f 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.29 2005/06/30 22:41:36 tpoynor Exp $ | 4 | # $Id: Makefile.common,v 1.30 2005/07/02 01:53:24 tpoynor Exp $ |
5 | 5 | ||
6 | ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y) | 6 | ifeq ($(CONFIG_MTD_COMPLEX_MAPPINGS),y) |
7 | obj-$(CONFIG_MTD) += map_funcs.o | 7 | obj-$(CONFIG_MTD) += map_funcs.o |
@@ -69,3 +69,4 @@ obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o | |||
69 | obj-$(CONFIG_MTD_DMV182) += dmv182.o | 69 | obj-$(CONFIG_MTD_DMV182) += dmv182.o |
70 | obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o | 70 | obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o |
71 | obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o | 71 | obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o |
72 | obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o | ||
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c new file mode 100644 index 000000000000..8cc71409a328 --- /dev/null +++ b/drivers/mtd/maps/omap_nor.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * Flash memory support for various TI OMAP boards | ||
3 | * | ||
4 | * Copyright (C) 2001-2002 MontaVista Software Inc. | ||
5 | * Copyright (C) 2003-2004 Texas Instruments | ||
6 | * Copyright (C) 2004 Nokia Corporation | ||
7 | * | ||
8 | * Assembled using driver code copyright the companies above | ||
9 | * and written by David Brownell, Jian Zhang <jzhang@ti.com>, | ||
10 | * Tony Lindgren <tony@atomide.com> and others. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License as published by the | ||
14 | * Free Software Foundation; either version 2 of the License, or (at your | ||
15 | * option) any later version. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
20 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
23 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
24 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
27 | * | ||
28 | * You should have received a copy of the GNU General Public License along | ||
29 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
30 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
31 | */ | ||
32 | |||
33 | #include <linux/device.h> | ||
34 | #include <linux/module.h> | ||
35 | #include <linux/types.h> | ||
36 | #include <linux/kernel.h> | ||
37 | #include <linux/init.h> | ||
38 | #include <linux/ioport.h> | ||
39 | #include <linux/mtd/mtd.h> | ||
40 | #include <linux/mtd/map.h> | ||
41 | #include <linux/mtd/partitions.h> | ||
42 | |||
43 | #include <asm/io.h> | ||
44 | #include <asm/hardware.h> | ||
45 | #include <asm/mach-types.h> | ||
46 | #include <asm/mach/flash.h> | ||
47 | #include <asm/arch/tc.h> | ||
48 | |||
49 | #ifdef CONFIG_MTD_PARTITIONS | ||
50 | static const char *part_probes[] = { /* "RedBoot", */ "cmdlinepart", NULL }; | ||
51 | #endif | ||
52 | |||
53 | struct omapflash_info { | ||
54 | struct mtd_partition *parts; | ||
55 | struct mtd_info *mtd; | ||
56 | struct map_info map; | ||
57 | }; | ||
58 | |||
59 | static void omap_set_vpp(struct map_info *map, int enable) | ||
60 | { | ||
61 | static int count; | ||
62 | |||
63 | if (enable) { | ||
64 | if (count++ == 0) | ||
65 | OMAP_EMIFS_CONFIG_REG |= OMAP_EMIFS_CONFIG_WP; | ||
66 | } else { | ||
67 | if (count && (--count == 0)) | ||
68 | OMAP_EMIFS_CONFIG_REG &= ~OMAP_EMIFS_CONFIG_WP; | ||
69 | } | ||
70 | } | ||
71 | |||
72 | static int __devinit omapflash_probe(struct device *dev) | ||
73 | { | ||
74 | int err; | ||
75 | struct omapflash_info *info; | ||
76 | struct platform_device *pdev = to_platform_device(dev); | ||
77 | struct flash_platform_data *pdata = pdev->dev.platform_data; | ||
78 | struct resource *res = pdev->resource; | ||
79 | unsigned long size = res->end - res->start + 1; | ||
80 | |||
81 | info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL); | ||
82 | if (!info) | ||
83 | return -ENOMEM; | ||
84 | |||
85 | memset(info, 0, sizeof(struct omapflash_info)); | ||
86 | |||
87 | if (!request_mem_region(res->start, size, "flash")) { | ||
88 | err = -EBUSY; | ||
89 | goto out_free_info; | ||
90 | } | ||
91 | |||
92 | info->map.virt = ioremap(res->start, size); | ||
93 | if (!info->map.virt) { | ||
94 | err = -ENOMEM; | ||
95 | goto out_release_mem_region; | ||
96 | } | ||
97 | info->map.name = pdev->dev.bus_id; | ||
98 | info->map.phys = res->start; | ||
99 | info->map.size = size; | ||
100 | info->map.bankwidth = pdata->width; | ||
101 | info->map.set_vpp = omap_set_vpp; | ||
102 | |||
103 | simple_map_init(&info->map); | ||
104 | info->mtd = do_map_probe(pdata->map_name, &info->map); | ||
105 | if (!info->mtd) { | ||
106 | err = -EIO; | ||
107 | goto out_iounmap; | ||
108 | } | ||
109 | info->mtd->owner = THIS_MODULE; | ||
110 | |||
111 | #ifdef CONFIG_MTD_PARTITIONS | ||
112 | err = parse_mtd_partitions(info->mtd, part_probes, &info->parts, 0); | ||
113 | if (err > 0) | ||
114 | add_mtd_partitions(info->mtd, info->parts, err); | ||
115 | else if (err < 0 && pdata->parts) | ||
116 | add_mtd_partitions(info->mtd, pdata->parts, pdata->nr_parts); | ||
117 | else | ||
118 | #endif | ||
119 | add_mtd_device(info->mtd); | ||
120 | |||
121 | dev_set_drvdata(&pdev->dev, info); | ||
122 | |||
123 | return 0; | ||
124 | |||
125 | out_iounmap: | ||
126 | iounmap(info->map.virt); | ||
127 | out_release_mem_region: | ||
128 | release_mem_region(res->start, size); | ||
129 | out_free_info: | ||
130 | kfree(info); | ||
131 | |||
132 | return err; | ||
133 | } | ||
134 | |||
135 | static int __devexit omapflash_remove(struct device *dev) | ||
136 | { | ||
137 | struct platform_device *pdev = to_platform_device(dev); | ||
138 | struct omapflash_info *info = dev_get_drvdata(&pdev->dev); | ||
139 | |||
140 | dev_set_drvdata(&pdev->dev, NULL); | ||
141 | |||
142 | if (info) { | ||
143 | if (info->parts) { | ||
144 | del_mtd_partitions(info->mtd); | ||
145 | kfree(info->parts); | ||
146 | } else | ||
147 | del_mtd_device(info->mtd); | ||
148 | map_destroy(info->mtd); | ||
149 | release_mem_region(info->map.phys, info->map.size); | ||
150 | iounmap((void __iomem *) info->map.virt); | ||
151 | kfree(info); | ||
152 | } | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static struct device_driver omapflash_driver = { | ||
158 | .name = "omapflash", | ||
159 | .bus = &platform_bus_type, | ||
160 | .probe = omapflash_probe, | ||
161 | .remove = __devexit_p(omapflash_remove), | ||
162 | }; | ||
163 | |||
164 | static int __init omapflash_init(void) | ||
165 | { | ||
166 | return driver_register(&omapflash_driver); | ||
167 | } | ||
168 | |||
169 | static void __exit omapflash_exit(void) | ||
170 | { | ||
171 | driver_unregister(&omapflash_driver); | ||
172 | } | ||
173 | |||
174 | module_init(omapflash_init); | ||
175 | module_exit(omapflash_exit); | ||
176 | |||
177 | MODULE_LICENSE("GPL"); | ||
178 | MODULE_DESCRIPTION("MTD NOR map driver for TI OMAP boards"); | ||
179 | |||