aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/h1910.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/h1910.c')
-rw-r--r--drivers/mtd/nand/h1910.c98
1 files changed, 39 insertions, 59 deletions
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index f68f7a99a630..2d585d2d090c 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com) 4 * Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com)
5 * 5 *
6 * Derived from drivers/mtd/nand/edb7312.c 6 * Derived from drivers/mtd/nand/edb7312.c
7 * Copyright (C) 2002 Marius Grger (mag@sysgo.de) 7 * Copyright (C) 2002 Marius Grรถger (mag@sysgo.de)
8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) 8 * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
9 * 9 *
10 * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $ 10 * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $
@@ -26,7 +26,7 @@
26#include <linux/mtd/nand.h> 26#include <linux/mtd/nand.h>
27#include <linux/mtd/partitions.h> 27#include <linux/mtd/partitions.h>
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ 29#include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */
30#include <asm/sizes.h> 30#include <asm/sizes.h>
31#include <asm/arch/h1900-gpio.h> 31#include <asm/arch/h1900-gpio.h>
32#include <asm/arch/ipaq.h> 32#include <asm/arch/ipaq.h>
@@ -45,47 +45,29 @@ static struct mtd_info *h1910_nand_mtd = NULL;
45 * Define static partitions for flash device 45 * Define static partitions for flash device
46 */ 46 */
47static struct mtd_partition partition_info[] = { 47static struct mtd_partition partition_info[] = {
48 { name: "h1910 NAND Flash", 48 {name:"h1910 NAND Flash",
49 offset: 0, 49 offset:0,
50 size: 16*1024*1024 } 50 size:16 * 1024 * 1024}
51}; 51};
52
52#define NUM_PARTITIONS 1 53#define NUM_PARTITIONS 1
53 54
54#endif 55#endif
55 56
56
57/* 57/*
58 * hardware specific access to control-lines 58 * hardware specific access to control-lines
59 *
60 * NAND_NCE: bit 0 - don't care
61 * NAND_CLE: bit 1 - address bit 2
62 * NAND_ALE: bit 2 - address bit 3
59 */ 63 */
60static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) 64static void h1910_hwcontrol(struct mtd_info *mtd, int cmd,
65 unsigned int ctrl)
61{ 66{
62 struct nand_chip* this = (struct nand_chip *) (mtd->priv); 67 struct nand_chip *chip = mtd->priv;
63 68
64 switch(cmd) { 69 if (cmd != NAND_CMD_NONE)
65 70 writeb(cmd, chip->IO_ADDR_W | ((ctrl & 0x6) << 1));
66 case NAND_CTL_SETCLE:
67 this->IO_ADDR_R |= (1 << 2);
68 this->IO_ADDR_W |= (1 << 2);
69 break;
70 case NAND_CTL_CLRCLE:
71 this->IO_ADDR_R &= ~(1 << 2);
72 this->IO_ADDR_W &= ~(1 << 2);
73 break;
74
75 case NAND_CTL_SETALE:
76 this->IO_ADDR_R |= (1 << 3);
77 this->IO_ADDR_W |= (1 << 3);
78 break;
79 case NAND_CTL_CLRALE:
80 this->IO_ADDR_R &= ~(1 << 3);
81 this->IO_ADDR_W &= ~(1 << 3);
82 break;
83
84 case NAND_CTL_SETNCE:
85 break;
86 case NAND_CTL_CLRNCE:
87 break;
88 }
89} 71}
90 72
91/* 73/*
@@ -101,7 +83,7 @@ static int h1910_device_ready(struct mtd_info *mtd)
101/* 83/*
102 * Main initialization routine 84 * Main initialization routine
103 */ 85 */
104static int __init h1910_init (void) 86static int __init h1910_init(void)
105{ 87{
106 struct nand_chip *this; 88 struct nand_chip *this;
107 const char *part_type = 0; 89 const char *part_type = 0;
@@ -119,24 +101,23 @@ static int __init h1910_init (void)
119 } 101 }
120 102
121 /* Allocate memory for MTD device structure and private data */ 103 /* Allocate memory for MTD device structure and private data */
122 h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + 104 h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
123 sizeof(struct nand_chip),
124 GFP_KERNEL);
125 if (!h1910_nand_mtd) { 105 if (!h1910_nand_mtd) {
126 printk("Unable to allocate h1910 NAND MTD device structure.\n"); 106 printk("Unable to allocate h1910 NAND MTD device structure.\n");
127 iounmap ((void *) nandaddr); 107 iounmap((void *)nandaddr);
128 return -ENOMEM; 108 return -ENOMEM;
129 } 109 }
130 110
131 /* Get pointer to private data */ 111 /* Get pointer to private data */
132 this = (struct nand_chip *) (&h1910_nand_mtd[1]); 112 this = (struct nand_chip *)(&h1910_nand_mtd[1]);
133 113
134 /* Initialize structures */ 114 /* Initialize structures */
135 memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info)); 115 memset(h1910_nand_mtd, 0, sizeof(struct mtd_info));
136 memset((char *) this, 0, sizeof(struct nand_chip)); 116 memset(this, 0, sizeof(struct nand_chip));
137 117
138 /* Link the private data with the MTD structure */ 118 /* Link the private data with the MTD structure */
139 h1910_nand_mtd->priv = this; 119 h1910_nand_mtd->priv = this;
120 h1910_nand_mtd->owner = THIS_MODULE;
140 121
141 /* 122 /*
142 * Enable VPEN 123 * Enable VPEN
@@ -146,31 +127,28 @@ static int __init h1910_init (void)
146 /* insert callbacks */ 127 /* insert callbacks */
147 this->IO_ADDR_R = nandaddr; 128 this->IO_ADDR_R = nandaddr;
148 this->IO_ADDR_W = nandaddr; 129 this->IO_ADDR_W = nandaddr;
149 this->hwcontrol = h1910_hwcontrol; 130 this->cmd_ctrl = h1910_hwcontrol;
150 this->dev_ready = NULL; /* unknown whether that was correct or not so we will just do it like this */ 131 this->dev_ready = NULL; /* unknown whether that was correct or not so we will just do it like this */
151 /* 15 us command delay time */ 132 /* 15 us command delay time */
152 this->chip_delay = 50; 133 this->chip_delay = 50;
153 this->eccmode = NAND_ECC_SOFT; 134 this->ecc.mode = NAND_ECC_SOFT;
154 this->options = NAND_NO_AUTOINCR; 135 this->options = NAND_NO_AUTOINCR;
155 136
156 /* Scan to find existence of the device */ 137 /* Scan to find existence of the device */
157 if (nand_scan (h1910_nand_mtd, 1)) { 138 if (nand_scan(h1910_nand_mtd, 1)) {
158 printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); 139 printk(KERN_NOTICE "No NAND device - returning -ENXIO\n");
159 kfree (h1910_nand_mtd); 140 kfree(h1910_nand_mtd);
160 iounmap ((void *) nandaddr); 141 iounmap((void *)nandaddr);
161 return -ENXIO; 142 return -ENXIO;
162 } 143 }
163
164#ifdef CONFIG_MTD_CMDLINE_PARTS 144#ifdef CONFIG_MTD_CMDLINE_PARTS
165 mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, 145 mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, "h1910-nand");
166 "h1910-nand");
167 if (mtd_parts_nb > 0) 146 if (mtd_parts_nb > 0)
168 part_type = "command line"; 147 part_type = "command line";
169 else 148 else
170 mtd_parts_nb = 0; 149 mtd_parts_nb = 0;
171#endif 150#endif
172 if (mtd_parts_nb == 0) 151 if (mtd_parts_nb == 0) {
173 {
174 mtd_parts = partition_info; 152 mtd_parts = partition_info;
175 mtd_parts_nb = NUM_PARTITIONS; 153 mtd_parts_nb = NUM_PARTITIONS;
176 part_type = "static"; 154 part_type = "static";
@@ -183,24 +161,26 @@ static int __init h1910_init (void)
183 /* Return happy */ 161 /* Return happy */
184 return 0; 162 return 0;
185} 163}
164
186module_init(h1910_init); 165module_init(h1910_init);
187 166
188/* 167/*
189 * Clean up routine 168 * Clean up routine
190 */ 169 */
191static void __exit h1910_cleanup (void) 170static void __exit h1910_cleanup(void)
192{ 171{
193 struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1]; 172 struct nand_chip *this = (struct nand_chip *)&h1910_nand_mtd[1];
194 173
195 /* Release resources, unregister device */ 174 /* Release resources, unregister device */
196 nand_release (h1910_nand_mtd); 175 nand_release(h1910_nand_mtd);
197 176
198 /* Release io resource */ 177 /* Release io resource */
199 iounmap ((void *) this->IO_ADDR_W); 178 iounmap((void *)this->IO_ADDR_W);
200 179
201 /* Free the MTD device structure */ 180 /* Free the MTD device structure */
202 kfree (h1910_nand_mtd); 181 kfree(h1910_nand_mtd);
203} 182}
183
204module_exit(h1910_cleanup); 184module_exit(h1910_cleanup);
205 185
206MODULE_LICENSE("GPL"); 186MODULE_LICENSE("GPL");