2 * Mapping for Ocotea user flash
4 * Matt Porter <mporter@kernel.crashing.org>
6 * Copyright 2002-2004 MontaVista Software Inc.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/map.h>
20 #include <linux/mtd/partitions.h>
21 #include <linux/config.h>
23 #include <asm/ibm44x.h>
24 #include <platforms/4xx/ocotea.h>
26 static struct mtd_info *flash;
28 static struct map_info ocotea_small_map = {
29 .name = "Ocotea small flash",
30 .size = OCOTEA_SMALL_FLASH_SIZE,
34 static struct map_info ocotea_large_map = {
35 .name = "Ocotea large flash",
36 .size = OCOTEA_LARGE_FLASH_SIZE,
40 static struct mtd_partition ocotea_small_partitions[] = {
48 static struct mtd_partition ocotea_large_partitions[] = {
61 int __init init_ocotea(void)
65 unsigned long long small_flash_base, large_flash_base;
67 fpga0_adr = ioremap64(OCOTEA_FPGA_ADDR, 16);
71 fpga0_reg = readb((unsigned long)fpga0_adr);
74 if (OCOTEA_BOOT_LARGE_FLASH(fpga0_reg)) {
75 small_flash_base = OCOTEA_SMALL_FLASH_HIGH;
76 large_flash_base = OCOTEA_LARGE_FLASH_LOW;
79 small_flash_base = OCOTEA_SMALL_FLASH_LOW;
80 large_flash_base = OCOTEA_LARGE_FLASH_HIGH;
83 ocotea_small_map.phys = small_flash_base;
84 ocotea_small_map.virt = ioremap64(small_flash_base,
85 ocotea_small_map.size);
87 if (!ocotea_small_map.virt) {
88 printk("Failed to ioremap flash\n");
92 simple_map_init(&ocotea_small_map);
94 flash = do_map_probe("map_rom", &ocotea_small_map);
96 flash->owner = THIS_MODULE;
97 add_mtd_partitions(flash, ocotea_small_partitions,
98 ARRAY_SIZE(ocotea_small_partitions));
100 printk("map probe failed for flash\n");
104 ocotea_large_map.phys = large_flash_base;
105 ocotea_large_map.virt = ioremap64(large_flash_base,
106 ocotea_large_map.size);
108 if (!ocotea_large_map.virt) {
109 printk("Failed to ioremap flash\n");
113 simple_map_init(&ocotea_large_map);
115 flash = do_map_probe("cfi_probe", &ocotea_large_map);
117 flash->owner = THIS_MODULE;
118 add_mtd_partitions(flash, ocotea_large_partitions,
119 ARRAY_SIZE(ocotea_large_partitions));
121 printk("map probe failed for flash\n");
128 static void __exit cleanup_ocotea(void)
131 del_mtd_partitions(flash);
135 if (ocotea_small_map.virt) {
136 iounmap((void *)ocotea_small_map.virt);
137 ocotea_small_map.virt = 0;
140 if (ocotea_large_map.virt) {
141 iounmap((void *)ocotea_large_map.virt);
142 ocotea_large_map.virt = 0;
146 module_init(init_ocotea);
147 module_exit(cleanup_ocotea);
149 MODULE_LICENSE("GPL");
150 MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
151 MODULE_DESCRIPTION("MTD map and partitions for IBM 440GX Ocotea boards");