blob: 933c0b63b0167d78eea816471f67e9fe9c12b9ab [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * drivers/mtd/maps/redwood.c
3 *
4 * FLASH map for the IBM Redwood 4/5/6 boards.
5 *
6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 *
8 * 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/module.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18
19#include <linux/mtd/mtd.h>
20#include <linux/mtd/map.h>
21#include <linux/mtd/partitions.h>
22
23#include <asm/io.h>
24
25#if !defined (CONFIG_REDWOOD_6)
26
27#define WINDOW_ADDR 0xffc00000
28#define WINDOW_SIZE 0x00400000
29
30#define RW_PART0_OF 0
31#define RW_PART0_SZ 0x10000
32#define RW_PART1_OF RW_PART0_SZ
33#define RW_PART1_SZ 0x200000 - 0x10000
34#define RW_PART2_OF 0x200000
35#define RW_PART2_SZ 0x10000
36#define RW_PART3_OF 0x210000
37#define RW_PART3_SZ 0x200000 - (0x10000 + 0x20000)
38#define RW_PART4_OF 0x3e0000
39#define RW_PART4_SZ 0x20000
40
41static struct mtd_partition redwood_flash_partitions[] = {
42 {
43 .name = "Redwood OpenBIOS Vital Product Data",
44 .offset = RW_PART0_OF,
45 .size = RW_PART0_SZ,
46 .mask_flags = MTD_WRITEABLE /* force read-only */
47 },
48 {
49 .name = "Redwood kernel",
50 .offset = RW_PART1_OF,
51 .size = RW_PART1_SZ
52 },
53 {
54 .name = "Redwood OpenBIOS non-volatile storage",
55 .offset = RW_PART2_OF,
56 .size = RW_PART2_SZ,
57 .mask_flags = MTD_WRITEABLE /* force read-only */
58 },
59 {
60 .name = "Redwood filesystem",
61 .offset = RW_PART3_OF,
62 .size = RW_PART3_SZ
63 },
64 {
65 .name = "Redwood OpenBIOS",
66 .offset = RW_PART4_OF,
67 .size = RW_PART4_SZ,
68 .mask_flags = MTD_WRITEABLE /* force read-only */
69 }
70};
71
72#else /* CONFIG_REDWOOD_6 */
73/* FIXME: the window is bigger - armin */
74#define WINDOW_ADDR 0xff800000
75#define WINDOW_SIZE 0x00800000
76
77#define RW_PART0_OF 0
78#define RW_PART0_SZ 0x400000 /* 4 MiB data */
Thomas Gleixner69f34c92005-11-07 11:15:40 +000079#define RW_PART1_OF RW_PART0_OF + RW_PART0_SZ
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define RW_PART1_SZ 0x10000 /* 64K VPD */
81#define RW_PART2_OF RW_PART1_OF + RW_PART1_SZ
82#define RW_PART2_SZ 0x400000 - (0x10000 + 0x20000)
83#define RW_PART3_OF RW_PART2_OF + RW_PART2_SZ
84#define RW_PART3_SZ 0x20000
85
86static struct mtd_partition redwood_flash_partitions[] = {
87 {
88 .name = "Redwood filesystem",
89 .offset = RW_PART0_OF,
90 .size = RW_PART0_SZ
91 },
92 {
93 .name = "Redwood OpenBIOS Vital Product Data",
94 .offset = RW_PART1_OF,
95 .size = RW_PART1_SZ,
96 .mask_flags = MTD_WRITEABLE /* force read-only */
97 },
98 {
99 .name = "Redwood kernel",
100 .offset = RW_PART2_OF,
101 .size = RW_PART2_SZ
102 },
103 {
104 .name = "Redwood OpenBIOS",
105 .offset = RW_PART3_OF,
106 .size = RW_PART3_SZ,
107 .mask_flags = MTD_WRITEABLE /* force read-only */
108 }
109};
110
111#endif /* CONFIG_REDWOOD_6 */
112
113struct map_info redwood_flash_map = {
114 .name = "IBM Redwood",
115 .size = WINDOW_SIZE,
116 .bankwidth = 2,
117 .phys = WINDOW_ADDR,
118};
119
120
Tobias Klauser87d10f32006-03-31 02:29:45 -0800121#define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123static struct mtd_info *redwood_mtd;
124
Dmitri Vorobiev9a2b3972008-11-25 02:55:04 +0200125static int __init init_redwood_flash(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126{
Amol Lad76a50272006-10-02 09:48:23 +0100127 int err;
Amol Lad25f0c652006-09-21 18:12:43 +0530128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
130 WINDOW_SIZE, WINDOW_ADDR);
131
132 redwood_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
133
134 if (!redwood_flash_map.virt) {
135 printk("init_redwood_flash: failed to ioremap\n");
136 return -EIO;
137 }
138 simple_map_init(&redwood_flash_map);
139
140 redwood_mtd = do_map_probe("cfi_probe",&redwood_flash_map);
141
142 if (redwood_mtd) {
143 redwood_mtd->owner = THIS_MODULE;
Amol Lad25f0c652006-09-21 18:12:43 +0530144 err = add_mtd_partitions(redwood_mtd,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 redwood_flash_partitions,
146 NUM_REDWOOD_FLASH_PARTITIONS);
Amol Lad25f0c652006-09-21 18:12:43 +0530147 if (err) {
148 printk("init_redwood_flash: add_mtd_partitions failed\n");
149 iounmap(redwood_flash_map.virt);
150 }
151 return err;
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 }
154
Amol Lad25f0c652006-09-21 18:12:43 +0530155 iounmap(redwood_flash_map.virt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 return -ENXIO;
157}
158
159static void __exit cleanup_redwood_flash(void)
160{
161 if (redwood_mtd) {
162 del_mtd_partitions(redwood_mtd);
163 /* moved iounmap after map_destroy - armin */
164 map_destroy(redwood_mtd);
165 iounmap((void *)redwood_flash_map.virt);
166 }
167}
168
169module_init(init_redwood_flash);
170module_exit(cleanup_redwood_flash);
171
172MODULE_LICENSE("GPL");
173MODULE_AUTHOR("MontaVista Software <source@mvista.com>");
174MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards");