2 * Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is>
4 * $Id: cfi_flagadm.c,v 1.15 2005/11/07 11:14:26 gleixner Exp $
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>
37 /* We split the flash chip up into four parts.
38 * 1: bootloader firts 128k (0x00000000 - 0x0001FFFF) size 0x020000
39 * 2: kernel 640k (0x00020000 - 0x000BFFFF) size 0x0A0000
40 * 3: compressed 1536k root ramdisk (0x000C0000 - 0x0023FFFF) size 0x180000
41 * 4: writeable diskpartition (jffs)(0x00240000 - 0x003FFFFF) size 0x1C0000
44 #define FLASH_PHYS_ADDR 0x40000000
45 #define FLASH_SIZE 0x400000
47 #define FLASH_PARTITION0_ADDR 0x00000000
48 #define FLASH_PARTITION0_SIZE 0x00020000
50 #define FLASH_PARTITION1_ADDR 0x00020000
51 #define FLASH_PARTITION1_SIZE 0x000A0000
53 #define FLASH_PARTITION2_ADDR 0x000C0000
54 #define FLASH_PARTITION2_SIZE 0x00180000
56 #define FLASH_PARTITION3_ADDR 0x00240000
57 #define FLASH_PARTITION3_SIZE 0x001C0000
60 struct map_info flagadm_map
= {
61 .name
= "FlagaDM flash device",
66 struct mtd_partition flagadm_parts
[] = {
69 .offset
= FLASH_PARTITION0_ADDR
,
70 .size
= FLASH_PARTITION0_SIZE
73 .name
= "Kernel image",
74 .offset
= FLASH_PARTITION1_ADDR
,
75 .size
= FLASH_PARTITION1_SIZE
78 .name
= "Initial ramdisk image",
79 .offset
= FLASH_PARTITION2_ADDR
,
80 .size
= FLASH_PARTITION2_SIZE
83 .name
= "Persistent storage",
84 .offset
= FLASH_PARTITION3_ADDR
,
85 .size
= FLASH_PARTITION3_SIZE
89 #define PARTITION_COUNT ARRAY_SIZE(flagadm_parts)
91 static struct mtd_info
*mymtd
;
93 int __init
init_flagadm(void)
95 printk(KERN_NOTICE
"FlagaDM flash device: %x at %x\n",
96 FLASH_SIZE
, FLASH_PHYS_ADDR
);
98 flagadm_map
.phys
= FLASH_PHYS_ADDR
;
99 flagadm_map
.virt
= ioremap(FLASH_PHYS_ADDR
,
102 if (!flagadm_map
.virt
) {
103 printk("Failed to ioremap\n");
107 simple_map_init(&flagadm_map
);
109 mymtd
= do_map_probe("cfi_probe", &flagadm_map
);
111 mymtd
->owner
= THIS_MODULE
;
112 add_mtd_partitions(mymtd
, flagadm_parts
, PARTITION_COUNT
);
113 printk(KERN_NOTICE
"FlagaDM flash device initialized\n");
117 iounmap((void *)flagadm_map
.virt
);
121 static void __exit
cleanup_flagadm(void)
124 del_mtd_partitions(mymtd
);
127 if (flagadm_map
.virt
) {
128 iounmap((void *)flagadm_map
.virt
);
129 flagadm_map
.virt
= 0;
133 module_init(init_flagadm
);
134 module_exit(cleanup_flagadm
);
137 MODULE_LICENSE("GPL");
138 MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>");
139 MODULE_DESCRIPTION("MTD map driver for Flaga digital module");