aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/toto.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/toto.c')
-rw-r--r--drivers/mtd/nand/toto.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c
index 7609c43cb3ec..c51c89559514 100644
--- a/drivers/mtd/nand/toto.c
+++ b/drivers/mtd/nand/toto.c
@@ -48,7 +48,7 @@ static unsigned long toto_io_base = OMAP_FLASH_1_BASE;
48 48
49#define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0) 49#define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0)
50#define T_NAND_CTL_SETALE(iob) gpiosetout(NAND_ALE, NAND_ALE) 50#define T_NAND_CTL_SETALE(iob) gpiosetout(NAND_ALE, NAND_ALE)
51#ifdef CONFIG_NAND_WORKAROUND /* "some" dev boards busted, blue wired to rts2 :( */ 51#ifdef CONFIG_NAND_WORKAROUND /* "some" dev boards busted, blue wired to rts2 :( */
52#define T_NAND_CTL_CLRCLE(iob) gpiosetout(NAND_CLE, 0); rts2setout(2, 2) 52#define T_NAND_CTL_CLRCLE(iob) gpiosetout(NAND_CLE, 0); rts2setout(2, 2)
53#define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE); rts2setout(2, 0) 53#define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE); rts2setout(2, 0)
54#else 54#else
@@ -98,9 +98,8 @@ static struct mtd_partition partition_info32M[] = {
98static void toto_hwcontrol(struct mtd_info *mtd, int cmd) 98static void toto_hwcontrol(struct mtd_info *mtd, int cmd)
99{ 99{
100 100
101 udelay(1); /* hopefully enough time for tc make proceding write to clear */ 101 udelay(1); /* hopefully enough time for tc make proceding write to clear */
102 switch(cmd){ 102 switch (cmd) {
103
104 case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break; 103 case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break;
105 case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break; 104 case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break;
106 105
@@ -110,35 +109,35 @@ static void toto_hwcontrol(struct mtd_info *mtd, int cmd)
110 case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break; 109 case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break;
111 case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break; 110 case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break;
112 } 111 }
113 udelay(1); /* allow time to ensure gpio state to over take memory write */ 112 udelay(1); /* allow time to ensure gpio state to over take memory write */
114} 113}
115 114
116/* 115/*
117 * Main initialization routine 116 * Main initialization routine
118 */ 117 */
119int __init toto_init (void) 118static int __init toto_init(void)
120{ 119{
121 struct nand_chip *this; 120 struct nand_chip *this;
122 int err = 0; 121 int err = 0;
123 122
124 /* Allocate memory for MTD device structure and private data */ 123 /* Allocate memory for MTD device structure and private data */
125 toto_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), 124 toto_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
126 GFP_KERNEL);
127 if (!toto_mtd) { 125 if (!toto_mtd) {
128 printk (KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n"); 126 printk(KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n");
129 err = -ENOMEM; 127 err = -ENOMEM;
130 goto out; 128 goto out;
131 } 129 }
132 130
133 /* Get pointer to private data */ 131 /* Get pointer to private data */
134 this = (struct nand_chip *) (&toto_mtd[1]); 132 this = (struct nand_chip *)(&toto_mtd[1]);
135 133
136 /* Initialize structures */ 134 /* Initialize structures */
137 memset((char *) toto_mtd, 0, sizeof(struct mtd_info)); 135 memset(toto_mtd, 0, sizeof(struct mtd_info));
138 memset((char *) this, 0, sizeof(struct nand_chip)); 136 memset(this, 0, sizeof(struct nand_chip));
139 137
140 /* Link the private data with the MTD structure */ 138 /* Link the private data with the MTD structure */
141 toto_mtd->priv = this; 139 toto_mtd->priv = this;
140 toto_mtd->owner = THIS_MODULE;
142 141
143 /* Set address of NAND IO lines */ 142 /* Set address of NAND IO lines */
144 this->IO_ADDR_R = toto_io_base; 143 this->IO_ADDR_R = toto_io_base;
@@ -149,33 +148,37 @@ int __init toto_init (void)
149 this->chip_delay = 30; 148 this->chip_delay = 30;
150 this->eccmode = NAND_ECC_SOFT; 149 this->eccmode = NAND_ECC_SOFT;
151 150
152 /* Scan to find existance of the device */ 151 /* Scan to find existance of the device */
153 if (nand_scan (toto_mtd, 1)) { 152 if (nand_scan(toto_mtd, 1)) {
154 err = -ENXIO; 153 err = -ENXIO;
155 goto out_mtd; 154 goto out_mtd;
156 } 155 }
157 156
158 /* Register the partitions */ 157 /* Register the partitions */
159 switch(toto_mtd->size){ 158 switch (toto_mtd->size) {
160 case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break; 159 case SZ_64M:
161 case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break; 160 add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M);
162 default: { 161 break;
163 printk (KERN_WARNING "Unsupported Nand device\n"); 162 case SZ_32M:
163 add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M);
164 break;
165 default:{
166 printk(KERN_WARNING "Unsupported Nand device\n");
164 err = -ENXIO; 167 err = -ENXIO;
165 goto out_buf; 168 goto out_buf;
166 } 169 }
167 } 170 }
168 171
169 gpioreserve(NAND_MASK); /* claim our gpios */ 172 gpioreserve(NAND_MASK); /* claim our gpios */
170 archflashwp(0,0); /* open up flash for writing */ 173 archflashwp(0, 0); /* open up flash for writing */
171 174
172 goto out; 175 goto out;
173 176
174out_buf: 177 out_buf:
175 kfree (this->data_buf); 178 kfree(this->data_buf);
176out_mtd: 179 out_mtd:
177 kfree (toto_mtd); 180 kfree(toto_mtd);
178out: 181 out:
179 return err; 182 return err;
180} 183}
181 184
@@ -184,20 +187,21 @@ module_init(toto_init);
184/* 187/*
185 * Clean up routine 188 * Clean up routine
186 */ 189 */
187static void __exit toto_cleanup (void) 190static void __exit toto_cleanup(void)
188{ 191{
189 /* Release resources, unregister device */ 192 /* Release resources, unregister device */
190 nand_release (toto_mtd); 193 nand_release(toto_mtd);
191 194
192 /* Free the MTD device structure */ 195 /* Free the MTD device structure */
193 kfree (toto_mtd); 196 kfree(toto_mtd);
194 197
195 /* stop flash writes */ 198 /* stop flash writes */
196 archflashwp(0,1); 199 archflashwp(0, 1);
197 200
198 /* release gpios to system */ 201 /* release gpios to system */
199 gpiorelease(NAND_MASK); 202 gpiorelease(NAND_MASK);
200} 203}
204
201module_exit(toto_cleanup); 205module_exit(toto_cleanup);
202 206
203MODULE_LICENSE("GPL"); 207MODULE_LICENSE("GPL");