diff options
Diffstat (limited to 'drivers/mtd/maps/dmv182.c')
-rw-r--r-- | drivers/mtd/maps/dmv182.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/drivers/mtd/maps/dmv182.c b/drivers/mtd/maps/dmv182.c new file mode 100644 index 000000000000..b9bc63503e26 --- /dev/null +++ b/drivers/mtd/maps/dmv182.c | |||
@@ -0,0 +1,149 @@ | |||
1 | |||
2 | /* | ||
3 | * drivers/mtd/maps/svme182.c | ||
4 | * | ||
5 | * Flash map driver for the Dy4 SVME182 board | ||
6 | * | ||
7 | * $Id: dmv182.c,v 1.5 2004/11/04 13:24:14 gleixner Exp $ | ||
8 | * | ||
9 | * Copyright 2003-2004, TimeSys Corporation | ||
10 | * | ||
11 | * Based on the SVME181 flash map, by Tom Nelson, Dot4, Inc. for TimeSys Corp. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the | ||
15 | * Free Software Foundation; either version 2 of the License, or (at your | ||
16 | * option) any later version. | ||
17 | */ | ||
18 | |||
19 | #include <linux/config.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/types.h> | ||
23 | #include <linux/kernel.h> | ||
24 | #include <asm/io.h> | ||
25 | #include <linux/mtd/mtd.h> | ||
26 | #include <linux/mtd/map.h> | ||
27 | #include <linux/mtd/partitions.h> | ||
28 | #include <linux/errno.h> | ||
29 | |||
30 | /* | ||
31 | * This driver currently handles only the 16MiB user flash bank 1 on the | ||
32 | * board. It does not provide access to bank 0 (contains the Dy4 FFW), bank 2 | ||
33 | * (VxWorks boot), or the optional 48MiB expansion flash. | ||
34 | * | ||
35 | * scott.wood@timesys.com: On the newer boards with 128MiB flash, it | ||
36 | * now supports the first 96MiB (the boot flash bank containing FFW | ||
37 | * is excluded). The VxWorks loader is in partition 1. | ||
38 | */ | ||
39 | |||
40 | #define FLASH_BASE_ADDR 0xf0000000 | ||
41 | #define FLASH_BANK_SIZE (128*1024*1024) | ||
42 | |||
43 | MODULE_AUTHOR("Scott Wood, TimeSys Corporation <scott.wood@timesys.com>"); | ||
44 | MODULE_DESCRIPTION("User-programmable flash device on the Dy4 SVME182 board"); | ||
45 | MODULE_LICENSE("GPL"); | ||
46 | |||
47 | static struct map_info svme182_map = { | ||
48 | .name = "Dy4 SVME182", | ||
49 | .bankwidth = 32, | ||
50 | .size = 128 * 1024 * 1024 | ||
51 | }; | ||
52 | |||
53 | #define BOOTIMAGE_PART_SIZE ((6*1024*1024)-RESERVED_PART_SIZE) | ||
54 | |||
55 | // Allow 6MiB for the kernel | ||
56 | #define NEW_BOOTIMAGE_PART_SIZE (6 * 1024 * 1024) | ||
57 | // Allow 1MiB for the bootloader | ||
58 | #define NEW_BOOTLOADER_PART_SIZE (1024 * 1024) | ||
59 | // Use the remaining 9MiB at the end of flash for the RFS | ||
60 | #define NEW_RFS_PART_SIZE (0x01000000 - NEW_BOOTLOADER_PART_SIZE - \ | ||
61 | NEW_BOOTIMAGE_PART_SIZE) | ||
62 | |||
63 | static struct mtd_partition svme182_partitions[] = { | ||
64 | // The Lower PABS is only 128KiB, but the partition code doesn't | ||
65 | // like partitions that don't end on the largest erase block | ||
66 | // size of the device, even if all of the erase blocks in the | ||
67 | // partition are small ones. The hardware should prevent | ||
68 | // writes to the actual PABS areas. | ||
69 | { | ||
70 | name: "Lower PABS and CPU 0 bootloader or kernel", | ||
71 | size: 6*1024*1024, | ||
72 | offset: 0, | ||
73 | }, | ||
74 | { | ||
75 | name: "Root Filesystem", | ||
76 | size: 10*1024*1024, | ||
77 | offset: MTDPART_OFS_NXTBLK | ||
78 | }, | ||
79 | { | ||
80 | name: "CPU1 Bootloader", | ||
81 | size: 1024*1024, | ||
82 | offset: MTDPART_OFS_NXTBLK, | ||
83 | }, | ||
84 | { | ||
85 | name: "Extra", | ||
86 | size: 110*1024*1024, | ||
87 | offset: MTDPART_OFS_NXTBLK | ||
88 | }, | ||
89 | { | ||
90 | name: "Foundation Firmware and Upper PABS", | ||
91 | size: 1024*1024, | ||
92 | offset: MTDPART_OFS_NXTBLK, | ||
93 | mask_flags: MTD_WRITEABLE // read-only | ||
94 | } | ||
95 | }; | ||
96 | |||
97 | static struct mtd_info *this_mtd; | ||
98 | |||
99 | static int __init init_svme182(void) | ||
100 | { | ||
101 | struct mtd_partition *partitions; | ||
102 | int num_parts = sizeof(svme182_partitions) / sizeof(struct mtd_partition); | ||
103 | |||
104 | partitions = svme182_partitions; | ||
105 | |||
106 | svme182_map.virt = ioremap(FLASH_BASE_ADDR, svme182_map.size); | ||
107 | |||
108 | if (svme182_map.virt == 0) { | ||
109 | printk("Failed to ioremap FLASH memory area.\n"); | ||
110 | return -EIO; | ||
111 | } | ||
112 | |||
113 | simple_map_init(&svme182_map); | ||
114 | |||
115 | this_mtd = do_map_probe("cfi_probe", &svme182_map); | ||
116 | if (!this_mtd) | ||
117 | { | ||
118 | iounmap((void *)svme182_map.virt); | ||
119 | return -ENXIO; | ||
120 | } | ||
121 | |||
122 | printk(KERN_NOTICE "SVME182 flash device: %dMiB at 0x%08x\n", | ||
123 | this_mtd->size >> 20, FLASH_BASE_ADDR); | ||
124 | |||
125 | this_mtd->owner = THIS_MODULE; | ||
126 | add_mtd_partitions(this_mtd, partitions, num_parts); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static void __exit cleanup_svme182(void) | ||
132 | { | ||
133 | if (this_mtd) | ||
134 | { | ||
135 | del_mtd_partitions(this_mtd); | ||
136 | map_destroy(this_mtd); | ||
137 | } | ||
138 | |||
139 | if (svme182_map.virt) | ||
140 | { | ||
141 | iounmap((void *)svme182_map.virt); | ||
142 | svme182_map.virt = 0; | ||
143 | } | ||
144 | |||
145 | return; | ||
146 | } | ||
147 | |||
148 | module_init(init_svme182); | ||
149 | module_exit(cleanup_svme182); | ||