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>
24 #include <asm/ibm44x.h>
25 #include <platforms/4xx/ebony.h>
27 static struct mtd_info
*flash
;
29 static struct map_info ebony_small_map
= {
30 .name
= "Ebony small flash",
31 .size
= EBONY_SMALL_FLASH_SIZE
,
35 static struct map_info ebony_large_map
= {
36 .name
= "Ebony large flash",
37 .size
= EBONY_LARGE_FLASH_SIZE
,
41 static struct mtd_partition ebony_small_partitions
[] = {
49 static struct mtd_partition ebony_large_partitions
[] = {
62 int __init
init_ebony(void)
65 u8 __iomem
*fpga0_adr
;
66 unsigned long long small_flash_base
, large_flash_base
;
68 fpga0_adr
= ioremap64(EBONY_FPGA_ADDR
, 16);
72 fpga0_reg
= readb(fpga0_adr
);
75 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg
) &&
76 !EBONY_FLASH_SEL(fpga0_reg
))
77 small_flash_base
= EBONY_SMALL_FLASH_HIGH2
;
78 else if (EBONY_BOOT_SMALL_FLASH(fpga0_reg
) &&
79 EBONY_FLASH_SEL(fpga0_reg
))
80 small_flash_base
= EBONY_SMALL_FLASH_HIGH1
;
81 else if (!EBONY_BOOT_SMALL_FLASH(fpga0_reg
) &&
82 !EBONY_FLASH_SEL(fpga0_reg
))
83 small_flash_base
= EBONY_SMALL_FLASH_LOW2
;
85 small_flash_base
= EBONY_SMALL_FLASH_LOW1
;
87 if (EBONY_BOOT_SMALL_FLASH(fpga0_reg
) &&
88 !EBONY_ONBRD_FLASH_EN(fpga0_reg
))
89 large_flash_base
= EBONY_LARGE_FLASH_LOW
;
91 large_flash_base
= EBONY_LARGE_FLASH_HIGH
;
93 ebony_small_map
.phys
= small_flash_base
;
94 ebony_small_map
.virt
= ioremap64(small_flash_base
,
95 ebony_small_map
.size
);
97 if (!ebony_small_map
.virt
) {
98 printk("Failed to ioremap flash\n");
102 simple_map_init(&ebony_small_map
);
104 flash
= do_map_probe("jedec_probe", &ebony_small_map
);
106 flash
->owner
= THIS_MODULE
;
107 add_mtd_partitions(flash
, ebony_small_partitions
,
108 ARRAY_SIZE(ebony_small_partitions
));
110 printk("map probe failed for flash\n");
111 iounmap(ebony_small_map
.virt
);
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 iounmap(ebony_small_map
.virt
);
125 simple_map_init(&ebony_large_map
);
127 flash
= do_map_probe("jedec_probe", &ebony_large_map
);
129 flash
->owner
= THIS_MODULE
;
130 add_mtd_partitions(flash
, ebony_large_partitions
,
131 ARRAY_SIZE(ebony_large_partitions
));
133 printk("map probe failed for flash\n");
134 iounmap(ebony_small_map
.virt
);
135 iounmap(ebony_large_map
.virt
);
142 static void __exit
cleanup_ebony(void)
145 del_mtd_partitions(flash
);
149 if (ebony_small_map
.virt
) {
150 iounmap(ebony_small_map
.virt
);
151 ebony_small_map
.virt
= NULL
;
154 if (ebony_large_map
.virt
) {
155 iounmap(ebony_large_map
.virt
);
156 ebony_large_map
.virt
= NULL
;
160 module_init(init_ebony
);
161 module_exit(cleanup_ebony
);
163 MODULE_LICENSE("GPL");
164 MODULE_AUTHOR("Matt Porter <mporter@kernel.crashing.org>");
165 MODULE_DESCRIPTION("MTD map and partitions for IBM 440GP Ebony boards");