2 * $Id: redwood.c,v 1.6 2003/05/21 12:45:19 dwmw2 Exp $
4 * drivers/mtd/maps/redwood.c
6 * FLASH map for the IBM Redwood 4/5/6 boards.
9 * Author: Armin Kuster <akuster@mvista.com>
11 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
12 * the terms of the GNU General Public License version 2. This program
13 * is licensed "as is" without any warranty of any kind, whether express
17 #include <linux/config.h>
18 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <linux/kernel.h>
21 #include <linux/init.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/map.h>
25 #include <linux/mtd/partitions.h>
29 #if !defined (CONFIG_REDWOOD_6)
31 #define WINDOW_ADDR 0xffc00000
32 #define WINDOW_SIZE 0x00400000
35 #define RW_PART0_SZ 0x10000
36 #define RW_PART1_OF RW_PART0_SZ
37 #define RW_PART1_SZ 0x200000 - 0x10000
38 #define RW_PART2_OF 0x200000
39 #define RW_PART2_SZ 0x10000
40 #define RW_PART3_OF 0x210000
41 #define RW_PART3_SZ 0x200000 - (0x10000 + 0x20000)
42 #define RW_PART4_OF 0x3e0000
43 #define RW_PART4_SZ 0x20000
45 static struct mtd_partition redwood_flash_partitions[] = {
47 .name = "Redwood OpenBIOS Vital Product Data",
48 .offset = RW_PART0_OF,
50 .mask_flags = MTD_WRITEABLE /* force read-only */
53 .name = "Redwood kernel",
54 .offset = RW_PART1_OF,
58 .name = "Redwood OpenBIOS non-volatile storage",
59 .offset = RW_PART2_OF,
61 .mask_flags = MTD_WRITEABLE /* force read-only */
64 .name = "Redwood filesystem",
65 .offset = RW_PART3_OF,
69 .name = "Redwood OpenBIOS",
70 .offset = RW_PART4_OF,
72 .mask_flags = MTD_WRITEABLE /* force read-only */
76 #else /* CONFIG_REDWOOD_6 */
77 /* FIXME: the window is bigger - armin */
78 #define WINDOW_ADDR 0xff800000
79 #define WINDOW_SIZE 0x00800000
82 #define RW_PART0_SZ 0x400000 /* 4 MiB data */
83 #define RW_PART1_OF RW_PART0_OF + RW_PART0_SZ
84 #define RW_PART1_SZ 0x10000 /* 64K VPD */
85 #define RW_PART2_OF RW_PART1_OF + RW_PART1_SZ
86 #define RW_PART2_SZ 0x400000 - (0x10000 + 0x20000)
87 #define RW_PART3_OF RW_PART2_OF + RW_PART2_SZ
88 #define RW_PART3_SZ 0x20000
90 static struct mtd_partition redwood_flash_partitions[] = {
92 .name = "Redwood kernel",
93 .offset = RW_PART0_OF,
97 .name = "Redwood OpenBIOS Vital Product Data",
98 .offset = RW_PART1_OF,
100 .mask_flags = MTD_WRITEABLE /* force read-only */
103 .name = "Redwood filesystem",
104 .offset = RW_PART2_OF,
108 .name = "Redwood OpenBIOS",
109 .offset = RW_PART3_OF,
111 .mask_flags = MTD_WRITEABLE /* force read-only */
115 #endif /* CONFIG_REDWOOD_6 */
117 struct map_info redwood_flash_map = {
118 .name = "IBM Redwood",
125 #define NUM_REDWOOD_FLASH_PARTITIONS \
126 (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0]))
128 static struct mtd_info *redwood_mtd;
130 int __init init_redwood_flash(void)
132 printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
133 WINDOW_SIZE, WINDOW_ADDR);
135 redwood_flash_map.virt =
136 (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
138 if (!redwood_flash_map.virt) {
139 printk("init_redwood_flash: failed to ioremap\n");
142 simple_map_init(&redwood_flash_map);
144 redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
147 redwood_mtd->owner = THIS_MODULE;
148 return add_mtd_partitions(redwood_mtd,
149 redwood_flash_partitions,
150 NUM_REDWOOD_FLASH_PARTITIONS);
156 static void __exit cleanup_redwood_flash(void)
159 del_mtd_partitions(redwood_mtd);
160 /* moved iounmap after map_destroy - armin */
161 map_destroy(redwood_mtd);
162 iounmap((void *)redwood_flash_map.virt);
166 module_init(init_redwood_flash);
167 module_exit(cleanup_redwood_flash);
169 MODULE_LICENSE("GPL");
170 MODULE_AUTHOR("Armin Kuster <akuster@mvista.com>");
171 MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards");