MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / drivers / mtd / maps / cobra5272.c
blob3b3049c9f2ac1be1b95394ed3da9727ec60876ac
1 /*
2 * Copyright Boris Koprinarov <crumpz@gmail.com>
4 * cobra5272.c ,v 1.14 2005/08/31 13:24:14
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
14 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
15 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
18 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
20 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/init.h>
31 #include <asm/io.h>
32 #include <linux/mtd/mtd.h>
33 #include <linux/mtd/map.h>
34 #include <linux/mtd/partitions.h>
36 #define FLASH_PHYS_ADDR 0xffe00000
37 #define FLASH_SIZE 0x200000
39 #define FLASH_PARTITION0_ADDR 0x1000000
40 #define FLASH_PARTITION0_SIZE 0x1000000
42 struct map_info flagadm_map = {
43 .name = "Flash chip on COBRA5272",
44 .size = FLASH_SIZE,
45 .bankwidth = 2,
48 struct mtd_partition flagadm_parts[] = {
50 .name = "boot (16K)",
51 .offset = 0x0,
52 .size = 0x4000
56 .name = "kernel (512K)",
57 .offset = 0x80000,
58 .size = 0x80000
61 .name = "rootfs (1024K)",
62 .offset = 0x100000,
63 .size = 0x100000
66 .name = "spare (8K)",
67 .offset = 0x4000,
68 .size = 0x2000
71 .name = "spare (8K)",
72 .offset = 0x6000,
73 .size = 0x2000
76 .name = "spare (256K)",
77 .offset = 0x40000,
78 .size = 0x40000
81 .name = "complete (2048K)",
82 .offset = 0x0,
83 .size = 0x200000
86 .name = "boot J13 (256K)",
87 .offset = 0x100000,
88 .size = 0x40000
91 .name = "kernel J13 (512K)",
92 .offset = 0x140000,
93 .size = 0x80000
96 .name = "rootfs J13 (256K)",
97 .offset = 0x1c0000,
98 .size = 0x40000
103 #define PARTITION_COUNT (sizeof(flagadm_parts)/sizeof(struct mtd_partition))
105 static struct mtd_info *mymtd;
107 int __init init_flagadm(void)
109 printk(KERN_NOTICE "COBRA5272 flash device: %x at %x\n",
110 FLASH_SIZE, FLASH_PHYS_ADDR);
112 flagadm_map.phys = FLASH_PHYS_ADDR;
113 flagadm_map.virt = ioremap(FLASH_PHYS_ADDR,
114 FLASH_SIZE);
116 if (!flagadm_map.virt) {
117 printk("Failed to ioremap\n");
118 return -EIO;
121 simple_map_init(&flagadm_map);
123 mymtd = do_map_probe("cfi_probe", &flagadm_map);
124 if (mymtd) {
125 mymtd->owner = THIS_MODULE;
126 add_mtd_partitions(mymtd, flagadm_parts, PARTITION_COUNT);
127 printk(KERN_NOTICE "COBRA5272 flash device initialized\n");
128 return 0;
131 iounmap((void *)flagadm_map.virt);
132 return -ENXIO;
135 static void __exit cleanup_flagadm(void)
137 if (mymtd) {
138 del_mtd_partitions(mymtd);
139 map_destroy(mymtd);
141 if (flagadm_map.virt) {
142 iounmap((void *)flagadm_map.virt);
143 flagadm_map.virt = 0;
147 module_init(init_flagadm);
148 module_exit(cleanup_flagadm);
151 MODULE_LICENSE("GPL");
152 MODULE_AUTHOR("Boris Koprinarov <crumpz@gmail.com>");
153 MODULE_DESCRIPTION("MTD map driver for COBRA5272 board");