2 * Mapping for Ebony 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>
22 #include <asm/ibm44x.h>
23 #include <platforms/4xx/ebony.h>
25 static struct mtd_info *flash;
27 static struct map_info ebony_small_map = {
28 .name = "Ebony small flash",
29 .size = EBONY_SMALL_FLASH_SIZE,
33 static struct map_info ebony_large_map = {
34 .name = "Ebony large flash",
35 .size = EBONY_LARGE_FLASH_SIZE,
39 static struct mtd_partition ebony_small_partitions[] = {
47 static struct mtd_partition ebony_large_partitions[] = {
60 int __init init_ebony(void)
63 u8 __iomem *fpga0_adr;
64 unsigned long long small_flash_base, large_flash_base;
66 fpga0_adr = ioremap64(EBONY_FPGA_ADDR, 16);
70 fpga0_reg = readb(fpga0_adr);
73 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
74 !EBONY_FLASH_SEL(fpga0_reg))
75 small_flash_base = EBONY_SMALL_FLASH_HIGH2;
76 else if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
77 EBONY_FLASH_SEL(fpga0_reg))
78 small_flash_base = EBONY_SMALL_FLASH_HIGH1;
79 else if (!EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
80 !EBONY_FLASH_SEL(fpga0_reg))
81 small_flash_base = EBONY_SMALL_FLASH_LOW2;
83 small_flash_base = EBONY_SMALL_FLASH_LOW1;
85 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
86 !EBONY_ONBRD_FLASH_EN(fpga0_reg))
87 large_flash_base = EBONY_LARGE_FLASH_LOW;
89 large_flash_base = EBONY_LARGE_FLASH_HIGH;
91 ebony_small_map.phys = small_flash_base;
92 ebony_small_map.virt = ioremap64(small_flash_base,
93 ebony_small_map.size);
95 if (!ebony_small_map.virt) {
96 printk("Failed to ioremap flash\n");
100 simple_map_init(&ebony_small_map);
102 flash = do_map_probe("jedec_probe", &ebony_small_map);
104 flash->owner = THIS_MODULE;
105 add_mtd_partitions(flash, ebony_small_partitions,
106 ARRAY_SIZE(ebony_small_partitions));
108 printk("map probe failed for flash\n");
109 iounmap(ebony_small_map.virt);
113 ebony_large_map.phys = large_flash_base;
114 ebony_large_map.virt = ioremap64(large_flash_base,
115 ebony_large_map.size);
117 if (!ebony_large_map.virt) {
118 printk("Failed to ioremap flash\n");
119 iounmap(ebony_small_map.virt);
123 simple_map_init(&ebony_large_map);
125 flash = do_map_probe("jedec_probe", &ebony_large_map);
127 flash->owner = THIS_MODULE;
128 add_mtd_partitions(flash, ebony_large_partitions,
129 ARRAY_SIZE(ebony_large_partitions));
131 printk("map probe failed for flash\n");
132 iounmap(ebony_small_map.virt);
133 iounmap(ebony_large_map.virt);
140 static void __exit cleanup_ebony(void)
143 del_mtd_partitions(flash);
147 if (ebony_small_map.virt) {
148 iounmap(ebony_small_map.virt);
149 ebony_small_map.virt = NULL;
152 if (ebony_large_map.virt) {
153 iounmap(ebony_large_map.virt);
154 ebony_large_map.virt = NULL;
158 module_init(init_ebony);
159 module_exit(cleanup_ebony);
161 MODULE_LICENSE("GPL");
162 MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
163 MODULE_DESCRIPTION("MTD map and partitions for IBM 440GP Ebony boards");