| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 2 | * $Id: redwood.c,v 1.11 2005/11/07 11:14:28 gleixner Exp $ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * | 
|  | 4 | * drivers/mtd/maps/redwood.c | 
|  | 5 | * | 
|  | 6 | * FLASH map for the IBM Redwood 4/5/6 boards. | 
|  | 7 | * | 
|  | 8 | * Author: MontaVista Software, Inc. <source@mvista.com> | 
|  | 9 | * | 
|  | 10 | * 2001-2003 (c) MontaVista, Software, Inc. This file is licensed under | 
|  | 11 | * the terms of the GNU General Public License version 2. This program | 
|  | 12 | * is licensed "as is" without any warranty of any kind, whether express | 
|  | 13 | * or implied. | 
|  | 14 | */ | 
|  | 15 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/module.h> | 
|  | 17 | #include <linux/types.h> | 
|  | 18 | #include <linux/kernel.h> | 
|  | 19 | #include <linux/init.h> | 
|  | 20 |  | 
|  | 21 | #include <linux/mtd/mtd.h> | 
|  | 22 | #include <linux/mtd/map.h> | 
|  | 23 | #include <linux/mtd/partitions.h> | 
|  | 24 |  | 
|  | 25 | #include <asm/io.h> | 
|  | 26 |  | 
|  | 27 | #if !defined (CONFIG_REDWOOD_6) | 
|  | 28 |  | 
|  | 29 | #define WINDOW_ADDR 0xffc00000 | 
|  | 30 | #define WINDOW_SIZE 0x00400000 | 
|  | 31 |  | 
|  | 32 | #define RW_PART0_OF	0 | 
|  | 33 | #define RW_PART0_SZ	0x10000 | 
|  | 34 | #define RW_PART1_OF	RW_PART0_SZ | 
|  | 35 | #define RW_PART1_SZ	0x200000 - 0x10000 | 
|  | 36 | #define RW_PART2_OF	0x200000 | 
|  | 37 | #define RW_PART2_SZ	0x10000 | 
|  | 38 | #define RW_PART3_OF	0x210000 | 
|  | 39 | #define RW_PART3_SZ	0x200000 - (0x10000 + 0x20000) | 
|  | 40 | #define RW_PART4_OF	0x3e0000 | 
|  | 41 | #define RW_PART4_SZ	0x20000 | 
|  | 42 |  | 
|  | 43 | static struct mtd_partition redwood_flash_partitions[] = { | 
|  | 44 | { | 
|  | 45 | .name = "Redwood OpenBIOS Vital Product Data", | 
|  | 46 | .offset = RW_PART0_OF, | 
|  | 47 | .size = RW_PART0_SZ, | 
|  | 48 | .mask_flags = MTD_WRITEABLE	/* force read-only */ | 
|  | 49 | }, | 
|  | 50 | { | 
|  | 51 | .name = "Redwood kernel", | 
|  | 52 | .offset = RW_PART1_OF, | 
|  | 53 | .size = RW_PART1_SZ | 
|  | 54 | }, | 
|  | 55 | { | 
|  | 56 | .name = "Redwood OpenBIOS non-volatile storage", | 
|  | 57 | .offset = RW_PART2_OF, | 
|  | 58 | .size = RW_PART2_SZ, | 
|  | 59 | .mask_flags = MTD_WRITEABLE	/* force read-only */ | 
|  | 60 | }, | 
|  | 61 | { | 
|  | 62 | .name = "Redwood filesystem", | 
|  | 63 | .offset = RW_PART3_OF, | 
|  | 64 | .size = RW_PART3_SZ | 
|  | 65 | }, | 
|  | 66 | { | 
|  | 67 | .name = "Redwood OpenBIOS", | 
|  | 68 | .offset = RW_PART4_OF, | 
|  | 69 | .size = RW_PART4_SZ, | 
|  | 70 | .mask_flags = MTD_WRITEABLE	/* force read-only */ | 
|  | 71 | } | 
|  | 72 | }; | 
|  | 73 |  | 
|  | 74 | #else /* CONFIG_REDWOOD_6 */ | 
|  | 75 | /* FIXME: the window is bigger - armin */ | 
|  | 76 | #define WINDOW_ADDR 0xff800000 | 
|  | 77 | #define WINDOW_SIZE 0x00800000 | 
|  | 78 |  | 
|  | 79 | #define RW_PART0_OF	0 | 
|  | 80 | #define RW_PART0_SZ	0x400000	/* 4 MiB data */ | 
| Thomas Gleixner | 69f34c9 | 2005-11-07 11:15:40 +0000 | [diff] [blame] | 81 | #define RW_PART1_OF	RW_PART0_OF + RW_PART0_SZ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | #define RW_PART1_SZ	0x10000		/* 64K VPD */ | 
|  | 83 | #define RW_PART2_OF	RW_PART1_OF + RW_PART1_SZ | 
|  | 84 | #define RW_PART2_SZ	0x400000 - (0x10000 + 0x20000) | 
|  | 85 | #define RW_PART3_OF	RW_PART2_OF + RW_PART2_SZ | 
|  | 86 | #define RW_PART3_SZ	0x20000 | 
|  | 87 |  | 
|  | 88 | static struct mtd_partition redwood_flash_partitions[] = { | 
|  | 89 | { | 
|  | 90 | .name = "Redwood filesystem", | 
|  | 91 | .offset = RW_PART0_OF, | 
|  | 92 | .size = RW_PART0_SZ | 
|  | 93 | }, | 
|  | 94 | { | 
|  | 95 | .name = "Redwood OpenBIOS Vital Product Data", | 
|  | 96 | .offset = RW_PART1_OF, | 
|  | 97 | .size = RW_PART1_SZ, | 
|  | 98 | .mask_flags = MTD_WRITEABLE	/* force read-only */ | 
|  | 99 | }, | 
|  | 100 | { | 
|  | 101 | .name = "Redwood kernel", | 
|  | 102 | .offset = RW_PART2_OF, | 
|  | 103 | .size = RW_PART2_SZ | 
|  | 104 | }, | 
|  | 105 | { | 
|  | 106 | .name = "Redwood OpenBIOS", | 
|  | 107 | .offset = RW_PART3_OF, | 
|  | 108 | .size = RW_PART3_SZ, | 
|  | 109 | .mask_flags = MTD_WRITEABLE	/* force read-only */ | 
|  | 110 | } | 
|  | 111 | }; | 
|  | 112 |  | 
|  | 113 | #endif /* CONFIG_REDWOOD_6 */ | 
|  | 114 |  | 
|  | 115 | struct map_info redwood_flash_map = { | 
|  | 116 | .name = "IBM Redwood", | 
|  | 117 | .size = WINDOW_SIZE, | 
|  | 118 | .bankwidth = 2, | 
|  | 119 | .phys = WINDOW_ADDR, | 
|  | 120 | }; | 
|  | 121 |  | 
|  | 122 |  | 
| Tobias Klauser | 87d10f3 | 2006-03-31 02:29:45 -0800 | [diff] [blame] | 123 | #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 |  | 
|  | 125 | static struct mtd_info *redwood_mtd; | 
|  | 126 |  | 
|  | 127 | int __init init_redwood_flash(void) | 
|  | 128 | { | 
|  | 129 | 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; | 
|  | 144 | return add_mtd_partitions(redwood_mtd, | 
|  | 145 | redwood_flash_partitions, | 
|  | 146 | NUM_REDWOOD_FLASH_PARTITIONS); | 
|  | 147 | } | 
|  | 148 |  | 
|  | 149 | return -ENXIO; | 
|  | 150 | } | 
|  | 151 |  | 
|  | 152 | static void __exit cleanup_redwood_flash(void) | 
|  | 153 | { | 
|  | 154 | if (redwood_mtd) { | 
|  | 155 | del_mtd_partitions(redwood_mtd); | 
|  | 156 | /* moved iounmap after map_destroy - armin */ | 
|  | 157 | map_destroy(redwood_mtd); | 
|  | 158 | iounmap((void *)redwood_flash_map.virt); | 
|  | 159 | } | 
|  | 160 | } | 
|  | 161 |  | 
|  | 162 | module_init(init_redwood_flash); | 
|  | 163 | module_exit(cleanup_redwood_flash); | 
|  | 164 |  | 
|  | 165 | MODULE_LICENSE("GPL"); | 
|  | 166 | MODULE_AUTHOR("MontaVista Software <source@mvista.com>"); | 
|  | 167 | MODULE_DESCRIPTION("MTD map driver for the IBM Redwood reference boards"); |