Expose "Optimize for size" option for everybody
[linux-2.6/kvm.git] / drivers / mtd / maps / ebony.c
blob60a6e51d662f33a80760738d57da53a85bdc0e2e
1 /*
2 * $Id: ebony.c,v 1.16 2005/11/07 11:14:26 gleixner Exp $
4 * Mapping for Ebony user flash
6 * Matt Porter <mporter@kernel.crashing.org>
8 * Copyright 2002-2004 MontaVista Software Inc.
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
16 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/config.h>
24 #include <asm/io.h>
25 #include <asm/ibm44x.h>
26 #include <platforms/4xx/ebony.h>
28 static struct mtd_info *flash;
30 static struct map_info ebony_small_map = {
31 .name = "Ebony small flash",
32 .size = EBONY_SMALL_FLASH_SIZE,
33 .bankwidth = 1,
36 static struct map_info ebony_large_map = {
37 .name = "Ebony large flash",
38 .size = EBONY_LARGE_FLASH_SIZE,
39 .bankwidth = 1,
42 static struct mtd_partition ebony_small_partitions[] = {
44 .name = "OpenBIOS",
45 .offset = 0x0,
46 .size = 0x80000,
50 static struct mtd_partition ebony_large_partitions[] = {
52 .name = "fs",
53 .offset = 0,
54 .size = 0x380000,
57 .name = "firmware",
58 .offset = 0x380000,
59 .size = 0x80000,
63 int __init init_ebony(void)
65 u8 fpga0_reg;
66 u8 __iomem *fpga0_adr;
67 unsigned long long small_flash_base, large_flash_base;
69 fpga0_adr = ioremap64(EBONY_FPGA_ADDR, 16);
70 if (!fpga0_adr)
71 return -ENOMEM;
73 fpga0_reg = readb(fpga0_adr);
74 iounmap(fpga0_adr);
76 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
77 !EBONY_FLASH_SEL(fpga0_reg))
78 small_flash_base = EBONY_SMALL_FLASH_HIGH2;
79 else if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
80 EBONY_FLASH_SEL(fpga0_reg))
81 small_flash_base = EBONY_SMALL_FLASH_HIGH1;
82 else if (!EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
83 !EBONY_FLASH_SEL(fpga0_reg))
84 small_flash_base = EBONY_SMALL_FLASH_LOW2;
85 else
86 small_flash_base = EBONY_SMALL_FLASH_LOW1;
88 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg) &&
89 !EBONY_ONBRD_FLASH_EN(fpga0_reg))
90 large_flash_base = EBONY_LARGE_FLASH_LOW;
91 else
92 large_flash_base = EBONY_LARGE_FLASH_HIGH;
94 ebony_small_map.phys = small_flash_base;
95 ebony_small_map.virt = ioremap64(small_flash_base,
96 ebony_small_map.size);
98 if (!ebony_small_map.virt) {
99 printk("Failed to ioremap flash\n");
100 return -EIO;
103 simple_map_init(&ebony_small_map);
105 flash = do_map_probe("jedec_probe", &ebony_small_map);
106 if (flash) {
107 flash->owner = THIS_MODULE;
108 add_mtd_partitions(flash, ebony_small_partitions,
109 ARRAY_SIZE(ebony_small_partitions));
110 } else {
111 printk("map probe failed for flash\n");
112 return -ENXIO;
115 ebony_large_map.phys = large_flash_base;
116 ebony_large_map.virt = ioremap64(large_flash_base,
117 ebony_large_map.size);
119 if (!ebony_large_map.virt) {
120 printk("Failed to ioremap flash\n");
121 return -EIO;
124 simple_map_init(&ebony_large_map);
126 flash = do_map_probe("jedec_probe", &ebony_large_map);
127 if (flash) {
128 flash->owner = THIS_MODULE;
129 add_mtd_partitions(flash, ebony_large_partitions,
130 ARRAY_SIZE(ebony_large_partitions));
131 } else {
132 printk("map probe failed for flash\n");
133 return -ENXIO;
136 return 0;
139 static void __exit cleanup_ebony(void)
141 if (flash) {
142 del_mtd_partitions(flash);
143 map_destroy(flash);
146 if (ebony_small_map.virt) {
147 iounmap(ebony_small_map.virt);
148 ebony_small_map.virt = NULL;
151 if (ebony_large_map.virt) {
152 iounmap(ebony_large_map.virt);
153 ebony_large_map.virt = NULL;
157 module_init(init_ebony);
158 module_exit(cleanup_ebony);
160 MODULE_LICENSE("GPL");
161 MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
162 MODULE_DESCRIPTION("MTD map and partitions for IBM 440GP Ebony boards");