[MTD] fix map probe name for cstm_mips_ixx
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mtd / maps / cstm_mips_ixx.c
blob2ef22a5a1de245ac2c6f6df6ad2ec28d9779bba4
1 /*
2 * $Id: cstm_mips_ixx.c,v 1.14 2005/11/07 11:14:26 gleixner Exp $
4 * Mapping of a custom board with both AMD CFI and JEDEC flash in partitions.
5 * Config with both CFI and JEDEC device support.
7 * Basically physmap.c with the addition of partitions and
8 * an array of mapping info to accomodate more than one flash type per board.
10 * Copyright 2000 MontaVista Software Inc.
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
33 #include <linux/module.h>
34 #include <linux/types.h>
35 #include <linux/kernel.h>
36 #include <linux/init.h>
37 #include <asm/io.h>
38 #include <linux/mtd/mtd.h>
39 #include <linux/mtd/map.h>
40 #include <linux/mtd/partitions.h>
41 #include <linux/delay.h>
43 /* board and partition description */
45 #define MAX_PHYSMAP_PARTITIONS 8
46 struct cstm_mips_ixx_info {
47 char *name;
48 unsigned long window_addr;
49 unsigned long window_size;
50 int bankwidth;
51 int num_partitions;
54 #define PHYSMAP_NUMBER 1 // number of board desc structs needed, one per contiguous flash type
55 const struct cstm_mips_ixx_info cstm_mips_ixx_board_desc[PHYSMAP_NUMBER] =
58 "MTD flash", // name
59 CONFIG_MTD_CSTM_MIPS_IXX_START, // window_addr
60 CONFIG_MTD_CSTM_MIPS_IXX_LEN, // window_size
61 CONFIG_MTD_CSTM_MIPS_IXX_BUSWIDTH, // bankwidth
62 1, // num_partitions
66 static struct mtd_partition cstm_mips_ixx_partitions[PHYSMAP_NUMBER][MAX_PHYSMAP_PARTITIONS] = {
69 .name = "main partition",
70 .size = CONFIG_MTD_CSTM_MIPS_IXX_LEN,
71 .offset = 0,
76 struct map_info cstm_mips_ixx_map[PHYSMAP_NUMBER];
78 int __init init_cstm_mips_ixx(void)
80 int i;
81 int jedec;
82 struct mtd_info *mymtd;
83 struct mtd_partition *parts;
85 /* Initialize mapping */
86 for (i=0;i<PHYSMAP_NUMBER;i++) {
87 printk(KERN_NOTICE "cstm_mips_ixx flash device: 0x%lx at 0x%lx\n",
88 cstm_mips_ixx_board_desc[i].window_size, cstm_mips_ixx_board_desc[i].window_addr);
91 cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr;
92 cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size);
93 if (!cstm_mips_ixx_map[i].virt) {
94 int j = 0;
95 printk(KERN_WARNING "Failed to ioremap\n");
96 for (j = 0; j < i; j++) {
97 if (cstm_mips_ixx_map[j].virt) {
98 iounmap(cstm_mips_ixx_map[j].virt);
99 cstm_mips_ixx_map[j].virt = NULL;
102 return -EIO;
104 cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name;
105 cstm_mips_ixx_map[i].size = cstm_mips_ixx_board_desc[i].window_size;
106 cstm_mips_ixx_map[i].bankwidth = cstm_mips_ixx_board_desc[i].bankwidth;
107 simple_map_init(&cstm_mips_ixx_map[i]);
108 //printk(KERN_NOTICE "cstm_mips_ixx: ioremap is %x\n",(unsigned int)(cstm_mips_ixx_map[i].virt));
111 for (i=0;i<PHYSMAP_NUMBER;i++) {
112 parts = &cstm_mips_ixx_partitions[i][0];
113 jedec = 0;
114 mymtd = (struct mtd_info *)do_map_probe("cfi_probe", &cstm_mips_ixx_map[i]);
115 //printk(KERN_NOTICE "phymap %d cfi_probe: mymtd is %x\n",i,(unsigned int)mymtd);
116 if (!mymtd) {
117 jedec = 1;
118 mymtd = (struct mtd_info *)do_map_probe("jedec_probe", &cstm_mips_ixx_map[i]);
119 printk(KERN_NOTICE "cstm_mips_ixx %d jedec: mymtd is %x\n",i,(unsigned int)mymtd);
121 if (mymtd) {
122 mymtd->owner = THIS_MODULE;
124 cstm_mips_ixx_map[i].map_priv_2 = (unsigned long)mymtd;
125 add_mtd_partitions(mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions);
127 else {
128 for (i = 0; i < PHYSMAP_NUMBER; i++) {
129 if (cstm_mips_ixx_map[i].virt) {
130 iounmap(cstm_mips_ixx_map[i].virt);
131 cstm_mips_ixx_map[i].virt = NULL;
134 return -ENXIO;
137 return 0;
140 static void __exit cleanup_cstm_mips_ixx(void)
142 int i;
143 struct mtd_info *mymtd;
145 for (i=0;i<PHYSMAP_NUMBER;i++) {
146 mymtd = (struct mtd_info *)cstm_mips_ixx_map[i].map_priv_2;
147 if (mymtd) {
148 del_mtd_partitions(mymtd);
149 map_destroy(mymtd);
151 if (cstm_mips_ixx_map[i].virt) {
152 iounmap((void *)cstm_mips_ixx_map[i].virt);
153 cstm_mips_ixx_map[i].virt = 0;
158 module_init(init_cstm_mips_ixx);
159 module_exit(cleanup_cstm_mips_ixx);
162 MODULE_LICENSE("GPL");
163 MODULE_AUTHOR("Alice Hennessy <ahennessy@mvista.com>");
164 MODULE_DESCRIPTION("MTD map driver for MIPS boards");