This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / mtd / maps / chestnut.c
1 /*
2  * drivers/mtd/maps/chestnut.c
3  *
4  * $Id: chestnut.c,v 1.1 2005/01/05 16:59:50 dwmw2 Exp $
5  *
6  * Flash map driver for IBM Chestnut (750FXGX Eval)
7  *
8  * Chose not to enable 8 bit flash as it contains the firmware and board
9  * info.  Thus only the 32bit flash is supported.
10  *
11  * Author: <source@mvista.com>
12  *
13  * 2004 (c) MontaVista Software, Inc. This file is licensed under
14  * the terms of the GNU General Public License version 2. This program
15  * is licensed "as is" without any warranty of any kind, whether express
16  * or implied.
17  */
18
19 #include <linux/module.h>
20 #include <linux/init.h>
21 #include <linux/types.h>
22 #include <linux/kernel.h>
23 #include <asm/io.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/map.h>
26 #include <linux/mtd/partitions.h>
27 #include <platforms/chestnut.h>
28
29 static struct map_info chestnut32_map = {
30         .name           = "User FS",
31         .size           = CHESTNUT_32BIT_SIZE,
32         .bankwidth      = 4,
33         .phys           = CHESTNUT_32BIT_BASE,
34 };
35
36 static struct mtd_partition chestnut32_partitions[] = {
37         {
38                 .name   = "User FS",
39                 .offset = 0,
40                 .size   = CHESTNUT_32BIT_SIZE,
41         }
42 };
43
44 static struct mtd_info *flash32;
45
46 int __init init_chestnut(void)
47 {
48         /* 32-bit FLASH */
49
50         chestnut32_map.virt = ioremap(chestnut32_map.phys, chestnut32_map.size);
51
52         if (!chestnut32_map.virt) {
53                 printk(KERN_NOTICE "Failed to ioremap 32-bit flash\n");
54                 return -EIO;
55         }
56
57         simple_map_init(&chestnut32_map);
58
59         flash32 = do_map_probe("cfi_probe", &chestnut32_map);
60         if (flash32) {
61                 flash32->owner = THIS_MODULE;
62                 add_mtd_partitions(flash32, chestnut32_partitions,
63                                         ARRAY_SIZE(chestnut32_partitions));
64         } else {
65                 printk(KERN_NOTICE "map probe failed for 32-bit flash\n");
66                 return -ENXIO;
67         }
68
69         return 0;
70 }
71
72 static void __exit
73 cleanup_chestnut(void)
74 {
75         if (flash32) {
76                 del_mtd_partitions(flash32);
77                 map_destroy(flash32);
78         }
79
80         if (chestnut32_map.virt) {
81                 iounmap((void *)chestnut32_map.virt);
82                 chestnut32_map.virt = 0;
83         }
84 }
85
86 module_init(init_chestnut);
87 module_exit(cleanup_chestnut);
88
89 MODULE_DESCRIPTION("MTD map and partitions for IBM Chestnut (750fxgx Eval)");
90 MODULE_AUTHOR("<source@mvista.com>");
91 MODULE_LICENSE("GPL");