diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-13 13:07:53 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-13 13:07:53 -0400 |
commit | e0c7d7675331140e5186d2d1a0efce1d3877d379 (patch) | |
tree | 45247eb5029382c64392aa641e8b0e5506ed152f | |
parent | 6943f8af7d6583be57d67bba8b2644371f6a10ca (diff) |
[MTD NAND] Indent all of drivers/mtd/nand/*.c.
It was just too painful to deal with.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r-- | drivers/mtd/nand/au1550nd.c | 143 | ||||
-rw-r--r-- | drivers/mtd/nand/autcpu12.c | 53 | ||||
-rw-r--r-- | drivers/mtd/nand/cs553x_nand.c | 30 | ||||
-rw-r--r-- | drivers/mtd/nand/diskonchip.c | 415 | ||||
-rw-r--r-- | drivers/mtd/nand/edb7312.c | 53 | ||||
-rw-r--r-- | drivers/mtd/nand/h1910.c | 57 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 694 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 263 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_ecc.c | 29 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_ids.c | 12 | ||||
-rw-r--r-- | drivers/mtd/nand/ppchameleonevb.c | 181 | ||||
-rw-r--r-- | drivers/mtd/nand/rtc_from4.c | 256 | ||||
-rw-r--r-- | drivers/mtd/nand/s3c2410.c | 79 | ||||
-rw-r--r-- | drivers/mtd/nand/sharpsl.c | 93 | ||||
-rw-r--r-- | drivers/mtd/nand/spia.c | 75 | ||||
-rw-r--r-- | drivers/mtd/nand/toto.c | 65 | ||||
-rw-r--r-- | drivers/mtd/nand/ts7250.c | 11 |
17 files changed, 1217 insertions, 1292 deletions
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index bde3550910a2..50cbfd4826fb 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c | |||
@@ -38,22 +38,20 @@ | |||
38 | */ | 38 | */ |
39 | static struct mtd_info *au1550_mtd = NULL; | 39 | static struct mtd_info *au1550_mtd = NULL; |
40 | static void __iomem *p_nand; | 40 | static void __iomem *p_nand; |
41 | static int nand_width = 1; /* default x8*/ | 41 | static int nand_width = 1; /* default x8 */ |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * Define partitions for flash device | 44 | * Define partitions for flash device |
45 | */ | 45 | */ |
46 | static const struct mtd_partition partition_info[] = { | 46 | static const struct mtd_partition partition_info[] = { |
47 | { | 47 | { |
48 | .name = "NAND FS 0", | 48 | .name = "NAND FS 0", |
49 | .offset = 0, | 49 | .offset = 0, |
50 | .size = 8*1024*1024 | 50 | .size = 8 * 1024 * 1024}, |
51 | }, | ||
52 | { | 51 | { |
53 | .name = "NAND FS 1", | 52 | .name = "NAND FS 1", |
54 | .offset = MTDPART_OFS_APPEND, | 53 | .offset = MTDPART_OFS_APPEND, |
55 | .size = MTDPART_SIZ_FULL | 54 | .size = MTDPART_SIZ_FULL} |
56 | } | ||
57 | }; | 55 | }; |
58 | 56 | ||
59 | /** | 57 | /** |
@@ -157,7 +155,7 @@ static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
157 | int i; | 155 | int i; |
158 | struct nand_chip *this = mtd->priv; | 156 | struct nand_chip *this = mtd->priv; |
159 | 157 | ||
160 | for (i=0; i<len; i++) { | 158 | for (i = 0; i < len; i++) { |
161 | writeb(buf[i], this->IO_ADDR_W); | 159 | writeb(buf[i], this->IO_ADDR_W); |
162 | au_sync(); | 160 | au_sync(); |
163 | } | 161 | } |
@@ -176,7 +174,7 @@ static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
176 | int i; | 174 | int i; |
177 | struct nand_chip *this = mtd->priv; | 175 | struct nand_chip *this = mtd->priv; |
178 | 176 | ||
179 | for (i=0; i<len; i++) { | 177 | for (i = 0; i < len; i++) { |
180 | buf[i] = readb(this->IO_ADDR_R); | 178 | buf[i] = readb(this->IO_ADDR_R); |
181 | au_sync(); | 179 | au_sync(); |
182 | } | 180 | } |
@@ -195,7 +193,7 @@ static int au_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
195 | int i; | 193 | int i; |
196 | struct nand_chip *this = mtd->priv; | 194 | struct nand_chip *this = mtd->priv; |
197 | 195 | ||
198 | for (i=0; i<len; i++) { | 196 | for (i = 0; i < len; i++) { |
199 | if (buf[i] != readb(this->IO_ADDR_R)) | 197 | if (buf[i] != readb(this->IO_ADDR_R)) |
200 | return -EFAULT; | 198 | return -EFAULT; |
201 | au_sync(); | 199 | au_sync(); |
@@ -219,7 +217,7 @@ static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
219 | u16 *p = (u16 *) buf; | 217 | u16 *p = (u16 *) buf; |
220 | len >>= 1; | 218 | len >>= 1; |
221 | 219 | ||
222 | for (i=0; i<len; i++) { | 220 | for (i = 0; i < len; i++) { |
223 | writew(p[i], this->IO_ADDR_W); | 221 | writew(p[i], this->IO_ADDR_W); |
224 | au_sync(); | 222 | au_sync(); |
225 | } | 223 | } |
@@ -241,7 +239,7 @@ static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len) | |||
241 | u16 *p = (u16 *) buf; | 239 | u16 *p = (u16 *) buf; |
242 | len >>= 1; | 240 | len >>= 1; |
243 | 241 | ||
244 | for (i=0; i<len; i++) { | 242 | for (i = 0; i < len; i++) { |
245 | p[i] = readw(this->IO_ADDR_R); | 243 | p[i] = readw(this->IO_ADDR_R); |
246 | au_sync(); | 244 | au_sync(); |
247 | } | 245 | } |
@@ -262,7 +260,7 @@ static int au_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
262 | u16 *p = (u16 *) buf; | 260 | u16 *p = (u16 *) buf; |
263 | len >>= 1; | 261 | len >>= 1; |
264 | 262 | ||
265 | for (i=0; i<len; i++) { | 263 | for (i = 0; i < len; i++) { |
266 | if (p[i] != readw(this->IO_ADDR_R)) | 264 | if (p[i] != readw(this->IO_ADDR_R)) |
267 | return -EFAULT; | 265 | return -EFAULT; |
268 | au_sync(); | 266 | au_sync(); |
@@ -275,27 +273,35 @@ static void au1550_hwcontrol(struct mtd_info *mtd, int cmd) | |||
275 | { | 273 | { |
276 | register struct nand_chip *this = mtd->priv; | 274 | register struct nand_chip *this = mtd->priv; |
277 | 275 | ||
278 | switch(cmd){ | 276 | switch (cmd) { |
277 | |||
278 | case NAND_CTL_SETCLE: | ||
279 | this->IO_ADDR_W = p_nand + MEM_STNAND_CMD; | ||
280 | break; | ||
281 | |||
282 | case NAND_CTL_CLRCLE: | ||
283 | this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; | ||
284 | break; | ||
279 | 285 | ||
280 | case NAND_CTL_SETCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_CMD; break; | 286 | case NAND_CTL_SETALE: |
281 | case NAND_CTL_CLRCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; break; | 287 | this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; |
288 | break; | ||
282 | 289 | ||
283 | case NAND_CTL_SETALE: this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; break; | ||
284 | case NAND_CTL_CLRALE: | 290 | case NAND_CTL_CLRALE: |
285 | this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; | 291 | this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; |
286 | /* FIXME: Nobody knows why this is neccecary, | 292 | /* FIXME: Nobody knows why this is necessary, |
287 | * but it works only that way */ | 293 | * but it works only that way */ |
288 | udelay(1); | 294 | udelay(1); |
289 | break; | 295 | break; |
290 | 296 | ||
291 | case NAND_CTL_SETNCE: | 297 | case NAND_CTL_SETNCE: |
292 | /* assert (force assert) chip enable */ | 298 | /* assert (force assert) chip enable */ |
293 | au_writel((1<<(4+NAND_CS)) , MEM_STNDCTL); break; | 299 | au_writel((1 << (4 + NAND_CS)), MEM_STNDCTL); |
294 | break; | 300 | break; |
295 | 301 | ||
296 | case NAND_CTL_CLRNCE: | 302 | case NAND_CTL_CLRNCE: |
297 | /* deassert chip enable */ | 303 | /* deassert chip enable */ |
298 | au_writel(0, MEM_STNDCTL); break; | 304 | au_writel(0, MEM_STNDCTL); |
299 | break; | 305 | break; |
300 | } | 306 | } |
301 | 307 | ||
@@ -315,66 +321,63 @@ int au1550_device_ready(struct mtd_info *mtd) | |||
315 | /* | 321 | /* |
316 | * Main initialization routine | 322 | * Main initialization routine |
317 | */ | 323 | */ |
318 | int __init au1xxx_nand_init (void) | 324 | int __init au1xxx_nand_init(void) |
319 | { | 325 | { |
320 | struct nand_chip *this; | 326 | struct nand_chip *this; |
321 | u16 boot_swapboot = 0; /* default value */ | 327 | u16 boot_swapboot = 0; /* default value */ |
322 | int retval; | 328 | int retval; |
323 | u32 mem_staddr; | 329 | u32 mem_staddr; |
324 | u32 nand_phys; | 330 | u32 nand_phys; |
325 | 331 | ||
326 | /* Allocate memory for MTD device structure and private data */ | 332 | /* Allocate memory for MTD device structure and private data */ |
327 | au1550_mtd = kmalloc (sizeof(struct mtd_info) + | 333 | au1550_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
328 | sizeof (struct nand_chip), GFP_KERNEL); | ||
329 | if (!au1550_mtd) { | 334 | if (!au1550_mtd) { |
330 | printk ("Unable to allocate NAND MTD dev structure.\n"); | 335 | printk("Unable to allocate NAND MTD dev structure.\n"); |
331 | return -ENOMEM; | 336 | return -ENOMEM; |
332 | } | 337 | } |
333 | 338 | ||
334 | /* Get pointer to private data */ | 339 | /* Get pointer to private data */ |
335 | this = (struct nand_chip *) (&au1550_mtd[1]); | 340 | this = (struct nand_chip *)(&au1550_mtd[1]); |
336 | 341 | ||
337 | /* Initialize structures */ | 342 | /* Initialize structures */ |
338 | memset((char *) au1550_mtd, 0, sizeof(struct mtd_info)); | 343 | memset(au1550_mtd, 0, sizeof(struct mtd_info)); |
339 | memset((char *) this, 0, sizeof(struct nand_chip)); | 344 | memset(this, 0, sizeof(struct nand_chip)); |
340 | 345 | ||
341 | /* Link the private data with the MTD structure */ | 346 | /* Link the private data with the MTD structure */ |
342 | au1550_mtd->priv = this; | 347 | au1550_mtd->priv = this; |
343 | 348 | ||
344 | |||
345 | /* disable interrupts */ | 349 | /* disable interrupts */ |
346 | au_writel(au_readl(MEM_STNDCTL) & ~(1<<8), MEM_STNDCTL); | 350 | au_writel(au_readl(MEM_STNDCTL) & ~(1 << 8), MEM_STNDCTL); |
347 | 351 | ||
348 | /* disable NAND boot */ | 352 | /* disable NAND boot */ |
349 | au_writel(au_readl(MEM_STNDCTL) & ~(1<<0), MEM_STNDCTL); | 353 | au_writel(au_readl(MEM_STNDCTL) & ~(1 << 0), MEM_STNDCTL); |
350 | 354 | ||
351 | #ifdef CONFIG_MIPS_PB1550 | 355 | #ifdef CONFIG_MIPS_PB1550 |
352 | /* set gpio206 high */ | 356 | /* set gpio206 high */ |
353 | au_writel(au_readl(GPIO2_DIR) & ~(1<<6), GPIO2_DIR); | 357 | au_writel(au_readl(GPIO2_DIR) & ~(1 << 6), GPIO2_DIR); |
354 | 358 | ||
355 | boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) | | 359 | boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | ((bcsr->status >> 6) & 0x1); |
356 | ((bcsr->status >> 6) & 0x1); | ||
357 | switch (boot_swapboot) { | 360 | switch (boot_swapboot) { |
358 | case 0: | 361 | case 0: |
359 | case 2: | 362 | case 2: |
360 | case 8: | 363 | case 8: |
361 | case 0xC: | 364 | case 0xC: |
362 | case 0xD: | 365 | case 0xD: |
363 | /* x16 NAND Flash */ | 366 | /* x16 NAND Flash */ |
364 | nand_width = 0; | 367 | nand_width = 0; |
365 | break; | 368 | break; |
366 | case 1: | 369 | case 1: |
367 | case 9: | 370 | case 9: |
368 | case 3: | 371 | case 3: |
369 | case 0xE: | 372 | case 0xE: |
370 | case 0xF: | 373 | case 0xF: |
371 | /* x8 NAND Flash */ | 374 | /* x8 NAND Flash */ |
372 | nand_width = 1; | 375 | nand_width = 1; |
373 | break; | 376 | break; |
374 | default: | 377 | default: |
375 | printk("Pb1550 NAND: bad boot:swap\n"); | 378 | printk("Pb1550 NAND: bad boot:swap\n"); |
376 | retval = -EINVAL; | 379 | retval = -EINVAL; |
377 | goto outmem; | 380 | goto outmem; |
378 | } | 381 | } |
379 | #endif | 382 | #endif |
380 | 383 | ||
@@ -424,14 +427,13 @@ int __init au1xxx_nand_init (void) | |||
424 | 427 | ||
425 | /* make controller and MTD agree */ | 428 | /* make controller and MTD agree */ |
426 | if (NAND_CS == 0) | 429 | if (NAND_CS == 0) |
427 | nand_width = au_readl(MEM_STCFG0) & (1<<22); | 430 | nand_width = au_readl(MEM_STCFG0) & (1 << 22); |
428 | if (NAND_CS == 1) | 431 | if (NAND_CS == 1) |
429 | nand_width = au_readl(MEM_STCFG1) & (1<<22); | 432 | nand_width = au_readl(MEM_STCFG1) & (1 << 22); |
430 | if (NAND_CS == 2) | 433 | if (NAND_CS == 2) |
431 | nand_width = au_readl(MEM_STCFG2) & (1<<22); | 434 | nand_width = au_readl(MEM_STCFG2) & (1 << 22); |
432 | if (NAND_CS == 3) | 435 | if (NAND_CS == 3) |
433 | nand_width = au_readl(MEM_STCFG3) & (1<<22); | 436 | nand_width = au_readl(MEM_STCFG3) & (1 << 22); |
434 | |||
435 | 437 | ||
436 | /* Set address of hardware control function */ | 438 | /* Set address of hardware control function */ |
437 | this->hwcontrol = au1550_hwcontrol; | 439 | this->hwcontrol = au1550_hwcontrol; |
@@ -454,7 +456,7 @@ int __init au1xxx_nand_init (void) | |||
454 | this->verify_buf = (!nand_width) ? au_verify_buf16 : au_verify_buf; | 456 | this->verify_buf = (!nand_width) ? au_verify_buf16 : au_verify_buf; |
455 | 457 | ||
456 | /* Scan to find existence of the device */ | 458 | /* Scan to find existence of the device */ |
457 | if (nand_scan (au1550_mtd, 1)) { | 459 | if (nand_scan(au1550_mtd, 1)) { |
458 | retval = -ENXIO; | 460 | retval = -ENXIO; |
459 | goto outio; | 461 | goto outio; |
460 | } | 462 | } |
@@ -465,10 +467,10 @@ int __init au1xxx_nand_init (void) | |||
465 | return 0; | 467 | return 0; |
466 | 468 | ||
467 | outio: | 469 | outio: |
468 | iounmap ((void *)p_nand); | 470 | iounmap((void *)p_nand); |
469 | 471 | ||
470 | outmem: | 472 | outmem: |
471 | kfree (au1550_mtd); | 473 | kfree(au1550_mtd); |
472 | return retval; | 474 | return retval; |
473 | } | 475 | } |
474 | 476 | ||
@@ -478,19 +480,20 @@ module_init(au1xxx_nand_init); | |||
478 | * Clean up routine | 480 | * Clean up routine |
479 | */ | 481 | */ |
480 | #ifdef MODULE | 482 | #ifdef MODULE |
481 | static void __exit au1550_cleanup (void) | 483 | static void __exit au1550_cleanup(void) |
482 | { | 484 | { |
483 | struct nand_chip *this = (struct nand_chip *) &au1550_mtd[1]; | 485 | struct nand_chip *this = (struct nand_chip *)&au1550_mtd[1]; |
484 | 486 | ||
485 | /* Release resources, unregister device */ | 487 | /* Release resources, unregister device */ |
486 | nand_release (au1550_mtd); | 488 | nand_release(au1550_mtd); |
487 | 489 | ||
488 | /* Free the MTD device structure */ | 490 | /* Free the MTD device structure */ |
489 | kfree (au1550_mtd); | 491 | kfree(au1550_mtd); |
490 | 492 | ||
491 | /* Unmap */ | 493 | /* Unmap */ |
492 | iounmap ((void *)p_nand); | 494 | iounmap((void *)p_nand); |
493 | } | 495 | } |
496 | |||
494 | module_exit(au1550_cleanup); | 497 | module_exit(au1550_cleanup); |
495 | #endif | 498 | #endif |
496 | 499 | ||
diff --git a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c index a3c7fea404d0..9c9f21b0d260 100644 --- a/drivers/mtd/nand/autcpu12.c +++ b/drivers/mtd/nand/autcpu12.c | |||
@@ -47,7 +47,7 @@ static int autcpu12_io_base = CS89712_VIRT_BASE; | |||
47 | static int autcpu12_fio_pbase = AUTCPU12_PHYS_SMC; | 47 | static int autcpu12_fio_pbase = AUTCPU12_PHYS_SMC; |
48 | static int autcpu12_fio_ctrl = AUTCPU12_SMC_SELECT_OFFSET; | 48 | static int autcpu12_fio_ctrl = AUTCPU12_SMC_SELECT_OFFSET; |
49 | static int autcpu12_pedr = AUTCPU12_SMC_PORT_OFFSET; | 49 | static int autcpu12_pedr = AUTCPU12_SMC_PORT_OFFSET; |
50 | static void __iomem * autcpu12_fio_base; | 50 | static void __iomem *autcpu12_fio_base; |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * Define partitions for flash devices | 53 | * Define partitions for flash devices |
@@ -95,10 +95,10 @@ static struct mtd_partition partition_info128k[] = { | |||
95 | /* | 95 | /* |
96 | * hardware specific access to control-lines | 96 | * hardware specific access to control-lines |
97 | */ | 97 | */ |
98 | |||
98 | static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) | 99 | static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) |
99 | { | 100 | { |
100 | 101 | switch (cmd) { | |
101 | switch(cmd){ | ||
102 | 102 | ||
103 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) |= AUTCPU12_SMC_CLE; break; | 103 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) |= AUTCPU12_SMC_CLE; break; |
104 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) &= ~AUTCPU12_SMC_CLE; break; | 104 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) &= ~AUTCPU12_SMC_CLE; break; |
@@ -117,41 +117,40 @@ static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) | |||
117 | int autcpu12_device_ready(struct mtd_info *mtd) | 117 | int autcpu12_device_ready(struct mtd_info *mtd) |
118 | { | 118 | { |
119 | 119 | ||
120 | return ( (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) & AUTCPU12_SMC_RDY) ? 1 : 0; | 120 | return ((*(volatile unsigned char *)(autcpu12_io_base + autcpu12_pedr)) & AUTCPU12_SMC_RDY) ? 1 : 0; |
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * Main initialization routine | 125 | * Main initialization routine |
126 | */ | 126 | */ |
127 | int __init autcpu12_init (void) | 127 | int __init autcpu12_init(void) |
128 | { | 128 | { |
129 | struct nand_chip *this; | 129 | struct nand_chip *this; |
130 | int err = 0; | 130 | int err = 0; |
131 | 131 | ||
132 | /* Allocate memory for MTD device structure and private data */ | 132 | /* Allocate memory for MTD device structure and private data */ |
133 | autcpu12_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), | 133 | autcpu12_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
134 | GFP_KERNEL); | ||
135 | if (!autcpu12_mtd) { | 134 | if (!autcpu12_mtd) { |
136 | printk ("Unable to allocate AUTCPU12 NAND MTD device structure.\n"); | 135 | printk("Unable to allocate AUTCPU12 NAND MTD device structure.\n"); |
137 | err = -ENOMEM; | 136 | err = -ENOMEM; |
138 | goto out; | 137 | goto out; |
139 | } | 138 | } |
140 | 139 | ||
141 | /* map physical adress */ | 140 | /* map physical adress */ |
142 | autcpu12_fio_base = ioremap(autcpu12_fio_pbase,SZ_1K); | 141 | autcpu12_fio_base = ioremap(autcpu12_fio_pbase, SZ_1K); |
143 | if(!autcpu12_fio_base){ | 142 | if (!autcpu12_fio_base) { |
144 | printk("Ioremap autcpu12 SmartMedia Card failed\n"); | 143 | printk("Ioremap autcpu12 SmartMedia Card failed\n"); |
145 | err = -EIO; | 144 | err = -EIO; |
146 | goto out_mtd; | 145 | goto out_mtd; |
147 | } | 146 | } |
148 | 147 | ||
149 | /* Get pointer to private data */ | 148 | /* Get pointer to private data */ |
150 | this = (struct nand_chip *) (&autcpu12_mtd[1]); | 149 | this = (struct nand_chip *)(&autcpu12_mtd[1]); |
151 | 150 | ||
152 | /* Initialize structures */ | 151 | /* Initialize structures */ |
153 | memset((char *) autcpu12_mtd, 0, sizeof(struct mtd_info)); | 152 | memset(autcpu12_mtd, 0, sizeof(struct mtd_info)); |
154 | memset((char *) this, 0, sizeof(struct nand_chip)); | 153 | memset(this, 0, sizeof(struct nand_chip)); |
155 | 154 | ||
156 | /* Link the private data with the MTD structure */ | 155 | /* Link the private data with the MTD structure */ |
157 | autcpu12_mtd->priv = this; | 156 | autcpu12_mtd->priv = this; |
@@ -167,35 +166,34 @@ int __init autcpu12_init (void) | |||
167 | 166 | ||
168 | /* Enable the following for a flash based bad block table */ | 167 | /* Enable the following for a flash based bad block table */ |
169 | /* | 168 | /* |
170 | this->options = NAND_USE_FLASH_BBT; | 169 | this->options = NAND_USE_FLASH_BBT; |
171 | */ | 170 | */ |
172 | this->options = NAND_USE_FLASH_BBT; | 171 | this->options = NAND_USE_FLASH_BBT; |
173 | 172 | ||
174 | /* Scan to find existance of the device */ | 173 | /* Scan to find existance of the device */ |
175 | if (nand_scan (autcpu12_mtd, 1)) { | 174 | if (nand_scan(autcpu12_mtd, 1)) { |
176 | err = -ENXIO; | 175 | err = -ENXIO; |
177 | goto out_ior; | 176 | goto out_ior; |
178 | } | 177 | } |
179 | 178 | ||
180 | /* Register the partitions */ | 179 | /* Register the partitions */ |
181 | switch(autcpu12_mtd->size){ | 180 | switch (autcpu12_mtd->size) { |
182 | case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break; | 181 | case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break; |
183 | case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break; | 182 | case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break; |
184 | case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break; | 183 | case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break; |
185 | case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break; | 184 | case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break; |
186 | default: { | 185 | default: |
187 | printk ("Unsupported SmartMedia device\n"); | 186 | printk("Unsupported SmartMedia device\n"); |
188 | err = -ENXIO; | 187 | err = -ENXIO; |
189 | goto out_ior; | 188 | goto out_ior; |
190 | } | ||
191 | } | 189 | } |
192 | goto out; | 190 | goto out; |
193 | 191 | ||
194 | out_ior: | 192 | out_ior: |
195 | iounmap((void *)autcpu12_fio_base); | 193 | iounmap((void *)autcpu12_fio_base); |
196 | out_mtd: | 194 | out_mtd: |
197 | kfree (autcpu12_mtd); | 195 | kfree(autcpu12_mtd); |
198 | out: | 196 | out: |
199 | return err; | 197 | return err; |
200 | } | 198 | } |
201 | 199 | ||
@@ -205,17 +203,18 @@ module_init(autcpu12_init); | |||
205 | * Clean up routine | 203 | * Clean up routine |
206 | */ | 204 | */ |
207 | #ifdef MODULE | 205 | #ifdef MODULE |
208 | static void __exit autcpu12_cleanup (void) | 206 | static void __exit autcpu12_cleanup(void) |
209 | { | 207 | { |
210 | /* Release resources, unregister device */ | 208 | /* Release resources, unregister device */ |
211 | nand_release (autcpu12_mtd); | 209 | nand_release(autcpu12_mtd); |
212 | 210 | ||
213 | /* unmap physical adress */ | 211 | /* unmap physical adress */ |
214 | iounmap((void *)autcpu12_fio_base); | 212 | iounmap((void *)autcpu12_fio_base); |
215 | 213 | ||
216 | /* Free the MTD device structure */ | 214 | /* Free the MTD device structure */ |
217 | kfree (autcpu12_mtd); | 215 | kfree(autcpu12_mtd); |
218 | } | 216 | } |
217 | |||
219 | module_exit(autcpu12_cleanup); | 218 | module_exit(autcpu12_cleanup); |
220 | #endif | 219 | #endif |
221 | 220 | ||
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c index 4f0b338f2f30..fba7be5cffe3 100644 --- a/drivers/mtd/nand/cs553x_nand.c +++ b/drivers/mtd/nand/cs553x_nand.c | |||
@@ -50,7 +50,7 @@ | |||
50 | 50 | ||
51 | /* Pin function selection MSR (IDE vs. flash on the IDE pins) */ | 51 | /* Pin function selection MSR (IDE vs. flash on the IDE pins) */ |
52 | #define MSR_DIVIL_BALL_OPTS 0x51400015 | 52 | #define MSR_DIVIL_BALL_OPTS 0x51400015 |
53 | #define PIN_OPT_IDE (1<<0) /* 0 for flash, 1 for IDE */ | 53 | #define PIN_OPT_IDE (1<<0) /* 0 for flash, 1 for IDE */ |
54 | 54 | ||
55 | /* Registers within the NAND flash controller BAR -- memory mapped */ | 55 | /* Registers within the NAND flash controller BAR -- memory mapped */ |
56 | #define MM_NAND_DATA 0x00 /* 0 to 0x7ff, in fact */ | 56 | #define MM_NAND_DATA 0x00 /* 0 to 0x7ff, in fact */ |
@@ -128,7 +128,7 @@ static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) | |||
128 | udelay(1); | 128 | udelay(1); |
129 | i--; | 129 | i--; |
130 | } | 130 | } |
131 | writeb(byte, this->IO_ADDR_W+0x801); | 131 | writeb(byte, this->IO_ADDR_W + 0x801); |
132 | } | 132 | } |
133 | 133 | ||
134 | static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd) | 134 | static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd) |
@@ -137,7 +137,7 @@ static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
137 | void __iomem *mmio_base = this->IO_ADDR_R; | 137 | void __iomem *mmio_base = this->IO_ADDR_R; |
138 | unsigned char ctl; | 138 | unsigned char ctl; |
139 | 139 | ||
140 | switch(cmd) { | 140 | switch (cmd) { |
141 | case NAND_CTL_SETCLE: | 141 | case NAND_CTL_SETCLE: |
142 | ctl = CS_NAND_CTL_CLE; | 142 | ctl = CS_NAND_CTL_CLE; |
143 | break; | 143 | break; |
@@ -160,17 +160,15 @@ static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
160 | writeb(ctl, mmio_base + MM_NAND_CTL); | 160 | writeb(ctl, mmio_base + MM_NAND_CTL); |
161 | } | 161 | } |
162 | 162 | ||
163 | |||
164 | static int cs553x_device_ready(struct mtd_info *mtd) | 163 | static int cs553x_device_ready(struct mtd_info *mtd) |
165 | { | 164 | { |
166 | struct nand_chip *this = mtd->priv; | 165 | struct nand_chip *this = mtd->priv; |
167 | void __iomem *mmio_base = this->IO_ADDR_R; | 166 | void __iomem *mmio_base = this->IO_ADDR_R; |
168 | unsigned char foo = readb(mmio_base + MM_NAND_STS); | 167 | unsigned char foo = readb(mmio_base + MM_NAND_STS); |
169 | 168 | ||
170 | return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY); | 169 | return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY); |
171 | } | 170 | } |
172 | 171 | ||
173 | |||
174 | static void cs_enable_hwecc(struct mtd_info *mtd, int mode) | 172 | static void cs_enable_hwecc(struct mtd_info *mtd, int mode) |
175 | { | 173 | { |
176 | struct nand_chip *this = mtd->priv; | 174 | struct nand_chip *this = mtd->priv; |
@@ -209,7 +207,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
209 | } | 207 | } |
210 | 208 | ||
211 | /* Allocate memory for MTD device structure and private data */ | 209 | /* Allocate memory for MTD device structure and private data */ |
212 | new_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip), GFP_KERNEL); | 210 | new_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
213 | if (!new_mtd) { | 211 | if (!new_mtd) { |
214 | printk(KERN_WARNING "Unable to allocate CS553X NAND MTD device structure.\n"); | 212 | printk(KERN_WARNING "Unable to allocate CS553X NAND MTD device structure.\n"); |
215 | err = -ENOMEM; | 213 | err = -ENOMEM; |
@@ -217,7 +215,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
217 | } | 215 | } |
218 | 216 | ||
219 | /* Get pointer to private data */ | 217 | /* Get pointer to private data */ |
220 | this = (struct nand_chip *) (&new_mtd[1]); | 218 | this = (struct nand_chip *)(&new_mtd[1]); |
221 | 219 | ||
222 | /* Initialize structures */ | 220 | /* Initialize structures */ |
223 | memset(new_mtd, 0, sizeof(struct mtd_info)); | 221 | memset(new_mtd, 0, sizeof(struct mtd_info)); |
@@ -286,16 +284,16 @@ int __init cs553x_init(void) | |||
286 | return -ENXIO; | 284 | return -ENXIO; |
287 | } | 285 | } |
288 | 286 | ||
289 | for (i=0; i<NR_CS553X_CONTROLLERS; i++) { | 287 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
290 | rdmsrl(MSR_DIVIL_LBAR_FLSH0+i, val); | 288 | rdmsrl(MSR_DIVIL_LBAR_FLSH0 + i, val); |
291 | 289 | ||
292 | if ((val & (FLSH_LBAR_EN|FLSH_NOR_NAND)) == (FLSH_LBAR_EN|FLSH_NOR_NAND)) | 290 | if ((val & (FLSH_LBAR_EN|FLSH_NOR_NAND)) == (FLSH_LBAR_EN|FLSH_NOR_NAND)) |
293 | err = cs553x_init_one(i, !!(val & FLSH_MEM_IO), val & 0xFFFFFFFF); | 291 | err = cs553x_init_one(i, !!(val & FLSH_MEM_IO), val & 0xFFFFFFFF); |
294 | } | 292 | } |
295 | 293 | ||
296 | /* Register all devices together here. This means we can easily hack it to | 294 | /* Register all devices together here. This means we can easily hack it to |
297 | do mtdconcat etc. if we want to. */ | 295 | do mtdconcat etc. if we want to. */ |
298 | for (i=0; i<NR_CS553X_CONTROLLERS; i++) { | 296 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
299 | if (cs553x_mtd[i]) { | 297 | if (cs553x_mtd[i]) { |
300 | add_mtd_device(cs553x_mtd[i]); | 298 | add_mtd_device(cs553x_mtd[i]); |
301 | 299 | ||
@@ -306,13 +304,14 @@ int __init cs553x_init(void) | |||
306 | 304 | ||
307 | return err; | 305 | return err; |
308 | } | 306 | } |
307 | |||
309 | module_init(cs553x_init); | 308 | module_init(cs553x_init); |
310 | 309 | ||
311 | static void __exit cs553x_cleanup (void) | 310 | static void __exit cs553x_cleanup(void) |
312 | { | 311 | { |
313 | int i; | 312 | int i; |
314 | 313 | ||
315 | for (i=0; i<NR_CS553X_CONTROLLERS; i++) { | 314 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
316 | struct mtd_info *mtd = cs553x_mtd[i]; | 315 | struct mtd_info *mtd = cs553x_mtd[i]; |
317 | struct nand_chip *this; | 316 | struct nand_chip *this; |
318 | void __iomem *mmio_base; | 317 | void __iomem *mmio_base; |
@@ -324,7 +323,7 @@ static void __exit cs553x_cleanup (void) | |||
324 | mmio_base = this->IO_ADDR_R; | 323 | mmio_base = this->IO_ADDR_R; |
325 | 324 | ||
326 | /* Release resources, unregister device */ | 325 | /* Release resources, unregister device */ |
327 | nand_release (cs553x_mtd[i]); | 326 | nand_release(cs553x_mtd[i]); |
328 | cs553x_mtd[i] = NULL; | 327 | cs553x_mtd[i] = NULL; |
329 | 328 | ||
330 | /* unmap physical adress */ | 329 | /* unmap physical adress */ |
@@ -334,6 +333,7 @@ static void __exit cs553x_cleanup (void) | |||
334 | kfree(mtd); | 333 | kfree(mtd); |
335 | } | 334 | } |
336 | } | 335 | } |
336 | |||
337 | module_exit(cs553x_cleanup); | 337 | module_exit(cs553x_cleanup); |
338 | 338 | ||
339 | MODULE_LICENSE("GPL"); | 339 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index ec5e45e4e4ef..a2391c66a63f 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -58,10 +58,10 @@ static unsigned long __initdata doc_locations[] = { | |||
58 | 0xe4000000, | 58 | 0xe4000000, |
59 | #elif defined(CONFIG_MOMENCO_OCELOT) | 59 | #elif defined(CONFIG_MOMENCO_OCELOT) |
60 | 0x2f000000, | 60 | 0x2f000000, |
61 | 0xff000000, | 61 | 0xff000000, |
62 | #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) | 62 | #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) |
63 | 0xff000000, | 63 | 0xff000000, |
64 | ##else | 64 | #else |
65 | #warning Unknown architecture for DiskOnChip. No default probe locations defined | 65 | #warning Unknown architecture for DiskOnChip. No default probe locations defined |
66 | #endif | 66 | #endif |
67 | 0xffffffff }; | 67 | 0xffffffff }; |
@@ -73,7 +73,7 @@ struct doc_priv { | |||
73 | unsigned long physadr; | 73 | unsigned long physadr; |
74 | u_char ChipID; | 74 | u_char ChipID; |
75 | u_char CDSNControl; | 75 | u_char CDSNControl; |
76 | int chips_per_floor; /* The number of chips detected on each floor */ | 76 | int chips_per_floor; /* The number of chips detected on each floor */ |
77 | int curfloor; | 77 | int curfloor; |
78 | int curchip; | 78 | int curchip; |
79 | int mh0_page; | 79 | int mh0_page; |
@@ -84,6 +84,7 @@ struct doc_priv { | |||
84 | /* This is the syndrome computed by the HW ecc generator upon reading an empty | 84 | /* This is the syndrome computed by the HW ecc generator upon reading an empty |
85 | page, one with all 0xff for data and stored ecc code. */ | 85 | page, one with all 0xff for data and stored ecc code. */ |
86 | static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; | 86 | static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; |
87 | |||
87 | /* This is the ecc value computed by the HW ecc generator upon writing an empty | 88 | /* This is the ecc value computed by the HW ecc generator upon writing an empty |
88 | page, one with all 0xff for data. */ | 89 | page, one with all 0xff for data. */ |
89 | static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; | 90 | static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; |
@@ -97,25 +98,25 @@ static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; | |||
97 | static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd); | 98 | static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd); |
98 | static void doc200x_select_chip(struct mtd_info *mtd, int chip); | 99 | static void doc200x_select_chip(struct mtd_info *mtd, int chip); |
99 | 100 | ||
100 | static int debug=0; | 101 | static int debug = 0; |
101 | module_param(debug, int, 0); | 102 | module_param(debug, int, 0); |
102 | 103 | ||
103 | static int try_dword=1; | 104 | static int try_dword = 1; |
104 | module_param(try_dword, int, 0); | 105 | module_param(try_dword, int, 0); |
105 | 106 | ||
106 | static int no_ecc_failures=0; | 107 | static int no_ecc_failures = 0; |
107 | module_param(no_ecc_failures, int, 0); | 108 | module_param(no_ecc_failures, int, 0); |
108 | 109 | ||
109 | static int no_autopart=0; | 110 | static int no_autopart = 0; |
110 | module_param(no_autopart, int, 0); | 111 | module_param(no_autopart, int, 0); |
111 | 112 | ||
112 | static int show_firmware_partition=0; | 113 | static int show_firmware_partition = 0; |
113 | module_param(show_firmware_partition, int, 0); | 114 | module_param(show_firmware_partition, int, 0); |
114 | 115 | ||
115 | #ifdef MTD_NAND_DISKONCHIP_BBTWRITE | 116 | #ifdef MTD_NAND_DISKONCHIP_BBTWRITE |
116 | static int inftl_bbt_write=1; | 117 | static int inftl_bbt_write = 1; |
117 | #else | 118 | #else |
118 | static int inftl_bbt_write=0; | 119 | static int inftl_bbt_write = 0; |
119 | #endif | 120 | #endif |
120 | module_param(inftl_bbt_write, int, 0); | 121 | module_param(inftl_bbt_write, int, 0); |
121 | 122 | ||
@@ -123,7 +124,6 @@ static unsigned long doc_config_location = CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDR | |||
123 | module_param(doc_config_location, ulong, 0); | 124 | module_param(doc_config_location, ulong, 0); |
124 | MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); | 125 | MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); |
125 | 126 | ||
126 | |||
127 | /* Sector size for HW ECC */ | 127 | /* Sector size for HW ECC */ |
128 | #define SECTOR_SIZE 512 | 128 | #define SECTOR_SIZE 512 |
129 | /* The sector bytes are packed into NB_DATA 10 bit words */ | 129 | /* The sector bytes are packed into NB_DATA 10 bit words */ |
@@ -147,7 +147,7 @@ static struct rs_control *rs_decoder; | |||
147 | * some comments, improved a minor bit and converted it to make use | 147 | * some comments, improved a minor bit and converted it to make use |
148 | * of the generic Reed-Solomon libary. tglx | 148 | * of the generic Reed-Solomon libary. tglx |
149 | */ | 149 | */ |
150 | static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | 150 | static int doc_ecc_decode(struct rs_control *rs, uint8_t *data, uint8_t *ecc) |
151 | { | 151 | { |
152 | int i, j, nerr, errpos[8]; | 152 | int i, j, nerr, errpos[8]; |
153 | uint8_t parity; | 153 | uint8_t parity; |
@@ -168,18 +168,18 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
168 | * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] | 168 | * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] |
169 | * where x = alpha^(FCR + i) | 169 | * where x = alpha^(FCR + i) |
170 | */ | 170 | */ |
171 | for(j = 1; j < NROOTS; j++) { | 171 | for (j = 1; j < NROOTS; j++) { |
172 | if(ds[j] == 0) | 172 | if (ds[j] == 0) |
173 | continue; | 173 | continue; |
174 | tmp = rs->index_of[ds[j]]; | 174 | tmp = rs->index_of[ds[j]]; |
175 | for(i = 0; i < NROOTS; i++) | 175 | for (i = 0; i < NROOTS; i++) |
176 | s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; | 176 | s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; |
177 | } | 177 | } |
178 | 178 | ||
179 | /* Calc s[i] = s[i] / alpha^(v + i) */ | 179 | /* Calc s[i] = s[i] / alpha^(v + i) */ |
180 | for (i = 0; i < NROOTS; i++) { | 180 | for (i = 0; i < NROOTS; i++) { |
181 | if (syn[i]) | 181 | if (syn[i]) |
182 | syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); | 182 | syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); |
183 | } | 183 | } |
184 | /* Call the decoder library */ | 184 | /* Call the decoder library */ |
185 | nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval); | 185 | nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval); |
@@ -193,7 +193,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
193 | * but they are given by the design of the de/encoder circuit | 193 | * but they are given by the design of the de/encoder circuit |
194 | * in the DoC ASIC's. | 194 | * in the DoC ASIC's. |
195 | */ | 195 | */ |
196 | for(i = 0;i < nerr; i++) { | 196 | for (i = 0; i < nerr; i++) { |
197 | int index, bitpos, pos = 1015 - errpos[i]; | 197 | int index, bitpos, pos = 1015 - errpos[i]; |
198 | uint8_t val; | 198 | uint8_t val; |
199 | if (pos >= NB_DATA && pos < 1019) | 199 | if (pos >= NB_DATA && pos < 1019) |
@@ -205,8 +205,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
205 | can be modified since pos is even */ | 205 | can be modified since pos is even */ |
206 | index = (pos >> 3) ^ 1; | 206 | index = (pos >> 3) ^ 1; |
207 | bitpos = pos & 7; | 207 | bitpos = pos & 7; |
208 | if ((index >= 0 && index < SECTOR_SIZE) || | 208 | if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) { |
209 | index == (SECTOR_SIZE + 1)) { | ||
210 | val = (uint8_t) (errval[i] >> (2 + bitpos)); | 209 | val = (uint8_t) (errval[i] >> (2 + bitpos)); |
211 | parity ^= val; | 210 | parity ^= val; |
212 | if (index < SECTOR_SIZE) | 211 | if (index < SECTOR_SIZE) |
@@ -216,9 +215,8 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
216 | bitpos = (bitpos + 10) & 7; | 215 | bitpos = (bitpos + 10) & 7; |
217 | if (bitpos == 0) | 216 | if (bitpos == 0) |
218 | bitpos = 8; | 217 | bitpos = 8; |
219 | if ((index >= 0 && index < SECTOR_SIZE) || | 218 | if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) { |
220 | index == (SECTOR_SIZE + 1)) { | 219 | val = (uint8_t) (errval[i] << (8 - bitpos)); |
221 | val = (uint8_t)(errval[i] << (8 - bitpos)); | ||
222 | parity ^= val; | 220 | parity ^= val; |
223 | if (index < SECTOR_SIZE) | 221 | if (index < SECTOR_SIZE) |
224 | data[index] ^= val; | 222 | data[index] ^= val; |
@@ -250,10 +248,11 @@ static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) | |||
250 | /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ | 248 | /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ |
251 | static int _DoC_WaitReady(struct doc_priv *doc) | 249 | static int _DoC_WaitReady(struct doc_priv *doc) |
252 | { | 250 | { |
253 | void __iomem *docptr = doc->virtadr; | 251 | void __iomem *docptr = doc->virtadr; |
254 | unsigned long timeo = jiffies + (HZ * 10); | 252 | unsigned long timeo = jiffies + (HZ * 10); |
255 | 253 | ||
256 | if(debug) printk("_DoC_WaitReady...\n"); | 254 | if (debug) |
255 | printk("_DoC_WaitReady...\n"); | ||
257 | /* Out-of-line routine to wait for chip response */ | 256 | /* Out-of-line routine to wait for chip response */ |
258 | if (DoC_is_MillenniumPlus(doc)) { | 257 | if (DoC_is_MillenniumPlus(doc)) { |
259 | while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { | 258 | while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { |
@@ -280,7 +279,7 @@ static int _DoC_WaitReady(struct doc_priv *doc) | |||
280 | 279 | ||
281 | static inline int DoC_WaitReady(struct doc_priv *doc) | 280 | static inline int DoC_WaitReady(struct doc_priv *doc) |
282 | { | 281 | { |
283 | void __iomem *docptr = doc->virtadr; | 282 | void __iomem *docptr = doc->virtadr; |
284 | int ret = 0; | 283 | int ret = 0; |
285 | 284 | ||
286 | if (DoC_is_MillenniumPlus(doc)) { | 285 | if (DoC_is_MillenniumPlus(doc)) { |
@@ -298,7 +297,8 @@ static inline int DoC_WaitReady(struct doc_priv *doc) | |||
298 | DoC_Delay(doc, 2); | 297 | DoC_Delay(doc, 2); |
299 | } | 298 | } |
300 | 299 | ||
301 | if(debug) printk("DoC_WaitReady OK\n"); | 300 | if (debug) |
301 | printk("DoC_WaitReady OK\n"); | ||
302 | return ret; | 302 | return ret; |
303 | } | 303 | } |
304 | 304 | ||
@@ -306,9 +306,10 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) | |||
306 | { | 306 | { |
307 | struct nand_chip *this = mtd->priv; | 307 | struct nand_chip *this = mtd->priv; |
308 | struct doc_priv *doc = this->priv; | 308 | struct doc_priv *doc = this->priv; |
309 | void __iomem *docptr = doc->virtadr; | 309 | void __iomem *docptr = doc->virtadr; |
310 | 310 | ||
311 | if(debug)printk("write_byte %02x\n", datum); | 311 | if (debug) |
312 | printk("write_byte %02x\n", datum); | ||
312 | WriteDOC(datum, docptr, CDSNSlowIO); | 313 | WriteDOC(datum, docptr, CDSNSlowIO); |
313 | WriteDOC(datum, docptr, 2k_CDSN_IO); | 314 | WriteDOC(datum, docptr, 2k_CDSN_IO); |
314 | } | 315 | } |
@@ -317,77 +318,78 @@ static u_char doc2000_read_byte(struct mtd_info *mtd) | |||
317 | { | 318 | { |
318 | struct nand_chip *this = mtd->priv; | 319 | struct nand_chip *this = mtd->priv; |
319 | struct doc_priv *doc = this->priv; | 320 | struct doc_priv *doc = this->priv; |
320 | void __iomem *docptr = doc->virtadr; | 321 | void __iomem *docptr = doc->virtadr; |
321 | u_char ret; | 322 | u_char ret; |
322 | 323 | ||
323 | ReadDOC(docptr, CDSNSlowIO); | 324 | ReadDOC(docptr, CDSNSlowIO); |
324 | DoC_Delay(doc, 2); | 325 | DoC_Delay(doc, 2); |
325 | ret = ReadDOC(docptr, 2k_CDSN_IO); | 326 | ret = ReadDOC(docptr, 2k_CDSN_IO); |
326 | if (debug) printk("read_byte returns %02x\n", ret); | 327 | if (debug) |
328 | printk("read_byte returns %02x\n", ret); | ||
327 | return ret; | 329 | return ret; |
328 | } | 330 | } |
329 | 331 | ||
330 | static void doc2000_writebuf(struct mtd_info *mtd, | 332 | static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
331 | const u_char *buf, int len) | ||
332 | { | 333 | { |
333 | struct nand_chip *this = mtd->priv; | 334 | struct nand_chip *this = mtd->priv; |
334 | struct doc_priv *doc = this->priv; | 335 | struct doc_priv *doc = this->priv; |
335 | void __iomem *docptr = doc->virtadr; | 336 | void __iomem *docptr = doc->virtadr; |
336 | int i; | 337 | int i; |
337 | if (debug)printk("writebuf of %d bytes: ", len); | 338 | if (debug) |
338 | for (i=0; i < len; i++) { | 339 | printk("writebuf of %d bytes: ", len); |
340 | for (i = 0; i < len; i++) { | ||
339 | WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i); | 341 | WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i); |
340 | if (debug && i < 16) | 342 | if (debug && i < 16) |
341 | printk("%02x ", buf[i]); | 343 | printk("%02x ", buf[i]); |
342 | } | 344 | } |
343 | if (debug) printk("\n"); | 345 | if (debug) |
346 | printk("\n"); | ||
344 | } | 347 | } |
345 | 348 | ||
346 | static void doc2000_readbuf(struct mtd_info *mtd, | 349 | static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
347 | u_char *buf, int len) | ||
348 | { | 350 | { |
349 | struct nand_chip *this = mtd->priv; | 351 | struct nand_chip *this = mtd->priv; |
350 | struct doc_priv *doc = this->priv; | 352 | struct doc_priv *doc = this->priv; |
351 | void __iomem *docptr = doc->virtadr; | 353 | void __iomem *docptr = doc->virtadr; |
352 | int i; | 354 | int i; |
353 | 355 | ||
354 | if (debug)printk("readbuf of %d bytes: ", len); | 356 | if (debug) |
357 | printk("readbuf of %d bytes: ", len); | ||
355 | 358 | ||
356 | for (i=0; i < len; i++) { | 359 | for (i = 0; i < len; i++) { |
357 | buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); | 360 | buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); |
358 | } | 361 | } |
359 | } | 362 | } |
360 | 363 | ||
361 | static void doc2000_readbuf_dword(struct mtd_info *mtd, | 364 | static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) |
362 | u_char *buf, int len) | ||
363 | { | 365 | { |
364 | struct nand_chip *this = mtd->priv; | 366 | struct nand_chip *this = mtd->priv; |
365 | struct doc_priv *doc = this->priv; | 367 | struct doc_priv *doc = this->priv; |
366 | void __iomem *docptr = doc->virtadr; | 368 | void __iomem *docptr = doc->virtadr; |
367 | int i; | 369 | int i; |
368 | 370 | ||
369 | if (debug) printk("readbuf_dword of %d bytes: ", len); | 371 | if (debug) |
372 | printk("readbuf_dword of %d bytes: ", len); | ||
370 | 373 | ||
371 | if (unlikely((((unsigned long)buf)|len) & 3)) { | 374 | if (unlikely((((unsigned long)buf) | len) & 3)) { |
372 | for (i=0; i < len; i++) { | 375 | for (i = 0; i < len; i++) { |
373 | *(uint8_t *)(&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i); | 376 | *(uint8_t *) (&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i); |
374 | } | 377 | } |
375 | } else { | 378 | } else { |
376 | for (i=0; i < len; i+=4) { | 379 | for (i = 0; i < len; i += 4) { |
377 | *(uint32_t*)(&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i); | 380 | *(uint32_t *) (&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i); |
378 | } | 381 | } |
379 | } | 382 | } |
380 | } | 383 | } |
381 | 384 | ||
382 | static int doc2000_verifybuf(struct mtd_info *mtd, | 385 | static int doc2000_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
383 | const u_char *buf, int len) | ||
384 | { | 386 | { |
385 | struct nand_chip *this = mtd->priv; | 387 | struct nand_chip *this = mtd->priv; |
386 | struct doc_priv *doc = this->priv; | 388 | struct doc_priv *doc = this->priv; |
387 | void __iomem *docptr = doc->virtadr; | 389 | void __iomem *docptr = doc->virtadr; |
388 | int i; | 390 | int i; |
389 | 391 | ||
390 | for (i=0; i < len; i++) | 392 | for (i = 0; i < len; i++) |
391 | if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO)) | 393 | if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO)) |
392 | return -EFAULT; | 394 | return -EFAULT; |
393 | return 0; | 395 | return 0; |
@@ -482,7 +484,7 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) | |||
482 | { | 484 | { |
483 | struct nand_chip *this = mtd->priv; | 485 | struct nand_chip *this = mtd->priv; |
484 | struct doc_priv *doc = this->priv; | 486 | struct doc_priv *doc = this->priv; |
485 | void __iomem *docptr = doc->virtadr; | 487 | void __iomem *docptr = doc->virtadr; |
486 | 488 | ||
487 | WriteDOC(datum, docptr, CDSNSlowIO); | 489 | WriteDOC(datum, docptr, CDSNSlowIO); |
488 | WriteDOC(datum, docptr, Mil_CDSN_IO); | 490 | WriteDOC(datum, docptr, Mil_CDSN_IO); |
@@ -493,7 +495,7 @@ static u_char doc2001_read_byte(struct mtd_info *mtd) | |||
493 | { | 495 | { |
494 | struct nand_chip *this = mtd->priv; | 496 | struct nand_chip *this = mtd->priv; |
495 | struct doc_priv *doc = this->priv; | 497 | struct doc_priv *doc = this->priv; |
496 | void __iomem *docptr = doc->virtadr; | 498 | void __iomem *docptr = doc->virtadr; |
497 | 499 | ||
498 | //ReadDOC(docptr, CDSNSlowIO); | 500 | //ReadDOC(docptr, CDSNSlowIO); |
499 | /* 11.4.5 -- delay twice to allow extended length cycle */ | 501 | /* 11.4.5 -- delay twice to allow extended length cycle */ |
@@ -503,50 +505,47 @@ static u_char doc2001_read_byte(struct mtd_info *mtd) | |||
503 | return ReadDOC(docptr, LastDataRead); | 505 | return ReadDOC(docptr, LastDataRead); |
504 | } | 506 | } |
505 | 507 | ||
506 | static void doc2001_writebuf(struct mtd_info *mtd, | 508 | static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
507 | const u_char *buf, int len) | ||
508 | { | 509 | { |
509 | struct nand_chip *this = mtd->priv; | 510 | struct nand_chip *this = mtd->priv; |
510 | struct doc_priv *doc = this->priv; | 511 | struct doc_priv *doc = this->priv; |
511 | void __iomem *docptr = doc->virtadr; | 512 | void __iomem *docptr = doc->virtadr; |
512 | int i; | 513 | int i; |
513 | 514 | ||
514 | for (i=0; i < len; i++) | 515 | for (i = 0; i < len; i++) |
515 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); | 516 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); |
516 | /* Terminate write pipeline */ | 517 | /* Terminate write pipeline */ |
517 | WriteDOC(0x00, docptr, WritePipeTerm); | 518 | WriteDOC(0x00, docptr, WritePipeTerm); |
518 | } | 519 | } |
519 | 520 | ||
520 | static void doc2001_readbuf(struct mtd_info *mtd, | 521 | static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
521 | u_char *buf, int len) | ||
522 | { | 522 | { |
523 | struct nand_chip *this = mtd->priv; | 523 | struct nand_chip *this = mtd->priv; |
524 | struct doc_priv *doc = this->priv; | 524 | struct doc_priv *doc = this->priv; |
525 | void __iomem *docptr = doc->virtadr; | 525 | void __iomem *docptr = doc->virtadr; |
526 | int i; | 526 | int i; |
527 | 527 | ||
528 | /* Start read pipeline */ | 528 | /* Start read pipeline */ |
529 | ReadDOC(docptr, ReadPipeInit); | 529 | ReadDOC(docptr, ReadPipeInit); |
530 | 530 | ||
531 | for (i=0; i < len-1; i++) | 531 | for (i = 0; i < len - 1; i++) |
532 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff)); | 532 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff)); |
533 | 533 | ||
534 | /* Terminate read pipeline */ | 534 | /* Terminate read pipeline */ |
535 | buf[i] = ReadDOC(docptr, LastDataRead); | 535 | buf[i] = ReadDOC(docptr, LastDataRead); |
536 | } | 536 | } |
537 | 537 | ||
538 | static int doc2001_verifybuf(struct mtd_info *mtd, | 538 | static int doc2001_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
539 | const u_char *buf, int len) | ||
540 | { | 539 | { |
541 | struct nand_chip *this = mtd->priv; | 540 | struct nand_chip *this = mtd->priv; |
542 | struct doc_priv *doc = this->priv; | 541 | struct doc_priv *doc = this->priv; |
543 | void __iomem *docptr = doc->virtadr; | 542 | void __iomem *docptr = doc->virtadr; |
544 | int i; | 543 | int i; |
545 | 544 | ||
546 | /* Start read pipeline */ | 545 | /* Start read pipeline */ |
547 | ReadDOC(docptr, ReadPipeInit); | 546 | ReadDOC(docptr, ReadPipeInit); |
548 | 547 | ||
549 | for (i=0; i < len-1; i++) | 548 | for (i = 0; i < len - 1; i++) |
550 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { | 549 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { |
551 | ReadDOC(docptr, LastDataRead); | 550 | ReadDOC(docptr, LastDataRead); |
552 | return i; | 551 | return i; |
@@ -560,87 +559,90 @@ static u_char doc2001plus_read_byte(struct mtd_info *mtd) | |||
560 | { | 559 | { |
561 | struct nand_chip *this = mtd->priv; | 560 | struct nand_chip *this = mtd->priv; |
562 | struct doc_priv *doc = this->priv; | 561 | struct doc_priv *doc = this->priv; |
563 | void __iomem *docptr = doc->virtadr; | 562 | void __iomem *docptr = doc->virtadr; |
564 | u_char ret; | 563 | u_char ret; |
565 | 564 | ||
566 | ReadDOC(docptr, Mplus_ReadPipeInit); | 565 | ReadDOC(docptr, Mplus_ReadPipeInit); |
567 | ReadDOC(docptr, Mplus_ReadPipeInit); | 566 | ReadDOC(docptr, Mplus_ReadPipeInit); |
568 | ret = ReadDOC(docptr, Mplus_LastDataRead); | 567 | ret = ReadDOC(docptr, Mplus_LastDataRead); |
569 | if (debug) printk("read_byte returns %02x\n", ret); | 568 | if (debug) |
569 | printk("read_byte returns %02x\n", ret); | ||
570 | return ret; | 570 | return ret; |
571 | } | 571 | } |
572 | 572 | ||
573 | static void doc2001plus_writebuf(struct mtd_info *mtd, | 573 | static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
574 | const u_char *buf, int len) | ||
575 | { | 574 | { |
576 | struct nand_chip *this = mtd->priv; | 575 | struct nand_chip *this = mtd->priv; |
577 | struct doc_priv *doc = this->priv; | 576 | struct doc_priv *doc = this->priv; |
578 | void __iomem *docptr = doc->virtadr; | 577 | void __iomem *docptr = doc->virtadr; |
579 | int i; | 578 | int i; |
580 | 579 | ||
581 | if (debug)printk("writebuf of %d bytes: ", len); | 580 | if (debug) |
582 | for (i=0; i < len; i++) { | 581 | printk("writebuf of %d bytes: ", len); |
582 | for (i = 0; i < len; i++) { | ||
583 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); | 583 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); |
584 | if (debug && i < 16) | 584 | if (debug && i < 16) |
585 | printk("%02x ", buf[i]); | 585 | printk("%02x ", buf[i]); |
586 | } | 586 | } |
587 | if (debug) printk("\n"); | 587 | if (debug) |
588 | printk("\n"); | ||
588 | } | 589 | } |
589 | 590 | ||
590 | static void doc2001plus_readbuf(struct mtd_info *mtd, | 591 | static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
591 | u_char *buf, int len) | ||
592 | { | 592 | { |
593 | struct nand_chip *this = mtd->priv; | 593 | struct nand_chip *this = mtd->priv; |
594 | struct doc_priv *doc = this->priv; | 594 | struct doc_priv *doc = this->priv; |
595 | void __iomem *docptr = doc->virtadr; | 595 | void __iomem *docptr = doc->virtadr; |
596 | int i; | 596 | int i; |
597 | 597 | ||
598 | if (debug)printk("readbuf of %d bytes: ", len); | 598 | if (debug) |
599 | printk("readbuf of %d bytes: ", len); | ||
599 | 600 | ||
600 | /* Start read pipeline */ | 601 | /* Start read pipeline */ |
601 | ReadDOC(docptr, Mplus_ReadPipeInit); | 602 | ReadDOC(docptr, Mplus_ReadPipeInit); |
602 | ReadDOC(docptr, Mplus_ReadPipeInit); | 603 | ReadDOC(docptr, Mplus_ReadPipeInit); |
603 | 604 | ||
604 | for (i=0; i < len-2; i++) { | 605 | for (i = 0; i < len - 2; i++) { |
605 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO); | 606 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO); |
606 | if (debug && i < 16) | 607 | if (debug && i < 16) |
607 | printk("%02x ", buf[i]); | 608 | printk("%02x ", buf[i]); |
608 | } | 609 | } |
609 | 610 | ||
610 | /* Terminate read pipeline */ | 611 | /* Terminate read pipeline */ |
611 | buf[len-2] = ReadDOC(docptr, Mplus_LastDataRead); | 612 | buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead); |
612 | if (debug && i < 16) | 613 | if (debug && i < 16) |
613 | printk("%02x ", buf[len-2]); | 614 | printk("%02x ", buf[len - 2]); |
614 | buf[len-1] = ReadDOC(docptr, Mplus_LastDataRead); | 615 | buf[len - 1] = ReadDOC(docptr, Mplus_LastDataRead); |
615 | if (debug && i < 16) | 616 | if (debug && i < 16) |
616 | printk("%02x ", buf[len-1]); | 617 | printk("%02x ", buf[len - 1]); |
617 | if (debug) printk("\n"); | 618 | if (debug) |
619 | printk("\n"); | ||
618 | } | 620 | } |
619 | 621 | ||
620 | static int doc2001plus_verifybuf(struct mtd_info *mtd, | 622 | static int doc2001plus_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
621 | const u_char *buf, int len) | ||
622 | { | 623 | { |
623 | struct nand_chip *this = mtd->priv; | 624 | struct nand_chip *this = mtd->priv; |
624 | struct doc_priv *doc = this->priv; | 625 | struct doc_priv *doc = this->priv; |
625 | void __iomem *docptr = doc->virtadr; | 626 | void __iomem *docptr = doc->virtadr; |
626 | int i; | 627 | int i; |
627 | 628 | ||
628 | if (debug)printk("verifybuf of %d bytes: ", len); | 629 | if (debug) |
630 | printk("verifybuf of %d bytes: ", len); | ||
629 | 631 | ||
630 | /* Start read pipeline */ | 632 | /* Start read pipeline */ |
631 | ReadDOC(docptr, Mplus_ReadPipeInit); | 633 | ReadDOC(docptr, Mplus_ReadPipeInit); |
632 | ReadDOC(docptr, Mplus_ReadPipeInit); | 634 | ReadDOC(docptr, Mplus_ReadPipeInit); |
633 | 635 | ||
634 | for (i=0; i < len-2; i++) | 636 | for (i = 0; i < len - 2; i++) |
635 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { | 637 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { |
636 | ReadDOC(docptr, Mplus_LastDataRead); | 638 | ReadDOC(docptr, Mplus_LastDataRead); |
637 | ReadDOC(docptr, Mplus_LastDataRead); | 639 | ReadDOC(docptr, Mplus_LastDataRead); |
638 | return i; | 640 | return i; |
639 | } | 641 | } |
640 | if (buf[len-2] != ReadDOC(docptr, Mplus_LastDataRead)) | 642 | if (buf[len - 2] != ReadDOC(docptr, Mplus_LastDataRead)) |
641 | return len-2; | 643 | return len - 2; |
642 | if (buf[len-1] != ReadDOC(docptr, Mplus_LastDataRead)) | 644 | if (buf[len - 1] != ReadDOC(docptr, Mplus_LastDataRead)) |
643 | return len-1; | 645 | return len - 1; |
644 | return 0; | 646 | return 0; |
645 | } | 647 | } |
646 | 648 | ||
@@ -648,10 +650,11 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) | |||
648 | { | 650 | { |
649 | struct nand_chip *this = mtd->priv; | 651 | struct nand_chip *this = mtd->priv; |
650 | struct doc_priv *doc = this->priv; | 652 | struct doc_priv *doc = this->priv; |
651 | void __iomem *docptr = doc->virtadr; | 653 | void __iomem *docptr = doc->virtadr; |
652 | int floor = 0; | 654 | int floor = 0; |
653 | 655 | ||
654 | if(debug)printk("select chip (%d)\n", chip); | 656 | if (debug) |
657 | printk("select chip (%d)\n", chip); | ||
655 | 658 | ||
656 | if (chip == -1) { | 659 | if (chip == -1) { |
657 | /* Disable flash internally */ | 660 | /* Disable flash internally */ |
@@ -660,7 +663,7 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) | |||
660 | } | 663 | } |
661 | 664 | ||
662 | floor = chip / doc->chips_per_floor; | 665 | floor = chip / doc->chips_per_floor; |
663 | chip -= (floor * doc->chips_per_floor); | 666 | chip -= (floor * doc->chips_per_floor); |
664 | 667 | ||
665 | /* Assert ChipEnable and deassert WriteProtect */ | 668 | /* Assert ChipEnable and deassert WriteProtect */ |
666 | WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect); | 669 | WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect); |
@@ -674,16 +677,17 @@ static void doc200x_select_chip(struct mtd_info *mtd, int chip) | |||
674 | { | 677 | { |
675 | struct nand_chip *this = mtd->priv; | 678 | struct nand_chip *this = mtd->priv; |
676 | struct doc_priv *doc = this->priv; | 679 | struct doc_priv *doc = this->priv; |
677 | void __iomem *docptr = doc->virtadr; | 680 | void __iomem *docptr = doc->virtadr; |
678 | int floor = 0; | 681 | int floor = 0; |
679 | 682 | ||
680 | if(debug)printk("select chip (%d)\n", chip); | 683 | if (debug) |
684 | printk("select chip (%d)\n", chip); | ||
681 | 685 | ||
682 | if (chip == -1) | 686 | if (chip == -1) |
683 | return; | 687 | return; |
684 | 688 | ||
685 | floor = chip / doc->chips_per_floor; | 689 | floor = chip / doc->chips_per_floor; |
686 | chip -= (floor * doc->chips_per_floor); | 690 | chip -= (floor * doc->chips_per_floor); |
687 | 691 | ||
688 | /* 11.4.4 -- deassert CE before changing chip */ | 692 | /* 11.4.4 -- deassert CE before changing chip */ |
689 | doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE); | 693 | doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE); |
@@ -701,9 +705,9 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
701 | { | 705 | { |
702 | struct nand_chip *this = mtd->priv; | 706 | struct nand_chip *this = mtd->priv; |
703 | struct doc_priv *doc = this->priv; | 707 | struct doc_priv *doc = this->priv; |
704 | void __iomem *docptr = doc->virtadr; | 708 | void __iomem *docptr = doc->virtadr; |
705 | 709 | ||
706 | switch(cmd) { | 710 | switch (cmd) { |
707 | case NAND_CTL_SETNCE: | 711 | case NAND_CTL_SETNCE: |
708 | doc->CDSNControl |= CDSN_CTRL_CE; | 712 | doc->CDSNControl |= CDSN_CTRL_CE; |
709 | break; | 713 | break; |
@@ -729,17 +733,18 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
729 | doc->CDSNControl &= ~CDSN_CTRL_WP; | 733 | doc->CDSNControl &= ~CDSN_CTRL_WP; |
730 | break; | 734 | break; |
731 | } | 735 | } |
732 | if (debug)printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl); | 736 | if (debug) |
737 | printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl); | ||
733 | WriteDOC(doc->CDSNControl, docptr, CDSNControl); | 738 | WriteDOC(doc->CDSNControl, docptr, CDSNControl); |
734 | /* 11.4.3 -- 4 NOPs after CSDNControl write */ | 739 | /* 11.4.3 -- 4 NOPs after CSDNControl write */ |
735 | DoC_Delay(doc, 4); | 740 | DoC_Delay(doc, 4); |
736 | } | 741 | } |
737 | 742 | ||
738 | static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 743 | static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
739 | { | 744 | { |
740 | struct nand_chip *this = mtd->priv; | 745 | struct nand_chip *this = mtd->priv; |
741 | struct doc_priv *doc = this->priv; | 746 | struct doc_priv *doc = this->priv; |
742 | void __iomem *docptr = doc->virtadr; | 747 | void __iomem *docptr = doc->virtadr; |
743 | 748 | ||
744 | /* | 749 | /* |
745 | * Must terminate write pipeline before sending any commands | 750 | * Must terminate write pipeline before sending any commands |
@@ -782,25 +787,26 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col | |||
782 | WriteDOC(column, docptr, Mplus_FlashAddress); | 787 | WriteDOC(column, docptr, Mplus_FlashAddress); |
783 | } | 788 | } |
784 | if (page_addr != -1) { | 789 | if (page_addr != -1) { |
785 | WriteDOC((unsigned char) (page_addr & 0xff), docptr, Mplus_FlashAddress); | 790 | WriteDOC((unsigned char)(page_addr & 0xff), docptr, Mplus_FlashAddress); |
786 | WriteDOC((unsigned char) ((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress); | 791 | WriteDOC((unsigned char)((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress); |
787 | /* One more address cycle for higher density devices */ | 792 | /* One more address cycle for higher density devices */ |
788 | if (this->chipsize & 0x0c000000) { | 793 | if (this->chipsize & 0x0c000000) { |
789 | WriteDOC((unsigned char) ((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress); | 794 | WriteDOC((unsigned char)((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress); |
790 | printk("high density\n"); | 795 | printk("high density\n"); |
791 | } | 796 | } |
792 | } | 797 | } |
793 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 798 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
794 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 799 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
795 | /* deassert ALE */ | 800 | /* deassert ALE */ |
796 | if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || command == NAND_CMD_READOOB || command == NAND_CMD_READID) | 801 | if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || |
802 | command == NAND_CMD_READOOB || command == NAND_CMD_READID) | ||
797 | WriteDOC(0, docptr, Mplus_FlashControl); | 803 | WriteDOC(0, docptr, Mplus_FlashControl); |
798 | } | 804 | } |
799 | 805 | ||
800 | /* | 806 | /* |
801 | * program and erase have their own busy handlers | 807 | * program and erase have their own busy handlers |
802 | * status and sequential in needs no delay | 808 | * status and sequential in needs no delay |
803 | */ | 809 | */ |
804 | switch (command) { | 810 | switch (command) { |
805 | 811 | ||
806 | case NAND_CMD_PAGEPROG: | 812 | case NAND_CMD_PAGEPROG: |
@@ -817,55 +823,57 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col | |||
817 | WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd); | 823 | WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd); |
818 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 824 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
819 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 825 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
820 | while ( !(this->read_byte(mtd) & 0x40)); | 826 | while (!(this->read_byte(mtd) & 0x40)) ; |
821 | return; | 827 | return; |
822 | 828 | ||
823 | /* This applies to read commands */ | 829 | /* This applies to read commands */ |
824 | default: | 830 | default: |
825 | /* | 831 | /* |
826 | * If we don't have access to the busy pin, we apply the given | 832 | * If we don't have access to the busy pin, we apply the given |
827 | * command delay | 833 | * command delay |
828 | */ | 834 | */ |
829 | if (!this->dev_ready) { | 835 | if (!this->dev_ready) { |
830 | udelay (this->chip_delay); | 836 | udelay(this->chip_delay); |
831 | return; | 837 | return; |
832 | } | 838 | } |
833 | } | 839 | } |
834 | 840 | ||
835 | /* Apply this short delay always to ensure that we do wait tWB in | 841 | /* Apply this short delay always to ensure that we do wait tWB in |
836 | * any case on any machine. */ | 842 | * any case on any machine. */ |
837 | ndelay (100); | 843 | ndelay(100); |
838 | /* wait until command is processed */ | 844 | /* wait until command is processed */ |
839 | while (!this->dev_ready(mtd)); | 845 | while (!this->dev_ready(mtd)) ; |
840 | } | 846 | } |
841 | 847 | ||
842 | static int doc200x_dev_ready(struct mtd_info *mtd) | 848 | static int doc200x_dev_ready(struct mtd_info *mtd) |
843 | { | 849 | { |
844 | struct nand_chip *this = mtd->priv; | 850 | struct nand_chip *this = mtd->priv; |
845 | struct doc_priv *doc = this->priv; | 851 | struct doc_priv *doc = this->priv; |
846 | void __iomem *docptr = doc->virtadr; | 852 | void __iomem *docptr = doc->virtadr; |
847 | 853 | ||
848 | if (DoC_is_MillenniumPlus(doc)) { | 854 | if (DoC_is_MillenniumPlus(doc)) { |
849 | /* 11.4.2 -- must NOP four times before checking FR/B# */ | 855 | /* 11.4.2 -- must NOP four times before checking FR/B# */ |
850 | DoC_Delay(doc, 4); | 856 | DoC_Delay(doc, 4); |
851 | if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { | 857 | if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { |
852 | if(debug) | 858 | if (debug) |
853 | printk("not ready\n"); | 859 | printk("not ready\n"); |
854 | return 0; | 860 | return 0; |
855 | } | 861 | } |
856 | if (debug)printk("was ready\n"); | 862 | if (debug) |
863 | printk("was ready\n"); | ||
857 | return 1; | 864 | return 1; |
858 | } else { | 865 | } else { |
859 | /* 11.4.2 -- must NOP four times before checking FR/B# */ | 866 | /* 11.4.2 -- must NOP four times before checking FR/B# */ |
860 | DoC_Delay(doc, 4); | 867 | DoC_Delay(doc, 4); |
861 | if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { | 868 | if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { |
862 | if(debug) | 869 | if (debug) |
863 | printk("not ready\n"); | 870 | printk("not ready\n"); |
864 | return 0; | 871 | return 0; |
865 | } | 872 | } |
866 | /* 11.4.2 -- Must NOP twice if it's ready */ | 873 | /* 11.4.2 -- Must NOP twice if it's ready */ |
867 | DoC_Delay(doc, 2); | 874 | DoC_Delay(doc, 2); |
868 | if (debug)printk("was ready\n"); | 875 | if (debug) |
876 | printk("was ready\n"); | ||
869 | return 1; | 877 | return 1; |
870 | } | 878 | } |
871 | } | 879 | } |
@@ -881,10 +889,10 @@ static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode) | |||
881 | { | 889 | { |
882 | struct nand_chip *this = mtd->priv; | 890 | struct nand_chip *this = mtd->priv; |
883 | struct doc_priv *doc = this->priv; | 891 | struct doc_priv *doc = this->priv; |
884 | void __iomem *docptr = doc->virtadr; | 892 | void __iomem *docptr = doc->virtadr; |
885 | 893 | ||
886 | /* Prime the ECC engine */ | 894 | /* Prime the ECC engine */ |
887 | switch(mode) { | 895 | switch (mode) { |
888 | case NAND_ECC_READ: | 896 | case NAND_ECC_READ: |
889 | WriteDOC(DOC_ECC_RESET, docptr, ECCConf); | 897 | WriteDOC(DOC_ECC_RESET, docptr, ECCConf); |
890 | WriteDOC(DOC_ECC_EN, docptr, ECCConf); | 898 | WriteDOC(DOC_ECC_EN, docptr, ECCConf); |
@@ -900,10 +908,10 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) | |||
900 | { | 908 | { |
901 | struct nand_chip *this = mtd->priv; | 909 | struct nand_chip *this = mtd->priv; |
902 | struct doc_priv *doc = this->priv; | 910 | struct doc_priv *doc = this->priv; |
903 | void __iomem *docptr = doc->virtadr; | 911 | void __iomem *docptr = doc->virtadr; |
904 | 912 | ||
905 | /* Prime the ECC engine */ | 913 | /* Prime the ECC engine */ |
906 | switch(mode) { | 914 | switch (mode) { |
907 | case NAND_ECC_READ: | 915 | case NAND_ECC_READ: |
908 | WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf); | 916 | WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf); |
909 | WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf); | 917 | WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf); |
@@ -916,12 +924,11 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) | |||
916 | } | 924 | } |
917 | 925 | ||
918 | /* This code is only called on write */ | 926 | /* This code is only called on write */ |
919 | static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | 927 | static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code) |
920 | unsigned char *ecc_code) | ||
921 | { | 928 | { |
922 | struct nand_chip *this = mtd->priv; | 929 | struct nand_chip *this = mtd->priv; |
923 | struct doc_priv *doc = this->priv; | 930 | struct doc_priv *doc = this->priv; |
924 | void __iomem *docptr = doc->virtadr; | 931 | void __iomem *docptr = doc->virtadr; |
925 | int i; | 932 | int i; |
926 | int emptymatch = 1; | 933 | int emptymatch = 1; |
927 | 934 | ||
@@ -961,7 +968,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
961 | often. It could be optimized away by examining the data in | 968 | often. It could be optimized away by examining the data in |
962 | the writebuf routine, and remembering the result. */ | 969 | the writebuf routine, and remembering the result. */ |
963 | for (i = 0; i < 512; i++) { | 970 | for (i = 0; i < 512; i++) { |
964 | if (dat[i] == 0xff) continue; | 971 | if (dat[i] == 0xff) |
972 | continue; | ||
965 | emptymatch = 0; | 973 | emptymatch = 0; |
966 | break; | 974 | break; |
967 | } | 975 | } |
@@ -969,7 +977,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
969 | /* If emptymatch still =1, we do have an all-0xff data buffer. | 977 | /* If emptymatch still =1, we do have an all-0xff data buffer. |
970 | Return all-0xff ecc value instead of the computed one, so | 978 | Return all-0xff ecc value instead of the computed one, so |
971 | it'll look just like a freshly-erased page. */ | 979 | it'll look just like a freshly-erased page. */ |
972 | if (emptymatch) memset(ecc_code, 0xff, 6); | 980 | if (emptymatch) |
981 | memset(ecc_code, 0xff, 6); | ||
973 | #endif | 982 | #endif |
974 | return 0; | 983 | return 0; |
975 | } | 984 | } |
@@ -979,7 +988,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
979 | int i, ret = 0; | 988 | int i, ret = 0; |
980 | struct nand_chip *this = mtd->priv; | 989 | struct nand_chip *this = mtd->priv; |
981 | struct doc_priv *doc = this->priv; | 990 | struct doc_priv *doc = this->priv; |
982 | void __iomem *docptr = doc->virtadr; | 991 | void __iomem *docptr = doc->virtadr; |
983 | volatile u_char dummy; | 992 | volatile u_char dummy; |
984 | int emptymatch = 1; | 993 | int emptymatch = 1; |
985 | 994 | ||
@@ -1012,18 +1021,20 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1012 | all-0xff data and stored ecc block. Check the stored ecc. */ | 1021 | all-0xff data and stored ecc block. Check the stored ecc. */ |
1013 | if (emptymatch) { | 1022 | if (emptymatch) { |
1014 | for (i = 0; i < 6; i++) { | 1023 | for (i = 0; i < 6; i++) { |
1015 | if (read_ecc[i] == 0xff) continue; | 1024 | if (read_ecc[i] == 0xff) |
1025 | continue; | ||
1016 | emptymatch = 0; | 1026 | emptymatch = 0; |
1017 | break; | 1027 | break; |
1018 | } | 1028 | } |
1019 | } | 1029 | } |
1020 | /* If emptymatch still =1, check the data block. */ | 1030 | /* If emptymatch still =1, check the data block. */ |
1021 | if (emptymatch) { | 1031 | if (emptymatch) { |
1022 | /* Note: this somewhat expensive test should not be triggered | 1032 | /* Note: this somewhat expensive test should not be triggered |
1023 | often. It could be optimized away by examining the data in | 1033 | often. It could be optimized away by examining the data in |
1024 | the readbuf routine, and remembering the result. */ | 1034 | the readbuf routine, and remembering the result. */ |
1025 | for (i = 0; i < 512; i++) { | 1035 | for (i = 0; i < 512; i++) { |
1026 | if (dat[i] == 0xff) continue; | 1036 | if (dat[i] == 0xff) |
1037 | continue; | ||
1027 | emptymatch = 0; | 1038 | emptymatch = 0; |
1028 | break; | 1039 | break; |
1029 | } | 1040 | } |
@@ -1032,7 +1043,8 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1032 | erased block, in which case the ECC will not come out right. | 1043 | erased block, in which case the ECC will not come out right. |
1033 | We'll suppress the error and tell the caller everything's | 1044 | We'll suppress the error and tell the caller everything's |
1034 | OK. Because it is. */ | 1045 | OK. Because it is. */ |
1035 | if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc); | 1046 | if (!emptymatch) |
1047 | ret = doc_ecc_decode(rs_decoder, dat, calc_ecc); | ||
1036 | if (ret > 0) | 1048 | if (ret > 0) |
1037 | printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); | 1049 | printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); |
1038 | } | 1050 | } |
@@ -1060,10 +1072,10 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1060 | * be able to handle out-of-order segments. | 1072 | * be able to handle out-of-order segments. |
1061 | */ | 1073 | */ |
1062 | static struct nand_oobinfo doc200x_oobinfo = { | 1074 | static struct nand_oobinfo doc200x_oobinfo = { |
1063 | .useecc = MTD_NANDECC_AUTOPLACE, | 1075 | .useecc = MTD_NANDECC_AUTOPLACE, |
1064 | .eccbytes = 6, | 1076 | .eccbytes = 6, |
1065 | .eccpos = {0, 1, 2, 3, 4, 5}, | 1077 | .eccpos = {0, 1, 2, 3, 4, 5}, |
1066 | .oobfree = { {8, 8}, {6, 2} } | 1078 | .oobfree = {{8, 8}, {6, 2}} |
1067 | }; | 1079 | }; |
1068 | 1080 | ||
1069 | /* Find the (I)NFTL Media Header, and optionally also the mirror media header. | 1081 | /* Find the (I)NFTL Media Header, and optionally also the mirror media header. |
@@ -1072,8 +1084,7 @@ static struct nand_oobinfo doc200x_oobinfo = { | |||
1072 | either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media | 1084 | either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media |
1073 | header. The page #s of the found media headers are placed in mh0_page and | 1085 | header. The page #s of the found media headers are placed in mh0_page and |
1074 | mh1_page in the DOC private structure. */ | 1086 | mh1_page in the DOC private structure. */ |
1075 | static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | 1087 | static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror) |
1076 | const char *id, int findmirror) | ||
1077 | { | 1088 | { |
1078 | struct nand_chip *this = mtd->priv; | 1089 | struct nand_chip *this = mtd->priv; |
1079 | struct doc_priv *doc = this->priv; | 1090 | struct doc_priv *doc = this->priv; |
@@ -1083,16 +1094,18 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | |||
1083 | 1094 | ||
1084 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { | 1095 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { |
1085 | ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); | 1096 | ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); |
1086 | if (retlen != mtd->oobblock) continue; | 1097 | if (retlen != mtd->oobblock) |
1098 | continue; | ||
1087 | if (ret) { | 1099 | if (ret) { |
1088 | printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", | 1100 | printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs); |
1089 | offs); | ||
1090 | } | 1101 | } |
1091 | if (memcmp(buf, id, 6)) continue; | 1102 | if (memcmp(buf, id, 6)) |
1103 | continue; | ||
1092 | printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs); | 1104 | printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs); |
1093 | if (doc->mh0_page == -1) { | 1105 | if (doc->mh0_page == -1) { |
1094 | doc->mh0_page = offs >> this->page_shift; | 1106 | doc->mh0_page = offs >> this->page_shift; |
1095 | if (!findmirror) return 1; | 1107 | if (!findmirror) |
1108 | return 1; | ||
1096 | continue; | 1109 | continue; |
1097 | } | 1110 | } |
1098 | doc->mh1_page = offs >> this->page_shift; | 1111 | doc->mh1_page = offs >> this->page_shift; |
@@ -1114,8 +1127,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | |||
1114 | return 1; | 1127 | return 1; |
1115 | } | 1128 | } |
1116 | 1129 | ||
1117 | static inline int __init nftl_partscan(struct mtd_info *mtd, | 1130 | static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) |
1118 | struct mtd_partition *parts) | ||
1119 | { | 1131 | { |
1120 | struct nand_chip *this = mtd->priv; | 1132 | struct nand_chip *this = mtd->priv; |
1121 | struct doc_priv *doc = this->priv; | 1133 | struct doc_priv *doc = this->priv; |
@@ -1132,8 +1144,9 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1132 | printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); | 1144 | printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); |
1133 | return 0; | 1145 | return 0; |
1134 | } | 1146 | } |
1135 | if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out; | 1147 | if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1))) |
1136 | mh = (struct NFTLMediaHeader *) buf; | 1148 | goto out; |
1149 | mh = (struct NFTLMediaHeader *)buf; | ||
1137 | 1150 | ||
1138 | mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); | 1151 | mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); |
1139 | mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); | 1152 | mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); |
@@ -1155,8 +1168,8 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1155 | /* Auto-determine UnitSizeFactor. The constraints are: | 1168 | /* Auto-determine UnitSizeFactor. The constraints are: |
1156 | - There can be at most 32768 virtual blocks. | 1169 | - There can be at most 32768 virtual blocks. |
1157 | - There can be at most (virtual block size - page size) | 1170 | - There can be at most (virtual block size - page size) |
1158 | virtual blocks (because MediaHeader+BBT must fit in 1). | 1171 | virtual blocks (because MediaHeader+BBT must fit in 1). |
1159 | */ | 1172 | */ |
1160 | mh->UnitSizeFactor = 0xff; | 1173 | mh->UnitSizeFactor = 0xff; |
1161 | while (blocks > maxblocks) { | 1174 | while (blocks > maxblocks) { |
1162 | blocks >>= 1; | 1175 | blocks >>= 1; |
@@ -1211,14 +1224,13 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1211 | } | 1224 | } |
1212 | 1225 | ||
1213 | ret = numparts; | 1226 | ret = numparts; |
1214 | out: | 1227 | out: |
1215 | kfree(buf); | 1228 | kfree(buf); |
1216 | return ret; | 1229 | return ret; |
1217 | } | 1230 | } |
1218 | 1231 | ||
1219 | /* This is a stripped-down copy of the code in inftlmount.c */ | 1232 | /* This is a stripped-down copy of the code in inftlmount.c */ |
1220 | static inline int __init inftl_partscan(struct mtd_info *mtd, | 1233 | static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) |
1221 | struct mtd_partition *parts) | ||
1222 | { | 1234 | { |
1223 | struct nand_chip *this = mtd->priv; | 1235 | struct nand_chip *this = mtd->priv; |
1224 | struct doc_priv *doc = this->priv; | 1236 | struct doc_priv *doc = this->priv; |
@@ -1241,9 +1253,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1241 | return 0; | 1253 | return 0; |
1242 | } | 1254 | } |
1243 | 1255 | ||
1244 | if (!find_media_headers(mtd, buf, "BNAND", 0)) goto out; | 1256 | if (!find_media_headers(mtd, buf, "BNAND", 0)) |
1257 | goto out; | ||
1245 | doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); | 1258 | doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); |
1246 | mh = (struct INFTLMediaHeader *) buf; | 1259 | mh = (struct INFTLMediaHeader *)buf; |
1247 | 1260 | ||
1248 | mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); | 1261 | mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); |
1249 | mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); | 1262 | mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); |
@@ -1319,8 +1332,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1319 | parts[numparts].offset = ip->firstUnit << vshift; | 1332 | parts[numparts].offset = ip->firstUnit << vshift; |
1320 | parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift; | 1333 | parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift; |
1321 | numparts++; | 1334 | numparts++; |
1322 | if (ip->lastUnit > lastvunit) lastvunit = ip->lastUnit; | 1335 | if (ip->lastUnit > lastvunit) |
1323 | if (ip->flags & INFTL_LAST) break; | 1336 | lastvunit = ip->lastUnit; |
1337 | if (ip->flags & INFTL_LAST) | ||
1338 | break; | ||
1324 | } | 1339 | } |
1325 | lastvunit++; | 1340 | lastvunit++; |
1326 | if ((lastvunit << vshift) < end) { | 1341 | if ((lastvunit << vshift) < end) { |
@@ -1330,7 +1345,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1330 | numparts++; | 1345 | numparts++; |
1331 | } | 1346 | } |
1332 | ret = numparts; | 1347 | ret = numparts; |
1333 | out: | 1348 | out: |
1334 | kfree(buf); | 1349 | kfree(buf); |
1335 | return ret; | 1350 | return ret; |
1336 | } | 1351 | } |
@@ -1342,11 +1357,12 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) | |||
1342 | struct doc_priv *doc = this->priv; | 1357 | struct doc_priv *doc = this->priv; |
1343 | struct mtd_partition parts[2]; | 1358 | struct mtd_partition parts[2]; |
1344 | 1359 | ||
1345 | memset((char *) parts, 0, sizeof(parts)); | 1360 | memset((char *)parts, 0, sizeof(parts)); |
1346 | /* On NFTL, we have to find the media headers before we can read the | 1361 | /* On NFTL, we have to find the media headers before we can read the |
1347 | BBTs, since they're stored in the media header eraseblocks. */ | 1362 | BBTs, since they're stored in the media header eraseblocks. */ |
1348 | numparts = nftl_partscan(mtd, parts); | 1363 | numparts = nftl_partscan(mtd, parts); |
1349 | if (!numparts) return -EIO; | 1364 | if (!numparts) |
1365 | return -EIO; | ||
1350 | this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT | | 1366 | this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT | |
1351 | NAND_BBT_SAVECONTENT | NAND_BBT_WRITE | | 1367 | NAND_BBT_SAVECONTENT | NAND_BBT_WRITE | |
1352 | NAND_BBT_VERSION; | 1368 | NAND_BBT_VERSION; |
@@ -1393,8 +1409,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1393 | this->bbt_td->pages[0] = 2; | 1409 | this->bbt_td->pages[0] = 2; |
1394 | this->bbt_md = NULL; | 1410 | this->bbt_md = NULL; |
1395 | } else { | 1411 | } else { |
1396 | this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | | 1412 | this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION; |
1397 | NAND_BBT_VERSION; | ||
1398 | if (inftl_bbt_write) | 1413 | if (inftl_bbt_write) |
1399 | this->bbt_td->options |= NAND_BBT_WRITE; | 1414 | this->bbt_td->options |= NAND_BBT_WRITE; |
1400 | this->bbt_td->offs = 8; | 1415 | this->bbt_td->offs = 8; |
@@ -1404,8 +1419,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1404 | this->bbt_td->reserved_block_code = 0x01; | 1419 | this->bbt_td->reserved_block_code = 0x01; |
1405 | this->bbt_td->pattern = "MSYS_BBT"; | 1420 | this->bbt_td->pattern = "MSYS_BBT"; |
1406 | 1421 | ||
1407 | this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | | 1422 | this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION; |
1408 | NAND_BBT_VERSION; | ||
1409 | if (inftl_bbt_write) | 1423 | if (inftl_bbt_write) |
1410 | this->bbt_md->options |= NAND_BBT_WRITE; | 1424 | this->bbt_md->options |= NAND_BBT_WRITE; |
1411 | this->bbt_md->offs = 8; | 1425 | this->bbt_md->offs = 8; |
@@ -1420,12 +1434,13 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1420 | At least as nand_bbt.c is currently written. */ | 1434 | At least as nand_bbt.c is currently written. */ |
1421 | if ((ret = nand_scan_bbt(mtd, NULL))) | 1435 | if ((ret = nand_scan_bbt(mtd, NULL))) |
1422 | return ret; | 1436 | return ret; |
1423 | memset((char *) parts, 0, sizeof(parts)); | 1437 | memset((char *)parts, 0, sizeof(parts)); |
1424 | numparts = inftl_partscan(mtd, parts); | 1438 | numparts = inftl_partscan(mtd, parts); |
1425 | /* At least for now, require the INFTL Media Header. We could probably | 1439 | /* At least for now, require the INFTL Media Header. We could probably |
1426 | do without it for non-INFTL use, since all it gives us is | 1440 | do without it for non-INFTL use, since all it gives us is |
1427 | autopartitioning, but I want to give it more thought. */ | 1441 | autopartitioning, but I want to give it more thought. */ |
1428 | if (!numparts) return -EIO; | 1442 | if (!numparts) |
1443 | return -EIO; | ||
1429 | add_mtd_device(mtd); | 1444 | add_mtd_device(mtd); |
1430 | #ifdef CONFIG_MTD_PARTITIONS | 1445 | #ifdef CONFIG_MTD_PARTITIONS |
1431 | if (!no_autopart) | 1446 | if (!no_autopart) |
@@ -1535,20 +1550,16 @@ static int __init doc_probe(unsigned long physadr) | |||
1535 | save_control = ReadDOC(virtadr, DOCControl); | 1550 | save_control = ReadDOC(virtadr, DOCControl); |
1536 | 1551 | ||
1537 | /* Reset the DiskOnChip ASIC */ | 1552 | /* Reset the DiskOnChip ASIC */ |
1538 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, | 1553 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl); |
1539 | virtadr, DOCControl); | 1554 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl); |
1540 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, | ||
1541 | virtadr, DOCControl); | ||
1542 | 1555 | ||
1543 | /* Enable the DiskOnChip ASIC */ | 1556 | /* Enable the DiskOnChip ASIC */ |
1544 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, | 1557 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl); |
1545 | virtadr, DOCControl); | 1558 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl); |
1546 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, | ||
1547 | virtadr, DOCControl); | ||
1548 | 1559 | ||
1549 | ChipID = ReadDOC(virtadr, ChipID); | 1560 | ChipID = ReadDOC(virtadr, ChipID); |
1550 | 1561 | ||
1551 | switch(ChipID) { | 1562 | switch (ChipID) { |
1552 | case DOC_ChipID_Doc2k: | 1563 | case DOC_ChipID_Doc2k: |
1553 | reg = DoC_2k_ECCStatus; | 1564 | reg = DoC_2k_ECCStatus; |
1554 | break; | 1565 | break; |
@@ -1564,15 +1575,13 @@ static int __init doc_probe(unsigned long physadr) | |||
1564 | ReadDOC(virtadr, Mplus_Power); | 1575 | ReadDOC(virtadr, Mplus_Power); |
1565 | 1576 | ||
1566 | /* Reset the Millennium Plus ASIC */ | 1577 | /* Reset the Millennium Plus ASIC */ |
1567 | tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | | 1578 | tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT; |
1568 | DOC_MODE_BDECT; | ||
1569 | WriteDOC(tmp, virtadr, Mplus_DOCControl); | 1579 | WriteDOC(tmp, virtadr, Mplus_DOCControl); |
1570 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); | 1580 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); |
1571 | 1581 | ||
1572 | mdelay(1); | 1582 | mdelay(1); |
1573 | /* Enable the Millennium Plus ASIC */ | 1583 | /* Enable the Millennium Plus ASIC */ |
1574 | tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | | 1584 | tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT; |
1575 | DOC_MODE_BDECT; | ||
1576 | WriteDOC(tmp, virtadr, Mplus_DOCControl); | 1585 | WriteDOC(tmp, virtadr, Mplus_DOCControl); |
1577 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); | 1586 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); |
1578 | mdelay(1); | 1587 | mdelay(1); |
@@ -1596,7 +1605,7 @@ static int __init doc_probe(unsigned long physadr) | |||
1596 | goto notfound; | 1605 | goto notfound; |
1597 | } | 1606 | } |
1598 | /* Check the TOGGLE bit in the ECC register */ | 1607 | /* Check the TOGGLE bit in the ECC register */ |
1599 | tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1608 | tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1600 | tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1609 | tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1601 | tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1610 | tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1602 | if ((tmp == tmpb) || (tmp != tmpc)) { | 1611 | if ((tmp == tmpb) || (tmp != tmpc)) { |
@@ -1626,11 +1635,11 @@ static int __init doc_probe(unsigned long physadr) | |||
1626 | if (ChipID == DOC_ChipID_DocMilPlus16) { | 1635 | if (ChipID == DOC_ChipID_DocMilPlus16) { |
1627 | WriteDOC(~newval, virtadr, Mplus_AliasResolution); | 1636 | WriteDOC(~newval, virtadr, Mplus_AliasResolution); |
1628 | oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution); | 1637 | oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution); |
1629 | WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it | 1638 | WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it |
1630 | } else { | 1639 | } else { |
1631 | WriteDOC(~newval, virtadr, AliasResolution); | 1640 | WriteDOC(~newval, virtadr, AliasResolution); |
1632 | oldval = ReadDOC(doc->virtadr, AliasResolution); | 1641 | oldval = ReadDOC(doc->virtadr, AliasResolution); |
1633 | WriteDOC(newval, virtadr, AliasResolution); // restore it | 1642 | WriteDOC(newval, virtadr, AliasResolution); // restore it |
1634 | } | 1643 | } |
1635 | newval = ~newval; | 1644 | newval = ~newval; |
1636 | if (oldval == newval) { | 1645 | if (oldval == newval) { |
@@ -1642,10 +1651,8 @@ static int __init doc_probe(unsigned long physadr) | |||
1642 | printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr); | 1651 | printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr); |
1643 | 1652 | ||
1644 | len = sizeof(struct mtd_info) + | 1653 | len = sizeof(struct mtd_info) + |
1645 | sizeof(struct nand_chip) + | 1654 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); |
1646 | sizeof(struct doc_priv) + | 1655 | mtd = kmalloc(len, GFP_KERNEL); |
1647 | (2 * sizeof(struct nand_bbt_descr)); | ||
1648 | mtd = kmalloc(len, GFP_KERNEL); | ||
1649 | if (!mtd) { | 1656 | if (!mtd) { |
1650 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); | 1657 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); |
1651 | ret = -ENOMEM; | 1658 | ret = -ENOMEM; |
@@ -1707,18 +1714,18 @@ static int __init doc_probe(unsigned long physadr) | |||
1707 | doclist = mtd; | 1714 | doclist = mtd; |
1708 | return 0; | 1715 | return 0; |
1709 | 1716 | ||
1710 | notfound: | 1717 | notfound: |
1711 | /* Put back the contents of the DOCControl register, in case it's not | 1718 | /* Put back the contents of the DOCControl register, in case it's not |
1712 | actually a DiskOnChip. */ | 1719 | actually a DiskOnChip. */ |
1713 | WriteDOC(save_control, virtadr, DOCControl); | 1720 | WriteDOC(save_control, virtadr, DOCControl); |
1714 | fail: | 1721 | fail: |
1715 | iounmap(virtadr); | 1722 | iounmap(virtadr); |
1716 | return ret; | 1723 | return ret; |
1717 | } | 1724 | } |
1718 | 1725 | ||
1719 | static void release_nanddoc(void) | 1726 | static void release_nanddoc(void) |
1720 | { | 1727 | { |
1721 | struct mtd_info *mtd, *nextmtd; | 1728 | struct mtd_info *mtd, *nextmtd; |
1722 | struct nand_chip *nand; | 1729 | struct nand_chip *nand; |
1723 | struct doc_priv *doc; | 1730 | struct doc_priv *doc; |
1724 | 1731 | ||
@@ -1747,8 +1754,8 @@ static int __init init_nanddoc(void) | |||
1747 | * generator polinomial degree = 4 | 1754 | * generator polinomial degree = 4 |
1748 | */ | 1755 | */ |
1749 | rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS); | 1756 | rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS); |
1750 | if (!rs_decoder) { | 1757 | if (!rs_decoder) { |
1751 | printk (KERN_ERR "DiskOnChip: Could not create a RS decoder\n"); | 1758 | printk(KERN_ERR "DiskOnChip: Could not create a RS decoder\n"); |
1752 | return -ENOMEM; | 1759 | return -ENOMEM; |
1753 | } | 1760 | } |
1754 | 1761 | ||
@@ -1758,7 +1765,7 @@ static int __init init_nanddoc(void) | |||
1758 | if (ret < 0) | 1765 | if (ret < 0) |
1759 | goto outerr; | 1766 | goto outerr; |
1760 | } else { | 1767 | } else { |
1761 | for (i=0; (doc_locations[i] != 0xffffffff); i++) { | 1768 | for (i = 0; (doc_locations[i] != 0xffffffff); i++) { |
1762 | doc_probe(doc_locations[i]); | 1769 | doc_probe(doc_locations[i]); |
1763 | } | 1770 | } |
1764 | } | 1771 | } |
@@ -1770,7 +1777,7 @@ static int __init init_nanddoc(void) | |||
1770 | goto outerr; | 1777 | goto outerr; |
1771 | } | 1778 | } |
1772 | return 0; | 1779 | return 0; |
1773 | outerr: | 1780 | outerr: |
1774 | free_rs(rs_decoder); | 1781 | free_rs(rs_decoder); |
1775 | return ret; | 1782 | return ret; |
1776 | } | 1783 | } |
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c index 9b1fd2f387fa..8467d770710c 100644 --- a/drivers/mtd/nand/edb7312.c +++ b/drivers/mtd/nand/edb7312.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/mtd/nand.h> | 25 | #include <linux/mtd/nand.h> |
26 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
27 | #include <asm/io.h> | 27 | #include <asm/io.h> |
28 | #include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ | 28 | #include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ |
29 | #include <asm/sizes.h> | 29 | #include <asm/sizes.h> |
30 | #include <asm/hardware/clps7111.h> | 30 | #include <asm/hardware/clps7111.h> |
31 | 31 | ||
@@ -54,29 +54,29 @@ static struct mtd_info *ep7312_mtd = NULL; | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE; | 56 | static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE; |
57 | static void __iomem * ep7312_pxdr = (void __iomem *) EP7312_PXDR; | 57 | static void __iomem *ep7312_pxdr = (void __iomem *)EP7312_PXDR; |
58 | static void __iomem * ep7312_pxddr = (void __iomem *) EP7312_PXDDR; | 58 | static void __iomem *ep7312_pxddr = (void __iomem *)EP7312_PXDDR; |
59 | 59 | ||
60 | #ifdef CONFIG_MTD_PARTITIONS | 60 | #ifdef CONFIG_MTD_PARTITIONS |
61 | /* | 61 | /* |
62 | * Define static partitions for flash device | 62 | * Define static partitions for flash device |
63 | */ | 63 | */ |
64 | static struct mtd_partition partition_info[] = { | 64 | static struct mtd_partition partition_info[] = { |
65 | { .name = "EP7312 Nand Flash", | 65 | {.name = "EP7312 Nand Flash", |
66 | .offset = 0, | 66 | .offset = 0, |
67 | .size = 8*1024*1024 } | 67 | .size = 8 * 1024 * 1024} |
68 | }; | 68 | }; |
69 | |||
69 | #define NUM_PARTITIONS 1 | 70 | #define NUM_PARTITIONS 1 |
70 | 71 | ||
71 | #endif | 72 | #endif |
72 | 73 | ||
73 | |||
74 | /* | 74 | /* |
75 | * hardware specific access to control-lines | 75 | * hardware specific access to control-lines |
76 | */ | 76 | */ |
77 | static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd) | 77 | static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd) |
78 | { | 78 | { |
79 | switch(cmd) { | 79 | switch (cmd) { |
80 | 80 | ||
81 | case NAND_CTL_SETCLE: | 81 | case NAND_CTL_SETCLE: |
82 | clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr); | 82 | clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr); |
@@ -108,6 +108,7 @@ static int ep7312_device_ready(struct mtd_info *mtd) | |||
108 | { | 108 | { |
109 | return 1; | 109 | return 1; |
110 | } | 110 | } |
111 | |||
111 | #ifdef CONFIG_MTD_PARTITIONS | 112 | #ifdef CONFIG_MTD_PARTITIONS |
112 | const char *part_probes[] = { "cmdlinepart", NULL }; | 113 | const char *part_probes[] = { "cmdlinepart", NULL }; |
113 | #endif | 114 | #endif |
@@ -115,18 +116,16 @@ const char *part_probes[] = { "cmdlinepart", NULL }; | |||
115 | /* | 116 | /* |
116 | * Main initialization routine | 117 | * Main initialization routine |
117 | */ | 118 | */ |
118 | static int __init ep7312_init (void) | 119 | static int __init ep7312_init(void) |
119 | { | 120 | { |
120 | struct nand_chip *this; | 121 | struct nand_chip *this; |
121 | const char *part_type = 0; | 122 | const char *part_type = 0; |
122 | int mtd_parts_nb = 0; | 123 | int mtd_parts_nb = 0; |
123 | struct mtd_partition *mtd_parts = 0; | 124 | struct mtd_partition *mtd_parts = 0; |
124 | void __iomem * ep7312_fio_base; | 125 | void __iomem *ep7312_fio_base; |
125 | 126 | ||
126 | /* Allocate memory for MTD device structure and private data */ | 127 | /* Allocate memory for MTD device structure and private data */ |
127 | ep7312_mtd = kmalloc(sizeof(struct mtd_info) + | 128 | ep7312_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
128 | sizeof(struct nand_chip), | ||
129 | GFP_KERNEL); | ||
130 | if (!ep7312_mtd) { | 129 | if (!ep7312_mtd) { |
131 | printk("Unable to allocate EDB7312 NAND MTD device structure.\n"); | 130 | printk("Unable to allocate EDB7312 NAND MTD device structure.\n"); |
132 | return -ENOMEM; | 131 | return -ENOMEM; |
@@ -134,18 +133,18 @@ static int __init ep7312_init (void) | |||
134 | 133 | ||
135 | /* map physical adress */ | 134 | /* map physical adress */ |
136 | ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K); | 135 | ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K); |
137 | if(!ep7312_fio_base) { | 136 | if (!ep7312_fio_base) { |
138 | printk("ioremap EDB7312 NAND flash failed\n"); | 137 | printk("ioremap EDB7312 NAND flash failed\n"); |
139 | kfree(ep7312_mtd); | 138 | kfree(ep7312_mtd); |
140 | return -EIO; | 139 | return -EIO; |
141 | } | 140 | } |
142 | 141 | ||
143 | /* Get pointer to private data */ | 142 | /* Get pointer to private data */ |
144 | this = (struct nand_chip *) (&ep7312_mtd[1]); | 143 | this = (struct nand_chip *)(&ep7312_mtd[1]); |
145 | 144 | ||
146 | /* Initialize structures */ | 145 | /* Initialize structures */ |
147 | memset((char *) ep7312_mtd, 0, sizeof(struct mtd_info)); | 146 | memset(ep7312_mtd, 0, sizeof(struct mtd_info)); |
148 | memset((char *) this, 0, sizeof(struct nand_chip)); | 147 | memset(this, 0, sizeof(struct nand_chip)); |
149 | 148 | ||
150 | /* Link the private data with the MTD structure */ | 149 | /* Link the private data with the MTD structure */ |
151 | ep7312_mtd->priv = this; | 150 | ep7312_mtd->priv = this; |
@@ -165,16 +164,14 @@ static int __init ep7312_init (void) | |||
165 | this->chip_delay = 15; | 164 | this->chip_delay = 15; |
166 | 165 | ||
167 | /* Scan to find existence of the device */ | 166 | /* Scan to find existence of the device */ |
168 | if (nand_scan (ep7312_mtd, 1)) { | 167 | if (nand_scan(ep7312_mtd, 1)) { |
169 | iounmap((void *)ep7312_fio_base); | 168 | iounmap((void *)ep7312_fio_base); |
170 | kfree (ep7312_mtd); | 169 | kfree(ep7312_mtd); |
171 | return -ENXIO; | 170 | return -ENXIO; |
172 | } | 171 | } |
173 | |||
174 | #ifdef CONFIG_MTD_PARTITIONS | 172 | #ifdef CONFIG_MTD_PARTITIONS |
175 | ep7312_mtd->name = "edb7312-nand"; | 173 | ep7312_mtd->name = "edb7312-nand"; |
176 | mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, | 174 | mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, &mtd_parts, 0); |
177 | &mtd_parts, 0); | ||
178 | if (mtd_parts_nb > 0) | 175 | if (mtd_parts_nb > 0) |
179 | part_type = "command line"; | 176 | part_type = "command line"; |
180 | else | 177 | else |
@@ -193,24 +190,26 @@ static int __init ep7312_init (void) | |||
193 | /* Return happy */ | 190 | /* Return happy */ |
194 | return 0; | 191 | return 0; |
195 | } | 192 | } |
193 | |||
196 | module_init(ep7312_init); | 194 | module_init(ep7312_init); |
197 | 195 | ||
198 | /* | 196 | /* |
199 | * Clean up routine | 197 | * Clean up routine |
200 | */ | 198 | */ |
201 | static void __exit ep7312_cleanup (void) | 199 | static void __exit ep7312_cleanup(void) |
202 | { | 200 | { |
203 | struct nand_chip *this = (struct nand_chip *) &ep7312_mtd[1]; | 201 | struct nand_chip *this = (struct nand_chip *)&ep7312_mtd[1]; |
204 | 202 | ||
205 | /* Release resources, unregister device */ | 203 | /* Release resources, unregister device */ |
206 | nand_release (ap7312_mtd); | 204 | nand_release(ap7312_mtd); |
207 | 205 | ||
208 | /* Free internal data buffer */ | 206 | /* Free internal data buffer */ |
209 | kfree (this->data_buf); | 207 | kfree(this->data_buf); |
210 | 208 | ||
211 | /* Free the MTD device structure */ | 209 | /* Free the MTD device structure */ |
212 | kfree (ep7312_mtd); | 210 | kfree(ep7312_mtd); |
213 | } | 211 | } |
212 | |||
214 | module_exit(ep7312_cleanup); | 213 | module_exit(ep7312_cleanup); |
215 | 214 | ||
216 | MODULE_LICENSE("GPL"); | 215 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c index f68f7a99a630..efa53a9adf23 100644 --- a/drivers/mtd/nand/h1910.c +++ b/drivers/mtd/nand/h1910.c | |||
@@ -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,23 +45,23 @@ static struct mtd_info *h1910_nand_mtd = NULL; | |||
45 | * Define static partitions for flash device | 45 | * Define static partitions for flash device |
46 | */ | 46 | */ |
47 | static struct mtd_partition partition_info[] = { | 47 | static 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 | */ | 59 | */ |
60 | static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) | 60 | static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) |
61 | { | 61 | { |
62 | struct nand_chip* this = (struct nand_chip *) (mtd->priv); | 62 | struct nand_chip *this = (struct nand_chip *)(mtd->priv); |
63 | 63 | ||
64 | switch(cmd) { | 64 | switch (cmd) { |
65 | 65 | ||
66 | case NAND_CTL_SETCLE: | 66 | case NAND_CTL_SETCLE: |
67 | this->IO_ADDR_R |= (1 << 2); | 67 | this->IO_ADDR_R |= (1 << 2); |
@@ -101,7 +101,7 @@ static int h1910_device_ready(struct mtd_info *mtd) | |||
101 | /* | 101 | /* |
102 | * Main initialization routine | 102 | * Main initialization routine |
103 | */ | 103 | */ |
104 | static int __init h1910_init (void) | 104 | static int __init h1910_init(void) |
105 | { | 105 | { |
106 | struct nand_chip *this; | 106 | struct nand_chip *this; |
107 | const char *part_type = 0; | 107 | const char *part_type = 0; |
@@ -119,21 +119,19 @@ static int __init h1910_init (void) | |||
119 | } | 119 | } |
120 | 120 | ||
121 | /* Allocate memory for MTD device structure and private data */ | 121 | /* Allocate memory for MTD device structure and private data */ |
122 | h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + | 122 | 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) { | 123 | if (!h1910_nand_mtd) { |
126 | printk("Unable to allocate h1910 NAND MTD device structure.\n"); | 124 | printk("Unable to allocate h1910 NAND MTD device structure.\n"); |
127 | iounmap ((void *) nandaddr); | 125 | iounmap((void *)nandaddr); |
128 | return -ENOMEM; | 126 | return -ENOMEM; |
129 | } | 127 | } |
130 | 128 | ||
131 | /* Get pointer to private data */ | 129 | /* Get pointer to private data */ |
132 | this = (struct nand_chip *) (&h1910_nand_mtd[1]); | 130 | this = (struct nand_chip *)(&h1910_nand_mtd[1]); |
133 | 131 | ||
134 | /* Initialize structures */ | 132 | /* Initialize structures */ |
135 | memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info)); | 133 | memset(h1910_nand_mtd, 0, sizeof(struct mtd_info)); |
136 | memset((char *) this, 0, sizeof(struct nand_chip)); | 134 | memset(this, 0, sizeof(struct nand_chip)); |
137 | 135 | ||
138 | /* Link the private data with the MTD structure */ | 136 | /* Link the private data with the MTD structure */ |
139 | h1910_nand_mtd->priv = this; | 137 | h1910_nand_mtd->priv = this; |
@@ -154,23 +152,20 @@ static int __init h1910_init (void) | |||
154 | this->options = NAND_NO_AUTOINCR; | 152 | this->options = NAND_NO_AUTOINCR; |
155 | 153 | ||
156 | /* Scan to find existence of the device */ | 154 | /* Scan to find existence of the device */ |
157 | if (nand_scan (h1910_nand_mtd, 1)) { | 155 | if (nand_scan(h1910_nand_mtd, 1)) { |
158 | printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); | 156 | printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); |
159 | kfree (h1910_nand_mtd); | 157 | kfree(h1910_nand_mtd); |
160 | iounmap ((void *) nandaddr); | 158 | iounmap((void *)nandaddr); |
161 | return -ENXIO; | 159 | return -ENXIO; |
162 | } | 160 | } |
163 | |||
164 | #ifdef CONFIG_MTD_CMDLINE_PARTS | 161 | #ifdef CONFIG_MTD_CMDLINE_PARTS |
165 | mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, | 162 | mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, "h1910-nand"); |
166 | "h1910-nand"); | ||
167 | if (mtd_parts_nb > 0) | 163 | if (mtd_parts_nb > 0) |
168 | part_type = "command line"; | 164 | part_type = "command line"; |
169 | else | 165 | else |
170 | mtd_parts_nb = 0; | 166 | mtd_parts_nb = 0; |
171 | #endif | 167 | #endif |
172 | if (mtd_parts_nb == 0) | 168 | if (mtd_parts_nb == 0) { |
173 | { | ||
174 | mtd_parts = partition_info; | 169 | mtd_parts = partition_info; |
175 | mtd_parts_nb = NUM_PARTITIONS; | 170 | mtd_parts_nb = NUM_PARTITIONS; |
176 | part_type = "static"; | 171 | part_type = "static"; |
@@ -183,24 +178,26 @@ static int __init h1910_init (void) | |||
183 | /* Return happy */ | 178 | /* Return happy */ |
184 | return 0; | 179 | return 0; |
185 | } | 180 | } |
181 | |||
186 | module_init(h1910_init); | 182 | module_init(h1910_init); |
187 | 183 | ||
188 | /* | 184 | /* |
189 | * Clean up routine | 185 | * Clean up routine |
190 | */ | 186 | */ |
191 | static void __exit h1910_cleanup (void) | 187 | static void __exit h1910_cleanup(void) |
192 | { | 188 | { |
193 | struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1]; | 189 | struct nand_chip *this = (struct nand_chip *)&h1910_nand_mtd[1]; |
194 | 190 | ||
195 | /* Release resources, unregister device */ | 191 | /* Release resources, unregister device */ |
196 | nand_release (h1910_nand_mtd); | 192 | nand_release(h1910_nand_mtd); |
197 | 193 | ||
198 | /* Release io resource */ | 194 | /* Release io resource */ |
199 | iounmap ((void *) this->IO_ADDR_W); | 195 | iounmap((void *)this->IO_ADDR_W); |
200 | 196 | ||
201 | /* Free the MTD device structure */ | 197 | /* Free the MTD device structure */ |
202 | kfree (h1910_nand_mtd); | 198 | kfree(h1910_nand_mtd); |
203 | } | 199 | } |
200 | |||
204 | module_exit(h1910_cleanup); | 201 | module_exit(h1910_cleanup); |
205 | 202 | ||
206 | MODULE_LICENSE("GPL"); | 203 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 95e96fa1fceb..fdaf32083ada 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -92,24 +92,24 @@ static struct nand_oobinfo nand_oob_8 = { | |||
92 | .useecc = MTD_NANDECC_AUTOPLACE, | 92 | .useecc = MTD_NANDECC_AUTOPLACE, |
93 | .eccbytes = 3, | 93 | .eccbytes = 3, |
94 | .eccpos = {0, 1, 2}, | 94 | .eccpos = {0, 1, 2}, |
95 | .oobfree = { {3, 2}, {6, 2} } | 95 | .oobfree = {{3, 2}, {6, 2}} |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static struct nand_oobinfo nand_oob_16 = { | 98 | static struct nand_oobinfo nand_oob_16 = { |
99 | .useecc = MTD_NANDECC_AUTOPLACE, | 99 | .useecc = MTD_NANDECC_AUTOPLACE, |
100 | .eccbytes = 6, | 100 | .eccbytes = 6, |
101 | .eccpos = {0, 1, 2, 3, 6, 7}, | 101 | .eccpos = {0, 1, 2, 3, 6, 7}, |
102 | .oobfree = { {8, 8} } | 102 | .oobfree = {{8, 8}} |
103 | }; | 103 | }; |
104 | 104 | ||
105 | static struct nand_oobinfo nand_oob_64 = { | 105 | static struct nand_oobinfo nand_oob_64 = { |
106 | .useecc = MTD_NANDECC_AUTOPLACE, | 106 | .useecc = MTD_NANDECC_AUTOPLACE, |
107 | .eccbytes = 24, | 107 | .eccbytes = 24, |
108 | .eccpos = { | 108 | .eccpos = { |
109 | 40, 41, 42, 43, 44, 45, 46, 47, | 109 | 40, 41, 42, 43, 44, 45, 46, 47, |
110 | 48, 49, 50, 51, 52, 53, 54, 55, | 110 | 48, 49, 50, 51, 52, 53, 54, 55, |
111 | 56, 57, 58, 59, 60, 61, 62, 63}, | 111 | 56, 57, 58, 59, 60, 61, 62, 63}, |
112 | .oobfree = { {2, 38} } | 112 | .oobfree = {{2, 38}} |
113 | }; | 113 | }; |
114 | 114 | ||
115 | /* This is used for padding purposes in nand_write_oob */ | 115 | /* This is used for padding purposes in nand_write_oob */ |
@@ -131,32 +131,32 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len); | |||
131 | static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); | 131 | static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); |
132 | static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); | 132 | static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); |
133 | 133 | ||
134 | static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf); | 134 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
135 | static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 135 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
136 | size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel); | 136 | size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); |
137 | static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf); | 137 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
138 | static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf); | 138 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
139 | static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | 139 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, |
140 | size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel); | 140 | size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); |
141 | static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf); | 141 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
142 | static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, | 142 | static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen); |
143 | unsigned long count, loff_t to, size_t * retlen); | 143 | static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, |
144 | static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, | 144 | unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf, |
145 | unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); | 145 | struct nand_oobinfo *oobsel); |
146 | static int nand_erase (struct mtd_info *mtd, struct erase_info *instr); | 146 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); |
147 | static void nand_sync (struct mtd_info *mtd); | 147 | static void nand_sync(struct mtd_info *mtd); |
148 | 148 | ||
149 | /* Some internal functions */ | 149 | /* Some internal functions */ |
150 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, | 150 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, u_char * oob_buf, |
151 | struct nand_oobinfo *oobsel, int mode); | 151 | struct nand_oobinfo *oobsel, int mode); |
152 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 152 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
153 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 153 | static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, |
154 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); | 154 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); |
155 | #else | 155 | #else |
156 | #define nand_verify_pages(...) (0) | 156 | #define nand_verify_pages(...) (0) |
157 | #endif | 157 | #endif |
158 | 158 | ||
159 | static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state); | 159 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | * nand_release_device - [GENERIC] release chip | 162 | * nand_release_device - [GENERIC] release chip |
@@ -164,7 +164,7 @@ static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int ne | |||
164 | * | 164 | * |
165 | * Deselect, release chip lock and wake up anyone waiting on the device | 165 | * Deselect, release chip lock and wake up anyone waiting on the device |
166 | */ | 166 | */ |
167 | static void nand_release_device (struct mtd_info *mtd) | 167 | static void nand_release_device(struct mtd_info *mtd) |
168 | { | 168 | { |
169 | struct nand_chip *this = mtd->priv; | 169 | struct nand_chip *this = mtd->priv; |
170 | 170 | ||
@@ -276,7 +276,7 @@ static void nand_write_word(struct mtd_info *mtd, u16 word) | |||
276 | static void nand_select_chip(struct mtd_info *mtd, int chip) | 276 | static void nand_select_chip(struct mtd_info *mtd, int chip) |
277 | { | 277 | { |
278 | struct nand_chip *this = mtd->priv; | 278 | struct nand_chip *this = mtd->priv; |
279 | switch(chip) { | 279 | switch (chip) { |
280 | case -1: | 280 | case -1: |
281 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); | 281 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); |
282 | break; | 282 | break; |
@@ -302,7 +302,7 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
302 | int i; | 302 | int i; |
303 | struct nand_chip *this = mtd->priv; | 303 | struct nand_chip *this = mtd->priv; |
304 | 304 | ||
305 | for (i=0; i<len; i++) | 305 | for (i = 0; i < len; i++) |
306 | writeb(buf[i], this->IO_ADDR_W); | 306 | writeb(buf[i], this->IO_ADDR_W); |
307 | } | 307 | } |
308 | 308 | ||
@@ -319,7 +319,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
319 | int i; | 319 | int i; |
320 | struct nand_chip *this = mtd->priv; | 320 | struct nand_chip *this = mtd->priv; |
321 | 321 | ||
322 | for (i=0; i<len; i++) | 322 | for (i = 0; i < len; i++) |
323 | buf[i] = readb(this->IO_ADDR_R); | 323 | buf[i] = readb(this->IO_ADDR_R); |
324 | } | 324 | } |
325 | 325 | ||
@@ -336,7 +336,7 @@ static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
336 | int i; | 336 | int i; |
337 | struct nand_chip *this = mtd->priv; | 337 | struct nand_chip *this = mtd->priv; |
338 | 338 | ||
339 | for (i=0; i<len; i++) | 339 | for (i = 0; i < len; i++) |
340 | if (buf[i] != readb(this->IO_ADDR_R)) | 340 | if (buf[i] != readb(this->IO_ADDR_R)) |
341 | return -EFAULT; | 341 | return -EFAULT; |
342 | 342 | ||
@@ -358,7 +358,7 @@ static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
358 | u16 *p = (u16 *) buf; | 358 | u16 *p = (u16 *) buf; |
359 | len >>= 1; | 359 | len >>= 1; |
360 | 360 | ||
361 | for (i=0; i<len; i++) | 361 | for (i = 0; i < len; i++) |
362 | writew(p[i], this->IO_ADDR_W); | 362 | writew(p[i], this->IO_ADDR_W); |
363 | 363 | ||
364 | } | 364 | } |
@@ -378,7 +378,7 @@ static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len) | |||
378 | u16 *p = (u16 *) buf; | 378 | u16 *p = (u16 *) buf; |
379 | len >>= 1; | 379 | len >>= 1; |
380 | 380 | ||
381 | for (i=0; i<len; i++) | 381 | for (i = 0; i < len; i++) |
382 | p[i] = readw(this->IO_ADDR_R); | 382 | p[i] = readw(this->IO_ADDR_R); |
383 | } | 383 | } |
384 | 384 | ||
@@ -397,7 +397,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
397 | u16 *p = (u16 *) buf; | 397 | u16 *p = (u16 *) buf; |
398 | len >>= 1; | 398 | len >>= 1; |
399 | 399 | ||
400 | for (i=0; i<len; i++) | 400 | for (i = 0; i < len; i++) |
401 | if (p[i] != readw(this->IO_ADDR_R)) | 401 | if (p[i] != readw(this->IO_ADDR_R)) |
402 | return -EFAULT; | 402 | return -EFAULT; |
403 | 403 | ||
@@ -423,22 +423,22 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
423 | chipnr = (int)(ofs >> this->chip_shift); | 423 | chipnr = (int)(ofs >> this->chip_shift); |
424 | 424 | ||
425 | /* Grab the lock and see if the device is available */ | 425 | /* Grab the lock and see if the device is available */ |
426 | nand_get_device (this, mtd, FL_READING); | 426 | nand_get_device(this, mtd, FL_READING); |
427 | 427 | ||
428 | /* Select the NAND device */ | 428 | /* Select the NAND device */ |
429 | this->select_chip(mtd, chipnr); | 429 | this->select_chip(mtd, chipnr); |
430 | } else | 430 | } else |
431 | page = (int) ofs; | 431 | page = (int)ofs; |
432 | 432 | ||
433 | if (this->options & NAND_BUSWIDTH_16) { | 433 | if (this->options & NAND_BUSWIDTH_16) { |
434 | this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); | 434 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); |
435 | bad = cpu_to_le16(this->read_word(mtd)); | 435 | bad = cpu_to_le16(this->read_word(mtd)); |
436 | if (this->badblockpos & 0x1) | 436 | if (this->badblockpos & 0x1) |
437 | bad >>= 8; | 437 | bad >>= 8; |
438 | if ((bad & 0xFF) != 0xff) | 438 | if ((bad & 0xFF) != 0xff) |
439 | res = 1; | 439 | res = 1; |
440 | } else { | 440 | } else { |
441 | this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); | 441 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); |
442 | if (this->read_byte(mtd) != 0xff) | 442 | if (this->read_byte(mtd) != 0xff) |
443 | res = 1; | 443 | res = 1; |
444 | } | 444 | } |
@@ -462,22 +462,22 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
462 | static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | 462 | static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) |
463 | { | 463 | { |
464 | struct nand_chip *this = mtd->priv; | 464 | struct nand_chip *this = mtd->priv; |
465 | u_char buf[2] = {0, 0}; | 465 | u_char buf[2] = { 0, 0 }; |
466 | size_t retlen; | 466 | size_t retlen; |
467 | int block; | 467 | int block; |
468 | 468 | ||
469 | /* Get block number */ | 469 | /* Get block number */ |
470 | block = ((int) ofs) >> this->bbt_erase_shift; | 470 | block = ((int)ofs) >> this->bbt_erase_shift; |
471 | if (this->bbt) | 471 | if (this->bbt) |
472 | this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); | 472 | this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); |
473 | 473 | ||
474 | /* Do we have a flash based bad block table ? */ | 474 | /* Do we have a flash based bad block table ? */ |
475 | if (this->options & NAND_USE_FLASH_BBT) | 475 | if (this->options & NAND_USE_FLASH_BBT) |
476 | return nand_update_bbt (mtd, ofs); | 476 | return nand_update_bbt(mtd, ofs); |
477 | 477 | ||
478 | /* We write two bytes, so we dont have to mess with 16 bit access */ | 478 | /* We write two bytes, so we dont have to mess with 16 bit access */ |
479 | ofs += mtd->oobsize + (this->badblockpos & ~0x01); | 479 | ofs += mtd->oobsize + (this->badblockpos & ~0x01); |
480 | return nand_write_oob (mtd, ofs , 2, &retlen, buf); | 480 | return nand_write_oob(mtd, ofs, 2, &retlen, buf); |
481 | } | 481 | } |
482 | 482 | ||
483 | /** | 483 | /** |
@@ -487,11 +487,11 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
487 | * | 487 | * |
488 | * The function expects, that the device is already selected | 488 | * The function expects, that the device is already selected |
489 | */ | 489 | */ |
490 | static int nand_check_wp (struct mtd_info *mtd) | 490 | static int nand_check_wp(struct mtd_info *mtd) |
491 | { | 491 | { |
492 | struct nand_chip *this = mtd->priv; | 492 | struct nand_chip *this = mtd->priv; |
493 | /* Check the WP bit */ | 493 | /* Check the WP bit */ |
494 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); | 494 | this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); |
495 | return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; | 495 | return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; |
496 | } | 496 | } |
497 | 497 | ||
@@ -505,7 +505,7 @@ static int nand_check_wp (struct mtd_info *mtd) | |||
505 | * Check, if the block is bad. Either by reading the bad block table or | 505 | * Check, if the block is bad. Either by reading the bad block table or |
506 | * calling of the scan function. | 506 | * calling of the scan function. |
507 | */ | 507 | */ |
508 | static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) | 508 | static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) |
509 | { | 509 | { |
510 | struct nand_chip *this = mtd->priv; | 510 | struct nand_chip *this = mtd->priv; |
511 | 511 | ||
@@ -513,7 +513,7 @@ static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, i | |||
513 | return this->block_bad(mtd, ofs, getchip); | 513 | return this->block_bad(mtd, ofs, getchip); |
514 | 514 | ||
515 | /* Return info from the table */ | 515 | /* Return info from the table */ |
516 | return nand_isbad_bbt (mtd, ofs, allowbbt); | 516 | return nand_isbad_bbt(mtd, ofs, allowbbt); |
517 | } | 517 | } |
518 | 518 | ||
519 | DEFINE_LED_TRIGGER(nand_led_trigger); | 519 | DEFINE_LED_TRIGGER(nand_led_trigger); |
@@ -525,7 +525,7 @@ DEFINE_LED_TRIGGER(nand_led_trigger); | |||
525 | static void nand_wait_ready(struct mtd_info *mtd) | 525 | static void nand_wait_ready(struct mtd_info *mtd) |
526 | { | 526 | { |
527 | struct nand_chip *this = mtd->priv; | 527 | struct nand_chip *this = mtd->priv; |
528 | unsigned long timeo = jiffies + 2; | 528 | unsigned long timeo = jiffies + 2; |
529 | 529 | ||
530 | led_trigger_event(nand_led_trigger, LED_FULL); | 530 | led_trigger_event(nand_led_trigger, LED_FULL); |
531 | /* wait until command is processed or timeout occures */ | 531 | /* wait until command is processed or timeout occures */ |
@@ -547,7 +547,7 @@ static void nand_wait_ready(struct mtd_info *mtd) | |||
547 | * Send command to NAND device. This function is used for small page | 547 | * Send command to NAND device. This function is used for small page |
548 | * devices (256/512 Bytes per page) | 548 | * devices (256/512 Bytes per page) |
549 | */ | 549 | */ |
550 | static void nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 550 | static void nand_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
551 | { | 551 | { |
552 | register struct nand_chip *this = mtd->priv; | 552 | register struct nand_chip *this = mtd->priv; |
553 | 553 | ||
@@ -588,11 +588,11 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
588 | this->write_byte(mtd, column); | 588 | this->write_byte(mtd, column); |
589 | } | 589 | } |
590 | if (page_addr != -1) { | 590 | if (page_addr != -1) { |
591 | this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); | 591 | this->write_byte(mtd, (unsigned char)(page_addr & 0xff)); |
592 | this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); | 592 | this->write_byte(mtd, (unsigned char)((page_addr >> 8) & 0xff)); |
593 | /* One more address cycle for devices > 32MiB */ | 593 | /* One more address cycle for devices > 32MiB */ |
594 | if (this->chipsize > (32 << 20)) | 594 | if (this->chipsize > (32 << 20)) |
595 | this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f)); | 595 | this->write_byte(mtd, (unsigned char)((page_addr >> 16) & 0x0f)); |
596 | } | 596 | } |
597 | /* Latch in address */ | 597 | /* Latch in address */ |
598 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | 598 | this->hwcontrol(mtd, NAND_CTL_CLRALE); |
@@ -601,7 +601,7 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
601 | /* | 601 | /* |
602 | * program and erase have their own busy handlers | 602 | * program and erase have their own busy handlers |
603 | * status and sequential in needs no delay | 603 | * status and sequential in needs no delay |
604 | */ | 604 | */ |
605 | switch (command) { | 605 | switch (command) { |
606 | 606 | ||
607 | case NAND_CMD_PAGEPROG: | 607 | case NAND_CMD_PAGEPROG: |
@@ -618,23 +618,23 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
618 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 618 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
619 | this->write_byte(mtd, NAND_CMD_STATUS); | 619 | this->write_byte(mtd, NAND_CMD_STATUS); |
620 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 620 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
621 | while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); | 621 | while (!(this->read_byte(mtd) & NAND_STATUS_READY)) ; |
622 | return; | 622 | return; |
623 | 623 | ||
624 | /* This applies to read commands */ | 624 | /* This applies to read commands */ |
625 | default: | 625 | default: |
626 | /* | 626 | /* |
627 | * If we don't have access to the busy pin, we apply the given | 627 | * If we don't have access to the busy pin, we apply the given |
628 | * command delay | 628 | * command delay |
629 | */ | 629 | */ |
630 | if (!this->dev_ready) { | 630 | if (!this->dev_ready) { |
631 | udelay (this->chip_delay); | 631 | udelay(this->chip_delay); |
632 | return; | 632 | return; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | /* Apply this short delay always to ensure that we do wait tWB in | 635 | /* Apply this short delay always to ensure that we do wait tWB in |
636 | * any case on any machine. */ | 636 | * any case on any machine. */ |
637 | ndelay (100); | 637 | ndelay(100); |
638 | 638 | ||
639 | nand_wait_ready(mtd); | 639 | nand_wait_ready(mtd); |
640 | } | 640 | } |
@@ -647,11 +647,11 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
647 | * @page_addr: the page address for this command, -1 if none | 647 | * @page_addr: the page address for this command, -1 if none |
648 | * | 648 | * |
649 | * Send command to NAND device. This is the version for the new large page devices | 649 | * Send command to NAND device. This is the version for the new large page devices |
650 | * We dont have the seperate regions as we have in the small page devices. | 650 | * We dont have the separate regions as we have in the small page devices. |
651 | * We must emulate NAND_CMD_READOOB to keep the code compatible. | 651 | * We must emulate NAND_CMD_READOOB to keep the code compatible. |
652 | * | 652 | * |
653 | */ | 653 | */ |
654 | static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 654 | static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
655 | { | 655 | { |
656 | register struct nand_chip *this = mtd->priv; | 656 | register struct nand_chip *this = mtd->priv; |
657 | 657 | ||
@@ -661,7 +661,6 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
661 | command = NAND_CMD_READ0; | 661 | command = NAND_CMD_READ0; |
662 | } | 662 | } |
663 | 663 | ||
664 | |||
665 | /* Begin command latch cycle */ | 664 | /* Begin command latch cycle */ |
666 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 665 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
667 | /* Write out the command to the device. */ | 666 | /* Write out the command to the device. */ |
@@ -681,11 +680,11 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
681 | this->write_byte(mtd, column >> 8); | 680 | this->write_byte(mtd, column >> 8); |
682 | } | 681 | } |
683 | if (page_addr != -1) { | 682 | if (page_addr != -1) { |
684 | this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); | 683 | this->write_byte(mtd, (unsigned char)(page_addr & 0xff)); |
685 | this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); | 684 | this->write_byte(mtd, (unsigned char)((page_addr >> 8) & 0xff)); |
686 | /* One more address cycle for devices > 128MiB */ | 685 | /* One more address cycle for devices > 128MiB */ |
687 | if (this->chipsize > (128 << 20)) | 686 | if (this->chipsize > (128 << 20)) |
688 | this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0xff)); | 687 | this->write_byte(mtd, (unsigned char)((page_addr >> 16) & 0xff)); |
689 | } | 688 | } |
690 | /* Latch in address */ | 689 | /* Latch in address */ |
691 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | 690 | this->hwcontrol(mtd, NAND_CTL_CLRALE); |
@@ -706,9 +705,9 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
706 | case NAND_CMD_DEPLETE1: | 705 | case NAND_CMD_DEPLETE1: |
707 | return; | 706 | return; |
708 | 707 | ||
709 | /* | 708 | /* |
710 | * read error status commands require only a short delay | 709 | * read error status commands require only a short delay |
711 | */ | 710 | */ |
712 | case NAND_CMD_STATUS_ERROR: | 711 | case NAND_CMD_STATUS_ERROR: |
713 | case NAND_CMD_STATUS_ERROR0: | 712 | case NAND_CMD_STATUS_ERROR0: |
714 | case NAND_CMD_STATUS_ERROR1: | 713 | case NAND_CMD_STATUS_ERROR1: |
@@ -724,7 +723,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
724 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 723 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
725 | this->write_byte(mtd, NAND_CMD_STATUS); | 724 | this->write_byte(mtd, NAND_CMD_STATUS); |
726 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 725 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
727 | while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); | 726 | while (!(this->read_byte(mtd) & NAND_STATUS_READY)) ; |
728 | return; | 727 | return; |
729 | 728 | ||
730 | case NAND_CMD_READ0: | 729 | case NAND_CMD_READ0: |
@@ -736,21 +735,21 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
736 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 735 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
737 | /* Fall through into ready check */ | 736 | /* Fall through into ready check */ |
738 | 737 | ||
739 | /* This applies to read commands */ | 738 | /* This applies to read commands */ |
740 | default: | 739 | default: |
741 | /* | 740 | /* |
742 | * If we don't have access to the busy pin, we apply the given | 741 | * If we don't have access to the busy pin, we apply the given |
743 | * command delay | 742 | * command delay |
744 | */ | 743 | */ |
745 | if (!this->dev_ready) { | 744 | if (!this->dev_ready) { |
746 | udelay (this->chip_delay); | 745 | udelay(this->chip_delay); |
747 | return; | 746 | return; |
748 | } | 747 | } |
749 | } | 748 | } |
750 | 749 | ||
751 | /* Apply this short delay always to ensure that we do wait tWB in | 750 | /* Apply this short delay always to ensure that we do wait tWB in |
752 | * any case on any machine. */ | 751 | * any case on any machine. */ |
753 | ndelay (100); | 752 | ndelay(100); |
754 | 753 | ||
755 | nand_wait_ready(mtd); | 754 | nand_wait_ready(mtd); |
756 | } | 755 | } |
@@ -763,16 +762,16 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
763 | * | 762 | * |
764 | * Get the device and lock it for exclusive access | 763 | * Get the device and lock it for exclusive access |
765 | */ | 764 | */ |
766 | static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state) | 765 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state) |
767 | { | 766 | { |
768 | struct nand_chip *active; | 767 | struct nand_chip *active; |
769 | spinlock_t *lock; | 768 | spinlock_t *lock; |
770 | wait_queue_head_t *wq; | 769 | wait_queue_head_t *wq; |
771 | DECLARE_WAITQUEUE (wait, current); | 770 | DECLARE_WAITQUEUE(wait, current); |
772 | 771 | ||
773 | lock = (this->controller) ? &this->controller->lock : &this->chip_lock; | 772 | lock = (this->controller) ? &this->controller->lock : &this->chip_lock; |
774 | wq = (this->controller) ? &this->controller->wq : &this->wq; | 773 | wq = (this->controller) ? &this->controller->wq : &this->wq; |
775 | retry: | 774 | retry: |
776 | active = this; | 775 | active = this; |
777 | spin_lock(lock); | 776 | spin_lock(lock); |
778 | 777 | ||
@@ -814,24 +813,24 @@ retry: | |||
814 | static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | 813 | static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) |
815 | { | 814 | { |
816 | 815 | ||
817 | unsigned long timeo = jiffies; | 816 | unsigned long timeo = jiffies; |
818 | int status; | 817 | int status; |
819 | 818 | ||
820 | if (state == FL_ERASING) | 819 | if (state == FL_ERASING) |
821 | timeo += (HZ * 400) / 1000; | 820 | timeo += (HZ * 400) / 1000; |
822 | else | 821 | else |
823 | timeo += (HZ * 20) / 1000; | 822 | timeo += (HZ * 20) / 1000; |
824 | 823 | ||
825 | led_trigger_event(nand_led_trigger, LED_FULL); | 824 | led_trigger_event(nand_led_trigger, LED_FULL); |
826 | 825 | ||
827 | /* Apply this short delay always to ensure that we do wait tWB in | 826 | /* Apply this short delay always to ensure that we do wait tWB in |
828 | * any case on any machine. */ | 827 | * any case on any machine. */ |
829 | ndelay (100); | 828 | ndelay(100); |
830 | 829 | ||
831 | if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) | 830 | if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) |
832 | this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1); | 831 | this->cmdfunc(mtd, NAND_CMD_STATUS_MULTI, -1, -1); |
833 | else | 832 | else |
834 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); | 833 | this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); |
835 | 834 | ||
836 | while (time_before(jiffies, timeo)) { | 835 | while (time_before(jiffies, timeo)) { |
837 | /* Check, if we were interrupted */ | 836 | /* Check, if we were interrupted */ |
@@ -849,7 +848,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
849 | } | 848 | } |
850 | led_trigger_event(nand_led_trigger, LED_OFF); | 849 | led_trigger_event(nand_led_trigger, LED_OFF); |
851 | 850 | ||
852 | status = (int) this->read_byte(mtd); | 851 | status = (int)this->read_byte(mtd); |
853 | return status; | 852 | return status; |
854 | } | 853 | } |
855 | 854 | ||
@@ -868,31 +867,31 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
868 | * | 867 | * |
869 | * Cached programming is not supported yet. | 868 | * Cached programming is not supported yet. |
870 | */ | 869 | */ |
871 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, | 870 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, |
872 | u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) | 871 | u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) |
873 | { | 872 | { |
874 | int i, status; | 873 | int i, status; |
875 | u_char ecc_code[32]; | 874 | u_char ecc_code[32]; |
876 | int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; | 875 | int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; |
877 | int *oob_config = oobsel->eccpos; | 876 | int *oob_config = oobsel->eccpos; |
878 | int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; | 877 | int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; |
879 | int eccbytes = 0; | 878 | int eccbytes = 0; |
880 | 879 | ||
881 | /* FIXME: Enable cached programming */ | 880 | /* FIXME: Enable cached programming */ |
882 | cached = 0; | 881 | cached = 0; |
883 | 882 | ||
884 | /* Send command to begin auto page programming */ | 883 | /* Send command to begin auto page programming */ |
885 | this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page); | 884 | this->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); |
886 | 885 | ||
887 | /* Write out complete page of data, take care of eccmode */ | 886 | /* Write out complete page of data, take care of eccmode */ |
888 | switch (eccmode) { | 887 | switch (eccmode) { |
889 | /* No ecc, write all */ | 888 | /* No ecc, write all */ |
890 | case NAND_ECC_NONE: | 889 | case NAND_ECC_NONE: |
891 | printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); | 890 | printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); |
892 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 891 | this->write_buf(mtd, this->data_poi, mtd->oobblock); |
893 | break; | 892 | break; |
894 | 893 | ||
895 | /* Software ecc 3/256, write all */ | 894 | /* Software ecc 3/256, write all */ |
896 | case NAND_ECC_SOFT: | 895 | case NAND_ECC_SOFT: |
897 | for (; eccsteps; eccsteps--) { | 896 | for (; eccsteps; eccsteps--) { |
898 | this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code); | 897 | this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code); |
@@ -928,11 +927,11 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
928 | this->write_buf(mtd, oob_buf, mtd->oobsize); | 927 | this->write_buf(mtd, oob_buf, mtd->oobsize); |
929 | 928 | ||
930 | /* Send command to actually program the data */ | 929 | /* Send command to actually program the data */ |
931 | this->cmdfunc (mtd, cached ? NAND_CMD_CACHEDPROG : NAND_CMD_PAGEPROG, -1, -1); | 930 | this->cmdfunc(mtd, cached ? NAND_CMD_CACHEDPROG : NAND_CMD_PAGEPROG, -1, -1); |
932 | 931 | ||
933 | if (!cached) { | 932 | if (!cached) { |
934 | /* call wait ready function */ | 933 | /* call wait ready function */ |
935 | status = this->waitfunc (mtd, this, FL_WRITING); | 934 | status = this->waitfunc(mtd, this, FL_WRITING); |
936 | 935 | ||
937 | /* See if operation failed and additional status checks are available */ | 936 | /* See if operation failed and additional status checks are available */ |
938 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { | 937 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { |
@@ -941,12 +940,12 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
941 | 940 | ||
942 | /* See if device thinks it succeeded */ | 941 | /* See if device thinks it succeeded */ |
943 | if (status & NAND_STATUS_FAIL) { | 942 | if (status & NAND_STATUS_FAIL) { |
944 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page); | 943 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page); |
945 | return -EIO; | 944 | return -EIO; |
946 | } | 945 | } |
947 | } else { | 946 | } else { |
948 | /* FIXME: Implement cached programming ! */ | 947 | /* FIXME: Implement cached programming ! */ |
949 | /* wait until cache is ready*/ | 948 | /* wait until cache is ready */ |
950 | // status = this->waitfunc (mtd, this, FL_CACHEDRPG); | 949 | // status = this->waitfunc (mtd, this, FL_CACHEDRPG); |
951 | } | 950 | } |
952 | return 0; | 951 | return 0; |
@@ -972,24 +971,24 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
972 | * the error later when the ECC page check fails, but we would rather catch | 971 | * the error later when the ECC page check fails, but we would rather catch |
973 | * it early in the page write stage. Better to write no data than invalid data. | 972 | * it early in the page write stage. Better to write no data than invalid data. |
974 | */ | 973 | */ |
975 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 974 | static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, |
976 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) | 975 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) |
977 | { | 976 | { |
978 | int i, j, datidx = 0, oobofs = 0, res = -EIO; | 977 | int i, j, datidx = 0, oobofs = 0, res = -EIO; |
979 | int eccsteps = this->eccsteps; | 978 | int eccsteps = this->eccsteps; |
980 | int hweccbytes; | 979 | int hweccbytes; |
981 | u_char oobdata[64]; | 980 | u_char oobdata[64]; |
982 | 981 | ||
983 | hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; | 982 | hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; |
984 | 983 | ||
985 | /* Send command to read back the first page */ | 984 | /* Send command to read back the first page */ |
986 | this->cmdfunc (mtd, NAND_CMD_READ0, 0, page); | 985 | this->cmdfunc(mtd, NAND_CMD_READ0, 0, page); |
987 | 986 | ||
988 | for(;;) { | 987 | for (;;) { |
989 | for (j = 0; j < eccsteps; j++) { | 988 | for (j = 0; j < eccsteps; j++) { |
990 | /* Loop through and verify the data */ | 989 | /* Loop through and verify the data */ |
991 | if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) { | 990 | if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) { |
992 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); | 991 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); |
993 | goto out; | 992 | goto out; |
994 | } | 993 | } |
995 | datidx += mtd->eccsize; | 994 | datidx += mtd->eccsize; |
@@ -997,7 +996,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
997 | if (!hweccbytes) | 996 | if (!hweccbytes) |
998 | continue; | 997 | continue; |
999 | if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) { | 998 | if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) { |
1000 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); | 999 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); |
1001 | goto out; | 1000 | goto out; |
1002 | } | 1001 | } |
1003 | oobofs += hweccbytes; | 1002 | oobofs += hweccbytes; |
@@ -1008,7 +1007,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1008 | */ | 1007 | */ |
1009 | if (oobmode) { | 1008 | if (oobmode) { |
1010 | if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) { | 1009 | if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) { |
1011 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); | 1010 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); |
1012 | goto out; | 1011 | goto out; |
1013 | } | 1012 | } |
1014 | } else { | 1013 | } else { |
@@ -1020,10 +1019,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1020 | 1019 | ||
1021 | for (i = 0; i < ecccnt; i++) { | 1020 | for (i = 0; i < ecccnt; i++) { |
1022 | int idx = oobsel->eccpos[i]; | 1021 | int idx = oobsel->eccpos[i]; |
1023 | if (oobdata[idx] != oob_buf[oobofs + idx] ) { | 1022 | if (oobdata[idx] != oob_buf[oobofs + idx]) { |
1024 | DEBUG (MTD_DEBUG_LEVEL0, | 1023 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Failed ECC write verify, page 0x%08x, %6i bytes were succesful\n", |
1025 | "%s: Failed ECC write " | 1024 | __FUNCTION__, page, i); |
1026 | "verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i); | ||
1027 | goto out; | 1025 | goto out; |
1028 | } | 1026 | } |
1029 | } | 1027 | } |
@@ -1039,9 +1037,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1039 | * is marked as NOAUTOINCR by the board driver. | 1037 | * is marked as NOAUTOINCR by the board driver. |
1040 | * Do this also before returning, so the chip is | 1038 | * Do this also before returning, so the chip is |
1041 | * ready for the next command. | 1039 | * ready for the next command. |
1042 | */ | 1040 | */ |
1043 | if (!this->dev_ready) | 1041 | if (!this->dev_ready) |
1044 | udelay (this->chip_delay); | 1042 | udelay(this->chip_delay); |
1045 | else | 1043 | else |
1046 | nand_wait_ready(mtd); | 1044 | nand_wait_ready(mtd); |
1047 | 1045 | ||
@@ -1049,17 +1047,16 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1049 | if (!numpages) | 1047 | if (!numpages) |
1050 | return 0; | 1048 | return 0; |
1051 | 1049 | ||
1052 | |||
1053 | /* Check, if the chip supports auto page increment */ | 1050 | /* Check, if the chip supports auto page increment */ |
1054 | if (!NAND_CANAUTOINCR(this)) | 1051 | if (!NAND_CANAUTOINCR(this)) |
1055 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); | 1052 | this->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); |
1056 | } | 1053 | } |
1057 | /* | 1054 | /* |
1058 | * Terminate the read command. We come here in case of an error | 1055 | * Terminate the read command. We come here in case of an error |
1059 | * So we must issue a reset command. | 1056 | * So we must issue a reset command. |
1060 | */ | 1057 | */ |
1061 | out: | 1058 | out: |
1062 | this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1); | 1059 | this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); |
1063 | return res; | 1060 | return res; |
1064 | } | 1061 | } |
1065 | #endif | 1062 | #endif |
@@ -1075,12 +1072,11 @@ out: | |||
1075 | * This function simply calls nand_do_read_ecc with oob buffer and oobsel = NULL | 1072 | * This function simply calls nand_do_read_ecc with oob buffer and oobsel = NULL |
1076 | * and flags = 0xff | 1073 | * and flags = 0xff |
1077 | */ | 1074 | */ |
1078 | static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf) | 1075 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) |
1079 | { | 1076 | { |
1080 | return nand_do_read_ecc (mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff); | 1077 | return nand_do_read_ecc(mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff); |
1081 | } | 1078 | } |
1082 | 1079 | ||
1083 | |||
1084 | /** | 1080 | /** |
1085 | * nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc | 1081 | * nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc |
1086 | * @mtd: MTD device structure | 1082 | * @mtd: MTD device structure |
@@ -1093,8 +1089,8 @@ static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * re | |||
1093 | * | 1089 | * |
1094 | * This function simply calls nand_do_read_ecc with flags = 0xff | 1090 | * This function simply calls nand_do_read_ecc with flags = 0xff |
1095 | */ | 1091 | */ |
1096 | static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 1092 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
1097 | size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel) | 1093 | size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel) |
1098 | { | 1094 | { |
1099 | /* use userspace supplied oobinfo, if zero */ | 1095 | /* use userspace supplied oobinfo, if zero */ |
1100 | if (oobsel == NULL) | 1096 | if (oobsel == NULL) |
@@ -1102,7 +1098,6 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1102 | return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff); | 1098 | return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff); |
1103 | } | 1099 | } |
1104 | 1100 | ||
1105 | |||
1106 | /** | 1101 | /** |
1107 | * nand_do_read_ecc - [MTD Interface] Read data with ECC | 1102 | * nand_do_read_ecc - [MTD Interface] Read data with ECC |
1108 | * @mtd: MTD device structure | 1103 | * @mtd: MTD device structure |
@@ -1119,9 +1114,8 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1119 | * | 1114 | * |
1120 | * NAND read with ECC | 1115 | * NAND read with ECC |
1121 | */ | 1116 | */ |
1122 | int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 1117 | int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
1123 | size_t * retlen, u_char * buf, u_char * oob_buf, | 1118 | size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel, int flags) |
1124 | struct nand_oobinfo *oobsel, int flags) | ||
1125 | { | 1119 | { |
1126 | 1120 | ||
1127 | int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1; | 1121 | int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1; |
@@ -1130,26 +1124,25 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1130 | u_char *data_poi, *oob_data = oob_buf; | 1124 | u_char *data_poi, *oob_data = oob_buf; |
1131 | u_char ecc_calc[32]; | 1125 | u_char ecc_calc[32]; |
1132 | u_char ecc_code[32]; | 1126 | u_char ecc_code[32]; |
1133 | int eccmode, eccsteps; | 1127 | int eccmode, eccsteps; |
1134 | int *oob_config, datidx; | 1128 | int *oob_config, datidx; |
1135 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1129 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1136 | int eccbytes; | 1130 | int eccbytes; |
1137 | int compareecc = 1; | 1131 | int compareecc = 1; |
1138 | int oobreadlen; | 1132 | int oobreadlen; |
1139 | 1133 | ||
1140 | 1134 | DEBUG(MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int)from, (int)len); | |
1141 | DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); | ||
1142 | 1135 | ||
1143 | /* Do not allow reads past end of device */ | 1136 | /* Do not allow reads past end of device */ |
1144 | if ((from + len) > mtd->size) { | 1137 | if ((from + len) > mtd->size) { |
1145 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n"); | 1138 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n"); |
1146 | *retlen = 0; | 1139 | *retlen = 0; |
1147 | return -EINVAL; | 1140 | return -EINVAL; |
1148 | } | 1141 | } |
1149 | 1142 | ||
1150 | /* Grab the lock and see if the device is available */ | 1143 | /* Grab the lock and see if the device is available */ |
1151 | if (flags & NAND_GET_DEVICE) | 1144 | if (flags & NAND_GET_DEVICE) |
1152 | nand_get_device (this, mtd, FL_READING); | 1145 | nand_get_device(this, mtd, FL_READING); |
1153 | 1146 | ||
1154 | /* Autoplace of oob data ? Use the default placement scheme */ | 1147 | /* Autoplace of oob data ? Use the default placement scheme */ |
1155 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) | 1148 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) |
@@ -1163,7 +1156,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1163 | this->select_chip(mtd, chipnr); | 1156 | this->select_chip(mtd, chipnr); |
1164 | 1157 | ||
1165 | /* First we calculate the starting page */ | 1158 | /* First we calculate the starting page */ |
1166 | realpage = (int) (from >> this->page_shift); | 1159 | realpage = (int)(from >> this->page_shift); |
1167 | page = realpage & this->pagemask; | 1160 | page = realpage & this->pagemask; |
1168 | 1161 | ||
1169 | /* Get raw starting column */ | 1162 | /* Get raw starting column */ |
@@ -1201,13 +1194,13 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1201 | if (realpage == this->pagebuf && !oob_buf) { | 1194 | if (realpage == this->pagebuf && !oob_buf) { |
1202 | /* aligned read ? */ | 1195 | /* aligned read ? */ |
1203 | if (aligned) | 1196 | if (aligned) |
1204 | memcpy (data_poi, this->data_buf, end); | 1197 | memcpy(data_poi, this->data_buf, end); |
1205 | goto readdata; | 1198 | goto readdata; |
1206 | } | 1199 | } |
1207 | 1200 | ||
1208 | /* Check, if we must send the read command */ | 1201 | /* Check, if we must send the read command */ |
1209 | if (sndcmd) { | 1202 | if (sndcmd) { |
1210 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); | 1203 | this->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); |
1211 | sndcmd = 0; | 1204 | sndcmd = 0; |
1212 | } | 1205 | } |
1213 | 1206 | ||
@@ -1219,24 +1212,26 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1219 | eccsteps = this->eccsteps; | 1212 | eccsteps = this->eccsteps; |
1220 | 1213 | ||
1221 | switch (eccmode) { | 1214 | switch (eccmode) { |
1222 | case NAND_ECC_NONE: { /* No ECC, Read in a page */ | 1215 | case NAND_ECC_NONE:{ |
1223 | static unsigned long lastwhinge = 0; | 1216 | /* No ECC, Read in a page */ |
1224 | if ((lastwhinge / HZ) != (jiffies / HZ)) { | 1217 | static unsigned long lastwhinge = 0; |
1225 | printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n"); | 1218 | if ((lastwhinge / HZ) != (jiffies / HZ)) { |
1226 | lastwhinge = jiffies; | 1219 | printk(KERN_WARNING |
1220 | "Reading data from NAND FLASH without ECC is not recommended\n"); | ||
1221 | lastwhinge = jiffies; | ||
1222 | } | ||
1223 | this->read_buf(mtd, data_poi, end); | ||
1224 | break; | ||
1227 | } | 1225 | } |
1228 | this->read_buf(mtd, data_poi, end); | ||
1229 | break; | ||
1230 | } | ||
1231 | 1226 | ||
1232 | case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ | 1227 | case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ |
1233 | this->read_buf(mtd, data_poi, end); | 1228 | this->read_buf(mtd, data_poi, end); |
1234 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) | 1229 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i += 3, datidx += ecc) |
1235 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); | 1230 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); |
1236 | break; | 1231 | break; |
1237 | 1232 | ||
1238 | default: | 1233 | default: |
1239 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) { | 1234 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i += eccbytes, datidx += ecc) { |
1240 | this->enable_hwecc(mtd, NAND_ECC_READ); | 1235 | this->enable_hwecc(mtd, NAND_ECC_READ); |
1241 | this->read_buf(mtd, &data_poi[datidx], ecc); | 1236 | this->read_buf(mtd, &data_poi[datidx], ecc); |
1242 | 1237 | ||
@@ -1252,8 +1247,8 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1252 | * does the error correction on the fly */ | 1247 | * does the error correction on the fly */ |
1253 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); | 1248 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); |
1254 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { | 1249 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { |
1255 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " | 1250 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: " |
1256 | "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); | 1251 | "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); |
1257 | ecc_failed++; | 1252 | ecc_failed++; |
1258 | } | 1253 | } |
1259 | } else { | 1254 | } else { |
@@ -1274,7 +1269,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1274 | for (j = 0; j < oobsel->eccbytes; j++) | 1269 | for (j = 0; j < oobsel->eccbytes; j++) |
1275 | ecc_code[j] = oob_data[oob_config[j]]; | 1270 | ecc_code[j] = oob_data[oob_config[j]]; |
1276 | 1271 | ||
1277 | /* correct data, if neccecary */ | 1272 | /* correct data, if necessary */ |
1278 | for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { | 1273 | for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { |
1279 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); | 1274 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); |
1280 | 1275 | ||
@@ -1291,16 +1286,16 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1291 | } | 1286 | } |
1292 | 1287 | ||
1293 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { | 1288 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { |
1294 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); | 1289 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); |
1295 | ecc_failed++; | 1290 | ecc_failed++; |
1296 | } | 1291 | } |
1297 | } | 1292 | } |
1298 | 1293 | ||
1299 | readoob: | 1294 | readoob: |
1300 | /* check, if we have a fs supplied oob-buffer */ | 1295 | /* check, if we have a fs supplied oob-buffer */ |
1301 | if (oob_buf) { | 1296 | if (oob_buf) { |
1302 | /* without autoplace. Legacy mode used by YAFFS1 */ | 1297 | /* without autoplace. Legacy mode used by YAFFS1 */ |
1303 | switch(oobsel->useecc) { | 1298 | switch (oobsel->useecc) { |
1304 | case MTD_NANDECC_AUTOPLACE: | 1299 | case MTD_NANDECC_AUTOPLACE: |
1305 | case MTD_NANDECC_AUTOPL_USR: | 1300 | case MTD_NANDECC_AUTOPL_USR: |
1306 | /* Walk through the autoplace chunks */ | 1301 | /* Walk through the autoplace chunks */ |
@@ -1313,7 +1308,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1313 | break; | 1308 | break; |
1314 | case MTD_NANDECC_PLACE: | 1309 | case MTD_NANDECC_PLACE: |
1315 | /* YAFFS1 legacy mode */ | 1310 | /* YAFFS1 legacy mode */ |
1316 | oob_data += this->eccsteps * sizeof (int); | 1311 | oob_data += this->eccsteps * sizeof(int); |
1317 | default: | 1312 | default: |
1318 | oob_data += mtd->oobsize; | 1313 | oob_data += mtd->oobsize; |
1319 | } | 1314 | } |
@@ -1331,9 +1326,9 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1331 | * Do this before the AUTOINCR check, so no problems | 1326 | * Do this before the AUTOINCR check, so no problems |
1332 | * arise if a chip which does auto increment | 1327 | * arise if a chip which does auto increment |
1333 | * is marked as NOAUTOINCR by the board driver. | 1328 | * is marked as NOAUTOINCR by the board driver. |
1334 | */ | 1329 | */ |
1335 | if (!this->dev_ready) | 1330 | if (!this->dev_ready) |
1336 | udelay (this->chip_delay); | 1331 | udelay(this->chip_delay); |
1337 | else | 1332 | else |
1338 | nand_wait_ready(mtd); | 1333 | nand_wait_ready(mtd); |
1339 | 1334 | ||
@@ -1354,7 +1349,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1354 | } | 1349 | } |
1355 | /* Check, if the chip supports auto page increment | 1350 | /* Check, if the chip supports auto page increment |
1356 | * or if we have hit a block boundary. | 1351 | * or if we have hit a block boundary. |
1357 | */ | 1352 | */ |
1358 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) | 1353 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) |
1359 | sndcmd = 1; | 1354 | sndcmd = 1; |
1360 | } | 1355 | } |
@@ -1382,13 +1377,13 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1382 | * | 1377 | * |
1383 | * NAND read out-of-band data from the spare area | 1378 | * NAND read out-of-band data from the spare area |
1384 | */ | 1379 | */ |
1385 | static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf) | 1380 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) |
1386 | { | 1381 | { |
1387 | int i, col, page, chipnr; | 1382 | int i, col, page, chipnr; |
1388 | struct nand_chip *this = mtd->priv; | 1383 | struct nand_chip *this = mtd->priv; |
1389 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1384 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1390 | 1385 | ||
1391 | DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); | 1386 | DEBUG(MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int)from, (int)len); |
1392 | 1387 | ||
1393 | /* Shift to get page */ | 1388 | /* Shift to get page */ |
1394 | page = (int)(from >> this->page_shift); | 1389 | page = (int)(from >> this->page_shift); |
@@ -1402,19 +1397,19 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1402 | 1397 | ||
1403 | /* Do not allow reads past end of device */ | 1398 | /* Do not allow reads past end of device */ |
1404 | if ((from + len) > mtd->size) { | 1399 | if ((from + len) > mtd->size) { |
1405 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n"); | 1400 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n"); |
1406 | *retlen = 0; | 1401 | *retlen = 0; |
1407 | return -EINVAL; | 1402 | return -EINVAL; |
1408 | } | 1403 | } |
1409 | 1404 | ||
1410 | /* Grab the lock and see if the device is available */ | 1405 | /* Grab the lock and see if the device is available */ |
1411 | nand_get_device (this, mtd , FL_READING); | 1406 | nand_get_device(this, mtd, FL_READING); |
1412 | 1407 | ||
1413 | /* Select the NAND device */ | 1408 | /* Select the NAND device */ |
1414 | this->select_chip(mtd, chipnr); | 1409 | this->select_chip(mtd, chipnr); |
1415 | 1410 | ||
1416 | /* Send the read command */ | 1411 | /* Send the read command */ |
1417 | this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask); | 1412 | this->cmdfunc(mtd, NAND_CMD_READOOB, col, page & this->pagemask); |
1418 | /* | 1413 | /* |
1419 | * Read the data, if we read more than one page | 1414 | * Read the data, if we read more than one page |
1420 | * oob data, let the device transfer the data ! | 1415 | * oob data, let the device transfer the data ! |
@@ -1444,16 +1439,16 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1444 | * is marked as NOAUTOINCR by the board driver. | 1439 | * is marked as NOAUTOINCR by the board driver. |
1445 | */ | 1440 | */ |
1446 | if (!this->dev_ready) | 1441 | if (!this->dev_ready) |
1447 | udelay (this->chip_delay); | 1442 | udelay(this->chip_delay); |
1448 | else | 1443 | else |
1449 | nand_wait_ready(mtd); | 1444 | nand_wait_ready(mtd); |
1450 | 1445 | ||
1451 | /* Check, if the chip supports auto page increment | 1446 | /* Check, if the chip supports auto page increment |
1452 | * or if we have hit a block boundary. | 1447 | * or if we have hit a block boundary. |
1453 | */ | 1448 | */ |
1454 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { | 1449 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { |
1455 | /* For subsequent page reads set offset to 0 */ | 1450 | /* For subsequent page reads set offset to 0 */ |
1456 | this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); | 1451 | this->cmdfunc(mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); |
1457 | } | 1452 | } |
1458 | } | 1453 | } |
1459 | } | 1454 | } |
@@ -1476,43 +1471,43 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1476 | * | 1471 | * |
1477 | * Read raw data including oob into buffer | 1472 | * Read raw data including oob into buffer |
1478 | */ | 1473 | */ |
1479 | int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen) | 1474 | int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen) |
1480 | { | 1475 | { |
1481 | struct nand_chip *this = mtd->priv; | 1476 | struct nand_chip *this = mtd->priv; |
1482 | int page = (int) (from >> this->page_shift); | 1477 | int page = (int)(from >> this->page_shift); |
1483 | int chip = (int) (from >> this->chip_shift); | 1478 | int chip = (int)(from >> this->chip_shift); |
1484 | int sndcmd = 1; | 1479 | int sndcmd = 1; |
1485 | int cnt = 0; | 1480 | int cnt = 0; |
1486 | int pagesize = mtd->oobblock + mtd->oobsize; | 1481 | int pagesize = mtd->oobblock + mtd->oobsize; |
1487 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1482 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1488 | 1483 | ||
1489 | /* Do not allow reads past end of device */ | 1484 | /* Do not allow reads past end of device */ |
1490 | if ((from + len) > mtd->size) { | 1485 | if ((from + len) > mtd->size) { |
1491 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n"); | 1486 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n"); |
1492 | return -EINVAL; | 1487 | return -EINVAL; |
1493 | } | 1488 | } |
1494 | 1489 | ||
1495 | /* Grab the lock and see if the device is available */ | 1490 | /* Grab the lock and see if the device is available */ |
1496 | nand_get_device (this, mtd , FL_READING); | 1491 | nand_get_device(this, mtd, FL_READING); |
1497 | 1492 | ||
1498 | this->select_chip (mtd, chip); | 1493 | this->select_chip(mtd, chip); |
1499 | 1494 | ||
1500 | /* Add requested oob length */ | 1495 | /* Add requested oob length */ |
1501 | len += ooblen; | 1496 | len += ooblen; |
1502 | 1497 | ||
1503 | while (len) { | 1498 | while (len) { |
1504 | if (sndcmd) | 1499 | if (sndcmd) |
1505 | this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask); | 1500 | this->cmdfunc(mtd, NAND_CMD_READ0, 0, page & this->pagemask); |
1506 | sndcmd = 0; | 1501 | sndcmd = 0; |
1507 | 1502 | ||
1508 | this->read_buf (mtd, &buf[cnt], pagesize); | 1503 | this->read_buf(mtd, &buf[cnt], pagesize); |
1509 | 1504 | ||
1510 | len -= pagesize; | 1505 | len -= pagesize; |
1511 | cnt += pagesize; | 1506 | cnt += pagesize; |
1512 | page++; | 1507 | page++; |
1513 | 1508 | ||
1514 | if (!this->dev_ready) | 1509 | if (!this->dev_ready) |
1515 | udelay (this->chip_delay); | 1510 | udelay(this->chip_delay); |
1516 | else | 1511 | else |
1517 | nand_wait_ready(mtd); | 1512 | nand_wait_ready(mtd); |
1518 | 1513 | ||
@@ -1526,7 +1521,6 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, | |||
1526 | return 0; | 1521 | return 0; |
1527 | } | 1522 | } |
1528 | 1523 | ||
1529 | |||
1530 | /** | 1524 | /** |
1531 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer | 1525 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer |
1532 | * @mtd: MTD device structure | 1526 | * @mtd: MTD device structure |
@@ -1550,8 +1544,8 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, | |||
1550 | * forces the 0xff fill before using the buffer again. | 1544 | * forces the 0xff fill before using the buffer again. |
1551 | * | 1545 | * |
1552 | */ | 1546 | */ |
1553 | static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct nand_oobinfo *oobsel, | 1547 | static u_char *nand_prepare_oobbuf(struct mtd_info *mtd, u_char *fsbuf, struct nand_oobinfo *oobsel, |
1554 | int autoplace, int numpages) | 1548 | int autoplace, int numpages) |
1555 | { | 1549 | { |
1556 | struct nand_chip *this = mtd->priv; | 1550 | struct nand_chip *this = mtd->priv; |
1557 | int i, len, ofs; | 1551 | int i, len, ofs; |
@@ -1562,8 +1556,7 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1562 | 1556 | ||
1563 | /* Check, if the buffer must be filled with ff again */ | 1557 | /* Check, if the buffer must be filled with ff again */ |
1564 | if (this->oobdirty) { | 1558 | if (this->oobdirty) { |
1565 | memset (this->oob_buf, 0xff, | 1559 | memset(this->oob_buf, 0xff, mtd->oobsize << (this->phys_erase_shift - this->page_shift)); |
1566 | mtd->oobsize << (this->phys_erase_shift - this->page_shift)); | ||
1567 | this->oobdirty = 0; | 1560 | this->oobdirty = 0; |
1568 | } | 1561 | } |
1569 | 1562 | ||
@@ -1578,7 +1571,7 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1578 | for (i = 0, len = 0; len < mtd->oobavail; i++) { | 1571 | for (i = 0, len = 0; len < mtd->oobavail; i++) { |
1579 | int to = ofs + oobsel->oobfree[i][0]; | 1572 | int to = ofs + oobsel->oobfree[i][0]; |
1580 | int num = oobsel->oobfree[i][1]; | 1573 | int num = oobsel->oobfree[i][1]; |
1581 | memcpy (&this->oob_buf[to], fsbuf, num); | 1574 | memcpy(&this->oob_buf[to], fsbuf, num); |
1582 | len += num; | 1575 | len += num; |
1583 | fsbuf += num; | 1576 | fsbuf += num; |
1584 | } | 1577 | } |
@@ -1600,9 +1593,9 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1600 | * This function simply calls nand_write_ecc with oob buffer and oobsel = NULL | 1593 | * This function simply calls nand_write_ecc with oob buffer and oobsel = NULL |
1601 | * | 1594 | * |
1602 | */ | 1595 | */ |
1603 | static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf) | 1596 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) |
1604 | { | 1597 | { |
1605 | return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL)); | 1598 | return (nand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL)); |
1606 | } | 1599 | } |
1607 | 1600 | ||
1608 | /** | 1601 | /** |
@@ -1617,34 +1610,35 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret | |||
1617 | * | 1610 | * |
1618 | * NAND write with ECC | 1611 | * NAND write with ECC |
1619 | */ | 1612 | */ |
1620 | static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | 1613 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, |
1621 | size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel) | 1614 | size_t *retlen, const u_char *buf, u_char *eccbuf, |
1615 | struct nand_oobinfo *oobsel) | ||
1622 | { | 1616 | { |
1623 | int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr; | 1617 | int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr; |
1624 | int autoplace = 0, numpages, totalpages; | 1618 | int autoplace = 0, numpages, totalpages; |
1625 | struct nand_chip *this = mtd->priv; | 1619 | struct nand_chip *this = mtd->priv; |
1626 | u_char *oobbuf, *bufstart; | 1620 | u_char *oobbuf, *bufstart; |
1627 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); | 1621 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); |
1628 | 1622 | ||
1629 | DEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len); | 1623 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len); |
1630 | 1624 | ||
1631 | /* Initialize retlen, in case of early exit */ | 1625 | /* Initialize retlen, in case of early exit */ |
1632 | *retlen = 0; | 1626 | *retlen = 0; |
1633 | 1627 | ||
1634 | /* Do not allow write past end of device */ | 1628 | /* Do not allow write past end of device */ |
1635 | if ((to + len) > mtd->size) { | 1629 | if ((to + len) > mtd->size) { |
1636 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n"); | 1630 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n"); |
1637 | return -EINVAL; | 1631 | return -EINVAL; |
1638 | } | 1632 | } |
1639 | 1633 | ||
1640 | /* reject writes, which are not page aligned */ | 1634 | /* reject writes, which are not page aligned */ |
1641 | if (NOTALIGNED (to) || NOTALIGNED(len)) { | 1635 | if (NOTALIGNED(to) || NOTALIGNED(len)) { |
1642 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1636 | printk(KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); |
1643 | return -EINVAL; | 1637 | return -EINVAL; |
1644 | } | 1638 | } |
1645 | 1639 | ||
1646 | /* Grab the lock and see if the device is available */ | 1640 | /* Grab the lock and see if the device is available */ |
1647 | nand_get_device (this, mtd, FL_WRITING); | 1641 | nand_get_device(this, mtd, FL_WRITING); |
1648 | 1642 | ||
1649 | /* Calculate chipnr */ | 1643 | /* Calculate chipnr */ |
1650 | chipnr = (int)(to >> this->chip_shift); | 1644 | chipnr = (int)(to >> this->chip_shift); |
@@ -1669,7 +1663,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1669 | 1663 | ||
1670 | /* Setup variables and oob buffer */ | 1664 | /* Setup variables and oob buffer */ |
1671 | totalpages = len >> this->page_shift; | 1665 | totalpages = len >> this->page_shift; |
1672 | page = (int) (to >> this->page_shift); | 1666 | page = (int)(to >> this->page_shift); |
1673 | /* Invalidate the page cache, if we write to the cached page */ | 1667 | /* Invalidate the page cache, if we write to the cached page */ |
1674 | if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) | 1668 | if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) |
1675 | this->pagebuf = -1; | 1669 | this->pagebuf = -1; |
@@ -1678,22 +1672,22 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1678 | page &= this->pagemask; | 1672 | page &= this->pagemask; |
1679 | startpage = page; | 1673 | startpage = page; |
1680 | /* Calc number of pages we can write in one go */ | 1674 | /* Calc number of pages we can write in one go */ |
1681 | numpages = min (ppblock - (startpage & (ppblock - 1)), totalpages); | 1675 | numpages = min(ppblock - (startpage & (ppblock - 1)), totalpages); |
1682 | oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, autoplace, numpages); | 1676 | oobbuf = nand_prepare_oobbuf(mtd, eccbuf, oobsel, autoplace, numpages); |
1683 | bufstart = (u_char *)buf; | 1677 | bufstart = (u_char *) buf; |
1684 | 1678 | ||
1685 | /* Loop until all data is written */ | 1679 | /* Loop until all data is written */ |
1686 | while (written < len) { | 1680 | while (written < len) { |
1687 | 1681 | ||
1688 | this->data_poi = (u_char*) &buf[written]; | 1682 | this->data_poi = (u_char *) &buf[written]; |
1689 | /* Write one page. If this is the last page to write | 1683 | /* Write one page. If this is the last page to write |
1690 | * or the last page in this block, then use the | 1684 | * or the last page in this block, then use the |
1691 | * real pageprogram command, else select cached programming | 1685 | * real pageprogram command, else select cached programming |
1692 | * if supported by the chip. | 1686 | * if supported by the chip. |
1693 | */ | 1687 | */ |
1694 | ret = nand_write_page (mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0)); | 1688 | ret = nand_write_page(mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0)); |
1695 | if (ret) { | 1689 | if (ret) { |
1696 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); | 1690 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); |
1697 | goto out; | 1691 | goto out; |
1698 | } | 1692 | } |
1699 | /* Next oob page */ | 1693 | /* Next oob page */ |
@@ -1709,15 +1703,14 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1709 | /* Have we hit a block boundary ? Then we have to verify and | 1703 | /* Have we hit a block boundary ? Then we have to verify and |
1710 | * if verify is ok, we have to setup the oob buffer for | 1704 | * if verify is ok, we have to setup the oob buffer for |
1711 | * the next pages. | 1705 | * the next pages. |
1712 | */ | 1706 | */ |
1713 | if (!(page & (ppblock - 1))){ | 1707 | if (!(page & (ppblock - 1))) { |
1714 | int ofs; | 1708 | int ofs; |
1715 | this->data_poi = bufstart; | 1709 | this->data_poi = bufstart; |
1716 | ret = nand_verify_pages (mtd, this, startpage, | 1710 | ret = nand_verify_pages(mtd, this, startpage, page - startpage, |
1717 | page - startpage, | 1711 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1718 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | ||
1719 | if (ret) { | 1712 | if (ret) { |
1720 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1713 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); |
1721 | goto out; | 1714 | goto out; |
1722 | } | 1715 | } |
1723 | *retlen = written; | 1716 | *retlen = written; |
@@ -1726,11 +1719,10 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1726 | if (eccbuf) | 1719 | if (eccbuf) |
1727 | eccbuf += (page - startpage) * ofs; | 1720 | eccbuf += (page - startpage) * ofs; |
1728 | totalpages -= page - startpage; | 1721 | totalpages -= page - startpage; |
1729 | numpages = min (totalpages, ppblock); | 1722 | numpages = min(totalpages, ppblock); |
1730 | page &= this->pagemask; | 1723 | page &= this->pagemask; |
1731 | startpage = page; | 1724 | startpage = page; |
1732 | oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, | 1725 | oobbuf = nand_prepare_oobbuf(mtd, eccbuf, oobsel, autoplace, numpages); |
1733 | autoplace, numpages); | ||
1734 | oob = 0; | 1726 | oob = 0; |
1735 | /* Check, if we cross a chip boundary */ | 1727 | /* Check, if we cross a chip boundary */ |
1736 | if (!page) { | 1728 | if (!page) { |
@@ -1741,23 +1733,21 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1741 | } | 1733 | } |
1742 | } | 1734 | } |
1743 | /* Verify the remaining pages */ | 1735 | /* Verify the remaining pages */ |
1744 | cmp: | 1736 | cmp: |
1745 | this->data_poi = bufstart; | 1737 | this->data_poi = bufstart; |
1746 | ret = nand_verify_pages (mtd, this, startpage, totalpages, | 1738 | ret = nand_verify_pages(mtd, this, startpage, totalpages, oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1747 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | ||
1748 | if (!ret) | 1739 | if (!ret) |
1749 | *retlen = written; | 1740 | *retlen = written; |
1750 | else | 1741 | else |
1751 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1742 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); |
1752 | 1743 | ||
1753 | out: | 1744 | out: |
1754 | /* Deselect and wake up anyone waiting on the device */ | 1745 | /* Deselect and wake up anyone waiting on the device */ |
1755 | nand_release_device(mtd); | 1746 | nand_release_device(mtd); |
1756 | 1747 | ||
1757 | return ret; | 1748 | return ret; |
1758 | } | 1749 | } |
1759 | 1750 | ||
1760 | |||
1761 | /** | 1751 | /** |
1762 | * nand_write_oob - [MTD Interface] NAND write out-of-band | 1752 | * nand_write_oob - [MTD Interface] NAND write out-of-band |
1763 | * @mtd: MTD device structure | 1753 | * @mtd: MTD device structure |
@@ -1768,16 +1758,16 @@ out: | |||
1768 | * | 1758 | * |
1769 | * NAND write out-of-band | 1759 | * NAND write out-of-band |
1770 | */ | 1760 | */ |
1771 | static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf) | 1761 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) |
1772 | { | 1762 | { |
1773 | int column, page, status, ret = -EIO, chipnr; | 1763 | int column, page, status, ret = -EIO, chipnr; |
1774 | struct nand_chip *this = mtd->priv; | 1764 | struct nand_chip *this = mtd->priv; |
1775 | 1765 | ||
1776 | DEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len); | 1766 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len); |
1777 | 1767 | ||
1778 | /* Shift to get page */ | 1768 | /* Shift to get page */ |
1779 | page = (int) (to >> this->page_shift); | 1769 | page = (int)(to >> this->page_shift); |
1780 | chipnr = (int) (to >> this->chip_shift); | 1770 | chipnr = (int)(to >> this->chip_shift); |
1781 | 1771 | ||
1782 | /* Mask to get column */ | 1772 | /* Mask to get column */ |
1783 | column = to & (mtd->oobsize - 1); | 1773 | column = to & (mtd->oobsize - 1); |
@@ -1787,12 +1777,12 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1787 | 1777 | ||
1788 | /* Do not allow write past end of page */ | 1778 | /* Do not allow write past end of page */ |
1789 | if ((column + len) > mtd->oobsize) { | 1779 | if ((column + len) > mtd->oobsize) { |
1790 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n"); | 1780 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n"); |
1791 | return -EINVAL; | 1781 | return -EINVAL; |
1792 | } | 1782 | } |
1793 | 1783 | ||
1794 | /* Grab the lock and see if the device is available */ | 1784 | /* Grab the lock and see if the device is available */ |
1795 | nand_get_device (this, mtd, FL_WRITING); | 1785 | nand_get_device(this, mtd, FL_WRITING); |
1796 | 1786 | ||
1797 | /* Select the NAND device */ | 1787 | /* Select the NAND device */ |
1798 | this->select_chip(mtd, chipnr); | 1788 | this->select_chip(mtd, chipnr); |
@@ -1814,27 +1804,27 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1814 | 1804 | ||
1815 | if (NAND_MUST_PAD(this)) { | 1805 | if (NAND_MUST_PAD(this)) { |
1816 | /* Write out desired data */ | 1806 | /* Write out desired data */ |
1817 | this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); | 1807 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); |
1818 | /* prepad 0xff for partial programming */ | 1808 | /* prepad 0xff for partial programming */ |
1819 | this->write_buf(mtd, ffchars, column); | 1809 | this->write_buf(mtd, ffchars, column); |
1820 | /* write data */ | 1810 | /* write data */ |
1821 | this->write_buf(mtd, buf, len); | 1811 | this->write_buf(mtd, buf, len); |
1822 | /* postpad 0xff for partial programming */ | 1812 | /* postpad 0xff for partial programming */ |
1823 | this->write_buf(mtd, ffchars, mtd->oobsize - (len+column)); | 1813 | this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); |
1824 | } else { | 1814 | } else { |
1825 | /* Write out desired data */ | 1815 | /* Write out desired data */ |
1826 | this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); | 1816 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); |
1827 | /* write data */ | 1817 | /* write data */ |
1828 | this->write_buf(mtd, buf, len); | 1818 | this->write_buf(mtd, buf, len); |
1829 | } | 1819 | } |
1830 | /* Send command to program the OOB data */ | 1820 | /* Send command to program the OOB data */ |
1831 | this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1); | 1821 | this->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); |
1832 | 1822 | ||
1833 | status = this->waitfunc (mtd, this, FL_WRITING); | 1823 | status = this->waitfunc(mtd, this, FL_WRITING); |
1834 | 1824 | ||
1835 | /* See if device thinks it succeeded */ | 1825 | /* See if device thinks it succeeded */ |
1836 | if (status & NAND_STATUS_FAIL) { | 1826 | if (status & NAND_STATUS_FAIL) { |
1837 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page); | 1827 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page); |
1838 | ret = -EIO; | 1828 | ret = -EIO; |
1839 | goto out; | 1829 | goto out; |
1840 | } | 1830 | } |
@@ -1843,23 +1833,22 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1843 | 1833 | ||
1844 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 1834 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
1845 | /* Send command to read back the data */ | 1835 | /* Send command to read back the data */ |
1846 | this->cmdfunc (mtd, NAND_CMD_READOOB, column, page & this->pagemask); | 1836 | this->cmdfunc(mtd, NAND_CMD_READOOB, column, page & this->pagemask); |
1847 | 1837 | ||
1848 | if (this->verify_buf(mtd, buf, len)) { | 1838 | if (this->verify_buf(mtd, buf, len)) { |
1849 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page); | 1839 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page); |
1850 | ret = -EIO; | 1840 | ret = -EIO; |
1851 | goto out; | 1841 | goto out; |
1852 | } | 1842 | } |
1853 | #endif | 1843 | #endif |
1854 | ret = 0; | 1844 | ret = 0; |
1855 | out: | 1845 | out: |
1856 | /* Deselect and wake up anyone waiting on the device */ | 1846 | /* Deselect and wake up anyone waiting on the device */ |
1857 | nand_release_device(mtd); | 1847 | nand_release_device(mtd); |
1858 | 1848 | ||
1859 | return ret; | 1849 | return ret; |
1860 | } | 1850 | } |
1861 | 1851 | ||
1862 | |||
1863 | /** | 1852 | /** |
1864 | * nand_writev - [MTD Interface] compabilty function for nand_writev_ecc | 1853 | * nand_writev - [MTD Interface] compabilty function for nand_writev_ecc |
1865 | * @mtd: MTD device structure | 1854 | * @mtd: MTD device structure |
@@ -1870,10 +1859,10 @@ out: | |||
1870 | * | 1859 | * |
1871 | * NAND write with kvec. This just calls the ecc function | 1860 | * NAND write with kvec. This just calls the ecc function |
1872 | */ | 1861 | */ |
1873 | static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, | 1862 | static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, |
1874 | loff_t to, size_t * retlen) | 1863 | loff_t to, size_t *retlen) |
1875 | { | 1864 | { |
1876 | return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL)); | 1865 | return (nand_writev_ecc(mtd, vecs, count, to, retlen, NULL, NULL)); |
1877 | } | 1866 | } |
1878 | 1867 | ||
1879 | /** | 1868 | /** |
@@ -1888,13 +1877,13 @@ static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned | |||
1888 | * | 1877 | * |
1889 | * NAND write with iovec with ecc | 1878 | * NAND write with iovec with ecc |
1890 | */ | 1879 | */ |
1891 | static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, | 1880 | static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, |
1892 | loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) | 1881 | loff_t to, size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) |
1893 | { | 1882 | { |
1894 | int i, page, len, total_len, ret = -EIO, written = 0, chipnr; | 1883 | int i, page, len, total_len, ret = -EIO, written = 0, chipnr; |
1895 | int oob, numpages, autoplace = 0, startpage; | 1884 | int oob, numpages, autoplace = 0, startpage; |
1896 | struct nand_chip *this = mtd->priv; | 1885 | struct nand_chip *this = mtd->priv; |
1897 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); | 1886 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); |
1898 | u_char *oobbuf, *bufstart; | 1887 | u_char *oobbuf, *bufstart; |
1899 | 1888 | ||
1900 | /* Preset written len for early exit */ | 1889 | /* Preset written len for early exit */ |
@@ -1903,28 +1892,27 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1903 | /* Calculate total length of data */ | 1892 | /* Calculate total length of data */ |
1904 | total_len = 0; | 1893 | total_len = 0; |
1905 | for (i = 0; i < count; i++) | 1894 | for (i = 0; i < count; i++) |
1906 | total_len += (int) vecs[i].iov_len; | 1895 | total_len += (int)vecs[i].iov_len; |
1907 | 1896 | ||
1908 | DEBUG (MTD_DEBUG_LEVEL3, | 1897 | DEBUG(MTD_DEBUG_LEVEL3, "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int)to, (unsigned int)total_len, count); |
1909 | "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count); | ||
1910 | 1898 | ||
1911 | /* Do not allow write past end of page */ | 1899 | /* Do not allow write past end of page */ |
1912 | if ((to + total_len) > mtd->size) { | 1900 | if ((to + total_len) > mtd->size) { |
1913 | DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n"); | 1901 | DEBUG(MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n"); |
1914 | return -EINVAL; | 1902 | return -EINVAL; |
1915 | } | 1903 | } |
1916 | 1904 | ||
1917 | /* reject writes, which are not page aligned */ | 1905 | /* reject writes, which are not page aligned */ |
1918 | if (NOTALIGNED (to) || NOTALIGNED(total_len)) { | 1906 | if (NOTALIGNED(to) || NOTALIGNED(total_len)) { |
1919 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1907 | printk(KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); |
1920 | return -EINVAL; | 1908 | return -EINVAL; |
1921 | } | 1909 | } |
1922 | 1910 | ||
1923 | /* Grab the lock and see if the device is available */ | 1911 | /* Grab the lock and see if the device is available */ |
1924 | nand_get_device (this, mtd, FL_WRITING); | 1912 | nand_get_device(this, mtd, FL_WRITING); |
1925 | 1913 | ||
1926 | /* Get the current chip-nr */ | 1914 | /* Get the current chip-nr */ |
1927 | chipnr = (int) (to >> this->chip_shift); | 1915 | chipnr = (int)(to >> this->chip_shift); |
1928 | /* Select the NAND device */ | 1916 | /* Select the NAND device */ |
1929 | this->select_chip(mtd, chipnr); | 1917 | this->select_chip(mtd, chipnr); |
1930 | 1918 | ||
@@ -1945,7 +1933,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1945 | autoplace = 1; | 1933 | autoplace = 1; |
1946 | 1934 | ||
1947 | /* Setup start page */ | 1935 | /* Setup start page */ |
1948 | page = (int) (to >> this->page_shift); | 1936 | page = (int)(to >> this->page_shift); |
1949 | /* Invalidate the page cache, if we write to the cached page */ | 1937 | /* Invalidate the page cache, if we write to the cached page */ |
1950 | if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) | 1938 | if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) |
1951 | this->pagebuf = -1; | 1939 | this->pagebuf = -1; |
@@ -1963,9 +1951,9 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1963 | * out of this iov in one go */ | 1951 | * out of this iov in one go */ |
1964 | numpages = (vecs->iov_len - len) >> this->page_shift; | 1952 | numpages = (vecs->iov_len - len) >> this->page_shift; |
1965 | /* Do not cross block boundaries */ | 1953 | /* Do not cross block boundaries */ |
1966 | numpages = min (ppblock - (startpage & (ppblock - 1)), numpages); | 1954 | numpages = min(ppblock - (startpage & (ppblock - 1)), numpages); |
1967 | oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); | 1955 | oobbuf = nand_prepare_oobbuf(mtd, NULL, oobsel, autoplace, numpages); |
1968 | bufstart = (u_char *)vecs->iov_base; | 1956 | bufstart = (u_char *) vecs->iov_base; |
1969 | bufstart += len; | 1957 | bufstart += len; |
1970 | this->data_poi = bufstart; | 1958 | this->data_poi = bufstart; |
1971 | oob = 0; | 1959 | oob = 0; |
@@ -1974,8 +1962,8 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1974 | * then use the real pageprogram command, else select | 1962 | * then use the real pageprogram command, else select |
1975 | * cached programming if supported by the chip. | 1963 | * cached programming if supported by the chip. |
1976 | */ | 1964 | */ |
1977 | ret = nand_write_page (mtd, this, page & this->pagemask, | 1965 | ret = nand_write_page(mtd, this, page & this->pagemask, |
1978 | &oobbuf[oob], oobsel, i != numpages); | 1966 | &oobbuf[oob], oobsel, i != numpages); |
1979 | if (ret) | 1967 | if (ret) |
1980 | goto out; | 1968 | goto out; |
1981 | this->data_poi += mtd->oobblock; | 1969 | this->data_poi += mtd->oobblock; |
@@ -1984,7 +1972,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1984 | page++; | 1972 | page++; |
1985 | } | 1973 | } |
1986 | /* Check, if we have to switch to the next tuple */ | 1974 | /* Check, if we have to switch to the next tuple */ |
1987 | if (len >= (int) vecs->iov_len) { | 1975 | if (len >= (int)vecs->iov_len) { |
1988 | vecs++; | 1976 | vecs++; |
1989 | len = 0; | 1977 | len = 0; |
1990 | count--; | 1978 | count--; |
@@ -1998,7 +1986,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1998 | if (vecs->iov_base != NULL && vecs->iov_len) | 1986 | if (vecs->iov_base != NULL && vecs->iov_len) |
1999 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; | 1987 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; |
2000 | /* Check, if we have to switch to the next tuple */ | 1988 | /* Check, if we have to switch to the next tuple */ |
2001 | if (len >= (int) vecs->iov_len) { | 1989 | if (len >= (int)vecs->iov_len) { |
2002 | vecs++; | 1990 | vecs++; |
2003 | len = 0; | 1991 | len = 0; |
2004 | count--; | 1992 | count--; |
@@ -2008,16 +1996,15 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
2008 | this->data_poi = this->data_buf; | 1996 | this->data_poi = this->data_buf; |
2009 | bufstart = this->data_poi; | 1997 | bufstart = this->data_poi; |
2010 | numpages = 1; | 1998 | numpages = 1; |
2011 | oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); | 1999 | oobbuf = nand_prepare_oobbuf(mtd, NULL, oobsel, autoplace, numpages); |
2012 | ret = nand_write_page (mtd, this, page & this->pagemask, | 2000 | ret = nand_write_page(mtd, this, page & this->pagemask, oobbuf, oobsel, 0); |
2013 | oobbuf, oobsel, 0); | ||
2014 | if (ret) | 2001 | if (ret) |
2015 | goto out; | 2002 | goto out; |
2016 | page++; | 2003 | page++; |
2017 | } | 2004 | } |
2018 | 2005 | ||
2019 | this->data_poi = bufstart; | 2006 | this->data_poi = bufstart; |
2020 | ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); | 2007 | ret = nand_verify_pages(mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); |
2021 | if (ret) | 2008 | if (ret) |
2022 | goto out; | 2009 | goto out; |
2023 | 2010 | ||
@@ -2035,7 +2022,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
2035 | } | 2022 | } |
2036 | } | 2023 | } |
2037 | ret = 0; | 2024 | ret = 0; |
2038 | out: | 2025 | out: |
2039 | /* Deselect and wake up anyone waiting on the device */ | 2026 | /* Deselect and wake up anyone waiting on the device */ |
2040 | nand_release_device(mtd); | 2027 | nand_release_device(mtd); |
2041 | 2028 | ||
@@ -2050,12 +2037,12 @@ out: | |||
2050 | * | 2037 | * |
2051 | * Standard erase command for NAND chips | 2038 | * Standard erase command for NAND chips |
2052 | */ | 2039 | */ |
2053 | static void single_erase_cmd (struct mtd_info *mtd, int page) | 2040 | static void single_erase_cmd(struct mtd_info *mtd, int page) |
2054 | { | 2041 | { |
2055 | struct nand_chip *this = mtd->priv; | 2042 | struct nand_chip *this = mtd->priv; |
2056 | /* Send commands to erase a block */ | 2043 | /* Send commands to erase a block */ |
2057 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page); | 2044 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); |
2058 | this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1); | 2045 | this->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); |
2059 | } | 2046 | } |
2060 | 2047 | ||
2061 | /** | 2048 | /** |
@@ -2066,15 +2053,15 @@ static void single_erase_cmd (struct mtd_info *mtd, int page) | |||
2066 | * AND multi block erase command function | 2053 | * AND multi block erase command function |
2067 | * Erase 4 consecutive blocks | 2054 | * Erase 4 consecutive blocks |
2068 | */ | 2055 | */ |
2069 | static void multi_erase_cmd (struct mtd_info *mtd, int page) | 2056 | static void multi_erase_cmd(struct mtd_info *mtd, int page) |
2070 | { | 2057 | { |
2071 | struct nand_chip *this = mtd->priv; | 2058 | struct nand_chip *this = mtd->priv; |
2072 | /* Send commands to erase a block */ | 2059 | /* Send commands to erase a block */ |
2073 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++); | 2060 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); |
2074 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++); | 2061 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); |
2075 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++); | 2062 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); |
2076 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page); | 2063 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); |
2077 | this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1); | 2064 | this->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); |
2078 | } | 2065 | } |
2079 | 2066 | ||
2080 | /** | 2067 | /** |
@@ -2084,9 +2071,9 @@ static void multi_erase_cmd (struct mtd_info *mtd, int page) | |||
2084 | * | 2071 | * |
2085 | * Erase one ore more blocks | 2072 | * Erase one ore more blocks |
2086 | */ | 2073 | */ |
2087 | static int nand_erase (struct mtd_info *mtd, struct erase_info *instr) | 2074 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) |
2088 | { | 2075 | { |
2089 | return nand_erase_nand (mtd, instr, 0); | 2076 | return nand_erase_nand(mtd, instr, 0); |
2090 | } | 2077 | } |
2091 | 2078 | ||
2092 | #define BBT_PAGE_MASK 0xffffff3f | 2079 | #define BBT_PAGE_MASK 0xffffff3f |
@@ -2098,7 +2085,7 @@ static int nand_erase (struct mtd_info *mtd, struct erase_info *instr) | |||
2098 | * | 2085 | * |
2099 | * Erase one ore more blocks | 2086 | * Erase one ore more blocks |
2100 | */ | 2087 | */ |
2101 | int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt) | 2088 | int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, int allowbbt) |
2102 | { | 2089 | { |
2103 | int page, len, status, pages_per_block, ret, chipnr; | 2090 | int page, len, status, pages_per_block, ret, chipnr; |
2104 | struct nand_chip *this = mtd->priv; | 2091 | struct nand_chip *this = mtd->priv; |
@@ -2107,35 +2094,34 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2107 | /* It is used to see if the current page is in the same */ | 2094 | /* It is used to see if the current page is in the same */ |
2108 | /* 256 block group and the same bank as the bbt. */ | 2095 | /* 256 block group and the same bank as the bbt. */ |
2109 | 2096 | ||
2110 | DEBUG (MTD_DEBUG_LEVEL3, | 2097 | DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n", (unsigned int)instr->addr, (unsigned int)instr->len); |
2111 | "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len); | ||
2112 | 2098 | ||
2113 | /* Start address must align on block boundary */ | 2099 | /* Start address must align on block boundary */ |
2114 | if (instr->addr & ((1 << this->phys_erase_shift) - 1)) { | 2100 | if (instr->addr & ((1 << this->phys_erase_shift) - 1)) { |
2115 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n"); | 2101 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n"); |
2116 | return -EINVAL; | 2102 | return -EINVAL; |
2117 | } | 2103 | } |
2118 | 2104 | ||
2119 | /* Length must align on block boundary */ | 2105 | /* Length must align on block boundary */ |
2120 | if (instr->len & ((1 << this->phys_erase_shift) - 1)) { | 2106 | if (instr->len & ((1 << this->phys_erase_shift) - 1)) { |
2121 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n"); | 2107 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n"); |
2122 | return -EINVAL; | 2108 | return -EINVAL; |
2123 | } | 2109 | } |
2124 | 2110 | ||
2125 | /* Do not allow erase past end of device */ | 2111 | /* Do not allow erase past end of device */ |
2126 | if ((instr->len + instr->addr) > mtd->size) { | 2112 | if ((instr->len + instr->addr) > mtd->size) { |
2127 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n"); | 2113 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n"); |
2128 | return -EINVAL; | 2114 | return -EINVAL; |
2129 | } | 2115 | } |
2130 | 2116 | ||
2131 | instr->fail_addr = 0xffffffff; | 2117 | instr->fail_addr = 0xffffffff; |
2132 | 2118 | ||
2133 | /* Grab the lock and see if the device is available */ | 2119 | /* Grab the lock and see if the device is available */ |
2134 | nand_get_device (this, mtd, FL_ERASING); | 2120 | nand_get_device(this, mtd, FL_ERASING); |
2135 | 2121 | ||
2136 | /* Shift to get first page */ | 2122 | /* Shift to get first page */ |
2137 | page = (int) (instr->addr >> this->page_shift); | 2123 | page = (int)(instr->addr >> this->page_shift); |
2138 | chipnr = (int) (instr->addr >> this->chip_shift); | 2124 | chipnr = (int)(instr->addr >> this->chip_shift); |
2139 | 2125 | ||
2140 | /* Calculate pages in each block */ | 2126 | /* Calculate pages in each block */ |
2141 | pages_per_block = 1 << (this->phys_erase_shift - this->page_shift); | 2127 | pages_per_block = 1 << (this->phys_erase_shift - this->page_shift); |
@@ -2146,7 +2132,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2146 | /* Check the WP bit */ | 2132 | /* Check the WP bit */ |
2147 | /* Check, if it is write protected */ | 2133 | /* Check, if it is write protected */ |
2148 | if (nand_check_wp(mtd)) { | 2134 | if (nand_check_wp(mtd)) { |
2149 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n"); | 2135 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n"); |
2150 | instr->state = MTD_ERASE_FAILED; | 2136 | instr->state = MTD_ERASE_FAILED; |
2151 | goto erase_exit; | 2137 | goto erase_exit; |
2152 | } | 2138 | } |
@@ -2166,7 +2152,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2166 | while (len) { | 2152 | while (len) { |
2167 | /* Check if we have a bad block, we do not erase bad blocks ! */ | 2153 | /* Check if we have a bad block, we do not erase bad blocks ! */ |
2168 | if (nand_block_checkbad(mtd, ((loff_t) page) << this->page_shift, 0, allowbbt)) { | 2154 | if (nand_block_checkbad(mtd, ((loff_t) page) << this->page_shift, 0, allowbbt)) { |
2169 | printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page); | 2155 | printk(KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page); |
2170 | instr->state = MTD_ERASE_FAILED; | 2156 | instr->state = MTD_ERASE_FAILED; |
2171 | goto erase_exit; | 2157 | goto erase_exit; |
2172 | } | 2158 | } |
@@ -2176,9 +2162,9 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2176 | if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) | 2162 | if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) |
2177 | this->pagebuf = -1; | 2163 | this->pagebuf = -1; |
2178 | 2164 | ||
2179 | this->erase_cmd (mtd, page & this->pagemask); | 2165 | this->erase_cmd(mtd, page & this->pagemask); |
2180 | 2166 | ||
2181 | status = this->waitfunc (mtd, this, FL_ERASING); | 2167 | status = this->waitfunc(mtd, this, FL_ERASING); |
2182 | 2168 | ||
2183 | /* See if operation failed and additional status checks are available */ | 2169 | /* See if operation failed and additional status checks are available */ |
2184 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { | 2170 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { |
@@ -2187,7 +2173,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2187 | 2173 | ||
2188 | /* See if block erase succeeded */ | 2174 | /* See if block erase succeeded */ |
2189 | if (status & NAND_STATUS_FAIL) { | 2175 | if (status & NAND_STATUS_FAIL) { |
2190 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page); | 2176 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page); |
2191 | instr->state = MTD_ERASE_FAILED; | 2177 | instr->state = MTD_ERASE_FAILED; |
2192 | instr->fail_addr = (page << this->page_shift); | 2178 | instr->fail_addr = (page << this->page_shift); |
2193 | goto erase_exit; | 2179 | goto erase_exit; |
@@ -2221,7 +2207,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2221 | } | 2207 | } |
2222 | instr->state = MTD_ERASE_DONE; | 2208 | instr->state = MTD_ERASE_DONE; |
2223 | 2209 | ||
2224 | erase_exit: | 2210 | erase_exit: |
2225 | 2211 | ||
2226 | ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO; | 2212 | ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO; |
2227 | /* Do call back function */ | 2213 | /* Do call back function */ |
@@ -2236,9 +2222,9 @@ erase_exit: | |||
2236 | for (chipnr = 0; chipnr < this->numchips; chipnr++) { | 2222 | for (chipnr = 0; chipnr < this->numchips; chipnr++) { |
2237 | if (rewrite_bbt[chipnr]) { | 2223 | if (rewrite_bbt[chipnr]) { |
2238 | /* update the BBT for chip */ | 2224 | /* update the BBT for chip */ |
2239 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", | 2225 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", |
2240 | chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); | 2226 | chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); |
2241 | nand_update_bbt (mtd, rewrite_bbt[chipnr]); | 2227 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); |
2242 | } | 2228 | } |
2243 | } | 2229 | } |
2244 | } | 2230 | } |
@@ -2253,31 +2239,30 @@ erase_exit: | |||
2253 | * | 2239 | * |
2254 | * Sync is actually a wait for chip ready function | 2240 | * Sync is actually a wait for chip ready function |
2255 | */ | 2241 | */ |
2256 | static void nand_sync (struct mtd_info *mtd) | 2242 | static void nand_sync(struct mtd_info *mtd) |
2257 | { | 2243 | { |
2258 | struct nand_chip *this = mtd->priv; | 2244 | struct nand_chip *this = mtd->priv; |
2259 | 2245 | ||
2260 | DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n"); | 2246 | DEBUG(MTD_DEBUG_LEVEL3, "nand_sync: called\n"); |
2261 | 2247 | ||
2262 | /* Grab the lock and see if the device is available */ | 2248 | /* Grab the lock and see if the device is available */ |
2263 | nand_get_device (this, mtd, FL_SYNCING); | 2249 | nand_get_device(this, mtd, FL_SYNCING); |
2264 | /* Release it and go back */ | 2250 | /* Release it and go back */ |
2265 | nand_release_device (mtd); | 2251 | nand_release_device(mtd); |
2266 | } | 2252 | } |
2267 | 2253 | ||
2268 | |||
2269 | /** | 2254 | /** |
2270 | * nand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad | 2255 | * nand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad |
2271 | * @mtd: MTD device structure | 2256 | * @mtd: MTD device structure |
2272 | * @ofs: offset relative to mtd start | 2257 | * @ofs: offset relative to mtd start |
2273 | */ | 2258 | */ |
2274 | static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) | 2259 | static int nand_block_isbad(struct mtd_info *mtd, loff_t ofs) |
2275 | { | 2260 | { |
2276 | /* Check for invalid offset */ | 2261 | /* Check for invalid offset */ |
2277 | if (ofs > mtd->size) | 2262 | if (ofs > mtd->size) |
2278 | return -EINVAL; | 2263 | return -EINVAL; |
2279 | 2264 | ||
2280 | return nand_block_checkbad (mtd, ofs, 1, 0); | 2265 | return nand_block_checkbad(mtd, ofs, 1, 0); |
2281 | } | 2266 | } |
2282 | 2267 | ||
2283 | /** | 2268 | /** |
@@ -2285,17 +2270,17 @@ static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) | |||
2285 | * @mtd: MTD device structure | 2270 | * @mtd: MTD device structure |
2286 | * @ofs: offset relative to mtd start | 2271 | * @ofs: offset relative to mtd start |
2287 | */ | 2272 | */ |
2288 | static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs) | 2273 | static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs) |
2289 | { | 2274 | { |
2290 | struct nand_chip *this = mtd->priv; | 2275 | struct nand_chip *this = mtd->priv; |
2291 | int ret; | 2276 | int ret; |
2292 | 2277 | ||
2293 | if ((ret = nand_block_isbad(mtd, ofs))) { | 2278 | if ((ret = nand_block_isbad(mtd, ofs))) { |
2294 | /* If it was bad already, return success and do nothing. */ | 2279 | /* If it was bad already, return success and do nothing. */ |
2295 | if (ret > 0) | 2280 | if (ret > 0) |
2296 | return 0; | 2281 | return 0; |
2297 | return ret; | 2282 | return ret; |
2298 | } | 2283 | } |
2299 | 2284 | ||
2300 | return this->block_markbad(mtd, ofs); | 2285 | return this->block_markbad(mtd, ofs); |
2301 | } | 2286 | } |
@@ -2308,7 +2293,7 @@ static int nand_suspend(struct mtd_info *mtd) | |||
2308 | { | 2293 | { |
2309 | struct nand_chip *this = mtd->priv; | 2294 | struct nand_chip *this = mtd->priv; |
2310 | 2295 | ||
2311 | return nand_get_device (this, mtd, FL_PM_SUSPENDED); | 2296 | return nand_get_device(this, mtd, FL_PM_SUSPENDED); |
2312 | } | 2297 | } |
2313 | 2298 | ||
2314 | /** | 2299 | /** |
@@ -2322,12 +2307,10 @@ static void nand_resume(struct mtd_info *mtd) | |||
2322 | if (this->state == FL_PM_SUSPENDED) | 2307 | if (this->state == FL_PM_SUSPENDED) |
2323 | nand_release_device(mtd); | 2308 | nand_release_device(mtd); |
2324 | else | 2309 | else |
2325 | printk(KERN_ERR "resume() called for the chip which is not " | 2310 | printk(KERN_ERR "resume() called for the chip which is not in suspended state\n"); |
2326 | "in suspended state\n"); | ||
2327 | 2311 | ||
2328 | } | 2312 | } |
2329 | 2313 | ||
2330 | |||
2331 | /** | 2314 | /** |
2332 | * nand_scan - [NAND Interface] Scan for the NAND device | 2315 | * nand_scan - [NAND Interface] Scan for the NAND device |
2333 | * @mtd: MTD device structure | 2316 | * @mtd: MTD device structure |
@@ -2340,12 +2323,12 @@ static void nand_resume(struct mtd_info *mtd) | |||
2340 | * they are not provided by the board driver | 2323 | * they are not provided by the board driver |
2341 | * | 2324 | * |
2342 | */ | 2325 | */ |
2343 | int nand_scan (struct mtd_info *mtd, int maxchips) | 2326 | int nand_scan(struct mtd_info *mtd, int maxchips) |
2344 | { | 2327 | { |
2345 | int i, nand_maf_id, nand_dev_id, busw, maf_id; | 2328 | int i, nand_maf_id, nand_dev_id, busw, maf_id; |
2346 | struct nand_chip *this = mtd->priv; | 2329 | struct nand_chip *this = mtd->priv; |
2347 | 2330 | ||
2348 | /* Get buswidth to select the correct functions*/ | 2331 | /* Get buswidth to select the correct functions */ |
2349 | busw = this->options & NAND_BUSWIDTH_16; | 2332 | busw = this->options & NAND_BUSWIDTH_16; |
2350 | 2333 | ||
2351 | /* check for proper chip_delay setup, set 20us if not */ | 2334 | /* check for proper chip_delay setup, set 20us if not */ |
@@ -2387,7 +2370,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2387 | this->select_chip(mtd, 0); | 2370 | this->select_chip(mtd, 0); |
2388 | 2371 | ||
2389 | /* Send the command for reading device ID */ | 2372 | /* Send the command for reading device ID */ |
2390 | this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1); | 2373 | this->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); |
2391 | 2374 | ||
2392 | /* Read manufacturer and device IDs */ | 2375 | /* Read manufacturer and device IDs */ |
2393 | nand_maf_id = this->read_byte(mtd); | 2376 | nand_maf_id = this->read_byte(mtd); |
@@ -2399,7 +2382,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2399 | if (nand_dev_id != nand_flash_ids[i].id) | 2382 | if (nand_dev_id != nand_flash_ids[i].id) |
2400 | continue; | 2383 | continue; |
2401 | 2384 | ||
2402 | if (!mtd->name) mtd->name = nand_flash_ids[i].name; | 2385 | if (!mtd->name) |
2386 | mtd->name = nand_flash_ids[i].name; | ||
2403 | this->chipsize = nand_flash_ids[i].chipsize << 20; | 2387 | this->chipsize = nand_flash_ids[i].chipsize << 20; |
2404 | 2388 | ||
2405 | /* New devices have all the information in additional id bytes */ | 2389 | /* New devices have all the information in additional id bytes */ |
@@ -2416,7 +2400,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2416 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); | 2400 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); |
2417 | extid >>= 2; | 2401 | extid >>= 2; |
2418 | /* Calc blocksize. Blocksize is multiples of 64KiB */ | 2402 | /* Calc blocksize. Blocksize is multiples of 64KiB */ |
2419 | mtd->erasesize = (64 * 1024) << (extid & 0x03); | 2403 | mtd->erasesize = (64 * 1024) << (extid & 0x03); |
2420 | extid >>= 2; | 2404 | extid >>= 2; |
2421 | /* Get buswidth information */ | 2405 | /* Get buswidth information */ |
2422 | busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; | 2406 | busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; |
@@ -2439,13 +2423,12 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2439 | /* Check, if buswidth is correct. Hardware drivers should set | 2423 | /* Check, if buswidth is correct. Hardware drivers should set |
2440 | * this correct ! */ | 2424 | * this correct ! */ |
2441 | if (busw != (this->options & NAND_BUSWIDTH_16)) { | 2425 | if (busw != (this->options & NAND_BUSWIDTH_16)) { |
2442 | printk (KERN_INFO "NAND device: Manufacturer ID:" | 2426 | printk(KERN_INFO "NAND device: Manufacturer ID:" |
2443 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, | 2427 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, |
2444 | nand_manuf_ids[maf_id].name , mtd->name); | 2428 | nand_manuf_ids[maf_id].name, mtd->name); |
2445 | printk (KERN_WARNING | 2429 | printk(KERN_WARNING |
2446 | "NAND bus width %d instead %d bit\n", | 2430 | "NAND bus width %d instead %d bit\n", |
2447 | (this->options & NAND_BUSWIDTH_16) ? 16 : 8, | 2431 | (this->options & NAND_BUSWIDTH_16) ? 16 : 8, busw ? 16 : 8); |
2448 | busw ? 16 : 8); | ||
2449 | this->select_chip(mtd, -1); | 2432 | this->select_chip(mtd, -1); |
2450 | return 1; | 2433 | return 1; |
2451 | } | 2434 | } |
@@ -2456,13 +2439,12 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2456 | this->chip_shift = ffs(this->chipsize) - 1; | 2439 | this->chip_shift = ffs(this->chipsize) - 1; |
2457 | 2440 | ||
2458 | /* Set the bad block position */ | 2441 | /* Set the bad block position */ |
2459 | this->badblockpos = mtd->oobblock > 512 ? | 2442 | this->badblockpos = mtd->oobblock > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; |
2460 | NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; | ||
2461 | 2443 | ||
2462 | /* Get chip options, preserve non chip based options */ | 2444 | /* Get chip options, preserve non chip based options */ |
2463 | this->options &= ~NAND_CHIPOPTIONS_MSK; | 2445 | this->options &= ~NAND_CHIPOPTIONS_MSK; |
2464 | this->options |= nand_flash_ids[i].options & NAND_CHIPOPTIONS_MSK; | 2446 | this->options |= nand_flash_ids[i].options & NAND_CHIPOPTIONS_MSK; |
2465 | /* Set this as a default. Board drivers can override it, if neccecary */ | 2447 | /* Set this as a default. Board drivers can override it, if necessary */ |
2466 | this->options |= NAND_NO_AUTOINCR; | 2448 | this->options |= NAND_NO_AUTOINCR; |
2467 | /* Check if this is a not a samsung device. Do not clear the options | 2449 | /* Check if this is a not a samsung device. Do not clear the options |
2468 | * for chips which are not having an extended id. | 2450 | * for chips which are not having an extended id. |
@@ -2480,23 +2462,23 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2480 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) | 2462 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) |
2481 | this->cmdfunc = nand_command_lp; | 2463 | this->cmdfunc = nand_command_lp; |
2482 | 2464 | ||
2483 | printk (KERN_INFO "NAND device: Manufacturer ID:" | 2465 | printk(KERN_INFO "NAND device: Manufacturer ID:" |
2484 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, | 2466 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, |
2485 | nand_manuf_ids[maf_id].name , nand_flash_ids[i].name); | 2467 | nand_manuf_ids[maf_id].name, nand_flash_ids[i].name); |
2486 | break; | 2468 | break; |
2487 | } | 2469 | } |
2488 | 2470 | ||
2489 | if (!nand_flash_ids[i].name) { | 2471 | if (!nand_flash_ids[i].name) { |
2490 | printk (KERN_WARNING "No NAND device found!!!\n"); | 2472 | printk(KERN_WARNING "No NAND device found!!!\n"); |
2491 | this->select_chip(mtd, -1); | 2473 | this->select_chip(mtd, -1); |
2492 | return 1; | 2474 | return 1; |
2493 | } | 2475 | } |
2494 | 2476 | ||
2495 | for (i=1; i < maxchips; i++) { | 2477 | for (i = 1; i < maxchips; i++) { |
2496 | this->select_chip(mtd, i); | 2478 | this->select_chip(mtd, i); |
2497 | 2479 | ||
2498 | /* Send the command for reading device ID */ | 2480 | /* Send the command for reading device ID */ |
2499 | this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1); | 2481 | this->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); |
2500 | 2482 | ||
2501 | /* Read manufacturer and device IDs */ | 2483 | /* Read manufacturer and device IDs */ |
2502 | if (nand_maf_id != this->read_byte(mtd) || | 2484 | if (nand_maf_id != this->read_byte(mtd) || |
@@ -2506,13 +2488,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2506 | if (i > 1) | 2488 | if (i > 1) |
2507 | printk(KERN_INFO "%d NAND chips detected\n", i); | 2489 | printk(KERN_INFO "%d NAND chips detected\n", i); |
2508 | 2490 | ||
2509 | /* Allocate buffers, if neccecary */ | 2491 | /* Allocate buffers, if necessary */ |
2510 | if (!this->oob_buf) { | 2492 | if (!this->oob_buf) { |
2511 | size_t len; | 2493 | size_t len; |
2512 | len = mtd->oobsize << (this->phys_erase_shift - this->page_shift); | 2494 | len = mtd->oobsize << (this->phys_erase_shift - this->page_shift); |
2513 | this->oob_buf = kmalloc (len, GFP_KERNEL); | 2495 | this->oob_buf = kmalloc(len, GFP_KERNEL); |
2514 | if (!this->oob_buf) { | 2496 | if (!this->oob_buf) { |
2515 | printk (KERN_ERR "nand_scan(): Cannot allocate oob_buf\n"); | 2497 | printk(KERN_ERR "nand_scan(): Cannot allocate oob_buf\n"); |
2516 | return -ENOMEM; | 2498 | return -ENOMEM; |
2517 | } | 2499 | } |
2518 | this->options |= NAND_OOBBUF_ALLOC; | 2500 | this->options |= NAND_OOBBUF_ALLOC; |
@@ -2521,11 +2503,11 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2521 | if (!this->data_buf) { | 2503 | if (!this->data_buf) { |
2522 | size_t len; | 2504 | size_t len; |
2523 | len = mtd->oobblock + mtd->oobsize; | 2505 | len = mtd->oobblock + mtd->oobsize; |
2524 | this->data_buf = kmalloc (len, GFP_KERNEL); | 2506 | this->data_buf = kmalloc(len, GFP_KERNEL); |
2525 | if (!this->data_buf) { | 2507 | if (!this->data_buf) { |
2526 | if (this->options & NAND_OOBBUF_ALLOC) | 2508 | if (this->options & NAND_OOBBUF_ALLOC) |
2527 | kfree (this->oob_buf); | 2509 | kfree(this->oob_buf); |
2528 | printk (KERN_ERR "nand_scan(): Cannot allocate data_buf\n"); | 2510 | printk(KERN_ERR "nand_scan(): Cannot allocate data_buf\n"); |
2529 | return -ENOMEM; | 2511 | return -ENOMEM; |
2530 | } | 2512 | } |
2531 | this->options |= NAND_DATABUF_ALLOC; | 2513 | this->options |= NAND_DATABUF_ALLOC; |
@@ -2555,8 +2537,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2555 | this->autooob = &nand_oob_64; | 2537 | this->autooob = &nand_oob_64; |
2556 | break; | 2538 | break; |
2557 | default: | 2539 | default: |
2558 | printk (KERN_WARNING "No oob scheme defined for oobsize %d\n", | 2540 | printk(KERN_WARNING "No oob scheme defined for oobsize %d\n", mtd->oobsize); |
2559 | mtd->oobsize); | ||
2560 | BUG(); | 2541 | BUG(); |
2561 | } | 2542 | } |
2562 | } | 2543 | } |
@@ -2571,7 +2552,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2571 | * check ECC mode, default to software | 2552 | * check ECC mode, default to software |
2572 | * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize | 2553 | * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize |
2573 | * fallback to software ECC | 2554 | * fallback to software ECC |
2574 | */ | 2555 | */ |
2575 | this->eccsize = 256; /* set default eccsize */ | 2556 | this->eccsize = 256; /* set default eccsize */ |
2576 | this->eccbytes = 3; | 2557 | this->eccbytes = 3; |
2577 | 2558 | ||
@@ -2591,19 +2572,19 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2591 | case NAND_ECC_HW6_512: | 2572 | case NAND_ECC_HW6_512: |
2592 | case NAND_ECC_HW8_512: | 2573 | case NAND_ECC_HW8_512: |
2593 | if (mtd->oobblock == 256) { | 2574 | if (mtd->oobblock == 256) { |
2594 | printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); | 2575 | printk(KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); |
2595 | this->eccmode = NAND_ECC_SOFT; | 2576 | this->eccmode = NAND_ECC_SOFT; |
2596 | this->calculate_ecc = nand_calculate_ecc; | 2577 | this->calculate_ecc = nand_calculate_ecc; |
2597 | this->correct_data = nand_correct_data; | 2578 | this->correct_data = nand_correct_data; |
2598 | } else | 2579 | } else |
2599 | this->eccsize = 512; /* set eccsize to 512 */ | 2580 | this->eccsize = 512; /* set eccsize to 512 */ |
2600 | break; | 2581 | break; |
2601 | 2582 | ||
2602 | case NAND_ECC_HW3_256: | 2583 | case NAND_ECC_HW3_256: |
2603 | break; | 2584 | break; |
2604 | 2585 | ||
2605 | case NAND_ECC_NONE: | 2586 | case NAND_ECC_NONE: |
2606 | printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); | 2587 | printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); |
2607 | this->eccmode = NAND_ECC_NONE; | 2588 | this->eccmode = NAND_ECC_NONE; |
2608 | break; | 2589 | break; |
2609 | 2590 | ||
@@ -2613,13 +2594,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2613 | break; | 2594 | break; |
2614 | 2595 | ||
2615 | default: | 2596 | default: |
2616 | printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); | 2597 | printk(KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); |
2617 | BUG(); | 2598 | BUG(); |
2618 | } | 2599 | } |
2619 | 2600 | ||
2620 | /* Check hardware ecc function availability and adjust number of ecc bytes per | 2601 | /* Check hardware ecc function availability and adjust number of ecc bytes per |
2621 | * calculation step | 2602 | * calculation step |
2622 | */ | 2603 | */ |
2623 | switch (this->eccmode) { | 2604 | switch (this->eccmode) { |
2624 | case NAND_ECC_HW12_2048: | 2605 | case NAND_ECC_HW12_2048: |
2625 | this->eccbytes += 4; | 2606 | this->eccbytes += 4; |
@@ -2631,7 +2612,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2631 | case NAND_ECC_HW3_256: | 2612 | case NAND_ECC_HW3_256: |
2632 | if (this->calculate_ecc && this->correct_data && this->enable_hwecc) | 2613 | if (this->calculate_ecc && this->correct_data && this->enable_hwecc) |
2633 | break; | 2614 | break; |
2634 | printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); | 2615 | printk(KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); |
2635 | BUG(); | 2616 | BUG(); |
2636 | } | 2617 | } |
2637 | 2618 | ||
@@ -2659,8 +2640,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2659 | 2640 | ||
2660 | /* Initialize state, waitqueue and spinlock */ | 2641 | /* Initialize state, waitqueue and spinlock */ |
2661 | this->state = FL_READY; | 2642 | this->state = FL_READY; |
2662 | init_waitqueue_head (&this->wq); | 2643 | init_waitqueue_head(&this->wq); |
2663 | spin_lock_init (&this->chip_lock); | 2644 | spin_lock_init(&this->chip_lock); |
2664 | 2645 | ||
2665 | /* De-select the device */ | 2646 | /* De-select the device */ |
2666 | this->select_chip(mtd, -1); | 2647 | this->select_chip(mtd, -1); |
@@ -2702,37 +2683,36 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2702 | return 0; | 2683 | return 0; |
2703 | 2684 | ||
2704 | /* Build bad block table */ | 2685 | /* Build bad block table */ |
2705 | return this->scan_bbt (mtd); | 2686 | return this->scan_bbt(mtd); |
2706 | } | 2687 | } |
2707 | 2688 | ||
2708 | /** | 2689 | /** |
2709 | * nand_release - [NAND Interface] Free resources held by the NAND device | 2690 | * nand_release - [NAND Interface] Free resources held by the NAND device |
2710 | * @mtd: MTD device structure | 2691 | * @mtd: MTD device structure |
2711 | */ | 2692 | */ |
2712 | void nand_release (struct mtd_info *mtd) | 2693 | void nand_release(struct mtd_info *mtd) |
2713 | { | 2694 | { |
2714 | struct nand_chip *this = mtd->priv; | 2695 | struct nand_chip *this = mtd->priv; |
2715 | 2696 | ||
2716 | #ifdef CONFIG_MTD_PARTITIONS | 2697 | #ifdef CONFIG_MTD_PARTITIONS |
2717 | /* Deregister partitions */ | 2698 | /* Deregister partitions */ |
2718 | del_mtd_partitions (mtd); | 2699 | del_mtd_partitions(mtd); |
2719 | #endif | 2700 | #endif |
2720 | /* Deregister the device */ | 2701 | /* Deregister the device */ |
2721 | del_mtd_device (mtd); | 2702 | del_mtd_device(mtd); |
2722 | 2703 | ||
2723 | /* Free bad block table memory */ | 2704 | /* Free bad block table memory */ |
2724 | kfree (this->bbt); | 2705 | kfree(this->bbt); |
2725 | /* Buffer allocated by nand_scan ? */ | 2706 | /* Buffer allocated by nand_scan ? */ |
2726 | if (this->options & NAND_OOBBUF_ALLOC) | 2707 | if (this->options & NAND_OOBBUF_ALLOC) |
2727 | kfree (this->oob_buf); | 2708 | kfree(this->oob_buf); |
2728 | /* Buffer allocated by nand_scan ? */ | 2709 | /* Buffer allocated by nand_scan ? */ |
2729 | if (this->options & NAND_DATABUF_ALLOC) | 2710 | if (this->options & NAND_DATABUF_ALLOC) |
2730 | kfree (this->data_buf); | 2711 | kfree(this->data_buf); |
2731 | } | 2712 | } |
2732 | 2713 | ||
2733 | EXPORT_SYMBOL_GPL (nand_scan); | 2714 | EXPORT_SYMBOL_GPL(nand_scan); |
2734 | EXPORT_SYMBOL_GPL (nand_release); | 2715 | EXPORT_SYMBOL_GPL(nand_release); |
2735 | |||
2736 | 2716 | ||
2737 | static int __init nand_base_init(void) | 2717 | static int __init nand_base_init(void) |
2738 | { | 2718 | { |
@@ -2748,6 +2728,6 @@ static void __exit nand_base_exit(void) | |||
2748 | module_init(nand_base_init); | 2728 | module_init(nand_base_init); |
2749 | module_exit(nand_base_exit); | 2729 | module_exit(nand_base_exit); |
2750 | 2730 | ||
2751 | MODULE_LICENSE ("GPL"); | 2731 | MODULE_LICENSE("GPL"); |
2752 | MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); | 2732 | MODULE_AUTHOR("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); |
2753 | MODULE_DESCRIPTION ("Generic NAND flash driver code"); | 2733 | MODULE_DESCRIPTION("Generic NAND flash driver code"); |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index ccc48a4a6ad0..9adc6d62332a 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -48,7 +48,7 @@ | |||
48 | * | 48 | * |
49 | * Following assumptions are made: | 49 | * Following assumptions are made: |
50 | * - bbts start at a page boundary, if autolocated on a block boundary | 50 | * - bbts start at a page boundary, if autolocated on a block boundary |
51 | * - the space neccecary for a bbt in FLASH does not exceed a block boundary | 51 | * - the space necessary for a bbt in FLASH does not exceed a block boundary |
52 | * | 52 | * |
53 | */ | 53 | */ |
54 | 54 | ||
@@ -75,7 +75,7 @@ | |||
75 | * pattern area contain 0xff | 75 | * pattern area contain 0xff |
76 | * | 76 | * |
77 | */ | 77 | */ |
78 | static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td) | 78 | static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td) |
79 | { | 79 | { |
80 | int i, end = 0; | 80 | int i, end = 0; |
81 | uint8_t *p = buf; | 81 | uint8_t *p = buf; |
@@ -116,7 +116,7 @@ static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_des | |||
116 | * no optional empty check | 116 | * no optional empty check |
117 | * | 117 | * |
118 | */ | 118 | */ |
119 | static int check_short_pattern (uint8_t *buf, struct nand_bbt_descr *td) | 119 | static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td) |
120 | { | 120 | { |
121 | int i; | 121 | int i; |
122 | uint8_t *p = buf; | 122 | uint8_t *p = buf; |
@@ -142,8 +142,8 @@ static int check_short_pattern (uint8_t *buf, struct nand_bbt_descr *td) | |||
142 | * Read the bad block table starting from page. | 142 | * Read the bad block table starting from page. |
143 | * | 143 | * |
144 | */ | 144 | */ |
145 | static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | 145 | static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, |
146 | int bits, int offs, int reserved_block_code) | 146 | int bits, int offs, int reserved_block_code) |
147 | { | 147 | { |
148 | int res, i, j, act = 0; | 148 | int res, i, j, act = 0; |
149 | struct nand_chip *this = mtd->priv; | 149 | struct nand_chip *this = mtd->priv; |
@@ -152,17 +152,17 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
152 | uint8_t msk = (uint8_t) ((1 << bits) - 1); | 152 | uint8_t msk = (uint8_t) ((1 << bits) - 1); |
153 | 153 | ||
154 | totlen = (num * bits) >> 3; | 154 | totlen = (num * bits) >> 3; |
155 | from = ((loff_t)page) << this->page_shift; | 155 | from = ((loff_t) page) << this->page_shift; |
156 | 156 | ||
157 | while (totlen) { | 157 | while (totlen) { |
158 | len = min (totlen, (size_t) (1 << this->bbt_erase_shift)); | 158 | len = min(totlen, (size_t) (1 << this->bbt_erase_shift)); |
159 | res = mtd->read_ecc (mtd, from, len, &retlen, buf, NULL, this->autooob); | 159 | res = mtd->read_ecc(mtd, from, len, &retlen, buf, NULL, this->autooob); |
160 | if (res < 0) { | 160 | if (res < 0) { |
161 | if (retlen != len) { | 161 | if (retlen != len) { |
162 | printk (KERN_INFO "nand_bbt: Error reading bad block table\n"); | 162 | printk(KERN_INFO "nand_bbt: Error reading bad block table\n"); |
163 | return res; | 163 | return res; |
164 | } | 164 | } |
165 | printk (KERN_WARNING "nand_bbt: ECC error while reading bad block table\n"); | 165 | printk(KERN_WARNING "nand_bbt: ECC error while reading bad block table\n"); |
166 | } | 166 | } |
167 | 167 | ||
168 | /* Analyse data */ | 168 | /* Analyse data */ |
@@ -172,17 +172,16 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
172 | uint8_t tmp = (dat >> j) & msk; | 172 | uint8_t tmp = (dat >> j) & msk; |
173 | if (tmp == msk) | 173 | if (tmp == msk) |
174 | continue; | 174 | continue; |
175 | if (reserved_block_code && | 175 | if (reserved_block_code && (tmp == reserved_block_code)) { |
176 | (tmp == reserved_block_code)) { | 176 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", |
177 | printk (KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", | 177 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
178 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | ||
179 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); | 178 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); |
180 | continue; | 179 | continue; |
181 | } | 180 | } |
182 | /* Leave it for now, if its matured we can move this | 181 | /* Leave it for now, if its matured we can move this |
183 | * message to MTD_DEBUG_LEVEL0 */ | 182 | * message to MTD_DEBUG_LEVEL0 */ |
184 | printk (KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", | 183 | printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", |
185 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 184 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
186 | /* Factory marked bad or worn out ? */ | 185 | /* Factory marked bad or worn out ? */ |
187 | if (tmp == 0) | 186 | if (tmp == 0) |
188 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); | 187 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); |
@@ -207,7 +206,7 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
207 | * Read the bad block table for all chips starting at a given page | 206 | * Read the bad block table for all chips starting at a given page |
208 | * We assume that the bbt bits are in consecutive order. | 207 | * We assume that the bbt bits are in consecutive order. |
209 | */ | 208 | */ |
210 | static int read_abs_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) | 209 | static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) |
211 | { | 210 | { |
212 | struct nand_chip *this = mtd->priv; | 211 | struct nand_chip *this = mtd->priv; |
213 | int res = 0, i; | 212 | int res = 0, i; |
@@ -242,23 +241,22 @@ static int read_abs_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des | |||
242 | * We assume that the bbt bits are in consecutive order. | 241 | * We assume that the bbt bits are in consecutive order. |
243 | * | 242 | * |
244 | */ | 243 | */ |
245 | static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, | 244 | static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md) |
246 | struct nand_bbt_descr *md) | ||
247 | { | 245 | { |
248 | struct nand_chip *this = mtd->priv; | 246 | struct nand_chip *this = mtd->priv; |
249 | 247 | ||
250 | /* Read the primary version, if available */ | 248 | /* Read the primary version, if available */ |
251 | if (td->options & NAND_BBT_VERSION) { | 249 | if (td->options & NAND_BBT_VERSION) { |
252 | nand_read_raw (mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); | 250 | nand_read_raw(mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); |
253 | td->version[0] = buf[mtd->oobblock + td->veroffs]; | 251 | td->version[0] = buf[mtd->oobblock + td->veroffs]; |
254 | printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); | 252 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); |
255 | } | 253 | } |
256 | 254 | ||
257 | /* Read the mirror version, if available */ | 255 | /* Read the mirror version, if available */ |
258 | if (md && (md->options & NAND_BBT_VERSION)) { | 256 | if (md && (md->options & NAND_BBT_VERSION)) { |
259 | nand_read_raw (mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); | 257 | nand_read_raw(mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); |
260 | md->version[0] = buf[mtd->oobblock + md->veroffs]; | 258 | md->version[0] = buf[mtd->oobblock + md->veroffs]; |
261 | printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); | 259 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); |
262 | } | 260 | } |
263 | 261 | ||
264 | return 1; | 262 | return 1; |
@@ -275,7 +273,7 @@ static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_de | |||
275 | * Create a bad block table by scanning the device | 273 | * Create a bad block table by scanning the device |
276 | * for the given good/bad block identify pattern | 274 | * for the given good/bad block identify pattern |
277 | */ | 275 | */ |
278 | static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) | 276 | static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) |
279 | { | 277 | { |
280 | struct nand_chip *this = mtd->priv; | 278 | struct nand_chip *this = mtd->priv; |
281 | int i, j, numblocks, len, scanlen; | 279 | int i, j, numblocks, len, scanlen; |
@@ -283,7 +281,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
283 | loff_t from; | 281 | loff_t from; |
284 | size_t readlen, ooblen; | 282 | size_t readlen, ooblen; |
285 | 283 | ||
286 | printk (KERN_INFO "Scanning device for bad blocks\n"); | 284 | printk(KERN_INFO "Scanning device for bad blocks\n"); |
287 | 285 | ||
288 | if (bd->options & NAND_BBT_SCANALLPAGES) | 286 | if (bd->options & NAND_BBT_SCANALLPAGES) |
289 | len = 1 << (this->bbt_erase_shift - this->page_shift); | 287 | len = 1 << (this->bbt_erase_shift - this->page_shift); |
@@ -300,7 +298,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
300 | readlen = bd->len; | 298 | readlen = bd->len; |
301 | } else { | 299 | } else { |
302 | /* Full page content should be read */ | 300 | /* Full page content should be read */ |
303 | scanlen = mtd->oobblock + mtd->oobsize; | 301 | scanlen = mtd->oobblock + mtd->oobsize; |
304 | readlen = len * mtd->oobblock; | 302 | readlen = len * mtd->oobblock; |
305 | ooblen = len * mtd->oobsize; | 303 | ooblen = len * mtd->oobsize; |
306 | } | 304 | } |
@@ -313,8 +311,8 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
313 | from = 0; | 311 | from = 0; |
314 | } else { | 312 | } else { |
315 | if (chip >= this->numchips) { | 313 | if (chip >= this->numchips) { |
316 | printk (KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n", | 314 | printk(KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n", |
317 | chip + 1, this->numchips); | 315 | chip + 1, this->numchips); |
318 | return -EINVAL; | 316 | return -EINVAL; |
319 | } | 317 | } |
320 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); | 318 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); |
@@ -327,7 +325,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
327 | int ret; | 325 | int ret; |
328 | 326 | ||
329 | if (bd->options & NAND_BBT_SCANEMPTY) | 327 | if (bd->options & NAND_BBT_SCANEMPTY) |
330 | if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen))) | 328 | if ((ret = nand_read_raw(mtd, buf, from, readlen, ooblen))) |
331 | return ret; | 329 | return ret; |
332 | 330 | ||
333 | for (j = 0; j < len; j++) { | 331 | for (j = 0; j < len; j++) { |
@@ -336,22 +334,21 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
336 | 334 | ||
337 | /* Read the full oob until read_oob is fixed to | 335 | /* Read the full oob until read_oob is fixed to |
338 | * handle single byte reads for 16 bit buswidth */ | 336 | * handle single byte reads for 16 bit buswidth */ |
339 | ret = mtd->read_oob(mtd, from + j * mtd->oobblock, | 337 | ret = mtd->read_oob(mtd, from + j * mtd->oobblock, mtd->oobsize, &retlen, buf); |
340 | mtd->oobsize, &retlen, buf); | ||
341 | if (ret) | 338 | if (ret) |
342 | return ret; | 339 | return ret; |
343 | 340 | ||
344 | if (check_short_pattern (buf, bd)) { | 341 | if (check_short_pattern(buf, bd)) { |
345 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 342 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
346 | printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 343 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", |
347 | i >> 1, (unsigned int) from); | 344 | i >> 1, (unsigned int)from); |
348 | break; | 345 | break; |
349 | } | 346 | } |
350 | } else { | 347 | } else { |
351 | if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { | 348 | if (check_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { |
352 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 349 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
353 | printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 350 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", |
354 | i >> 1, (unsigned int) from); | 351 | i >> 1, (unsigned int)from); |
355 | break; | 352 | break; |
356 | } | 353 | } |
357 | } | 354 | } |
@@ -374,12 +371,12 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
374 | * block. | 371 | * block. |
375 | * If the option NAND_BBT_PERCHIP is given, each chip is searched | 372 | * If the option NAND_BBT_PERCHIP is given, each chip is searched |
376 | * for a bbt, which contains the bad block information of this chip. | 373 | * for a bbt, which contains the bad block information of this chip. |
377 | * This is neccecary to provide support for certain DOC devices. | 374 | * This is necessary to provide support for certain DOC devices. |
378 | * | 375 | * |
379 | * The bbt ident pattern resides in the oob area of the first page | 376 | * The bbt ident pattern resides in the oob area of the first page |
380 | * in a block. | 377 | * in a block. |
381 | */ | 378 | */ |
382 | static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) | 379 | static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) |
383 | { | 380 | { |
384 | struct nand_chip *this = mtd->priv; | 381 | struct nand_chip *this = mtd->priv; |
385 | int i, chips; | 382 | int i, chips; |
@@ -389,7 +386,7 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
389 | 386 | ||
390 | /* Search direction top -> down ? */ | 387 | /* Search direction top -> down ? */ |
391 | if (td->options & NAND_BBT_LASTBLOCK) { | 388 | if (td->options & NAND_BBT_LASTBLOCK) { |
392 | startblock = (mtd->size >> this->bbt_erase_shift) -1; | 389 | startblock = (mtd->size >> this->bbt_erase_shift) - 1; |
393 | dir = -1; | 390 | dir = -1; |
394 | } else { | 391 | } else { |
395 | startblock = 0; | 392 | startblock = 0; |
@@ -417,7 +414,7 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
417 | for (block = 0; block < td->maxblocks; block++) { | 414 | for (block = 0; block < td->maxblocks; block++) { |
418 | int actblock = startblock + dir * block; | 415 | int actblock = startblock + dir * block; |
419 | /* Read first page */ | 416 | /* Read first page */ |
420 | nand_read_raw (mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); | 417 | nand_read_raw(mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); |
421 | if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { | 418 | if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { |
422 | td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); | 419 | td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); |
423 | if (td->options & NAND_BBT_VERSION) { | 420 | if (td->options & NAND_BBT_VERSION) { |
@@ -431,9 +428,10 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
431 | /* Check, if we found a bbt for each requested chip */ | 428 | /* Check, if we found a bbt for each requested chip */ |
432 | for (i = 0; i < chips; i++) { | 429 | for (i = 0; i < chips; i++) { |
433 | if (td->pages[i] == -1) | 430 | if (td->pages[i] == -1) |
434 | printk (KERN_WARNING "Bad block table not found for chip %d\n", i); | 431 | printk(KERN_WARNING "Bad block table not found for chip %d\n", i); |
435 | else | 432 | else |
436 | printk (KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], td->version[i]); | 433 | printk(KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], |
434 | td->version[i]); | ||
437 | } | 435 | } |
438 | return 0; | 436 | return 0; |
439 | } | 437 | } |
@@ -447,21 +445,19 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
447 | * | 445 | * |
448 | * Search and read the bad block table(s) | 446 | * Search and read the bad block table(s) |
449 | */ | 447 | */ |
450 | static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf, | 448 | static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md) |
451 | struct nand_bbt_descr *td, struct nand_bbt_descr *md) | ||
452 | { | 449 | { |
453 | /* Search the primary table */ | 450 | /* Search the primary table */ |
454 | search_bbt (mtd, buf, td); | 451 | search_bbt(mtd, buf, td); |
455 | 452 | ||
456 | /* Search the mirror table */ | 453 | /* Search the mirror table */ |
457 | if (md) | 454 | if (md) |
458 | search_bbt (mtd, buf, md); | 455 | search_bbt(mtd, buf, md); |
459 | 456 | ||
460 | /* Force result check */ | 457 | /* Force result check */ |
461 | return 1; | 458 | return 1; |
462 | } | 459 | } |
463 | 460 | ||
464 | |||
465 | /** | 461 | /** |
466 | * write_bbt - [GENERIC] (Re)write the bad block table | 462 | * write_bbt - [GENERIC] (Re)write the bad block table |
467 | * | 463 | * |
@@ -474,8 +470,8 @@ static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf, | |||
474 | * (Re)write the bad block table | 470 | * (Re)write the bad block table |
475 | * | 471 | * |
476 | */ | 472 | */ |
477 | static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | 473 | static int write_bbt(struct mtd_info *mtd, uint8_t *buf, |
478 | struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) | 474 | struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) |
479 | { | 475 | { |
480 | struct nand_chip *this = mtd->priv; | 476 | struct nand_chip *this = mtd->priv; |
481 | struct nand_oobinfo oobinfo; | 477 | struct nand_oobinfo oobinfo; |
@@ -492,7 +488,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | |||
492 | rcode = 0xff; | 488 | rcode = 0xff; |
493 | /* Write bad block table per chip rather than per device ? */ | 489 | /* Write bad block table per chip rather than per device ? */ |
494 | if (td->options & NAND_BBT_PERCHIP) { | 490 | if (td->options & NAND_BBT_PERCHIP) { |
495 | numblocks = (int) (this->chipsize >> this->bbt_erase_shift); | 491 | numblocks = (int)(this->chipsize >> this->bbt_erase_shift); |
496 | /* Full device write or specific chip ? */ | 492 | /* Full device write or specific chip ? */ |
497 | if (chipsel == -1) { | 493 | if (chipsel == -1) { |
498 | nrchips = this->numchips; | 494 | nrchips = this->numchips; |
@@ -501,7 +497,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | |||
501 | chip = chipsel; | 497 | chip = chipsel; |
502 | } | 498 | } |
503 | } else { | 499 | } else { |
504 | numblocks = (int) (mtd->size >> this->bbt_erase_shift); | 500 | numblocks = (int)(mtd->size >> this->bbt_erase_shift); |
505 | nrchips = 1; | 501 | nrchips = 1; |
506 | } | 502 | } |
507 | 503 | ||
@@ -540,9 +536,9 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | |||
540 | if (!md || md->pages[chip] != page) | 536 | if (!md || md->pages[chip] != page) |
541 | goto write; | 537 | goto write; |
542 | } | 538 | } |
543 | printk (KERN_ERR "No space left to write bad block table\n"); | 539 | printk(KERN_ERR "No space left to write bad block table\n"); |
544 | return -ENOSPC; | 540 | return -ENOSPC; |
545 | write: | 541 | write: |
546 | 542 | ||
547 | /* Set up shift count and masks for the flash table */ | 543 | /* Set up shift count and masks for the flash table */ |
548 | bits = td->options & NAND_BBT_NRBITS_MSK; | 544 | bits = td->options & NAND_BBT_NRBITS_MSK; |
@@ -558,7 +554,7 @@ write: | |||
558 | 554 | ||
559 | to = ((loff_t) page) << this->page_shift; | 555 | to = ((loff_t) page) << this->page_shift; |
560 | 556 | ||
561 | memcpy (&oobinfo, this->autooob, sizeof(oobinfo)); | 557 | memcpy(&oobinfo, this->autooob, sizeof(oobinfo)); |
562 | oobinfo.useecc = MTD_NANDECC_PLACEONLY; | 558 | oobinfo.useecc = MTD_NANDECC_PLACEONLY; |
563 | 559 | ||
564 | /* Must we save the block contents ? */ | 560 | /* Must we save the block contents ? */ |
@@ -566,22 +562,23 @@ write: | |||
566 | /* Make it block aligned */ | 562 | /* Make it block aligned */ |
567 | to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1)); | 563 | to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1)); |
568 | len = 1 << this->bbt_erase_shift; | 564 | len = 1 << this->bbt_erase_shift; |
569 | res = mtd->read_ecc (mtd, to, len, &retlen, buf, &buf[len], &oobinfo); | 565 | res = mtd->read_ecc(mtd, to, len, &retlen, buf, &buf[len], &oobinfo); |
570 | if (res < 0) { | 566 | if (res < 0) { |
571 | if (retlen != len) { | 567 | if (retlen != len) { |
572 | printk (KERN_INFO "nand_bbt: Error reading block for writing the bad block table\n"); | 568 | printk(KERN_INFO |
569 | "nand_bbt: Error reading block for writing the bad block table\n"); | ||
573 | return res; | 570 | return res; |
574 | } | 571 | } |
575 | printk (KERN_WARNING "nand_bbt: ECC error while reading block for writing bad block table\n"); | 572 | printk(KERN_WARNING "nand_bbt: ECC error while reading block for writing bad block table\n"); |
576 | } | 573 | } |
577 | /* Calc the byte offset in the buffer */ | 574 | /* Calc the byte offset in the buffer */ |
578 | pageoffs = page - (int)(to >> this->page_shift); | 575 | pageoffs = page - (int)(to >> this->page_shift); |
579 | offs = pageoffs << this->page_shift; | 576 | offs = pageoffs << this->page_shift; |
580 | /* Preset the bbt area with 0xff */ | 577 | /* Preset the bbt area with 0xff */ |
581 | memset (&buf[offs], 0xff, (size_t)(numblocks >> sft)); | 578 | memset(&buf[offs], 0xff, (size_t) (numblocks >> sft)); |
582 | /* Preset the bbt's oob area with 0xff */ | 579 | /* Preset the bbt's oob area with 0xff */ |
583 | memset (&buf[len + pageoffs * mtd->oobsize], 0xff, | 580 | memset(&buf[len + pageoffs * mtd->oobsize], 0xff, |
584 | ((len >> this->page_shift) - pageoffs) * mtd->oobsize); | 581 | ((len >> this->page_shift) - pageoffs) * mtd->oobsize); |
585 | if (td->options & NAND_BBT_VERSION) { | 582 | if (td->options & NAND_BBT_VERSION) { |
586 | buf[len + (pageoffs * mtd->oobsize) + td->veroffs] = td->version[chip]; | 583 | buf[len + (pageoffs * mtd->oobsize) + td->veroffs] = td->version[chip]; |
587 | } | 584 | } |
@@ -589,22 +586,22 @@ write: | |||
589 | /* Calc length */ | 586 | /* Calc length */ |
590 | len = (size_t) (numblocks >> sft); | 587 | len = (size_t) (numblocks >> sft); |
591 | /* Make it page aligned ! */ | 588 | /* Make it page aligned ! */ |
592 | len = (len + (mtd->oobblock-1)) & ~(mtd->oobblock-1); | 589 | len = (len + (mtd->oobblock - 1)) & ~(mtd->oobblock - 1); |
593 | /* Preset the buffer with 0xff */ | 590 | /* Preset the buffer with 0xff */ |
594 | memset (buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize); | 591 | memset(buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize); |
595 | offs = 0; | 592 | offs = 0; |
596 | /* Pattern is located in oob area of first page */ | 593 | /* Pattern is located in oob area of first page */ |
597 | memcpy (&buf[len + td->offs], td->pattern, td->len); | 594 | memcpy(&buf[len + td->offs], td->pattern, td->len); |
598 | if (td->options & NAND_BBT_VERSION) { | 595 | if (td->options & NAND_BBT_VERSION) { |
599 | buf[len + td->veroffs] = td->version[chip]; | 596 | buf[len + td->veroffs] = td->version[chip]; |
600 | } | 597 | } |
601 | } | 598 | } |
602 | 599 | ||
603 | /* walk through the memory table */ | 600 | /* walk through the memory table */ |
604 | for (i = 0; i < numblocks; ) { | 601 | for (i = 0; i < numblocks;) { |
605 | uint8_t dat; | 602 | uint8_t dat; |
606 | dat = this->bbt[bbtoffs + (i >> 2)]; | 603 | dat = this->bbt[bbtoffs + (i >> 2)]; |
607 | for (j = 0; j < 4; j++ , i++) { | 604 | for (j = 0; j < 4; j++, i++) { |
608 | int sftcnt = (i << (3 - sft)) & sftmsk; | 605 | int sftcnt = (i << (3 - sft)) & sftmsk; |
609 | /* Do not store the reserved bbt blocks ! */ | 606 | /* Do not store the reserved bbt blocks ! */ |
610 | buf[offs + (i >> sft)] &= ~(msk[dat & 0x03] << sftcnt); | 607 | buf[offs + (i >> sft)] &= ~(msk[dat & 0x03] << sftcnt); |
@@ -612,23 +609,23 @@ write: | |||
612 | } | 609 | } |
613 | } | 610 | } |
614 | 611 | ||
615 | memset (&einfo, 0, sizeof (einfo)); | 612 | memset(&einfo, 0, sizeof(einfo)); |
616 | einfo.mtd = mtd; | 613 | einfo.mtd = mtd; |
617 | einfo.addr = (unsigned long) to; | 614 | einfo.addr = (unsigned long)to; |
618 | einfo.len = 1 << this->bbt_erase_shift; | 615 | einfo.len = 1 << this->bbt_erase_shift; |
619 | res = nand_erase_nand (mtd, &einfo, 1); | 616 | res = nand_erase_nand(mtd, &einfo, 1); |
620 | if (res < 0) { | 617 | if (res < 0) { |
621 | printk (KERN_WARNING "nand_bbt: Error during block erase: %d\n", res); | 618 | printk(KERN_WARNING "nand_bbt: Error during block erase: %d\n", res); |
622 | return res; | 619 | return res; |
623 | } | 620 | } |
624 | 621 | ||
625 | res = mtd->write_ecc (mtd, to, len, &retlen, buf, &buf[len], &oobinfo); | 622 | res = mtd->write_ecc(mtd, to, len, &retlen, buf, &buf[len], &oobinfo); |
626 | if (res < 0) { | 623 | if (res < 0) { |
627 | printk (KERN_WARNING "nand_bbt: Error while writing bad block table %d\n", res); | 624 | printk(KERN_WARNING "nand_bbt: Error while writing bad block table %d\n", res); |
628 | return res; | 625 | return res; |
629 | } | 626 | } |
630 | printk (KERN_DEBUG "Bad block table written to 0x%08x, version 0x%02X\n", | 627 | printk(KERN_DEBUG "Bad block table written to 0x%08x, version 0x%02X\n", |
631 | (unsigned int) to, td->version[chip]); | 628 | (unsigned int)to, td->version[chip]); |
632 | 629 | ||
633 | /* Mark it as used */ | 630 | /* Mark it as used */ |
634 | td->pages[chip] = page; | 631 | td->pages[chip] = page; |
@@ -644,27 +641,27 @@ write: | |||
644 | * The function creates a memory based bbt by scanning the device | 641 | * The function creates a memory based bbt by scanning the device |
645 | * for manufacturer / software marked good / bad blocks | 642 | * for manufacturer / software marked good / bad blocks |
646 | */ | 643 | */ |
647 | static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | 644 | static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) |
648 | { | 645 | { |
649 | struct nand_chip *this = mtd->priv; | 646 | struct nand_chip *this = mtd->priv; |
650 | 647 | ||
651 | bd->options &= ~NAND_BBT_SCANEMPTY; | 648 | bd->options &= ~NAND_BBT_SCANEMPTY; |
652 | return create_bbt (mtd, this->data_buf, bd, -1); | 649 | return create_bbt(mtd, this->data_buf, bd, -1); |
653 | } | 650 | } |
654 | 651 | ||
655 | /** | 652 | /** |
656 | * check_create - [GENERIC] create and write bbt(s) if neccecary | 653 | * check_create - [GENERIC] create and write bbt(s) if necessary |
657 | * @mtd: MTD device structure | 654 | * @mtd: MTD device structure |
658 | * @buf: temporary buffer | 655 | * @buf: temporary buffer |
659 | * @bd: descriptor for the good/bad block search pattern | 656 | * @bd: descriptor for the good/bad block search pattern |
660 | * | 657 | * |
661 | * The function checks the results of the previous call to read_bbt | 658 | * The function checks the results of the previous call to read_bbt |
662 | * and creates / updates the bbt(s) if neccecary | 659 | * and creates / updates the bbt(s) if necessary |
663 | * Creation is neccecary if no bbt was found for the chip/device | 660 | * Creation is necessary if no bbt was found for the chip/device |
664 | * Update is neccecary if one of the tables is missing or the | 661 | * Update is necessary if one of the tables is missing or the |
665 | * version nr. of one table is less than the other | 662 | * version nr. of one table is less than the other |
666 | */ | 663 | */ |
667 | static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) | 664 | static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) |
668 | { | 665 | { |
669 | int i, chips, writeops, chipsel, res; | 666 | int i, chips, writeops, chipsel, res; |
670 | struct nand_chip *this = mtd->priv; | 667 | struct nand_chip *this = mtd->priv; |
@@ -732,35 +729,35 @@ static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des | |||
732 | rd = td; | 729 | rd = td; |
733 | goto writecheck; | 730 | goto writecheck; |
734 | } | 731 | } |
735 | create: | 732 | create: |
736 | /* Create the bad block table by scanning the device ? */ | 733 | /* Create the bad block table by scanning the device ? */ |
737 | if (!(td->options & NAND_BBT_CREATE)) | 734 | if (!(td->options & NAND_BBT_CREATE)) |
738 | continue; | 735 | continue; |
739 | 736 | ||
740 | /* Create the table in memory by scanning the chip(s) */ | 737 | /* Create the table in memory by scanning the chip(s) */ |
741 | create_bbt (mtd, buf, bd, chipsel); | 738 | create_bbt(mtd, buf, bd, chipsel); |
742 | 739 | ||
743 | td->version[i] = 1; | 740 | td->version[i] = 1; |
744 | if (md) | 741 | if (md) |
745 | md->version[i] = 1; | 742 | md->version[i] = 1; |
746 | writecheck: | 743 | writecheck: |
747 | /* read back first ? */ | 744 | /* read back first ? */ |
748 | if (rd) | 745 | if (rd) |
749 | read_abs_bbt (mtd, buf, rd, chipsel); | 746 | read_abs_bbt(mtd, buf, rd, chipsel); |
750 | /* If they weren't versioned, read both. */ | 747 | /* If they weren't versioned, read both. */ |
751 | if (rd2) | 748 | if (rd2) |
752 | read_abs_bbt (mtd, buf, rd2, chipsel); | 749 | read_abs_bbt(mtd, buf, rd2, chipsel); |
753 | 750 | ||
754 | /* Write the bad block table to the device ? */ | 751 | /* Write the bad block table to the device ? */ |
755 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { | 752 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { |
756 | res = write_bbt (mtd, buf, td, md, chipsel); | 753 | res = write_bbt(mtd, buf, td, md, chipsel); |
757 | if (res < 0) | 754 | if (res < 0) |
758 | return res; | 755 | return res; |
759 | } | 756 | } |
760 | 757 | ||
761 | /* Write the mirror bad block table to the device ? */ | 758 | /* Write the mirror bad block table to the device ? */ |
762 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { | 759 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { |
763 | res = write_bbt (mtd, buf, md, td, chipsel); | 760 | res = write_bbt(mtd, buf, md, td, chipsel); |
764 | if (res < 0) | 761 | if (res < 0) |
765 | return res; | 762 | return res; |
766 | } | 763 | } |
@@ -777,7 +774,7 @@ writecheck: | |||
777 | * accidental erasures / writes. The regions are identified by | 774 | * accidental erasures / writes. The regions are identified by |
778 | * the mark 0x02. | 775 | * the mark 0x02. |
779 | */ | 776 | */ |
780 | static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | 777 | static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) |
781 | { | 778 | { |
782 | struct nand_chip *this = mtd->priv; | 779 | struct nand_chip *this = mtd->priv; |
783 | int i, j, chips, block, nrblocks, update; | 780 | int i, j, chips, block, nrblocks, update; |
@@ -795,7 +792,8 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
795 | for (i = 0; i < chips; i++) { | 792 | for (i = 0; i < chips; i++) { |
796 | if ((td->options & NAND_BBT_ABSPAGE) || | 793 | if ((td->options & NAND_BBT_ABSPAGE) || |
797 | !(td->options & NAND_BBT_WRITE)) { | 794 | !(td->options & NAND_BBT_WRITE)) { |
798 | if (td->pages[i] == -1) continue; | 795 | if (td->pages[i] == -1) |
796 | continue; | ||
799 | block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); | 797 | block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); |
800 | block <<= 1; | 798 | block <<= 1; |
801 | oldval = this->bbt[(block >> 3)]; | 799 | oldval = this->bbt[(block >> 3)]; |
@@ -815,7 +813,8 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
815 | oldval = this->bbt[(block >> 3)]; | 813 | oldval = this->bbt[(block >> 3)]; |
816 | newval = oldval | (0x2 << (block & 0x06)); | 814 | newval = oldval | (0x2 << (block & 0x06)); |
817 | this->bbt[(block >> 3)] = newval; | 815 | this->bbt[(block >> 3)] = newval; |
818 | if (oldval != newval) update = 1; | 816 | if (oldval != newval) |
817 | update = 1; | ||
819 | block += 2; | 818 | block += 2; |
820 | } | 819 | } |
821 | /* If we want reserved blocks to be recorded to flash, and some | 820 | /* If we want reserved blocks to be recorded to flash, and some |
@@ -840,7 +839,7 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
840 | * by calling the nand_free_bbt function. | 839 | * by calling the nand_free_bbt function. |
841 | * | 840 | * |
842 | */ | 841 | */ |
843 | int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | 842 | int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) |
844 | { | 843 | { |
845 | struct nand_chip *this = mtd->priv; | 844 | struct nand_chip *this = mtd->priv; |
846 | int len, res = 0; | 845 | int len, res = 0; |
@@ -850,21 +849,21 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
850 | 849 | ||
851 | len = mtd->size >> (this->bbt_erase_shift + 2); | 850 | len = mtd->size >> (this->bbt_erase_shift + 2); |
852 | /* Allocate memory (2bit per block) */ | 851 | /* Allocate memory (2bit per block) */ |
853 | this->bbt = kmalloc (len, GFP_KERNEL); | 852 | this->bbt = kmalloc(len, GFP_KERNEL); |
854 | if (!this->bbt) { | 853 | if (!this->bbt) { |
855 | printk (KERN_ERR "nand_scan_bbt: Out of memory\n"); | 854 | printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); |
856 | return -ENOMEM; | 855 | return -ENOMEM; |
857 | } | 856 | } |
858 | /* Clear the memory bad block table */ | 857 | /* Clear the memory bad block table */ |
859 | memset (this->bbt, 0x00, len); | 858 | memset(this->bbt, 0x00, len); |
860 | 859 | ||
861 | /* If no primary table decriptor is given, scan the device | 860 | /* If no primary table decriptor is given, scan the device |
862 | * to build a memory based bad block table | 861 | * to build a memory based bad block table |
863 | */ | 862 | */ |
864 | if (!td) { | 863 | if (!td) { |
865 | if ((res = nand_memory_bbt(mtd, bd))) { | 864 | if ((res = nand_memory_bbt(mtd, bd))) { |
866 | printk (KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n"); | 865 | printk(KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n"); |
867 | kfree (this->bbt); | 866 | kfree(this->bbt); |
868 | this->bbt = NULL; | 867 | this->bbt = NULL; |
869 | } | 868 | } |
870 | return res; | 869 | return res; |
@@ -875,33 +874,32 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
875 | len += (len >> this->page_shift) * mtd->oobsize; | 874 | len += (len >> this->page_shift) * mtd->oobsize; |
876 | buf = vmalloc(len); | 875 | buf = vmalloc(len); |
877 | if (!buf) { | 876 | if (!buf) { |
878 | printk (KERN_ERR "nand_bbt: Out of memory\n"); | 877 | printk(KERN_ERR "nand_bbt: Out of memory\n"); |
879 | kfree (this->bbt); | 878 | kfree(this->bbt); |
880 | this->bbt = NULL; | 879 | this->bbt = NULL; |
881 | return -ENOMEM; | 880 | return -ENOMEM; |
882 | } | 881 | } |
883 | 882 | ||
884 | /* Is the bbt at a given page ? */ | 883 | /* Is the bbt at a given page ? */ |
885 | if (td->options & NAND_BBT_ABSPAGE) { | 884 | if (td->options & NAND_BBT_ABSPAGE) { |
886 | res = read_abs_bbts (mtd, buf, td, md); | 885 | res = read_abs_bbts(mtd, buf, td, md); |
887 | } else { | 886 | } else { |
888 | /* Search the bad block table using a pattern in oob */ | 887 | /* Search the bad block table using a pattern in oob */ |
889 | res = search_read_bbts (mtd, buf, td, md); | 888 | res = search_read_bbts(mtd, buf, td, md); |
890 | } | 889 | } |
891 | 890 | ||
892 | if (res) | 891 | if (res) |
893 | res = check_create (mtd, buf, bd); | 892 | res = check_create(mtd, buf, bd); |
894 | 893 | ||
895 | /* Prevent the bbt regions from erasing / writing */ | 894 | /* Prevent the bbt regions from erasing / writing */ |
896 | mark_bbt_region (mtd, td); | 895 | mark_bbt_region(mtd, td); |
897 | if (md) | 896 | if (md) |
898 | mark_bbt_region (mtd, md); | 897 | mark_bbt_region(mtd, md); |
899 | 898 | ||
900 | vfree (buf); | 899 | vfree(buf); |
901 | return res; | 900 | return res; |
902 | } | 901 | } |
903 | 902 | ||
904 | |||
905 | /** | 903 | /** |
906 | * nand_update_bbt - [NAND Interface] update bad block table(s) | 904 | * nand_update_bbt - [NAND Interface] update bad block table(s) |
907 | * @mtd: MTD device structure | 905 | * @mtd: MTD device structure |
@@ -909,7 +907,7 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
909 | * | 907 | * |
910 | * The function updates the bad block table(s) | 908 | * The function updates the bad block table(s) |
911 | */ | 909 | */ |
912 | int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | 910 | int nand_update_bbt(struct mtd_info *mtd, loff_t offs) |
913 | { | 911 | { |
914 | struct nand_chip *this = mtd->priv; | 912 | struct nand_chip *this = mtd->priv; |
915 | int len, res = 0, writeops = 0; | 913 | int len, res = 0, writeops = 0; |
@@ -925,9 +923,9 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | |||
925 | /* Allocate a temporary buffer for one eraseblock incl. oob */ | 923 | /* Allocate a temporary buffer for one eraseblock incl. oob */ |
926 | len = (1 << this->bbt_erase_shift); | 924 | len = (1 << this->bbt_erase_shift); |
927 | len += (len >> this->page_shift) * mtd->oobsize; | 925 | len += (len >> this->page_shift) * mtd->oobsize; |
928 | buf = kmalloc (len, GFP_KERNEL); | 926 | buf = kmalloc(len, GFP_KERNEL); |
929 | if (!buf) { | 927 | if (!buf) { |
930 | printk (KERN_ERR "nand_update_bbt: Out of memory\n"); | 928 | printk(KERN_ERR "nand_update_bbt: Out of memory\n"); |
931 | return -ENOMEM; | 929 | return -ENOMEM; |
932 | } | 930 | } |
933 | 931 | ||
@@ -935,7 +933,7 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | |||
935 | 933 | ||
936 | /* Do we have a bbt per chip ? */ | 934 | /* Do we have a bbt per chip ? */ |
937 | if (td->options & NAND_BBT_PERCHIP) { | 935 | if (td->options & NAND_BBT_PERCHIP) { |
938 | chip = (int) (offs >> this->chip_shift); | 936 | chip = (int)(offs >> this->chip_shift); |
939 | chipsel = chip; | 937 | chipsel = chip; |
940 | } else { | 938 | } else { |
941 | chip = 0; | 939 | chip = 0; |
@@ -948,17 +946,17 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | |||
948 | 946 | ||
949 | /* Write the bad block table to the device ? */ | 947 | /* Write the bad block table to the device ? */ |
950 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { | 948 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { |
951 | res = write_bbt (mtd, buf, td, md, chipsel); | 949 | res = write_bbt(mtd, buf, td, md, chipsel); |
952 | if (res < 0) | 950 | if (res < 0) |
953 | goto out; | 951 | goto out; |
954 | } | 952 | } |
955 | /* Write the mirror bad block table to the device ? */ | 953 | /* Write the mirror bad block table to the device ? */ |
956 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { | 954 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { |
957 | res = write_bbt (mtd, buf, md, td, chipsel); | 955 | res = write_bbt(mtd, buf, md, td, chipsel); |
958 | } | 956 | } |
959 | 957 | ||
960 | out: | 958 | out: |
961 | kfree (buf); | 959 | kfree(buf); |
962 | return res; | 960 | return res; |
963 | } | 961 | } |
964 | 962 | ||
@@ -1036,7 +1034,7 @@ static struct nand_bbt_descr bbt_mirror_descr = { | |||
1036 | * support for the device and calls the nand_scan_bbt function | 1034 | * support for the device and calls the nand_scan_bbt function |
1037 | * | 1035 | * |
1038 | */ | 1036 | */ |
1039 | int nand_default_bbt (struct mtd_info *mtd) | 1037 | int nand_default_bbt(struct mtd_info *mtd) |
1040 | { | 1038 | { |
1041 | struct nand_chip *this = mtd->priv; | 1039 | struct nand_chip *this = mtd->priv; |
1042 | 1040 | ||
@@ -1046,7 +1044,7 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1046 | * of the good / bad information, so we _must_ store | 1044 | * of the good / bad information, so we _must_ store |
1047 | * this information in a good / bad table during | 1045 | * this information in a good / bad table during |
1048 | * startup | 1046 | * startup |
1049 | */ | 1047 | */ |
1050 | if (this->options & NAND_IS_AND) { | 1048 | if (this->options & NAND_IS_AND) { |
1051 | /* Use the default pattern descriptors */ | 1049 | /* Use the default pattern descriptors */ |
1052 | if (!this->bbt_td) { | 1050 | if (!this->bbt_td) { |
@@ -1054,10 +1052,9 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1054 | this->bbt_md = &bbt_mirror_descr; | 1052 | this->bbt_md = &bbt_mirror_descr; |
1055 | } | 1053 | } |
1056 | this->options |= NAND_USE_FLASH_BBT; | 1054 | this->options |= NAND_USE_FLASH_BBT; |
1057 | return nand_scan_bbt (mtd, &agand_flashbased); | 1055 | return nand_scan_bbt(mtd, &agand_flashbased); |
1058 | } | 1056 | } |
1059 | 1057 | ||
1060 | |||
1061 | /* Is a flash based bad block table requested ? */ | 1058 | /* Is a flash based bad block table requested ? */ |
1062 | if (this->options & NAND_USE_FLASH_BBT) { | 1059 | if (this->options & NAND_USE_FLASH_BBT) { |
1063 | /* Use the default pattern descriptors */ | 1060 | /* Use the default pattern descriptors */ |
@@ -1066,18 +1063,17 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1066 | this->bbt_md = &bbt_mirror_descr; | 1063 | this->bbt_md = &bbt_mirror_descr; |
1067 | } | 1064 | } |
1068 | if (!this->badblock_pattern) { | 1065 | if (!this->badblock_pattern) { |
1069 | this->badblock_pattern = (mtd->oobblock > 512) ? | 1066 | this->badblock_pattern = (mtd->oobblock > 512) ? &largepage_flashbased : &smallpage_flashbased; |
1070 | &largepage_flashbased : &smallpage_flashbased; | ||
1071 | } | 1067 | } |
1072 | } else { | 1068 | } else { |
1073 | this->bbt_td = NULL; | 1069 | this->bbt_td = NULL; |
1074 | this->bbt_md = NULL; | 1070 | this->bbt_md = NULL; |
1075 | if (!this->badblock_pattern) { | 1071 | if (!this->badblock_pattern) { |
1076 | this->badblock_pattern = (mtd->oobblock > 512) ? | 1072 | this->badblock_pattern = (mtd->oobblock > 512) ? |
1077 | &largepage_memorybased : &smallpage_memorybased; | 1073 | &largepage_memorybased : &smallpage_memorybased; |
1078 | } | 1074 | } |
1079 | } | 1075 | } |
1080 | return nand_scan_bbt (mtd, this->badblock_pattern); | 1076 | return nand_scan_bbt(mtd, this->badblock_pattern); |
1081 | } | 1077 | } |
1082 | 1078 | ||
1083 | /** | 1079 | /** |
@@ -1087,26 +1083,29 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1087 | * @allowbbt: allow access to bad block table region | 1083 | * @allowbbt: allow access to bad block table region |
1088 | * | 1084 | * |
1089 | */ | 1085 | */ |
1090 | int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt) | 1086 | int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) |
1091 | { | 1087 | { |
1092 | struct nand_chip *this = mtd->priv; | 1088 | struct nand_chip *this = mtd->priv; |
1093 | int block; | 1089 | int block; |
1094 | uint8_t res; | 1090 | uint8_t res; |
1095 | 1091 | ||
1096 | /* Get block number * 2 */ | 1092 | /* Get block number * 2 */ |
1097 | block = (int) (offs >> (this->bbt_erase_shift - 1)); | 1093 | block = (int)(offs >> (this->bbt_erase_shift - 1)); |
1098 | res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03; | 1094 | res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03; |
1099 | 1095 | ||
1100 | DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", | 1096 | DEBUG(MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", |
1101 | (unsigned int)offs, block >> 1, res); | 1097 | (unsigned int)offs, block >> 1, res); |
1102 | 1098 | ||
1103 | switch ((int)res) { | 1099 | switch ((int)res) { |
1104 | case 0x00: return 0; | 1100 | case 0x00: |
1105 | case 0x01: return 1; | 1101 | return 0; |
1106 | case 0x02: return allowbbt ? 0 : 1; | 1102 | case 0x01: |
1103 | return 1; | ||
1104 | case 0x02: | ||
1105 | return allowbbt ? 0 : 1; | ||
1107 | } | 1106 | } |
1108 | return 1; | 1107 | return 1; |
1109 | } | 1108 | } |
1110 | 1109 | ||
1111 | EXPORT_SYMBOL (nand_scan_bbt); | 1110 | EXPORT_SYMBOL(nand_scan_bbt); |
1112 | EXPORT_SYMBOL (nand_default_bbt); | 1111 | EXPORT_SYMBOL(nand_default_bbt); |
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c index 40ac909150a3..101892985b02 100644 --- a/drivers/mtd/nand/nand_ecc.c +++ b/drivers/mtd/nand/nand_ecc.c | |||
@@ -62,7 +62,6 @@ static const u_char nand_ecc_precalc_table[] = { | |||
62 | 0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00 | 62 | 0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00 |
63 | }; | 63 | }; |
64 | 64 | ||
65 | |||
66 | /** | 65 | /** |
67 | * nand_trans_result - [GENERIC] create non-inverted ECC | 66 | * nand_trans_result - [GENERIC] create non-inverted ECC |
68 | * @reg2: line parity reg 2 | 67 | * @reg2: line parity reg 2 |
@@ -71,8 +70,7 @@ static const u_char nand_ecc_precalc_table[] = { | |||
71 | * | 70 | * |
72 | * Creates non-inverted ECC code from line parity | 71 | * Creates non-inverted ECC code from line parity |
73 | */ | 72 | */ |
74 | static void nand_trans_result(u_char reg2, u_char reg3, | 73 | static void nand_trans_result(u_char reg2, u_char reg3, u_char *ecc_code) |
75 | u_char *ecc_code) | ||
76 | { | 74 | { |
77 | u_char a, b, i, tmp1, tmp2; | 75 | u_char a, b, i, tmp1, tmp2; |
78 | 76 | ||
@@ -82,10 +80,10 @@ static void nand_trans_result(u_char reg2, u_char reg3, | |||
82 | 80 | ||
83 | /* Calculate first ECC byte */ | 81 | /* Calculate first ECC byte */ |
84 | for (i = 0; i < 4; i++) { | 82 | for (i = 0; i < 4; i++) { |
85 | if (reg3 & a) /* LP15,13,11,9 --> ecc_code[0] */ | 83 | if (reg3 & a) /* LP15,13,11,9 --> ecc_code[0] */ |
86 | tmp1 |= b; | 84 | tmp1 |= b; |
87 | b >>= 1; | 85 | b >>= 1; |
88 | if (reg2 & a) /* LP14,12,10,8 --> ecc_code[0] */ | 86 | if (reg2 & a) /* LP14,12,10,8 --> ecc_code[0] */ |
89 | tmp1 |= b; | 87 | tmp1 |= b; |
90 | b >>= 1; | 88 | b >>= 1; |
91 | a >>= 1; | 89 | a >>= 1; |
@@ -94,10 +92,10 @@ static void nand_trans_result(u_char reg2, u_char reg3, | |||
94 | /* Calculate second ECC byte */ | 92 | /* Calculate second ECC byte */ |
95 | b = 0x80; | 93 | b = 0x80; |
96 | for (i = 0; i < 4; i++) { | 94 | for (i = 0; i < 4; i++) { |
97 | if (reg3 & a) /* LP7,5,3,1 --> ecc_code[1] */ | 95 | if (reg3 & a) /* LP7,5,3,1 --> ecc_code[1] */ |
98 | tmp2 |= b; | 96 | tmp2 |= b; |
99 | b >>= 1; | 97 | b >>= 1; |
100 | if (reg2 & a) /* LP6,4,2,0 --> ecc_code[1] */ | 98 | if (reg2 & a) /* LP6,4,2,0 --> ecc_code[1] */ |
101 | tmp2 |= b; | 99 | tmp2 |= b; |
102 | b >>= 1; | 100 | b >>= 1; |
103 | a >>= 1; | 101 | a >>= 1; |
@@ -124,7 +122,7 @@ int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code | |||
124 | ecc_code[0] = ecc_code[1] = ecc_code[2] = 0; | 122 | ecc_code[0] = ecc_code[1] = ecc_code[2] = 0; |
125 | 123 | ||
126 | /* Build up column parity */ | 124 | /* Build up column parity */ |
127 | for(j = 0; j < 256; j++) { | 125 | for (j = 0; j < 256; j++) { |
128 | 126 | ||
129 | /* Get CP0 - CP5 from table */ | 127 | /* Get CP0 - CP5 from table */ |
130 | idx = nand_ecc_precalc_table[dat[j]]; | 128 | idx = nand_ecc_precalc_table[dat[j]]; |
@@ -168,8 +166,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
168 | if ((d1 | d2 | d3) == 0) { | 166 | if ((d1 | d2 | d3) == 0) { |
169 | /* No errors */ | 167 | /* No errors */ |
170 | return 0; | 168 | return 0; |
171 | } | 169 | } else { |
172 | else { | ||
173 | a = (d1 ^ (d1 >> 1)) & 0x55; | 170 | a = (d1 ^ (d1 >> 1)) & 0x55; |
174 | b = (d2 ^ (d2 >> 1)) & 0x55; | 171 | b = (d2 ^ (d2 >> 1)) & 0x55; |
175 | c = (d3 ^ (d3 >> 1)) & 0x54; | 172 | c = (d3 ^ (d3 >> 1)) & 0x54; |
@@ -179,14 +176,14 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
179 | c = 0x80; | 176 | c = 0x80; |
180 | add = 0; | 177 | add = 0; |
181 | a = 0x80; | 178 | a = 0x80; |
182 | for (i=0; i<4; i++) { | 179 | for (i = 0; i < 4; i++) { |
183 | if (d1 & c) | 180 | if (d1 & c) |
184 | add |= a; | 181 | add |= a; |
185 | c >>= 2; | 182 | c >>= 2; |
186 | a >>= 1; | 183 | a >>= 1; |
187 | } | 184 | } |
188 | c = 0x80; | 185 | c = 0x80; |
189 | for (i=0; i<4; i++) { | 186 | for (i = 0; i < 4; i++) { |
190 | if (d2 & c) | 187 | if (d2 & c) |
191 | add |= a; | 188 | add |= a; |
192 | c >>= 2; | 189 | c >>= 2; |
@@ -195,7 +192,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
195 | bit = 0; | 192 | bit = 0; |
196 | b = 0x04; | 193 | b = 0x04; |
197 | c = 0x80; | 194 | c = 0x80; |
198 | for (i=0; i<3; i++) { | 195 | for (i = 0; i < 3; i++) { |
199 | if (d3 & c) | 196 | if (d3 & c) |
200 | bit |= b; | 197 | bit |= b; |
201 | c >>= 2; | 198 | c >>= 2; |
@@ -206,8 +203,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
206 | a ^= (b << bit); | 203 | a ^= (b << bit); |
207 | dat[add] = a; | 204 | dat[add] = a; |
208 | return 1; | 205 | return 1; |
209 | } | 206 | } else { |
210 | else { | ||
211 | i = 0; | 207 | i = 0; |
212 | while (d1) { | 208 | while (d1) { |
213 | if (d1 & 0x01) | 209 | if (d1 & 0x01) |
@@ -230,8 +226,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
230 | read_ecc[1] = calc_ecc[1]; | 226 | read_ecc[1] = calc_ecc[1]; |
231 | read_ecc[2] = calc_ecc[2]; | 227 | read_ecc[2] = calc_ecc[2]; |
232 | return 2; | 228 | return 2; |
233 | } | 229 | } else { |
234 | else { | ||
235 | /* Uncorrectable Error */ | 230 | /* Uncorrectable Error */ |
236 | return -1; | 231 | return -1; |
237 | } | 232 | } |
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c index dbc7e55a4247..a9d52fc6e5d7 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c | |||
@@ -125,13 +125,13 @@ struct nand_manufacturers nand_manuf_ids[] = { | |||
125 | {NAND_MFR_NATIONAL, "National"}, | 125 | {NAND_MFR_NATIONAL, "National"}, |
126 | {NAND_MFR_RENESAS, "Renesas"}, | 126 | {NAND_MFR_RENESAS, "Renesas"}, |
127 | {NAND_MFR_STMICRO, "ST Micro"}, | 127 | {NAND_MFR_STMICRO, "ST Micro"}, |
128 | {NAND_MFR_HYNIX, "Hynix"}, | 128 | {NAND_MFR_HYNIX, "Hynix"}, |
129 | {0x0, "Unknown"} | 129 | {0x0, "Unknown"} |
130 | }; | 130 | }; |
131 | 131 | ||
132 | EXPORT_SYMBOL (nand_manuf_ids); | 132 | EXPORT_SYMBOL(nand_manuf_ids); |
133 | EXPORT_SYMBOL (nand_flash_ids); | 133 | EXPORT_SYMBOL(nand_flash_ids); |
134 | 134 | ||
135 | MODULE_LICENSE ("GPL"); | 135 | MODULE_LICENSE("GPL"); |
136 | MODULE_AUTHOR ("Thomas Gleixner <tglx@linutronix.de>"); | 136 | MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>"); |
137 | MODULE_DESCRIPTION ("Nand device & manufacturer ID's"); | 137 | MODULE_DESCRIPTION("Nand device & manufacturer IDs"); |
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c index 91a95f34a6ee..405beece9c5a 100644 --- a/drivers/mtd/nand/ppchameleonevb.c +++ b/drivers/mtd/nand/ppchameleonevb.c | |||
@@ -58,21 +58,21 @@ | |||
58 | /* | 58 | /* |
59 | * MTD structure for PPChameleonEVB board | 59 | * MTD structure for PPChameleonEVB board |
60 | */ | 60 | */ |
61 | static struct mtd_info *ppchameleon_mtd = NULL; | 61 | static struct mtd_info *ppchameleon_mtd = NULL; |
62 | static struct mtd_info *ppchameleonevb_mtd = NULL; | 62 | static struct mtd_info *ppchameleonevb_mtd = NULL; |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Module stuff | 65 | * Module stuff |
66 | */ | 66 | */ |
67 | static unsigned long ppchameleon_fio_pbase = CFG_NAND0_PADDR; | 67 | static unsigned long ppchameleon_fio_pbase = CFG_NAND0_PADDR; |
68 | static unsigned long ppchameleonevb_fio_pbase = CFG_NAND1_PADDR; | 68 | static unsigned long ppchameleonevb_fio_pbase = CFG_NAND1_PADDR; |
69 | 69 | ||
70 | #ifdef MODULE | 70 | #ifdef MODULE |
71 | module_param(ppchameleon_fio_pbase, ulong, 0); | 71 | module_param(ppchameleon_fio_pbase, ulong, 0); |
72 | module_param(ppchameleonevb_fio_pbase, ulong, 0); | 72 | module_param(ppchameleonevb_fio_pbase, ulong, 0); |
73 | #else | 73 | #else |
74 | __setup("ppchameleon_fio_pbase=",ppchameleon_fio_pbase); | 74 | __setup("ppchameleon_fio_pbase=", ppchameleon_fio_pbase); |
75 | __setup("ppchameleonevb_fio_pbase=",ppchameleonevb_fio_pbase); | 75 | __setup("ppchameleonevb_fio_pbase=", ppchameleonevb_fio_pbase); |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #ifdef CONFIG_MTD_PARTITIONS | 78 | #ifdef CONFIG_MTD_PARTITIONS |
@@ -80,80 +80,80 @@ __setup("ppchameleonevb_fio_pbase=",ppchameleonevb_fio_pbase); | |||
80 | * Define static partitions for flash devices | 80 | * Define static partitions for flash devices |
81 | */ | 81 | */ |
82 | static struct mtd_partition partition_info_hi[] = { | 82 | static struct mtd_partition partition_info_hi[] = { |
83 | { name: "PPChameleon HI Nand Flash", | 83 | { .name = "PPChameleon HI Nand Flash", |
84 | offset: 0, | 84 | offset = 0, |
85 | size: 128*1024*1024 } | 85 | .size = 128 * 1024 * 1024 |
86 | } | ||
86 | }; | 87 | }; |
87 | 88 | ||
88 | static struct mtd_partition partition_info_me[] = { | 89 | static struct mtd_partition partition_info_me[] = { |
89 | { name: "PPChameleon ME Nand Flash", | 90 | { .name = "PPChameleon ME Nand Flash", |
90 | offset: 0, | 91 | .offset = 0, |
91 | size: 32*1024*1024 } | 92 | .size = 32 * 1024 * 1024 |
93 | } | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | static struct mtd_partition partition_info_evb[] = { | 96 | static struct mtd_partition partition_info_evb[] = { |
95 | { name: "PPChameleonEVB Nand Flash", | 97 | { .name = "PPChameleonEVB Nand Flash", |
96 | offset: 0, | 98 | .offset = 0, |
97 | size: 32*1024*1024 } | 99 | .size = 32 * 1024 * 1024 |
100 | } | ||
98 | }; | 101 | }; |
99 | 102 | ||
100 | #define NUM_PARTITIONS 1 | 103 | #define NUM_PARTITIONS 1 |
101 | 104 | ||
102 | extern int parse_cmdline_partitions(struct mtd_info *master, | 105 | extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partition **pparts, const char *mtd_id); |
103 | struct mtd_partition **pparts, | ||
104 | const char *mtd_id); | ||
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | |||
108 | /* | 108 | /* |
109 | * hardware specific access to control-lines | 109 | * hardware specific access to control-lines |
110 | */ | 110 | */ |
111 | static void ppchameleon_hwcontrol(struct mtd_info *mtdinfo, int cmd) | 111 | static void ppchameleon_hwcontrol(struct mtd_info *mtdinfo, int cmd) |
112 | { | 112 | { |
113 | switch(cmd) { | 113 | switch (cmd) { |
114 | 114 | ||
115 | case NAND_CTL_SETCLE: | 115 | case NAND_CTL_SETCLE: |
116 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND0_PADDR); | 116 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND0_PADDR); |
117 | break; | 117 | break; |
118 | case NAND_CTL_CLRCLE: | 118 | case NAND_CTL_CLRCLE: |
119 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND0_PADDR); | 119 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND0_PADDR); |
120 | break; | 120 | break; |
121 | case NAND_CTL_SETALE: | 121 | case NAND_CTL_SETALE: |
122 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND0_PADDR); | 122 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND0_PADDR); |
123 | break; | 123 | break; |
124 | case NAND_CTL_CLRALE: | 124 | case NAND_CTL_CLRALE: |
125 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND0_PADDR); | 125 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND0_PADDR); |
126 | break; | 126 | break; |
127 | case NAND_CTL_SETNCE: | 127 | case NAND_CTL_SETNCE: |
128 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND0_PADDR); | 128 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND0_PADDR); |
129 | break; | 129 | break; |
130 | case NAND_CTL_CLRNCE: | 130 | case NAND_CTL_CLRNCE: |
131 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND0_PADDR); | 131 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND0_PADDR); |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd) | 136 | static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd) |
137 | { | 137 | { |
138 | switch(cmd) { | 138 | switch (cmd) { |
139 | 139 | ||
140 | case NAND_CTL_SETCLE: | 140 | case NAND_CTL_SETCLE: |
141 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND1_PADDR); | 141 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND1_PADDR); |
142 | break; | 142 | break; |
143 | case NAND_CTL_CLRCLE: | 143 | case NAND_CTL_CLRCLE: |
144 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND1_PADDR); | 144 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND1_PADDR); |
145 | break; | 145 | break; |
146 | case NAND_CTL_SETALE: | 146 | case NAND_CTL_SETALE: |
147 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND1_PADDR); | 147 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND1_PADDR); |
148 | break; | 148 | break; |
149 | case NAND_CTL_CLRALE: | 149 | case NAND_CTL_CLRALE: |
150 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND1_PADDR); | 150 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND1_PADDR); |
151 | break; | 151 | break; |
152 | case NAND_CTL_SETNCE: | 152 | case NAND_CTL_SETNCE: |
153 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND1_PADDR); | 153 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND1_PADDR); |
154 | break; | 154 | break; |
155 | case NAND_CTL_CLRNCE: | 155 | case NAND_CTL_CLRNCE: |
156 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND1_PADDR); | 156 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND1_PADDR); |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | } | 159 | } |
@@ -164,15 +164,15 @@ static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd) | |||
164 | */ | 164 | */ |
165 | static int ppchameleon_device_ready(struct mtd_info *minfo) | 165 | static int ppchameleon_device_ready(struct mtd_info *minfo) |
166 | { | 166 | { |
167 | if (in_be32((volatile unsigned*)GPIO0_IR) & NAND_RB_GPIO_PIN) | 167 | if (in_be32((volatile unsigned *)GPIO0_IR) & NAND_RB_GPIO_PIN) |
168 | return 1; | 168 | return 1; |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | static int ppchameleonevb_device_ready(struct mtd_info *minfo) | 172 | static int ppchameleonevb_device_ready(struct mtd_info *minfo) |
173 | { | 173 | { |
174 | if (in_be32((volatile unsigned*)GPIO0_IR) & NAND_EVB_RB_GPIO_PIN) | 174 | if (in_be32((volatile unsigned *)GPIO0_IR) & NAND_EVB_RB_GPIO_PIN) |
175 | return 1; | 175 | return 1; |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | #endif | 178 | #endif |
@@ -185,7 +185,7 @@ const char *part_probes_evb[] = { "cmdlinepart", NULL }; | |||
185 | /* | 185 | /* |
186 | * Main initialization routine | 186 | * Main initialization routine |
187 | */ | 187 | */ |
188 | static int __init ppchameleonevb_init (void) | 188 | static int __init ppchameleonevb_init(void) |
189 | { | 189 | { |
190 | struct nand_chip *this; | 190 | struct nand_chip *this; |
191 | const char *part_type = 0; | 191 | const char *part_type = 0; |
@@ -194,13 +194,11 @@ static int __init ppchameleonevb_init (void) | |||
194 | void __iomem *ppchameleon_fio_base; | 194 | void __iomem *ppchameleon_fio_base; |
195 | void __iomem *ppchameleonevb_fio_base; | 195 | void __iomem *ppchameleonevb_fio_base; |
196 | 196 | ||
197 | |||
198 | /********************************* | 197 | /********************************* |
199 | * Processor module NAND (if any) * | 198 | * Processor module NAND (if any) * |
200 | *********************************/ | 199 | *********************************/ |
201 | /* Allocate memory for MTD device structure and private data */ | 200 | /* Allocate memory for MTD device structure and private data */ |
202 | ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) + | 201 | ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
203 | sizeof(struct nand_chip), GFP_KERNEL); | ||
204 | if (!ppchameleon_mtd) { | 202 | if (!ppchameleon_mtd) { |
205 | printk("Unable to allocate PPChameleon NAND MTD device structure.\n"); | 203 | printk("Unable to allocate PPChameleon NAND MTD device structure.\n"); |
206 | return -ENOMEM; | 204 | return -ENOMEM; |
@@ -208,43 +206,45 @@ static int __init ppchameleonevb_init (void) | |||
208 | 206 | ||
209 | /* map physical address */ | 207 | /* map physical address */ |
210 | ppchameleon_fio_base = ioremap(ppchameleon_fio_pbase, SZ_4M); | 208 | ppchameleon_fio_base = ioremap(ppchameleon_fio_pbase, SZ_4M); |
211 | if(!ppchameleon_fio_base) { | 209 | if (!ppchameleon_fio_base) { |
212 | printk("ioremap PPChameleon NAND flash failed\n"); | 210 | printk("ioremap PPChameleon NAND flash failed\n"); |
213 | kfree(ppchameleon_mtd); | 211 | kfree(ppchameleon_mtd); |
214 | return -EIO; | 212 | return -EIO; |
215 | } | 213 | } |
216 | 214 | ||
217 | /* Get pointer to private data */ | 215 | /* Get pointer to private data */ |
218 | this = (struct nand_chip *) (&ppchameleon_mtd[1]); | 216 | this = (struct nand_chip *)(&ppchameleon_mtd[1]); |
219 | 217 | ||
220 | /* Initialize structures */ | 218 | /* Initialize structures */ |
221 | memset((char *) ppchameleon_mtd, 0, sizeof(struct mtd_info)); | 219 | memset(ppchameleon_mtd, 0, sizeof(struct mtd_info)); |
222 | memset((char *) this, 0, sizeof(struct nand_chip)); | 220 | memset(this, 0, sizeof(struct nand_chip)); |
223 | 221 | ||
224 | /* Link the private data with the MTD structure */ | 222 | /* Link the private data with the MTD structure */ |
225 | ppchameleon_mtd->priv = this; | 223 | ppchameleon_mtd->priv = this; |
226 | 224 | ||
227 | /* Initialize GPIOs */ | 225 | /* Initialize GPIOs */ |
228 | /* Pin mapping for NAND chip */ | 226 | /* Pin mapping for NAND chip */ |
229 | /* | 227 | /* |
230 | CE GPIO_01 | 228 | CE GPIO_01 |
231 | CLE GPIO_02 | 229 | CLE GPIO_02 |
232 | ALE GPIO_03 | 230 | ALE GPIO_03 |
233 | R/B GPIO_04 | 231 | R/B GPIO_04 |
234 | */ | 232 | */ |
235 | /* output select */ | 233 | /* output select */ |
236 | out_be32((volatile unsigned*)GPIO0_OSRH, in_be32((volatile unsigned*)GPIO0_OSRH) & 0xC0FFFFFF); | 234 | out_be32((volatile unsigned *)GPIO0_OSRH, in_be32((volatile unsigned *)GPIO0_OSRH) & 0xC0FFFFFF); |
237 | /* three-state select */ | 235 | /* three-state select */ |
238 | out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xC0FFFFFF); | 236 | out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xC0FFFFFF); |
239 | /* enable output driver */ | 237 | /* enable output driver */ |
240 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_nCE_GPIO_PIN | NAND_CLE_GPIO_PIN | NAND_ALE_GPIO_PIN); | 238 | out_be32((volatile unsigned *)GPIO0_TCR, |
239 | in_be32((volatile unsigned *)GPIO0_TCR) | NAND_nCE_GPIO_PIN | NAND_CLE_GPIO_PIN | NAND_ALE_GPIO_PIN); | ||
241 | #ifdef USE_READY_BUSY_PIN | 240 | #ifdef USE_READY_BUSY_PIN |
242 | /* three-state select */ | 241 | /* three-state select */ |
243 | out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFF3FFFFF); | 242 | out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xFF3FFFFF); |
244 | /* high-impedecence */ | 243 | /* high-impedecence */ |
245 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) & (~NAND_RB_GPIO_PIN)); | 244 | out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) & (~NAND_RB_GPIO_PIN)); |
246 | /* input select */ | 245 | /* input select */ |
247 | out_be32((volatile unsigned*)GPIO0_ISR1H, (in_be32((volatile unsigned*)GPIO0_ISR1H) & 0xFF3FFFFF) | 0x00400000); | 246 | out_be32((volatile unsigned *)GPIO0_ISR1H, |
247 | (in_be32((volatile unsigned *)GPIO0_ISR1H) & 0xFF3FFFFF) | 0x00400000); | ||
248 | #endif | 248 | #endif |
249 | 249 | ||
250 | /* insert callbacks */ | 250 | /* insert callbacks */ |
@@ -259,12 +259,11 @@ static int __init ppchameleonevb_init (void) | |||
259 | this->eccmode = NAND_ECC_SOFT; | 259 | this->eccmode = NAND_ECC_SOFT; |
260 | 260 | ||
261 | /* Scan to find existence of the device (it could not be mounted) */ | 261 | /* Scan to find existence of the device (it could not be mounted) */ |
262 | if (nand_scan (ppchameleon_mtd, 1)) { | 262 | if (nand_scan(ppchameleon_mtd, 1)) { |
263 | iounmap((void *)ppchameleon_fio_base); | 263 | iounmap((void *)ppchameleon_fio_base); |
264 | kfree (ppchameleon_mtd); | 264 | kfree(ppchameleon_mtd); |
265 | goto nand_evb_init; | 265 | goto nand_evb_init; |
266 | } | 266 | } |
267 | |||
268 | #ifndef USE_READY_BUSY_PIN | 267 | #ifndef USE_READY_BUSY_PIN |
269 | /* Adjust delay if necessary */ | 268 | /* Adjust delay if necessary */ |
270 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) | 269 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) |
@@ -275,12 +274,11 @@ static int __init ppchameleonevb_init (void) | |||
275 | ppchameleon_mtd->name = "ppchameleon-nand"; | 274 | ppchameleon_mtd->name = "ppchameleon-nand"; |
276 | mtd_parts_nb = parse_mtd_partitions(ppchameleon_mtd, part_probes, &mtd_parts, 0); | 275 | mtd_parts_nb = parse_mtd_partitions(ppchameleon_mtd, part_probes, &mtd_parts, 0); |
277 | if (mtd_parts_nb > 0) | 276 | if (mtd_parts_nb > 0) |
278 | part_type = "command line"; | 277 | part_type = "command line"; |
279 | else | 278 | else |
280 | mtd_parts_nb = 0; | 279 | mtd_parts_nb = 0; |
281 | #endif | 280 | #endif |
282 | if (mtd_parts_nb == 0) | 281 | if (mtd_parts_nb == 0) { |
283 | { | ||
284 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) | 282 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) |
285 | mtd_parts = partition_info_me; | 283 | mtd_parts = partition_info_me; |
286 | else | 284 | else |
@@ -293,13 +291,12 @@ static int __init ppchameleonevb_init (void) | |||
293 | printk(KERN_NOTICE "Using %s partition definition\n", part_type); | 291 | printk(KERN_NOTICE "Using %s partition definition\n", part_type); |
294 | add_mtd_partitions(ppchameleon_mtd, mtd_parts, mtd_parts_nb); | 292 | add_mtd_partitions(ppchameleon_mtd, mtd_parts, mtd_parts_nb); |
295 | 293 | ||
296 | nand_evb_init: | 294 | nand_evb_init: |
297 | /**************************** | 295 | /**************************** |
298 | * EVB NAND (always present) * | 296 | * EVB NAND (always present) * |
299 | ****************************/ | 297 | ****************************/ |
300 | /* Allocate memory for MTD device structure and private data */ | 298 | /* Allocate memory for MTD device structure and private data */ |
301 | ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + | 299 | ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
302 | sizeof(struct nand_chip), GFP_KERNEL); | ||
303 | if (!ppchameleonevb_mtd) { | 300 | if (!ppchameleonevb_mtd) { |
304 | printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); | 301 | printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); |
305 | return -ENOMEM; | 302 | return -ENOMEM; |
@@ -307,46 +304,47 @@ nand_evb_init: | |||
307 | 304 | ||
308 | /* map physical address */ | 305 | /* map physical address */ |
309 | ppchameleonevb_fio_base = ioremap(ppchameleonevb_fio_pbase, SZ_4M); | 306 | ppchameleonevb_fio_base = ioremap(ppchameleonevb_fio_pbase, SZ_4M); |
310 | if(!ppchameleonevb_fio_base) { | 307 | if (!ppchameleonevb_fio_base) { |
311 | printk("ioremap PPChameleonEVB NAND flash failed\n"); | 308 | printk("ioremap PPChameleonEVB NAND flash failed\n"); |
312 | kfree(ppchameleonevb_mtd); | 309 | kfree(ppchameleonevb_mtd); |
313 | return -EIO; | 310 | return -EIO; |
314 | } | 311 | } |
315 | 312 | ||
316 | /* Get pointer to private data */ | 313 | /* Get pointer to private data */ |
317 | this = (struct nand_chip *) (&ppchameleonevb_mtd[1]); | 314 | this = (struct nand_chip *)(&ppchameleonevb_mtd[1]); |
318 | 315 | ||
319 | /* Initialize structures */ | 316 | /* Initialize structures */ |
320 | memset((char *) ppchameleonevb_mtd, 0, sizeof(struct mtd_info)); | 317 | memset(ppchameleonevb_mtd, 0, sizeof(struct mtd_info)); |
321 | memset((char *) this, 0, sizeof(struct nand_chip)); | 318 | memset(this, 0, sizeof(struct nand_chip)); |
322 | 319 | ||
323 | /* Link the private data with the MTD structure */ | 320 | /* Link the private data with the MTD structure */ |
324 | ppchameleonevb_mtd->priv = this; | 321 | ppchameleonevb_mtd->priv = this; |
325 | 322 | ||
326 | /* Initialize GPIOs */ | 323 | /* Initialize GPIOs */ |
327 | /* Pin mapping for NAND chip */ | 324 | /* Pin mapping for NAND chip */ |
328 | /* | 325 | /* |
329 | CE GPIO_14 | 326 | CE GPIO_14 |
330 | CLE GPIO_15 | 327 | CLE GPIO_15 |
331 | ALE GPIO_16 | 328 | ALE GPIO_16 |
332 | R/B GPIO_31 | 329 | R/B GPIO_31 |
333 | */ | 330 | */ |
334 | /* output select */ | 331 | /* output select */ |
335 | out_be32((volatile unsigned*)GPIO0_OSRH, in_be32((volatile unsigned*)GPIO0_OSRH) & 0xFFFFFFF0); | 332 | out_be32((volatile unsigned *)GPIO0_OSRH, in_be32((volatile unsigned *)GPIO0_OSRH) & 0xFFFFFFF0); |
336 | out_be32((volatile unsigned*)GPIO0_OSRL, in_be32((volatile unsigned*)GPIO0_OSRL) & 0x3FFFFFFF); | 333 | out_be32((volatile unsigned *)GPIO0_OSRL, in_be32((volatile unsigned *)GPIO0_OSRL) & 0x3FFFFFFF); |
337 | /* three-state select */ | 334 | /* three-state select */ |
338 | out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFFFFFFF0); | 335 | out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xFFFFFFF0); |
339 | out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0x3FFFFFFF); | 336 | out_be32((volatile unsigned *)GPIO0_TSRL, in_be32((volatile unsigned *)GPIO0_TSRL) & 0x3FFFFFFF); |
340 | /* enable output driver */ | 337 | /* enable output driver */ |
341 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | | 338 | out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | |
342 | NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN); | 339 | NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN); |
343 | #ifdef USE_READY_BUSY_PIN | 340 | #ifdef USE_READY_BUSY_PIN |
344 | /* three-state select */ | 341 | /* three-state select */ |
345 | out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0xFFFFFFFC); | 342 | out_be32((volatile unsigned *)GPIO0_TSRL, in_be32((volatile unsigned *)GPIO0_TSRL) & 0xFFFFFFFC); |
346 | /* high-impedecence */ | 343 | /* high-impedecence */ |
347 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) & (~NAND_EVB_RB_GPIO_PIN)); | 344 | out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) & (~NAND_EVB_RB_GPIO_PIN)); |
348 | /* input select */ | 345 | /* input select */ |
349 | out_be32((volatile unsigned*)GPIO0_ISR1L, (in_be32((volatile unsigned*)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001); | 346 | out_be32((volatile unsigned *)GPIO0_ISR1L, |
347 | (in_be32((volatile unsigned *)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001); | ||
350 | #endif | 348 | #endif |
351 | 349 | ||
352 | /* insert callbacks */ | 350 | /* insert callbacks */ |
@@ -362,22 +360,20 @@ nand_evb_init: | |||
362 | this->eccmode = NAND_ECC_SOFT; | 360 | this->eccmode = NAND_ECC_SOFT; |
363 | 361 | ||
364 | /* Scan to find existence of the device */ | 362 | /* Scan to find existence of the device */ |
365 | if (nand_scan (ppchameleonevb_mtd, 1)) { | 363 | if (nand_scan(ppchameleonevb_mtd, 1)) { |
366 | iounmap((void *)ppchameleonevb_fio_base); | 364 | iounmap((void *)ppchameleonevb_fio_base); |
367 | kfree (ppchameleonevb_mtd); | 365 | kfree(ppchameleonevb_mtd); |
368 | return -ENXIO; | 366 | return -ENXIO; |
369 | } | 367 | } |
370 | |||
371 | #ifdef CONFIG_MTD_PARTITIONS | 368 | #ifdef CONFIG_MTD_PARTITIONS |
372 | ppchameleonevb_mtd->name = NAND_EVB_MTD_NAME; | 369 | ppchameleonevb_mtd->name = NAND_EVB_MTD_NAME; |
373 | mtd_parts_nb = parse_mtd_partitions(ppchameleonevb_mtd, part_probes_evb, &mtd_parts, 0); | 370 | mtd_parts_nb = parse_mtd_partitions(ppchameleonevb_mtd, part_probes_evb, &mtd_parts, 0); |
374 | if (mtd_parts_nb > 0) | 371 | if (mtd_parts_nb > 0) |
375 | part_type = "command line"; | 372 | part_type = "command line"; |
376 | else | 373 | else |
377 | mtd_parts_nb = 0; | 374 | mtd_parts_nb = 0; |
378 | #endif | 375 | #endif |
379 | if (mtd_parts_nb == 0) | 376 | if (mtd_parts_nb == 0) { |
380 | { | ||
381 | mtd_parts = partition_info_evb; | 377 | mtd_parts = partition_info_evb; |
382 | mtd_parts_nb = NUM_PARTITIONS; | 378 | mtd_parts_nb = NUM_PARTITIONS; |
383 | part_type = "static"; | 379 | part_type = "static"; |
@@ -390,18 +386,19 @@ nand_evb_init: | |||
390 | /* Return happy */ | 386 | /* Return happy */ |
391 | return 0; | 387 | return 0; |
392 | } | 388 | } |
389 | |||
393 | module_init(ppchameleonevb_init); | 390 | module_init(ppchameleonevb_init); |
394 | 391 | ||
395 | /* | 392 | /* |
396 | * Clean up routine | 393 | * Clean up routine |
397 | */ | 394 | */ |
398 | static void __exit ppchameleonevb_cleanup (void) | 395 | static void __exit ppchameleonevb_cleanup(void) |
399 | { | 396 | { |
400 | struct nand_chip *this; | 397 | struct nand_chip *this; |
401 | 398 | ||
402 | /* Release resources, unregister device(s) */ | 399 | /* Release resources, unregister device(s) */ |
403 | nand_release (ppchameleon_mtd); | 400 | nand_release(ppchameleon_mtd); |
404 | nand_release (ppchameleonevb_mtd); | 401 | nand_release(ppchameleonevb_mtd); |
405 | 402 | ||
406 | /* Release iomaps */ | 403 | /* Release iomaps */ |
407 | this = (struct nand_chip *) &ppchameleon_mtd[1]; | 404 | this = (struct nand_chip *) &ppchameleon_mtd[1]; |
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c index 4129c03dfd90..1887989fb885 100644 --- a/drivers/mtd/nand/rtc_from4.c +++ b/drivers/mtd/nand/rtc_from4.c | |||
@@ -97,12 +97,12 @@ static struct mtd_info *rtc_from4_mtd = NULL; | |||
97 | static void __iomem *rtc_from4_fio_base = (void *)P2SEGADDR(RTC_FROM4_FIO_BASE); | 97 | static void __iomem *rtc_from4_fio_base = (void *)P2SEGADDR(RTC_FROM4_FIO_BASE); |
98 | 98 | ||
99 | static const struct mtd_partition partition_info[] = { | 99 | static const struct mtd_partition partition_info[] = { |
100 | { | 100 | { |
101 | .name = "Renesas flash partition 1", | 101 | .name = "Renesas flash partition 1", |
102 | .offset = 0, | 102 | .offset = 0, |
103 | .size = MTDPART_SIZ_FULL | 103 | .size = MTDPART_SIZ_FULL}, |
104 | }, | ||
105 | }; | 104 | }; |
105 | |||
106 | #define NUM_PARTITIONS 1 | 106 | #define NUM_PARTITIONS 1 |
107 | 107 | ||
108 | /* | 108 | /* |
@@ -111,8 +111,8 @@ static const struct mtd_partition partition_info[] = { | |||
111 | * NAND_BBT_CREATE and/or NAND_BBT_WRITE | 111 | * NAND_BBT_CREATE and/or NAND_BBT_WRITE |
112 | * | 112 | * |
113 | */ | 113 | */ |
114 | static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' }; | 114 | static uint8_t bbt_pattern[] = { 'B', 'b', 't', '0' }; |
115 | static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' }; | 115 | static uint8_t mirror_pattern[] = { '1', 't', 'b', 'B' }; |
116 | 116 | ||
117 | static struct nand_bbt_descr rtc_from4_bbt_main_descr = { | 117 | static struct nand_bbt_descr rtc_from4_bbt_main_descr = { |
118 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 118 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
@@ -134,8 +134,6 @@ static struct nand_bbt_descr rtc_from4_bbt_mirror_descr = { | |||
134 | .pattern = mirror_pattern | 134 | .pattern = mirror_pattern |
135 | }; | 135 | }; |
136 | 136 | ||
137 | |||
138 | |||
139 | #ifdef RTC_FROM4_HWECC | 137 | #ifdef RTC_FROM4_HWECC |
140 | 138 | ||
141 | /* the Reed Solomon control structure */ | 139 | /* the Reed Solomon control structure */ |
@@ -148,11 +146,11 @@ static struct nand_oobinfo rtc_from4_nand_oobinfo = { | |||
148 | .useecc = MTD_NANDECC_AUTOPLACE, | 146 | .useecc = MTD_NANDECC_AUTOPLACE, |
149 | .eccbytes = 32, | 147 | .eccbytes = 32, |
150 | .eccpos = { | 148 | .eccpos = { |
151 | 0, 1, 2, 3, 4, 5, 6, 7, | 149 | 0, 1, 2, 3, 4, 5, 6, 7, |
152 | 8, 9, 10, 11, 12, 13, 14, 15, | 150 | 8, 9, 10, 11, 12, 13, 14, 15, |
153 | 16, 17, 18, 19, 20, 21, 22, 23, | 151 | 16, 17, 18, 19, 20, 21, 22, 23, |
154 | 24, 25, 26, 27, 28, 29, 30, 31}, | 152 | 24, 25, 26, 27, 28, 29, 30, 31}, |
155 | .oobfree = { {32, 32} } | 153 | .oobfree = {{32, 32}} |
156 | }; | 154 | }; |
157 | 155 | ||
158 | /* Aargh. I missed the reversed bit order, when I | 156 | /* Aargh. I missed the reversed bit order, when I |
@@ -162,44 +160,42 @@ static struct nand_oobinfo rtc_from4_nand_oobinfo = { | |||
162 | * of the ecc byte which we get from the FPGA | 160 | * of the ecc byte which we get from the FPGA |
163 | */ | 161 | */ |
164 | static uint8_t revbits[256] = { | 162 | static uint8_t revbits[256] = { |
165 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, | 163 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, |
166 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | 164 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, |
167 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, | 165 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, |
168 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | 166 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, |
169 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, | 167 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, |
170 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | 168 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, |
171 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, | 169 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, |
172 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | 170 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, |
173 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, | 171 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, |
174 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | 172 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, |
175 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, | 173 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, |
176 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | 174 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, |
177 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, | 175 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, |
178 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | 176 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, |
179 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, | 177 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, |
180 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | 178 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, |
181 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, | 179 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, |
182 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | 180 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, |
183 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, | 181 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, |
184 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | 182 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, |
185 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, | 183 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, |
186 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | 184 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, |
187 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, | 185 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, |
188 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | 186 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, |
189 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, | 187 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, |
190 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | 188 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, |
191 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, | 189 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, |
192 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | 190 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, |
193 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, | 191 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, |
194 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | 192 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, |
195 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, | 193 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, |
196 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, | 194 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, |
197 | }; | 195 | }; |
198 | 196 | ||
199 | #endif | 197 | #endif |
200 | 198 | ||
201 | |||
202 | |||
203 | /* | 199 | /* |
204 | * rtc_from4_hwcontrol - hardware specific access to control-lines | 200 | * rtc_from4_hwcontrol - hardware specific access to control-lines |
205 | * @mtd: MTD device structure | 201 | * @mtd: MTD device structure |
@@ -214,9 +210,9 @@ static uint8_t revbits[256] = { | |||
214 | */ | 210 | */ |
215 | static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) | 211 | static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) |
216 | { | 212 | { |
217 | struct nand_chip* this = (struct nand_chip *) (mtd->priv); | 213 | struct nand_chip *this = (struct nand_chip *)(mtd->priv); |
218 | 214 | ||
219 | switch(cmd) { | 215 | switch (cmd) { |
220 | 216 | ||
221 | case NAND_CTL_SETCLE: | 217 | case NAND_CTL_SETCLE: |
222 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE); | 218 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE); |
@@ -240,7 +236,6 @@ static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) | |||
240 | } | 236 | } |
241 | } | 237 | } |
242 | 238 | ||
243 | |||
244 | /* | 239 | /* |
245 | * rtc_from4_nand_select_chip - hardware specific chip select | 240 | * rtc_from4_nand_select_chip - hardware specific chip select |
246 | * @mtd: MTD device structure | 241 | * @mtd: MTD device structure |
@@ -252,26 +247,25 @@ static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) | |||
252 | */ | 247 | */ |
253 | static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip) | 248 | static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip) |
254 | { | 249 | { |
255 | struct nand_chip *this = mtd->priv; | 250 | struct nand_chip *this = mtd->priv; |
256 | 251 | ||
257 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R & ~RTC_FROM4_NAND_ADDR_MASK); | 252 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R & ~RTC_FROM4_NAND_ADDR_MASK); |
258 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_NAND_ADDR_MASK); | 253 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_NAND_ADDR_MASK); |
259 | 254 | ||
260 | switch(chip) { | 255 | switch (chip) { |
261 | 256 | ||
262 | case 0: /* select slot 3 chip */ | 257 | case 0: /* select slot 3 chip */ |
263 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT3); | 258 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT3); |
264 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT3); | 259 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT3); |
265 | break; | 260 | break; |
266 | case 1: /* select slot 4 chip */ | 261 | case 1: /* select slot 4 chip */ |
267 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT4); | 262 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT4); |
268 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT4); | 263 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT4); |
269 | break; | 264 | break; |
270 | 265 | ||
271 | } | 266 | } |
272 | } | 267 | } |
273 | 268 | ||
274 | |||
275 | /* | 269 | /* |
276 | * rtc_from4_nand_device_ready - hardware specific ready/busy check | 270 | * rtc_from4_nand_device_ready - hardware specific ready/busy check |
277 | * @mtd: MTD device structure | 271 | * @mtd: MTD device structure |
@@ -290,7 +284,6 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd) | |||
290 | 284 | ||
291 | } | 285 | } |
292 | 286 | ||
293 | |||
294 | /* | 287 | /* |
295 | * deplete - code to perform device recovery in case there was a power loss | 288 | * deplete - code to perform device recovery in case there was a power loss |
296 | * @mtd: MTD device structure | 289 | * @mtd: MTD device structure |
@@ -306,24 +299,23 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd) | |||
306 | */ | 299 | */ |
307 | static void deplete(struct mtd_info *mtd, int chip) | 300 | static void deplete(struct mtd_info *mtd, int chip) |
308 | { | 301 | { |
309 | struct nand_chip *this = mtd->priv; | 302 | struct nand_chip *this = mtd->priv; |
310 | 303 | ||
311 | /* wait until device is ready */ | 304 | /* wait until device is ready */ |
312 | while (!this->dev_ready(mtd)); | 305 | while (!this->dev_ready(mtd)) ; |
313 | 306 | ||
314 | this->select_chip(mtd, chip); | 307 | this->select_chip(mtd, chip); |
315 | 308 | ||
316 | /* Send the commands for device recovery, phase 1 */ | 309 | /* Send the commands for device recovery, phase 1 */ |
317 | this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000); | 310 | this->cmdfunc(mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000); |
318 | this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1); | 311 | this->cmdfunc(mtd, NAND_CMD_DEPLETE2, -1, -1); |
319 | 312 | ||
320 | /* Send the commands for device recovery, phase 2 */ | 313 | /* Send the commands for device recovery, phase 2 */ |
321 | this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0004); | 314 | this->cmdfunc(mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0004); |
322 | this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1); | 315 | this->cmdfunc(mtd, NAND_CMD_DEPLETE2, -1, -1); |
323 | 316 | ||
324 | } | 317 | } |
325 | 318 | ||
326 | |||
327 | #ifdef RTC_FROM4_HWECC | 319 | #ifdef RTC_FROM4_HWECC |
328 | /* | 320 | /* |
329 | * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function | 321 | * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function |
@@ -335,39 +327,35 @@ static void deplete(struct mtd_info *mtd, int chip) | |||
335 | */ | 327 | */ |
336 | static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) | 328 | static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) |
337 | { | 329 | { |
338 | volatile unsigned short * rs_ecc_ctl = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CTL); | 330 | volatile unsigned short *rs_ecc_ctl = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CTL); |
339 | unsigned short status; | 331 | unsigned short status; |
340 | 332 | ||
341 | switch (mode) { | 333 | switch (mode) { |
342 | case NAND_ECC_READ : | 334 | case NAND_ECC_READ: |
343 | status = RTC_FROM4_RS_ECC_CTL_CLR | 335 | status = RTC_FROM4_RS_ECC_CTL_CLR | RTC_FROM4_RS_ECC_CTL_FD_E; |
344 | | RTC_FROM4_RS_ECC_CTL_FD_E; | ||
345 | 336 | ||
346 | *rs_ecc_ctl = status; | 337 | *rs_ecc_ctl = status; |
347 | break; | 338 | break; |
348 | 339 | ||
349 | case NAND_ECC_READSYN : | 340 | case NAND_ECC_READSYN: |
350 | status = 0x00; | 341 | status = 0x00; |
351 | 342 | ||
352 | *rs_ecc_ctl = status; | 343 | *rs_ecc_ctl = status; |
353 | break; | 344 | break; |
354 | 345 | ||
355 | case NAND_ECC_WRITE : | 346 | case NAND_ECC_WRITE: |
356 | status = RTC_FROM4_RS_ECC_CTL_CLR | 347 | status = RTC_FROM4_RS_ECC_CTL_CLR | RTC_FROM4_RS_ECC_CTL_GEN | RTC_FROM4_RS_ECC_CTL_FD_E; |
357 | | RTC_FROM4_RS_ECC_CTL_GEN | ||
358 | | RTC_FROM4_RS_ECC_CTL_FD_E; | ||
359 | 348 | ||
360 | *rs_ecc_ctl = status; | 349 | *rs_ecc_ctl = status; |
361 | break; | 350 | break; |
362 | 351 | ||
363 | default: | 352 | default: |
364 | BUG(); | 353 | BUG(); |
365 | break; | 354 | break; |
366 | } | 355 | } |
367 | 356 | ||
368 | } | 357 | } |
369 | 358 | ||
370 | |||
371 | /* | 359 | /* |
372 | * rtc_from4_calculate_ecc - hardware specific code to read ECC code | 360 | * rtc_from4_calculate_ecc - hardware specific code to read ECC code |
373 | * @mtd: MTD device structure | 361 | * @mtd: MTD device structure |
@@ -383,7 +371,7 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) | |||
383 | */ | 371 | */ |
384 | static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | 372 | static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) |
385 | { | 373 | { |
386 | volatile unsigned short * rs_eccn = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECCN); | 374 | volatile unsigned short *rs_eccn = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECCN); |
387 | unsigned short value; | 375 | unsigned short value; |
388 | int i; | 376 | int i; |
389 | 377 | ||
@@ -395,7 +383,6 @@ static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_c | |||
395 | ecc_code[7] |= 0x0f; /* set the last four bits (not used) */ | 383 | ecc_code[7] |= 0x0f; /* set the last four bits (not used) */ |
396 | } | 384 | } |
397 | 385 | ||
398 | |||
399 | /* | 386 | /* |
400 | * rtc_from4_correct_data - hardware specific code to correct data using ECC code | 387 | * rtc_from4_correct_data - hardware specific code to correct data using ECC code |
401 | * @mtd: MTD device structure | 388 | * @mtd: MTD device structure |
@@ -414,7 +401,7 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
414 | unsigned short status; | 401 | unsigned short status; |
415 | uint16_t par[6], syn[6]; | 402 | uint16_t par[6], syn[6]; |
416 | uint8_t ecc[8]; | 403 | uint8_t ecc[8]; |
417 | volatile unsigned short *rs_ecc; | 404 | volatile unsigned short *rs_ecc; |
418 | 405 | ||
419 | status = *((volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CHK)); | 406 | status = *((volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CHK)); |
420 | 407 | ||
@@ -424,23 +411,18 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
424 | 411 | ||
425 | /* Read the syndrom pattern from the FPGA and correct the bitorder */ | 412 | /* Read the syndrom pattern from the FPGA and correct the bitorder */ |
426 | rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC); | 413 | rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC); |
427 | for (i = 0; i < 8; i++) { | 414 | for (i = 0; i < 8; i++) { |
428 | ecc[i] = revbits[(*rs_ecc) & 0xFF]; | 415 | ecc[i] = revbits[(*rs_ecc) & 0xFF]; |
429 | rs_ecc++; | 416 | rs_ecc++; |
430 | } | 417 | } |
431 | 418 | ||
432 | /* convert into 6 10bit syndrome fields */ | 419 | /* convert into 6 10bit syndrome fields */ |
433 | par[5] = rs_decoder->index_of[(((uint16_t)ecc[0] >> 0) & 0x0ff) | | 420 | par[5] = rs_decoder->index_of[(((uint16_t) ecc[0] >> 0) & 0x0ff) | (((uint16_t) ecc[1] << 8) & 0x300)]; |
434 | (((uint16_t)ecc[1] << 8) & 0x300)]; | 421 | par[4] = rs_decoder->index_of[(((uint16_t) ecc[1] >> 2) & 0x03f) | (((uint16_t) ecc[2] << 6) & 0x3c0)]; |
435 | par[4] = rs_decoder->index_of[(((uint16_t)ecc[1] >> 2) & 0x03f) | | 422 | par[3] = rs_decoder->index_of[(((uint16_t) ecc[2] >> 4) & 0x00f) | (((uint16_t) ecc[3] << 4) & 0x3f0)]; |
436 | (((uint16_t)ecc[2] << 6) & 0x3c0)]; | 423 | par[2] = rs_decoder->index_of[(((uint16_t) ecc[3] >> 6) & 0x003) | (((uint16_t) ecc[4] << 2) & 0x3fc)]; |
437 | par[3] = rs_decoder->index_of[(((uint16_t)ecc[2] >> 4) & 0x00f) | | 424 | par[1] = rs_decoder->index_of[(((uint16_t) ecc[5] >> 0) & 0x0ff) | (((uint16_t) ecc[6] << 8) & 0x300)]; |
438 | (((uint16_t)ecc[3] << 4) & 0x3f0)]; | 425 | par[0] = (((uint16_t) ecc[6] >> 2) & 0x03f) | (((uint16_t) ecc[7] << 6) & 0x3c0); |
439 | par[2] = rs_decoder->index_of[(((uint16_t)ecc[3] >> 6) & 0x003) | | ||
440 | (((uint16_t)ecc[4] << 2) & 0x3fc)]; | ||
441 | par[1] = rs_decoder->index_of[(((uint16_t)ecc[5] >> 0) & 0x0ff) | | ||
442 | (((uint16_t)ecc[6] << 8) & 0x300)]; | ||
443 | par[0] = (((uint16_t)ecc[6] >> 2) & 0x03f) | (((uint16_t)ecc[7] << 6) & 0x3c0); | ||
444 | 426 | ||
445 | /* Convert to computable syndrome */ | 427 | /* Convert to computable syndrome */ |
446 | for (i = 0; i < 6; i++) { | 428 | for (i = 0; i < 6; i++) { |
@@ -453,16 +435,14 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
453 | syn[i] = rs_decoder->index_of[syn[i]]; | 435 | syn[i] = rs_decoder->index_of[syn[i]]; |
454 | } | 436 | } |
455 | 437 | ||
456 | /* Let the library code do its magic.*/ | 438 | /* Let the library code do its magic. */ |
457 | res = decode_rs8(rs_decoder, (uint8_t *)buf, par, 512, syn, 0, NULL, 0xff, NULL); | 439 | res = decode_rs8(rs_decoder, (uint8_t *) buf, par, 512, syn, 0, NULL, 0xff, NULL); |
458 | if (res > 0) { | 440 | if (res > 0) { |
459 | DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " | 441 | DEBUG(MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " "ECC corrected %d errors on read\n", res); |
460 | "ECC corrected %d errors on read\n", res); | ||
461 | } | 442 | } |
462 | return res; | 443 | return res; |
463 | } | 444 | } |
464 | 445 | ||
465 | |||
466 | /** | 446 | /** |
467 | * rtc_from4_errstat - perform additional error status checks | 447 | * rtc_from4_errstat - perform additional error status checks |
468 | * @mtd: MTD device structure | 448 | * @mtd: MTD device structure |
@@ -480,44 +460,44 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
480 | */ | 460 | */ |
481 | static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page) | 461 | static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page) |
482 | { | 462 | { |
483 | int er_stat=0; | 463 | int er_stat = 0; |
484 | int rtn, retlen; | 464 | int rtn, retlen; |
485 | size_t len; | 465 | size_t len; |
486 | uint8_t *buf; | 466 | uint8_t *buf; |
487 | int i; | 467 | int i; |
488 | 468 | ||
489 | this->cmdfunc (mtd, NAND_CMD_STATUS_CLEAR, -1, -1); | 469 | this->cmdfunc(mtd, NAND_CMD_STATUS_CLEAR, -1, -1); |
490 | 470 | ||
491 | if (state == FL_ERASING) { | 471 | if (state == FL_ERASING) { |
492 | for (i=0; i<4; i++) { | 472 | for (i = 0; i < 4; i++) { |
493 | if (status & 1<<(i+1)) { | 473 | if (status & 1 << (i + 1)) { |
494 | this->cmdfunc (mtd, (NAND_CMD_STATUS_ERROR + i + 1), -1, -1); | 474 | this->cmdfunc(mtd, (NAND_CMD_STATUS_ERROR + i + 1), -1, -1); |
495 | rtn = this->read_byte(mtd); | 475 | rtn = this->read_byte(mtd); |
496 | this->cmdfunc (mtd, NAND_CMD_STATUS_RESET, -1, -1); | 476 | this->cmdfunc(mtd, NAND_CMD_STATUS_RESET, -1, -1); |
497 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { | 477 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { |
498 | er_stat |= 1<<(i+1); /* err_ecc_not_avail */ | 478 | er_stat |= 1 << (i + 1); /* err_ecc_not_avail */ |
499 | } | 479 | } |
500 | } | 480 | } |
501 | } | 481 | } |
502 | } else if (state == FL_WRITING) { | 482 | } else if (state == FL_WRITING) { |
503 | /* single bank write logic */ | 483 | /* single bank write logic */ |
504 | this->cmdfunc (mtd, NAND_CMD_STATUS_ERROR, -1, -1); | 484 | this->cmdfunc(mtd, NAND_CMD_STATUS_ERROR, -1, -1); |
505 | rtn = this->read_byte(mtd); | 485 | rtn = this->read_byte(mtd); |
506 | this->cmdfunc (mtd, NAND_CMD_STATUS_RESET, -1, -1); | 486 | this->cmdfunc(mtd, NAND_CMD_STATUS_RESET, -1, -1); |
507 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { | 487 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { |
508 | er_stat |= 1<<1; /* err_ecc_not_avail */ | 488 | er_stat |= 1 << 1; /* err_ecc_not_avail */ |
509 | } else { | 489 | } else { |
510 | len = mtd->oobblock; | 490 | len = mtd->oobblock; |
511 | buf = kmalloc (len, GFP_KERNEL); | 491 | buf = kmalloc(len, GFP_KERNEL); |
512 | if (!buf) { | 492 | if (!buf) { |
513 | printk (KERN_ERR "rtc_from4_errstat: Out of memory!\n"); | 493 | printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n"); |
514 | er_stat = 1; /* if we can't check, assume failed */ | 494 | er_stat = 1; /* if we can't check, assume failed */ |
515 | } else { | 495 | } else { |
516 | /* recovery read */ | 496 | /* recovery read */ |
517 | /* page read */ | 497 | /* page read */ |
518 | rtn = nand_do_read_ecc (mtd, page, len, &retlen, buf, NULL, this->autooob, 1); | 498 | rtn = nand_do_read_ecc(mtd, page, len, &retlen, buf, NULL, this->autooob, 1); |
519 | if (rtn) { /* if read failed or > 1-bit error corrected */ | 499 | if (rtn) { /* if read failed or > 1-bit error corrected */ |
520 | er_stat |= 1<<1; /* ECC read failed */ | 500 | er_stat |= 1 << 1; /* ECC read failed */ |
521 | } | 501 | } |
522 | kfree(buf); | 502 | kfree(buf); |
523 | } | 503 | } |
@@ -525,7 +505,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s | |||
525 | } | 505 | } |
526 | 506 | ||
527 | rtn = status; | 507 | rtn = status; |
528 | if (er_stat == 0) { /* if ECC is available */ | 508 | if (er_stat == 0) { /* if ECC is available */ |
529 | rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ | 509 | rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ |
530 | } | 510 | } |
531 | 511 | ||
@@ -533,30 +513,28 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s | |||
533 | } | 513 | } |
534 | #endif | 514 | #endif |
535 | 515 | ||
536 | |||
537 | /* | 516 | /* |
538 | * Main initialization routine | 517 | * Main initialization routine |
539 | */ | 518 | */ |
540 | int __init rtc_from4_init (void) | 519 | int __init rtc_from4_init(void) |
541 | { | 520 | { |
542 | struct nand_chip *this; | 521 | struct nand_chip *this; |
543 | unsigned short bcr1, bcr2, wcr2; | 522 | unsigned short bcr1, bcr2, wcr2; |
544 | int i; | 523 | int i; |
545 | 524 | ||
546 | /* Allocate memory for MTD device structure and private data */ | 525 | /* Allocate memory for MTD device structure and private data */ |
547 | rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip), | 526 | rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
548 | GFP_KERNEL); | ||
549 | if (!rtc_from4_mtd) { | 527 | if (!rtc_from4_mtd) { |
550 | printk ("Unable to allocate Renesas NAND MTD device structure.\n"); | 528 | printk("Unable to allocate Renesas NAND MTD device structure.\n"); |
551 | return -ENOMEM; | 529 | return -ENOMEM; |
552 | } | 530 | } |
553 | 531 | ||
554 | /* Get pointer to private data */ | 532 | /* Get pointer to private data */ |
555 | this = (struct nand_chip *) (&rtc_from4_mtd[1]); | 533 | this = (struct nand_chip *)(&rtc_from4_mtd[1]); |
556 | 534 | ||
557 | /* Initialize structures */ | 535 | /* Initialize structures */ |
558 | memset((char *) rtc_from4_mtd, 0, sizeof(struct mtd_info)); | 536 | memset(rtc_from4_mtd, 0, sizeof(struct mtd_info)); |
559 | memset((char *) this, 0, sizeof(struct nand_chip)); | 537 | memset(this, 0, sizeof(struct nand_chip)); |
560 | 538 | ||
561 | /* Link the private data with the MTD structure */ | 539 | /* Link the private data with the MTD structure */ |
562 | rtc_from4_mtd->priv = this; | 540 | rtc_from4_mtd->priv = this; |
@@ -582,7 +560,7 @@ int __init rtc_from4_init (void) | |||
582 | /* Set address of hardware control function */ | 560 | /* Set address of hardware control function */ |
583 | this->hwcontrol = rtc_from4_hwcontrol; | 561 | this->hwcontrol = rtc_from4_hwcontrol; |
584 | /* Set address of chip select function */ | 562 | /* Set address of chip select function */ |
585 | this->select_chip = rtc_from4_nand_select_chip; | 563 | this->select_chip = rtc_from4_nand_select_chip; |
586 | /* command delay time (in us) */ | 564 | /* command delay time (in us) */ |
587 | this->chip_delay = 100; | 565 | this->chip_delay = 100; |
588 | /* return the status of the Ready/Busy line */ | 566 | /* return the status of the Ready/Busy line */ |
@@ -591,7 +569,7 @@ int __init rtc_from4_init (void) | |||
591 | #ifdef RTC_FROM4_HWECC | 569 | #ifdef RTC_FROM4_HWECC |
592 | printk(KERN_INFO "rtc_from4_init: using hardware ECC detection.\n"); | 570 | printk(KERN_INFO "rtc_from4_init: using hardware ECC detection.\n"); |
593 | 571 | ||
594 | this->eccmode = NAND_ECC_HW8_512; | 572 | this->eccmode = NAND_ECC_HW8_512; |
595 | this->options |= NAND_HWECC_SYNDROME; | 573 | this->options |= NAND_HWECC_SYNDROME; |
596 | /* return the status of extra status and ECC checks */ | 574 | /* return the status of extra status and ECC checks */ |
597 | this->errstat = rtc_from4_errstat; | 575 | this->errstat = rtc_from4_errstat; |
@@ -617,7 +595,7 @@ int __init rtc_from4_init (void) | |||
617 | } | 595 | } |
618 | 596 | ||
619 | /* Perform 'device recovery' for each chip in case there was a power loss. */ | 597 | /* Perform 'device recovery' for each chip in case there was a power loss. */ |
620 | for (i=0; i < this->numchips; i++) { | 598 | for (i = 0; i < this->numchips; i++) { |
621 | deplete(rtc_from4_mtd, i); | 599 | deplete(rtc_from4_mtd, i); |
622 | } | 600 | } |
623 | 601 | ||
@@ -643,7 +621,7 @@ int __init rtc_from4_init (void) | |||
643 | */ | 621 | */ |
644 | rs_decoder = init_rs(10, 0x409, 0, 1, 6); | 622 | rs_decoder = init_rs(10, 0x409, 0, 1, 6); |
645 | if (!rs_decoder) { | 623 | if (!rs_decoder) { |
646 | printk (KERN_ERR "Could not create a RS decoder\n"); | 624 | printk(KERN_ERR "Could not create a RS decoder\n"); |
647 | nand_release(rtc_from4_mtd); | 625 | nand_release(rtc_from4_mtd); |
648 | kfree(rtc_from4_mtd); | 626 | kfree(rtc_from4_mtd); |
649 | return -ENOMEM; | 627 | return -ENOMEM; |
@@ -652,20 +630,20 @@ int __init rtc_from4_init (void) | |||
652 | /* Return happy */ | 630 | /* Return happy */ |
653 | return 0; | 631 | return 0; |
654 | } | 632 | } |
655 | module_init(rtc_from4_init); | ||
656 | 633 | ||
634 | module_init(rtc_from4_init); | ||
657 | 635 | ||
658 | /* | 636 | /* |
659 | * Clean up routine | 637 | * Clean up routine |
660 | */ | 638 | */ |
661 | #ifdef MODULE | 639 | #ifdef MODULE |
662 | static void __exit rtc_from4_cleanup (void) | 640 | static void __exit rtc_from4_cleanup(void) |
663 | { | 641 | { |
664 | /* Release resource, unregister partitions */ | 642 | /* Release resource, unregister partitions */ |
665 | nand_release(rtc_from4_mtd); | 643 | nand_release(rtc_from4_mtd); |
666 | 644 | ||
667 | /* Free the MTD device structure */ | 645 | /* Free the MTD device structure */ |
668 | kfree (rtc_from4_mtd); | 646 | kfree(rtc_from4_mtd); |
669 | 647 | ||
670 | #ifdef RTC_FROM4_HWECC | 648 | #ifdef RTC_FROM4_HWECC |
671 | /* Free the reed solomon resources */ | 649 | /* Free the reed solomon resources */ |
@@ -674,10 +652,10 @@ static void __exit rtc_from4_cleanup (void) | |||
674 | } | 652 | } |
675 | #endif | 653 | #endif |
676 | } | 654 | } |
655 | |||
677 | module_exit(rtc_from4_cleanup); | 656 | module_exit(rtc_from4_cleanup); |
678 | #endif | 657 | #endif |
679 | 658 | ||
680 | MODULE_LICENSE("GPL"); | 659 | MODULE_LICENSE("GPL"); |
681 | MODULE_AUTHOR("d.marlin <dmarlin@redhat.com"); | 660 | MODULE_AUTHOR("d.marlin <dmarlin@redhat.com"); |
682 | MODULE_DESCRIPTION("Board-specific glue layer for AG-AND flash on Renesas FROM_BOARD4"); | 661 | MODULE_DESCRIPTION("Board-specific glue layer for AG-AND flash on Renesas FROM_BOARD4"); |
683 | |||
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 5b55599739f3..338fda87b9e5 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -77,10 +77,10 @@ static int hardware_ecc = 0; | |||
77 | */ | 77 | */ |
78 | 78 | ||
79 | static struct nand_oobinfo nand_hw_eccoob = { | 79 | static struct nand_oobinfo nand_hw_eccoob = { |
80 | .useecc = MTD_NANDECC_AUTOPLACE, | 80 | .useecc = MTD_NANDECC_AUTOPLACE, |
81 | .eccbytes = 3, | 81 | .eccbytes = 3, |
82 | .eccpos = {0, 1, 2 }, | 82 | .eccpos = {0, 1, 2}, |
83 | .oobfree = { {8, 8} } | 83 | .oobfree = {{8, 8}} |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /* controller and mtd information */ | 86 | /* controller and mtd information */ |
@@ -149,8 +149,7 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) | |||
149 | pr_debug("result %d from %ld, %d\n", result, clk, wanted); | 149 | pr_debug("result %d from %ld, %d\n", result, clk, wanted); |
150 | 150 | ||
151 | if (result > max) { | 151 | if (result > max) { |
152 | printk("%d ns is too big for current clock rate %ld\n", | 152 | printk("%d ns is too big for current clock rate %ld\n", wanted, clk); |
153 | wanted, clk); | ||
154 | return -1; | 153 | return -1; |
155 | } | 154 | } |
156 | 155 | ||
@@ -164,8 +163,7 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) | |||
164 | 163 | ||
165 | /* controller setup */ | 164 | /* controller setup */ |
166 | 165 | ||
167 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | 166 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, struct platform_device *pdev) |
168 | struct platform_device *pdev) | ||
169 | { | 167 | { |
170 | struct s3c2410_platform_nand *plat = to_nand_plat(pdev); | 168 | struct s3c2410_platform_nand *plat = to_nand_plat(pdev); |
171 | unsigned long clkrate = clk_get_rate(info->clk); | 169 | unsigned long clkrate = clk_get_rate(info->clk); |
@@ -177,7 +175,7 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | |||
177 | clkrate /= 1000; /* turn clock into kHz for ease of use */ | 175 | clkrate /= 1000; /* turn clock into kHz for ease of use */ |
178 | 176 | ||
179 | if (plat != NULL) { | 177 | if (plat != NULL) { |
180 | tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4); | 178 | tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4); |
181 | twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); | 179 | twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); |
182 | twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8); | 180 | twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8); |
183 | } else { | 181 | } else { |
@@ -193,19 +191,17 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | |||
193 | } | 191 | } |
194 | 192 | ||
195 | printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n", | 193 | printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n", |
196 | tacls, to_ns(tacls, clkrate), | 194 | tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate)); |
197 | twrph0, to_ns(twrph0, clkrate), | ||
198 | twrph1, to_ns(twrph1, clkrate)); | ||
199 | 195 | ||
200 | if (!info->is_s3c2440) { | 196 | if (!info->is_s3c2440) { |
201 | cfg = S3C2410_NFCONF_EN; | 197 | cfg = S3C2410_NFCONF_EN; |
202 | cfg |= S3C2410_NFCONF_TACLS(tacls-1); | 198 | cfg |= S3C2410_NFCONF_TACLS(tacls - 1); |
203 | cfg |= S3C2410_NFCONF_TWRPH0(twrph0-1); | 199 | cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1); |
204 | cfg |= S3C2410_NFCONF_TWRPH1(twrph1-1); | 200 | cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1); |
205 | } else { | 201 | } else { |
206 | cfg = S3C2440_NFCONF_TACLS(tacls-1); | 202 | cfg = S3C2440_NFCONF_TACLS(tacls - 1); |
207 | cfg |= S3C2440_NFCONF_TWRPH0(twrph0-1); | 203 | cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1); |
208 | cfg |= S3C2440_NFCONF_TWRPH1(twrph1-1); | 204 | cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1); |
209 | } | 205 | } |
210 | 206 | ||
211 | pr_debug(PFX "NF_CONF is 0x%lx\n", cfg); | 207 | pr_debug(PFX "NF_CONF is 0x%lx\n", cfg); |
@@ -229,7 +225,7 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) | |||
229 | info = nmtd->info; | 225 | info = nmtd->info; |
230 | 226 | ||
231 | bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE; | 227 | bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE; |
232 | reg = info->regs+((info->is_s3c2440) ? S3C2440_NFCONT:S3C2410_NFCONF); | 228 | reg = info->regs + ((info->is_s3c2440) ? S3C2440_NFCONT : S3C2410_NFCONF); |
233 | 229 | ||
234 | cur = readl(reg); | 230 | cur = readl(reg); |
235 | 231 | ||
@@ -243,7 +239,7 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) | |||
243 | 239 | ||
244 | if (info->platform != NULL) { | 240 | if (info->platform != NULL) { |
245 | if (info->platform->select_chip != NULL) | 241 | if (info->platform->select_chip != NULL) |
246 | (info->platform->select_chip)(nmtd->set, chip); | 242 | (info->platform->select_chip) (nmtd->set, chip); |
247 | } | 243 | } |
248 | 244 | ||
249 | cur &= ~bit; | 245 | cur &= ~bit; |
@@ -330,22 +326,16 @@ static int s3c2410_nand_devready(struct mtd_info *mtd) | |||
330 | return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; | 326 | return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; |
331 | } | 327 | } |
332 | 328 | ||
333 | |||
334 | /* ECC handling functions */ | 329 | /* ECC handling functions */ |
335 | 330 | ||
336 | static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, | 331 | static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc) |
337 | u_char *read_ecc, u_char *calc_ecc) | ||
338 | { | 332 | { |
339 | pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", | 333 | pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", mtd, dat, read_ecc, calc_ecc); |
340 | mtd, dat, read_ecc, calc_ecc); | ||
341 | 334 | ||
342 | pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n", | 335 | pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n", |
343 | read_ecc[0], read_ecc[1], read_ecc[2], | 336 | read_ecc[0], read_ecc[1], read_ecc[2], calc_ecc[0], calc_ecc[1], calc_ecc[2]); |
344 | calc_ecc[0], calc_ecc[1], calc_ecc[2]); | ||
345 | 337 | ||
346 | if (read_ecc[0] == calc_ecc[0] && | 338 | if (read_ecc[0] == calc_ecc[0] && read_ecc[1] == calc_ecc[1] && read_ecc[2] == calc_ecc[2]) |
347 | read_ecc[1] == calc_ecc[1] && | ||
348 | read_ecc[2] == calc_ecc[2]) | ||
349 | return 0; | 339 | return 0; |
350 | 340 | ||
351 | /* we curently have no method for correcting the error */ | 341 | /* we curently have no method for correcting the error */ |
@@ -378,8 +368,7 @@ static void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode) | |||
378 | writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT); | 368 | writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT); |
379 | } | 369 | } |
380 | 370 | ||
381 | static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, | 371 | static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) |
382 | const u_char *dat, u_char *ecc_code) | ||
383 | { | 372 | { |
384 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); | 373 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); |
385 | 374 | ||
@@ -387,15 +376,12 @@ static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, | |||
387 | ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1); | 376 | ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1); |
388 | ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2); | 377 | ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2); |
389 | 378 | ||
390 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", | 379 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]); |
391 | ecc_code[0], ecc_code[1], ecc_code[2]); | ||
392 | 380 | ||
393 | return 0; | 381 | return 0; |
394 | } | 382 | } |
395 | 383 | ||
396 | 384 | static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | |
397 | static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, | ||
398 | const u_char *dat, u_char *ecc_code) | ||
399 | { | 385 | { |
400 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); | 386 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); |
401 | unsigned long ecc = readl(info->regs + S3C2440_NFMECC0); | 387 | unsigned long ecc = readl(info->regs + S3C2440_NFMECC0); |
@@ -404,13 +390,11 @@ static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, | |||
404 | ecc_code[1] = ecc >> 8; | 390 | ecc_code[1] = ecc >> 8; |
405 | ecc_code[2] = ecc >> 16; | 391 | ecc_code[2] = ecc >> 16; |
406 | 392 | ||
407 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", | 393 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]); |
408 | ecc_code[0], ecc_code[1], ecc_code[2]); | ||
409 | 394 | ||
410 | return 0; | 395 | return 0; |
411 | } | 396 | } |
412 | 397 | ||
413 | |||
414 | /* over-ride the standard functions for a little more speed. We can | 398 | /* over-ride the standard functions for a little more speed. We can |
415 | * use read/write block to move the data buffers to/from the controller | 399 | * use read/write block to move the data buffers to/from the controller |
416 | */ | 400 | */ |
@@ -421,8 +405,7 @@ static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
421 | readsb(this->IO_ADDR_R, buf, len); | 405 | readsb(this->IO_ADDR_R, buf, len); |
422 | } | 406 | } |
423 | 407 | ||
424 | static void s3c2410_nand_write_buf(struct mtd_info *mtd, | 408 | static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) |
425 | const u_char *buf, int len) | ||
426 | { | 409 | { |
427 | struct nand_chip *this = mtd->priv; | 410 | struct nand_chip *this = mtd->priv; |
428 | writesb(this->IO_ADDR_W, buf, len); | 411 | writesb(this->IO_ADDR_W, buf, len); |
@@ -488,9 +471,7 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info, | |||
488 | return add_mtd_device(&mtd->mtd); | 471 | return add_mtd_device(&mtd->mtd); |
489 | 472 | ||
490 | if (set->nr_partitions > 0 && set->partitions != NULL) { | 473 | if (set->nr_partitions > 0 && set->partitions != NULL) { |
491 | return add_mtd_partitions(&mtd->mtd, | 474 | return add_mtd_partitions(&mtd->mtd, set->partitions, set->nr_partitions); |
492 | set->partitions, | ||
493 | set->nr_partitions); | ||
494 | } | 475 | } |
495 | 476 | ||
496 | return add_mtd_device(&mtd->mtd); | 477 | return add_mtd_device(&mtd->mtd); |
@@ -654,13 +635,11 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440) | |||
654 | nmtd = info->mtds; | 635 | nmtd = info->mtds; |
655 | 636 | ||
656 | for (setno = 0; setno < nr_sets; setno++, nmtd++) { | 637 | for (setno = 0; setno < nr_sets; setno++, nmtd++) { |
657 | pr_debug("initialising set %d (%p, info %p)\n", | 638 | pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info); |
658 | setno, nmtd, info); | ||
659 | 639 | ||
660 | s3c2410_nand_init_chip(info, nmtd, sets); | 640 | s3c2410_nand_init_chip(info, nmtd, sets); |
661 | 641 | ||
662 | nmtd->scan_res = nand_scan(&nmtd->mtd, | 642 | nmtd->scan_res = nand_scan(&nmtd->mtd, (sets) ? sets->nr_chips : 1); |
663 | (sets) ? sets->nr_chips : 1); | ||
664 | 643 | ||
665 | if (nmtd->scan_res == 0) { | 644 | if (nmtd->scan_res == 0) { |
666 | s3c2410_nand_add_partition(info, nmtd, sets); | 645 | s3c2410_nand_add_partition(info, nmtd, sets); |
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index c294374871a4..25322a8d44d8 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -46,7 +46,6 @@ static int sharpsl_phys_base = 0x0C000000; | |||
46 | #define FLCLE (1 << 1) | 46 | #define FLCLE (1 << 1) |
47 | #define FLCE0 (1 << 0) | 47 | #define FLCE0 (1 << 0) |
48 | 48 | ||
49 | |||
50 | /* | 49 | /* |
51 | * MTD structure for SharpSL | 50 | * MTD structure for SharpSL |
52 | */ | 51 | */ |
@@ -60,27 +59,26 @@ static struct mtd_info *sharpsl_mtd = NULL; | |||
60 | static int nr_partitions; | 59 | static int nr_partitions; |
61 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { | 60 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { |
62 | { | 61 | { |
63 | .name = "System Area", | 62 | .name = "System Area", |
64 | .offset = 0, | 63 | .offset = 0, |
65 | .size = 7 * 1024 * 1024, | 64 | .size = 7 * 1024 * 1024, |
66 | }, | 65 | }, |
67 | { | 66 | { |
68 | .name = "Root Filesystem", | 67 | .name = "Root Filesystem", |
69 | .offset = 7 * 1024 * 1024, | 68 | .offset = 7 * 1024 * 1024, |
70 | .size = 30 * 1024 * 1024, | 69 | .size = 30 * 1024 * 1024, |
71 | }, | 70 | }, |
72 | { | 71 | { |
73 | .name = "Home Filesystem", | 72 | .name = "Home Filesystem", |
74 | .offset = MTDPART_OFS_APPEND , | 73 | .offset = MTDPART_OFS_APPEND, |
75 | .size = MTDPART_SIZ_FULL , | 74 | .size = MTDPART_SIZ_FULL, |
76 | }, | 75 | }, |
77 | }; | 76 | }; |
78 | 77 | ||
79 | /* | 78 | /* |
80 | * hardware specific access to control-lines | 79 | * hardware specific access to control-lines |
81 | */ | 80 | */ |
82 | static void | 81 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd) |
83 | sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) | ||
84 | { | 82 | { |
85 | switch (cmd) { | 83 | switch (cmd) { |
86 | case NAND_CTL_SETCLE: | 84 | case NAND_CTL_SETCLE: |
@@ -98,10 +96,10 @@ sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) | |||
98 | break; | 96 | break; |
99 | 97 | ||
100 | case NAND_CTL_SETNCE: | 98 | case NAND_CTL_SETNCE: |
101 | writeb(readb(FLASHCTL) & ~(FLCE0|FLCE1), FLASHCTL); | 99 | writeb(readb(FLASHCTL) & ~(FLCE0 | FLCE1), FLASHCTL); |
102 | break; | 100 | break; |
103 | case NAND_CTL_CLRNCE: | 101 | case NAND_CTL_CLRNCE: |
104 | writeb(readb(FLASHCTL) | (FLCE0|FLCE1), FLASHCTL); | 102 | writeb(readb(FLASHCTL) | (FLCE0 | FLCE1), FLASHCTL); |
105 | break; | 103 | break; |
106 | } | 104 | } |
107 | } | 105 | } |
@@ -126,27 +124,23 @@ static struct nand_oobinfo akita_oobinfo = { | |||
126 | .useecc = MTD_NANDECC_AUTOPLACE, | 124 | .useecc = MTD_NANDECC_AUTOPLACE, |
127 | .eccbytes = 24, | 125 | .eccbytes = 24, |
128 | .eccpos = { | 126 | .eccpos = { |
129 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, | 127 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, |
130 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, | 128 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, |
131 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, | 129 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, |
132 | .oobfree = { {0x08, 0x09} } | 130 | .oobfree = {{0x08, 0x09}} |
133 | }; | 131 | }; |
134 | 132 | ||
135 | static int | 133 | static int sharpsl_nand_dev_ready(struct mtd_info *mtd) |
136 | sharpsl_nand_dev_ready(struct mtd_info* mtd) | ||
137 | { | 134 | { |
138 | return !((readb(FLASHCTL) & FLRYBY) == 0); | 135 | return !((readb(FLASHCTL) & FLRYBY) == 0); |
139 | } | 136 | } |
140 | 137 | ||
141 | static void | 138 | static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) |
142 | sharpsl_nand_enable_hwecc(struct mtd_info* mtd, int mode) | ||
143 | { | 139 | { |
144 | writeb(0 ,ECCCLRR); | 140 | writeb(0, ECCCLRR); |
145 | } | 141 | } |
146 | 142 | ||
147 | static int | 143 | static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) |
148 | sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat, | ||
149 | u_char* ecc_code) | ||
150 | { | 144 | { |
151 | ecc_code[0] = ~readb(ECCLPUB); | 145 | ecc_code[0] = ~readb(ECCLPUB); |
152 | ecc_code[1] = ~readb(ECCLPLB); | 146 | ecc_code[1] = ~readb(ECCLPLB); |
@@ -154,44 +148,40 @@ sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat, | |||
154 | return readb(ECCCNTR) != 0; | 148 | return readb(ECCCNTR) != 0; |
155 | } | 149 | } |
156 | 150 | ||
157 | |||
158 | #ifdef CONFIG_MTD_PARTITIONS | 151 | #ifdef CONFIG_MTD_PARTITIONS |
159 | const char *part_probes[] = { "cmdlinepart", NULL }; | 152 | const char *part_probes[] = { "cmdlinepart", NULL }; |
160 | #endif | 153 | #endif |
161 | 154 | ||
162 | |||
163 | /* | 155 | /* |
164 | * Main initialization routine | 156 | * Main initialization routine |
165 | */ | 157 | */ |
166 | int __init | 158 | int __init sharpsl_nand_init(void) |
167 | sharpsl_nand_init(void) | ||
168 | { | 159 | { |
169 | struct nand_chip *this; | 160 | struct nand_chip *this; |
170 | struct mtd_partition* sharpsl_partition_info; | 161 | struct mtd_partition *sharpsl_partition_info; |
171 | int err = 0; | 162 | int err = 0; |
172 | 163 | ||
173 | /* Allocate memory for MTD device structure and private data */ | 164 | /* Allocate memory for MTD device structure and private data */ |
174 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), | 165 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
175 | GFP_KERNEL); | ||
176 | if (!sharpsl_mtd) { | 166 | if (!sharpsl_mtd) { |
177 | printk ("Unable to allocate SharpSL NAND MTD device structure.\n"); | 167 | printk("Unable to allocate SharpSL NAND MTD device structure.\n"); |
178 | return -ENOMEM; | 168 | return -ENOMEM; |
179 | } | 169 | } |
180 | 170 | ||
181 | /* map physical adress */ | 171 | /* map physical adress */ |
182 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); | 172 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); |
183 | if(!sharpsl_io_base){ | 173 | if (!sharpsl_io_base) { |
184 | printk("ioremap to access Sharp SL NAND chip failed\n"); | 174 | printk("ioremap to access Sharp SL NAND chip failed\n"); |
185 | kfree(sharpsl_mtd); | 175 | kfree(sharpsl_mtd); |
186 | return -EIO; | 176 | return -EIO; |
187 | } | 177 | } |
188 | 178 | ||
189 | /* Get pointer to private data */ | 179 | /* Get pointer to private data */ |
190 | this = (struct nand_chip *) (&sharpsl_mtd[1]); | 180 | this = (struct nand_chip *)(&sharpsl_mtd[1]); |
191 | 181 | ||
192 | /* Initialize structures */ | 182 | /* Initialize structures */ |
193 | memset((char *) sharpsl_mtd, 0, sizeof(struct mtd_info)); | 183 | memset(sharpsl_mtd, 0, sizeof(struct mtd_info)); |
194 | memset((char *) this, 0, sizeof(struct nand_chip)); | 184 | memset(this, 0, sizeof(struct nand_chip)); |
195 | 185 | ||
196 | /* Link the private data with the MTD structure */ | 186 | /* Link the private data with the MTD structure */ |
197 | sharpsl_mtd->priv = this; | 187 | sharpsl_mtd->priv = this; |
@@ -221,7 +211,7 @@ sharpsl_nand_init(void) | |||
221 | this->correct_data = nand_correct_data; | 211 | this->correct_data = nand_correct_data; |
222 | 212 | ||
223 | /* Scan to find existence of the device */ | 213 | /* Scan to find existence of the device */ |
224 | err=nand_scan(sharpsl_mtd,1); | 214 | err = nand_scan(sharpsl_mtd, 1); |
225 | if (err) { | 215 | if (err) { |
226 | iounmap(sharpsl_io_base); | 216 | iounmap(sharpsl_io_base); |
227 | kfree(sharpsl_mtd); | 217 | kfree(sharpsl_mtd); |
@@ -230,24 +220,23 @@ sharpsl_nand_init(void) | |||
230 | 220 | ||
231 | /* Register the partitions */ | 221 | /* Register the partitions */ |
232 | sharpsl_mtd->name = "sharpsl-nand"; | 222 | sharpsl_mtd->name = "sharpsl-nand"; |
233 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, | 223 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0); |
234 | &sharpsl_partition_info, 0); | ||
235 | 224 | ||
236 | if (nr_partitions <= 0) { | 225 | if (nr_partitions <= 0) { |
237 | nr_partitions = DEFAULT_NUM_PARTITIONS; | 226 | nr_partitions = DEFAULT_NUM_PARTITIONS; |
238 | sharpsl_partition_info = sharpsl_nand_default_partition_info; | 227 | sharpsl_partition_info = sharpsl_nand_default_partition_info; |
239 | if (machine_is_poodle()) { | 228 | if (machine_is_poodle()) { |
240 | sharpsl_partition_info[1].size=22 * 1024 * 1024; | 229 | sharpsl_partition_info[1].size = 22 * 1024 * 1024; |
241 | } else if (machine_is_corgi() || machine_is_shepherd()) { | 230 | } else if (machine_is_corgi() || machine_is_shepherd()) { |
242 | sharpsl_partition_info[1].size=25 * 1024 * 1024; | 231 | sharpsl_partition_info[1].size = 25 * 1024 * 1024; |
243 | } else if (machine_is_husky()) { | 232 | } else if (machine_is_husky()) { |
244 | sharpsl_partition_info[1].size=53 * 1024 * 1024; | 233 | sharpsl_partition_info[1].size = 53 * 1024 * 1024; |
245 | } else if (machine_is_spitz()) { | 234 | } else if (machine_is_spitz()) { |
246 | sharpsl_partition_info[1].size=5 * 1024 * 1024; | 235 | sharpsl_partition_info[1].size = 5 * 1024 * 1024; |
247 | } else if (machine_is_akita()) { | 236 | } else if (machine_is_akita()) { |
248 | sharpsl_partition_info[1].size=58 * 1024 * 1024; | 237 | sharpsl_partition_info[1].size = 58 * 1024 * 1024; |
249 | } else if (machine_is_borzoi()) { | 238 | } else if (machine_is_borzoi()) { |
250 | sharpsl_partition_info[1].size=32 * 1024 * 1024; | 239 | sharpsl_partition_info[1].size = 32 * 1024 * 1024; |
251 | } | 240 | } |
252 | } | 241 | } |
253 | 242 | ||
@@ -261,6 +250,7 @@ sharpsl_nand_init(void) | |||
261 | /* Return happy */ | 250 | /* Return happy */ |
262 | return 0; | 251 | return 0; |
263 | } | 252 | } |
253 | |||
264 | module_init(sharpsl_nand_init); | 254 | module_init(sharpsl_nand_init); |
265 | 255 | ||
266 | /* | 256 | /* |
@@ -269,7 +259,7 @@ module_init(sharpsl_nand_init); | |||
269 | #ifdef MODULE | 259 | #ifdef MODULE |
270 | static void __exit sharpsl_nand_cleanup(void) | 260 | static void __exit sharpsl_nand_cleanup(void) |
271 | { | 261 | { |
272 | struct nand_chip *this = (struct nand_chip *) &sharpsl_mtd[1]; | 262 | struct nand_chip *this = (struct nand_chip *)&sharpsl_mtd[1]; |
273 | 263 | ||
274 | /* Release resources, unregister device */ | 264 | /* Release resources, unregister device */ |
275 | nand_release(sharpsl_mtd); | 265 | nand_release(sharpsl_mtd); |
@@ -279,6 +269,7 @@ static void __exit sharpsl_nand_cleanup(void) | |||
279 | /* Free the MTD device structure */ | 269 | /* Free the MTD device structure */ |
280 | kfree(sharpsl_mtd); | 270 | kfree(sharpsl_mtd); |
281 | } | 271 | } |
272 | |||
282 | module_exit(sharpsl_nand_cleanup); | 273 | module_exit(sharpsl_nand_cleanup); |
283 | #endif | 274 | #endif |
284 | 275 | ||
diff --git a/drivers/mtd/nand/spia.c b/drivers/mtd/nand/spia.c index 9cf1ce718ec1..a11354b9afa2 100644 --- a/drivers/mtd/nand/spia.c +++ b/drivers/mtd/nand/spia.c | |||
@@ -39,16 +39,16 @@ static struct mtd_info *spia_mtd = NULL; | |||
39 | */ | 39 | */ |
40 | #define SPIA_IO_BASE 0xd0000000 /* Start of EP7212 IO address space */ | 40 | #define SPIA_IO_BASE 0xd0000000 /* Start of EP7212 IO address space */ |
41 | #define SPIA_FIO_BASE 0xf0000000 /* Address where flash is mapped */ | 41 | #define SPIA_FIO_BASE 0xf0000000 /* Address where flash is mapped */ |
42 | #define SPIA_PEDR 0x0080 /* | 42 | #define SPIA_PEDR 0x0080 /* |
43 | * IO offset to Port E data register | 43 | * IO offset to Port E data register |
44 | * where the CLE, ALE and NCE pins | 44 | * where the CLE, ALE and NCE pins |
45 | * are wired to. | 45 | * are wired to. |
46 | */ | 46 | */ |
47 | #define SPIA_PEDDR 0x00c0 /* | 47 | #define SPIA_PEDDR 0x00c0 /* |
48 | * IO offset to Port E data direction | 48 | * IO offset to Port E data direction |
49 | * register so we can control the IO | 49 | * register so we can control the IO |
50 | * lines. | 50 | * lines. |
51 | */ | 51 | */ |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * Module stuff | 54 | * Module stuff |
@@ -69,25 +69,23 @@ module_param(spia_peddr, int, 0); | |||
69 | */ | 69 | */ |
70 | static const struct mtd_partition partition_info[] = { | 70 | static const struct mtd_partition partition_info[] = { |
71 | { | 71 | { |
72 | .name = "SPIA flash partition 1", | 72 | .name = "SPIA flash partition 1", |
73 | .offset = 0, | 73 | .offset = 0, |
74 | .size = 2*1024*1024 | 74 | .size = 2 * 1024 * 1024}, |
75 | }, | ||
76 | { | 75 | { |
77 | .name = "SPIA flash partition 2", | 76 | .name = "SPIA flash partition 2", |
78 | .offset = 2*1024*1024, | 77 | .offset = 2 * 1024 * 1024, |
79 | .size = 6*1024*1024 | 78 | .size = 6 * 1024 * 1024} |
80 | } | ||
81 | }; | 79 | }; |
82 | #define NUM_PARTITIONS 2 | ||
83 | 80 | ||
81 | #define NUM_PARTITIONS 2 | ||
84 | 82 | ||
85 | /* | 83 | /* |
86 | * hardware specific access to control-lines | 84 | * hardware specific access to control-lines |
87 | */ | 85 | */ |
88 | static void spia_hwcontrol(struct mtd_info *mtd, int cmd){ | 86 | static void spia_hwcontrol(struct mtd_info *mtd, int cmd) |
89 | 87 | { | |
90 | switch(cmd){ | 88 | switch (cmd) { |
91 | 89 | ||
92 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x01; break; | 90 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x01; break; |
93 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x01; break; | 91 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x01; break; |
@@ -97,30 +95,29 @@ static void spia_hwcontrol(struct mtd_info *mtd, int cmd){ | |||
97 | 95 | ||
98 | case NAND_CTL_SETNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x04; break; | 96 | case NAND_CTL_SETNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x04; break; |
99 | case NAND_CTL_CLRNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x04; break; | 97 | case NAND_CTL_CLRNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x04; break; |
100 | } | 98 | } |
101 | } | 99 | } |
102 | 100 | ||
103 | /* | 101 | /* |
104 | * Main initialization routine | 102 | * Main initialization routine |
105 | */ | 103 | */ |
106 | int __init spia_init (void) | 104 | int __init spia_init(void) |
107 | { | 105 | { |
108 | struct nand_chip *this; | 106 | struct nand_chip *this; |
109 | 107 | ||
110 | /* Allocate memory for MTD device structure and private data */ | 108 | /* Allocate memory for MTD device structure and private data */ |
111 | spia_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), | 109 | spia_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
112 | GFP_KERNEL); | ||
113 | if (!spia_mtd) { | 110 | if (!spia_mtd) { |
114 | printk ("Unable to allocate SPIA NAND MTD device structure.\n"); | 111 | printk("Unable to allocate SPIA NAND MTD device structure.\n"); |
115 | return -ENOMEM; | 112 | return -ENOMEM; |
116 | } | 113 | } |
117 | 114 | ||
118 | /* Get pointer to private data */ | 115 | /* Get pointer to private data */ |
119 | this = (struct nand_chip *) (&spia_mtd[1]); | 116 | this = (struct nand_chip *)(&spia_mtd[1]); |
120 | 117 | ||
121 | /* Initialize structures */ | 118 | /* Initialize structures */ |
122 | memset((char *) spia_mtd, 0, sizeof(struct mtd_info)); | 119 | memset(spia_mtd, 0, sizeof(struct mtd_info)); |
123 | memset((char *) this, 0, sizeof(struct nand_chip)); | 120 | memset(this, 0, sizeof(struct nand_chip)); |
124 | 121 | ||
125 | /* Link the private data with the MTD structure */ | 122 | /* Link the private data with the MTD structure */ |
126 | spia_mtd->priv = this; | 123 | spia_mtd->priv = this; |
@@ -129,19 +126,19 @@ int __init spia_init (void) | |||
129 | * Set GPIO Port E control register so that the pins are configured | 126 | * Set GPIO Port E control register so that the pins are configured |
130 | * to be outputs for controlling the NAND flash. | 127 | * to be outputs for controlling the NAND flash. |
131 | */ | 128 | */ |
132 | (*(volatile unsigned char *) (spia_io_base + spia_peddr)) = 0x07; | 129 | (*(volatile unsigned char *)(spia_io_base + spia_peddr)) = 0x07; |
133 | 130 | ||
134 | /* Set address of NAND IO lines */ | 131 | /* Set address of NAND IO lines */ |
135 | this->IO_ADDR_R = (void __iomem *) spia_fio_base; | 132 | this->IO_ADDR_R = (void __iomem *)spia_fio_base; |
136 | this->IO_ADDR_W = (void __iomem *) spia_fio_base; | 133 | this->IO_ADDR_W = (void __iomem *)spia_fio_base; |
137 | /* Set address of hardware control function */ | 134 | /* Set address of hardware control function */ |
138 | this->hwcontrol = spia_hwcontrol; | 135 | this->hwcontrol = spia_hwcontrol; |
139 | /* 15 us command delay time */ | 136 | /* 15 us command delay time */ |
140 | this->chip_delay = 15; | 137 | this->chip_delay = 15; |
141 | 138 | ||
142 | /* Scan to find existence of the device */ | 139 | /* Scan to find existence of the device */ |
143 | if (nand_scan (spia_mtd, 1)) { | 140 | if (nand_scan(spia_mtd, 1)) { |
144 | kfree (spia_mtd); | 141 | kfree(spia_mtd); |
145 | return -ENXIO; | 142 | return -ENXIO; |
146 | } | 143 | } |
147 | 144 | ||
@@ -151,20 +148,22 @@ int __init spia_init (void) | |||
151 | /* Return happy */ | 148 | /* Return happy */ |
152 | return 0; | 149 | return 0; |
153 | } | 150 | } |
151 | |||
154 | module_init(spia_init); | 152 | module_init(spia_init); |
155 | 153 | ||
156 | /* | 154 | /* |
157 | * Clean up routine | 155 | * Clean up routine |
158 | */ | 156 | */ |
159 | #ifdef MODULE | 157 | #ifdef MODULE |
160 | static void __exit spia_cleanup (void) | 158 | static void __exit spia_cleanup(void) |
161 | { | 159 | { |
162 | /* Release resources, unregister device */ | 160 | /* Release resources, unregister device */ |
163 | nand_release (spia_mtd); | 161 | nand_release(spia_mtd); |
164 | 162 | ||
165 | /* Free the MTD device structure */ | 163 | /* Free the MTD device structure */ |
166 | kfree (spia_mtd); | 164 | kfree(spia_mtd); |
167 | } | 165 | } |
166 | |||
168 | module_exit(spia_cleanup); | 167 | module_exit(spia_cleanup); |
169 | #endif | 168 | #endif |
170 | 169 | ||
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c index 7609c43cb3ec..e3a90e60e249 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[] = { | |||
98 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd) | 98 | static 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,32 +109,31 @@ 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 | */ |
119 | int __init toto_init (void) | 118 | 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; |
@@ -149,33 +147,37 @@ int __init toto_init (void) | |||
149 | this->chip_delay = 30; | 147 | this->chip_delay = 30; |
150 | this->eccmode = NAND_ECC_SOFT; | 148 | this->eccmode = NAND_ECC_SOFT; |
151 | 149 | ||
152 | /* Scan to find existance of the device */ | 150 | /* Scan to find existance of the device */ |
153 | if (nand_scan (toto_mtd, 1)) { | 151 | if (nand_scan(toto_mtd, 1)) { |
154 | err = -ENXIO; | 152 | err = -ENXIO; |
155 | goto out_mtd; | 153 | goto out_mtd; |
156 | } | 154 | } |
157 | 155 | ||
158 | /* Register the partitions */ | 156 | /* Register the partitions */ |
159 | switch(toto_mtd->size){ | 157 | switch (toto_mtd->size) { |
160 | case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break; | 158 | case SZ_64M: |
161 | case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break; | 159 | add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); |
162 | default: { | 160 | break; |
163 | printk (KERN_WARNING "Unsupported Nand device\n"); | 161 | case SZ_32M: |
162 | add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); | ||
163 | break; | ||
164 | default:{ | ||
165 | printk(KERN_WARNING "Unsupported Nand device\n"); | ||
164 | err = -ENXIO; | 166 | err = -ENXIO; |
165 | goto out_buf; | 167 | goto out_buf; |
166 | } | 168 | } |
167 | } | 169 | } |
168 | 170 | ||
169 | gpioreserve(NAND_MASK); /* claim our gpios */ | 171 | gpioreserve(NAND_MASK); /* claim our gpios */ |
170 | archflashwp(0,0); /* open up flash for writing */ | 172 | archflashwp(0, 0); /* open up flash for writing */ |
171 | 173 | ||
172 | goto out; | 174 | goto out; |
173 | 175 | ||
174 | out_buf: | 176 | out_buf: |
175 | kfree (this->data_buf); | 177 | kfree(this->data_buf); |
176 | out_mtd: | 178 | out_mtd: |
177 | kfree (toto_mtd); | 179 | kfree(toto_mtd); |
178 | out: | 180 | out: |
179 | return err; | 181 | return err; |
180 | } | 182 | } |
181 | 183 | ||
@@ -184,20 +186,21 @@ module_init(toto_init); | |||
184 | /* | 186 | /* |
185 | * Clean up routine | 187 | * Clean up routine |
186 | */ | 188 | */ |
187 | static void __exit toto_cleanup (void) | 189 | static void __exit toto_cleanup(void) |
188 | { | 190 | { |
189 | /* Release resources, unregister device */ | 191 | /* Release resources, unregister device */ |
190 | nand_release (toto_mtd); | 192 | nand_release(toto_mtd); |
191 | 193 | ||
192 | /* Free the MTD device structure */ | 194 | /* Free the MTD device structure */ |
193 | kfree (toto_mtd); | 195 | kfree(toto_mtd); |
194 | 196 | ||
195 | /* stop flash writes */ | 197 | /* stop flash writes */ |
196 | archflashwp(0,1); | 198 | archflashwp(0, 1); |
197 | 199 | ||
198 | /* release gpios to system */ | 200 | /* release gpios to system */ |
199 | gpiorelease(NAND_MASK); | 201 | gpiorelease(NAND_MASK); |
200 | } | 202 | } |
203 | |||
201 | module_exit(toto_cleanup); | 204 | module_exit(toto_cleanup); |
202 | 205 | ||
203 | MODULE_LICENSE("GPL"); | 206 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c index 643633d91a8b..d2b7d57ace42 100644 --- a/drivers/mtd/nand/ts7250.c +++ b/drivers/mtd/nand/ts7250.c | |||
@@ -88,7 +88,7 @@ static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd) | |||
88 | { | 88 | { |
89 | unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE; | 89 | unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE; |
90 | 90 | ||
91 | switch(cmd) { | 91 | switch (cmd) { |
92 | case NAND_CTL_SETCLE: | 92 | case NAND_CTL_SETCLE: |
93 | __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl); | 93 | __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl); |
94 | break; | 94 | break; |
@@ -132,8 +132,7 @@ static int __init ts7250_init(void) | |||
132 | return -ENXIO; | 132 | return -ENXIO; |
133 | 133 | ||
134 | /* Allocate memory for MTD device structure and private data */ | 134 | /* Allocate memory for MTD device structure and private data */ |
135 | ts7250_mtd = kmalloc(sizeof(struct mtd_info) + | 135 | ts7250_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
136 | sizeof(struct nand_chip), GFP_KERNEL); | ||
137 | if (!ts7250_mtd) { | 136 | if (!ts7250_mtd) { |
138 | printk("Unable to allocate TS7250 NAND MTD device structure.\n"); | 137 | printk("Unable to allocate TS7250 NAND MTD device structure.\n"); |
139 | return -ENOMEM; | 138 | return -ENOMEM; |
@@ -163,11 +162,9 @@ static int __init ts7250_init(void) | |||
163 | kfree(ts7250_mtd); | 162 | kfree(ts7250_mtd); |
164 | return -ENXIO; | 163 | return -ENXIO; |
165 | } | 164 | } |
166 | |||
167 | #ifdef CONFIG_MTD_PARTITIONS | 165 | #ifdef CONFIG_MTD_PARTITIONS |
168 | ts7250_mtd->name = "ts7250-nand"; | 166 | ts7250_mtd->name = "ts7250-nand"; |
169 | mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, | 167 | mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, &mtd_parts, 0); |
170 | &mtd_parts, 0); | ||
171 | if (mtd_parts_nb > 0) | 168 | if (mtd_parts_nb > 0) |
172 | part_type = "command line"; | 169 | part_type = "command line"; |
173 | else | 170 | else |
@@ -188,6 +185,7 @@ static int __init ts7250_init(void) | |||
188 | /* Return happy */ | 185 | /* Return happy */ |
189 | return 0; | 186 | return 0; |
190 | } | 187 | } |
188 | |||
191 | module_init(ts7250_init); | 189 | module_init(ts7250_init); |
192 | 190 | ||
193 | /* | 191 | /* |
@@ -201,6 +199,7 @@ static void __exit ts7250_cleanup(void) | |||
201 | /* Free the MTD device structure */ | 199 | /* Free the MTD device structure */ |
202 | kfree(ts7250_mtd); | 200 | kfree(ts7250_mtd); |
203 | } | 201 | } |
202 | |||
204 | module_exit(ts7250_cleanup); | 203 | module_exit(ts7250_cleanup); |
205 | 204 | ||
206 | MODULE_LICENSE("GPL"); | 205 | MODULE_LICENSE("GPL"); |