2 * Copyright Boris Koprinarov <crumpz@gmail.com>
4 * cobra5272.c ,v 1.14 2005/08/31 13:24:14
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>
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",
48 struct mtd_partition flagadm_parts
[] = {
56 .name
= "kernel (512K)",
61 .name
= "rootfs (1024K)",
76 .name
= "spare (256K)",
81 .name
= "complete (2048K)",
86 .name
= "boot J13 (256K)",
91 .name
= "kernel J13 (512K)",
96 .name
= "rootfs J13 (256K)",
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
,
116 if (!flagadm_map
.virt
) {
117 printk("Failed to ioremap\n");
121 simple_map_init(&flagadm_map
);
123 mymtd
= do_map_probe("cfi_probe", &flagadm_map
);
125 mymtd
->owner
= THIS_MODULE
;
126 add_mtd_partitions(mymtd
, flagadm_parts
, PARTITION_COUNT
);
127 printk(KERN_NOTICE
"COBRA5272 flash device initialized\n");
131 iounmap((void *)flagadm_map
.virt
);
135 static void __exit
cleanup_flagadm(void)
138 del_mtd_partitions(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");