3 * Copyright (C) 2005 Gemtek Corporation, Dante Su (dante_su@gemtek.com.tw)
4 * Copyright (C) 2006 Florian Fainelli <florian@openwrt.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <linux/init.h>
23 #include <linux/kernel.h>
24 #include <linux/mtd/map.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/partitions.h>
27 #include <linux/vmalloc.h>
29 #define WINDOW_ADDR 0xFFC00000
30 #define WINDOW_SIZE 0x00400000
33 extern int parse_redboot_partitions(struct mtd_info
*master
, struct mtd_partition
**pparts
, unsigned long fis_origin
);
35 static struct mtd_partition
*parsed_parts
;
36 static struct mtd_info
*rdc3210_mtd_info
;
38 static struct map_info rdc3210_map
= {
41 .bankwidth
= BUSWIDTH
,
45 static struct mtd_partition rdc3210_parts
[] = {
46 { name
: "linux", offset
: 0, size
: 0x003C0000 }, /* 3840 KB = (Kernel + ROMFS) = (768 KB + 3072 KB) */
47 { name
: "romfs", offset
: 0x000C0000, size
: 0x00300000 }, /* 3072 KB */
48 { name
: "nvram", offset
: 0x003C0000, size
: 0x00010000 }, /* 64 KB */
49 { name
: "factory", offset
: 0x003D0000, size
: 0x00010000 }, /* 64 KB */
50 { name
: "bootldr", offset
: 0x003E0000, size
: 0x00020000, mask_flags
: MTD_WRITEABLE
},/* 128 KB */
53 static int __init
rdc3210_mtd_init(void)
55 printk(KERN_INFO
"rdc3210: 0x%08x at 0x%08x\n", WINDOW_SIZE
, WINDOW_ADDR
);
56 rdc3210_map
.virt
= ioremap_nocache(WINDOW_ADDR
, WINDOW_SIZE
);
58 if (!rdc3210_map
.virt
) {
59 printk(KERN_ERR
"rdc3210: failed to ioremap\n");
63 simple_map_init(&rdc3210_map
);
65 rdc3210_mtd_info
= do_map_probe("cfi_probe", &rdc3210_map
);
69 rdc3210_mtd_info
->owner
= THIS_MODULE
;
70 int parsed_nr_parts
= 0;
73 #ifdef CONFIG_MTD_REDBOOT_PARTS
74 if (parsed_nr_parts
== 0)
76 int ret
= parse_redboot_partitions(rdc3210_mtd_info
, &parsed_parts
, 0);
79 part_type
= "RedBoot";
80 parsed_nr_parts
= ret
;
82 printk(KERN_ERR
"rdc3210: failed to parse RedBoot partitions, using static mapping\n");
83 add_mtd_partitions(rdc3210_mtd_info
, rdc3210_parts
, sizeof(rdc3210_parts
)/sizeof(rdc3210_parts
[0]));
88 add_mtd_partitions(rdc3210_mtd_info
, parsed_parts
, parsed_nr_parts
);
92 iounmap(rdc3210_map
.virt
);
96 static void __exit
rdc3210_mtd_cleanup(void)
100 del_mtd_partitions(rdc3210_mtd_info
);
101 map_destroy(rdc3210_mtd_info
);
104 if (rdc3210_map
.virt
) {
105 iounmap(rdc3210_map
.virt
);
106 rdc3210_map
.virt
= 0;
110 module_init(rdc3210_mtd_init
);
111 module_exit(rdc3210_mtd_cleanup
);
113 MODULE_LICENSE("GPL");
114 MODULE_DESCRIPTION("RDC3210 flash map driver");
115 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");