aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips/cfi_cmdset_0001.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/chips/cfi_cmdset_0001.c')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c150
1 files changed, 75 insertions, 75 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 61a2ec9901e2..e3a5c5d331b4 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,9 +4,9 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0001.c,v 1.184 2005/10/25 20:28:40 nico Exp $ 7 * $Id: cfi_cmdset_0001.c,v 1.185 2005/11/07 11:14:22 gleixner Exp $
8 *
8 * 9 *
9 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 10 * 10/10/2000 Nicolas Pitre <nico@cam.org>
11 * - completely revamped method functions so they are aware and 11 * - completely revamped method functions so they are aware and
12 * independent of the flash geometry (buswidth, interleave, etc.) 12 * independent of the flash geometry (buswidth, interleave, etc.)
@@ -120,17 +120,17 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
120 printk(" - Simultaneous operations: %s\n", extp->FeatureSupport&512?"supported":"unsupported"); 120 printk(" - Simultaneous operations: %s\n", extp->FeatureSupport&512?"supported":"unsupported");
121 printk(" - Extended Flash Array: %s\n", extp->FeatureSupport&1024?"supported":"unsupported"); 121 printk(" - Extended Flash Array: %s\n", extp->FeatureSupport&1024?"supported":"unsupported");
122 for (i=11; i<32; i++) { 122 for (i=11; i<32; i++) {
123 if (extp->FeatureSupport & (1<<i)) 123 if (extp->FeatureSupport & (1<<i))
124 printk(" - Unknown Bit %X: supported\n", i); 124 printk(" - Unknown Bit %X: supported\n", i);
125 } 125 }
126 126
127 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport); 127 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport);
128 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported"); 128 printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported");
129 for (i=1; i<8; i++) { 129 for (i=1; i<8; i++) {
130 if (extp->SuspendCmdSupport & (1<<i)) 130 if (extp->SuspendCmdSupport & (1<<i))
131 printk(" - Unknown Bit %X: supported\n", i); 131 printk(" - Unknown Bit %X: supported\n", i);
132 } 132 }
133 133
134 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask); 134 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask);
135 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no"); 135 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no");
136 printk(" - Lock-Down Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no"); 136 printk(" - Lock-Down Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no");
@@ -145,16 +145,16 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
145 printk(" - Unknown Bit %X Active: yes\n",i); 145 printk(" - Unknown Bit %X Active: yes\n",i);
146 } 146 }
147 147
148 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n", 148 printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n",
149 extp->VccOptimal >> 4, extp->VccOptimal & 0xf); 149 extp->VccOptimal >> 4, extp->VccOptimal & 0xf);
150 if (extp->VppOptimal) 150 if (extp->VppOptimal)
151 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n", 151 printk(" Vpp Programming Supply Optimum Program/Erase Voltage: %d.%d V\n",
152 extp->VppOptimal >> 4, extp->VppOptimal & 0xf); 152 extp->VppOptimal >> 4, extp->VppOptimal & 0xf);
153} 153}
154#endif 154#endif
155 155
156#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE 156#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
157/* Some Intel Strata Flash prior to FPO revision C has bugs in this area */ 157/* Some Intel Strata Flash prior to FPO revision C has bugs in this area */
158static void fixup_intel_strataflash(struct mtd_info *mtd, void* param) 158static void fixup_intel_strataflash(struct mtd_info *mtd, void* param)
159{ 159{
160 struct map_info *map = mtd->priv; 160 struct map_info *map = mtd->priv;
@@ -185,7 +185,7 @@ static void fixup_st_m28w320ct(struct mtd_info *mtd, void* param)
185{ 185{
186 struct map_info *map = mtd->priv; 186 struct map_info *map = mtd->priv;
187 struct cfi_private *cfi = map->fldrv_priv; 187 struct cfi_private *cfi = map->fldrv_priv;
188 188
189 cfi->cfiq->BufWriteTimeoutTyp = 0; /* Not supported */ 189 cfi->cfiq->BufWriteTimeoutTyp = 0; /* Not supported */
190 cfi->cfiq->BufWriteTimeoutMax = 0; /* Not supported */ 190 cfi->cfiq->BufWriteTimeoutMax = 0; /* Not supported */
191} 191}
@@ -194,7 +194,7 @@ static void fixup_st_m28w320cb(struct mtd_info *mtd, void* param)
194{ 194{
195 struct map_info *map = mtd->priv; 195 struct map_info *map = mtd->priv;
196 struct cfi_private *cfi = map->fldrv_priv; 196 struct cfi_private *cfi = map->fldrv_priv;
197 197
198 /* Note this is done after the region info is endian swapped */ 198 /* Note this is done after the region info is endian swapped */
199 cfi->cfiq->EraseRegionInfo[1] = 199 cfi->cfiq->EraseRegionInfo[1] =
200 (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e; 200 (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e;
@@ -222,7 +222,7 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
222 222
223static struct cfi_fixup cfi_fixup_table[] = { 223static struct cfi_fixup cfi_fixup_table[] = {
224#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE 224#ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
225 { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL }, 225 { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL },
226#endif 226#endif
227#ifdef CMDSET0001_DISABLE_WRITE_SUSPEND 227#ifdef CMDSET0001_DISABLE_WRITE_SUSPEND
228 { CFI_MFR_ANY, CFI_ID_ANY, fixup_no_write_suspend, NULL }, 228 { CFI_MFR_ANY, CFI_ID_ANY, fixup_no_write_suspend, NULL },
@@ -327,7 +327,7 @@ read_pri_intelext(struct map_info *map, __u16 adr)
327 goto again; 327 goto again;
328 } 328 }
329 } 329 }
330 330
331 return extp; 331 return extp;
332} 332}
333 333
@@ -368,7 +368,7 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
368 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; 368 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot;
369 369
370 if (cfi->cfi_mode == CFI_MODE_CFI) { 370 if (cfi->cfi_mode == CFI_MODE_CFI) {
371 /* 371 /*
372 * It's a real CFI chip, not one for which the probe 372 * It's a real CFI chip, not one for which the probe
373 * routine faked a CFI structure. So we read the feature 373 * routine faked a CFI structure. So we read the feature
374 * table from it. 374 * table from it.
@@ -383,14 +383,14 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
383 } 383 }
384 384
385 /* Install our own private info structure */ 385 /* Install our own private info structure */
386 cfi->cmdset_priv = extp; 386 cfi->cmdset_priv = extp;
387 387
388 cfi_fixup(mtd, cfi_fixup_table); 388 cfi_fixup(mtd, cfi_fixup_table);
389 389
390#ifdef DEBUG_CFI_FEATURES 390#ifdef DEBUG_CFI_FEATURES
391 /* Tell the user about it in lots of lovely detail */ 391 /* Tell the user about it in lots of lovely detail */
392 cfi_tell_features(extp); 392 cfi_tell_features(extp);
393#endif 393#endif
394 394
395 if(extp->SuspendCmdSupport & 1) { 395 if(extp->SuspendCmdSupport & 1) {
396 printk(KERN_NOTICE "cfi_cmdset_0001: Erase suspend on write enabled\n"); 396 printk(KERN_NOTICE "cfi_cmdset_0001: Erase suspend on write enabled\n");
@@ -408,10 +408,10 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
408 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; 408 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
409 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; 409 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
410 cfi->chips[i].ref_point_counter = 0; 410 cfi->chips[i].ref_point_counter = 0;
411 } 411 }
412 412
413 map->fldrv = &cfi_intelext_chipdrv; 413 map->fldrv = &cfi_intelext_chipdrv;
414 414
415 return cfi_intelext_setup(mtd); 415 return cfi_intelext_setup(mtd);
416} 416}
417 417
@@ -428,13 +428,13 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
428 mtd->size = devsize * cfi->numchips; 428 mtd->size = devsize * cfi->numchips;
429 429
430 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; 430 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
431 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) 431 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
432 * mtd->numeraseregions, GFP_KERNEL); 432 * mtd->numeraseregions, GFP_KERNEL);
433 if (!mtd->eraseregions) { 433 if (!mtd->eraseregions) {
434 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n"); 434 printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
435 goto setup_err; 435 goto setup_err;
436 } 436 }
437 437
438 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 438 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
439 unsigned long ernum, ersize; 439 unsigned long ernum, ersize;
440 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; 440 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
@@ -701,7 +701,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
701 break; 701 break;
702 702
703 if (time_after(jiffies, timeo)) { 703 if (time_after(jiffies, timeo)) {
704 printk(KERN_ERR "%s: Waiting for chip to be ready timed out. Status %lx\n", 704 printk(KERN_ERR "%s: Waiting for chip to be ready timed out. Status %lx\n",
705 map->name, status.x[0]); 705 map->name, status.x[0]);
706 return -EIO; 706 return -EIO;
707 } 707 }
@@ -711,7 +711,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
711 /* Someone else might have been playing with it. */ 711 /* Someone else might have been playing with it. */
712 goto retry; 712 goto retry;
713 } 713 }
714 714
715 case FL_READY: 715 case FL_READY:
716 case FL_CFI_QUERY: 716 case FL_CFI_QUERY:
717 case FL_JEDEC_QUERY: 717 case FL_JEDEC_QUERY:
@@ -830,14 +830,14 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
830 switch(chip->oldstate) { 830 switch(chip->oldstate) {
831 case FL_ERASING: 831 case FL_ERASING:
832 chip->state = chip->oldstate; 832 chip->state = chip->oldstate;
833 /* What if one interleaved chip has finished and the 833 /* What if one interleaved chip has finished and the
834 other hasn't? The old code would leave the finished 834 other hasn't? The old code would leave the finished
835 one in READY mode. That's bad, and caused -EROFS 835 one in READY mode. That's bad, and caused -EROFS
836 errors to be returned from do_erase_oneblock because 836 errors to be returned from do_erase_oneblock because
837 that's the only bit it checked for at the time. 837 that's the only bit it checked for at the time.
838 As the state machine appears to explicitly allow 838 As the state machine appears to explicitly allow
839 sending the 0x70 (Read Status) command to an erasing 839 sending the 0x70 (Read Status) command to an erasing
840 chip and expecting it to be ignored, that's what we 840 chip and expecting it to be ignored, that's what we
841 do. */ 841 do. */
842 map_write(map, CMD(0xd0), adr); 842 map_write(map, CMD(0xd0), adr);
843 map_write(map, CMD(0x70), adr); 843 map_write(map, CMD(0x70), adr);
@@ -1073,8 +1073,8 @@ static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t a
1073 1073
1074 adr += chip->start; 1074 adr += chip->start;
1075 1075
1076 /* Ensure cmd read/writes are aligned. */ 1076 /* Ensure cmd read/writes are aligned. */
1077 cmd_addr = adr & ~(map_bankwidth(map)-1); 1077 cmd_addr = adr & ~(map_bankwidth(map)-1);
1078 1078
1079 spin_lock(chip->mutex); 1079 spin_lock(chip->mutex);
1080 1080
@@ -1102,7 +1102,7 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, si
1102 1102
1103 if (!map->virt || (from + len > mtd->size)) 1103 if (!map->virt || (from + len > mtd->size))
1104 return -EINVAL; 1104 return -EINVAL;
1105 1105
1106 *mtdbuf = (void *)map->virt + from; 1106 *mtdbuf = (void *)map->virt + from;
1107 *retlen = 0; 1107 *retlen = 0;
1108 1108
@@ -1129,7 +1129,7 @@ static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, si
1129 1129
1130 *retlen += thislen; 1130 *retlen += thislen;
1131 len -= thislen; 1131 len -= thislen;
1132 1132
1133 ofs = 0; 1133 ofs = 0;
1134 chipnum++; 1134 chipnum++;
1135 } 1135 }
@@ -1187,8 +1187,8 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
1187 1187
1188 adr += chip->start; 1188 adr += chip->start;
1189 1189
1190 /* Ensure cmd read/writes are aligned. */ 1190 /* Ensure cmd read/writes are aligned. */
1191 cmd_addr = adr & ~(map_bankwidth(map)-1); 1191 cmd_addr = adr & ~(map_bankwidth(map)-1);
1192 1192
1193 spin_lock(chip->mutex); 1193 spin_lock(chip->mutex);
1194 ret = get_chip(map, chip, cmd_addr, FL_READY); 1194 ret = get_chip(map, chip, cmd_addr, FL_READY);
@@ -1243,7 +1243,7 @@ static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, siz
1243 *retlen += thislen; 1243 *retlen += thislen;
1244 len -= thislen; 1244 len -= thislen;
1245 buf += thislen; 1245 buf += thislen;
1246 1246
1247 ofs = 0; 1247 ofs = 0;
1248 chipnum++; 1248 chipnum++;
1249 } 1249 }
@@ -1311,7 +1311,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1311 status = map_read(map, adr); 1311 status = map_read(map, adr);
1312 if (map_word_andequal(map, status, status_OK, status_OK)) 1312 if (map_word_andequal(map, status, status_OK, status_OK))
1313 break; 1313 break;
1314 1314
1315 /* OK Still waiting */ 1315 /* OK Still waiting */
1316 if (time_after(jiffies, timeo)) { 1316 if (time_after(jiffies, timeo)) {
1317 map_write(map, CMD(0x70), adr); 1317 map_write(map, CMD(0x70), adr);
@@ -1331,7 +1331,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1331 if (!chip->word_write_time) 1331 if (!chip->word_write_time)
1332 chip->word_write_time = 1; 1332 chip->word_write_time = 1;
1333 } 1333 }
1334 if (z > 1) 1334 if (z > 1)
1335 chip->word_write_time++; 1335 chip->word_write_time++;
1336 1336
1337 /* Done and happy. */ 1337 /* Done and happy. */
@@ -1394,7 +1394,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1394 1394
1395 ret = do_write_oneword(map, &cfi->chips[chipnum], 1395 ret = do_write_oneword(map, &cfi->chips[chipnum],
1396 bus_ofs, datum, FL_WRITING); 1396 bus_ofs, datum, FL_WRITING);
1397 if (ret) 1397 if (ret)
1398 return ret; 1398 return ret;
1399 1399
1400 len -= n; 1400 len -= n;
@@ -1403,13 +1403,13 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1403 (*retlen) += n; 1403 (*retlen) += n;
1404 1404
1405 if (ofs >> cfi->chipshift) { 1405 if (ofs >> cfi->chipshift) {
1406 chipnum ++; 1406 chipnum ++;
1407 ofs = 0; 1407 ofs = 0;
1408 if (chipnum == cfi->numchips) 1408 if (chipnum == cfi->numchips)
1409 return 0; 1409 return 0;
1410 } 1410 }
1411 } 1411 }
1412 1412
1413 while(len >= map_bankwidth(map)) { 1413 while(len >= map_bankwidth(map)) {
1414 map_word datum = map_word_load(map, buf); 1414 map_word datum = map_word_load(map, buf);
1415 1415
@@ -1424,7 +1424,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1424 len -= map_bankwidth(map); 1424 len -= map_bankwidth(map);
1425 1425
1426 if (ofs >> cfi->chipshift) { 1426 if (ofs >> cfi->chipshift) {
1427 chipnum ++; 1427 chipnum ++;
1428 ofs = 0; 1428 ofs = 0;
1429 if (chipnum == cfi->numchips) 1429 if (chipnum == cfi->numchips)
1430 return 0; 1430 return 0;
@@ -1439,9 +1439,9 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1439 1439
1440 ret = do_write_oneword(map, &cfi->chips[chipnum], 1440 ret = do_write_oneword(map, &cfi->chips[chipnum],
1441 ofs, datum, FL_WRITING); 1441 ofs, datum, FL_WRITING);
1442 if (ret) 1442 if (ret)
1443 return ret; 1443 return ret;
1444 1444
1445 (*retlen) += len; 1445 (*retlen) += len;
1446 } 1446 }
1447 1447
@@ -1449,7 +1449,7 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1449} 1449}
1450 1450
1451 1451
1452static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, 1452static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1453 unsigned long adr, const struct kvec **pvec, 1453 unsigned long adr, const struct kvec **pvec,
1454 unsigned long *pvec_seek, int len) 1454 unsigned long *pvec_seek, int len)
1455{ 1455{
@@ -1480,7 +1480,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1480 xip_disable(map, chip, cmd_adr); 1480 xip_disable(map, chip, cmd_adr);
1481 1481
1482 /* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set 1482 /* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set
1483 [...], the device will not accept any more Write to Buffer commands". 1483 [...], the device will not accept any more Write to Buffer commands".
1484 So we must check here and reset those bits if they're set. Otherwise 1484 So we must check here and reset those bits if they're set. Otherwise
1485 we're just pissing in the wind */ 1485 we're just pissing in the wind */
1486 if (chip->state != FL_STATUS) 1486 if (chip->state != FL_STATUS)
@@ -1549,9 +1549,9 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1549 1549
1550 if (!word_gap && len < map_bankwidth(map)) 1550 if (!word_gap && len < map_bankwidth(map))
1551 datum = map_word_ff(map); 1551 datum = map_word_ff(map);
1552 1552
1553 datum = map_word_load_partial(map, datum, 1553 datum = map_word_load_partial(map, datum,
1554 vec->iov_base + vec_seek, 1554 vec->iov_base + vec_seek,
1555 word_gap, n); 1555 word_gap, n);
1556 1556
1557 len -= n; 1557 len -= n;
@@ -1575,7 +1575,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1575 map_write(map, CMD(0xd0), cmd_adr); 1575 map_write(map, CMD(0xd0), cmd_adr);
1576 chip->state = FL_WRITING; 1576 chip->state = FL_WRITING;
1577 1577
1578 INVALIDATE_CACHE_UDELAY(map, chip, 1578 INVALIDATE_CACHE_UDELAY(map, chip,
1579 cmd_adr, len, 1579 cmd_adr, len,
1580 chip->buffer_write_time); 1580 chip->buffer_write_time);
1581 1581
@@ -1608,7 +1608,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1608 ret = -EIO; 1608 ret = -EIO;
1609 goto out; 1609 goto out;
1610 } 1610 }
1611 1611
1612 /* Latency issues. Drop the lock, wait a while and retry */ 1612 /* Latency issues. Drop the lock, wait a while and retry */
1613 z++; 1613 z++;
1614 UDELAY(map, chip, cmd_adr, 1); 1614 UDELAY(map, chip, cmd_adr, 1);
@@ -1618,7 +1618,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1618 if (!chip->buffer_write_time) 1618 if (!chip->buffer_write_time)
1619 chip->buffer_write_time = 1; 1619 chip->buffer_write_time = 1;
1620 } 1620 }
1621 if (z > 1) 1621 if (z > 1)
1622 chip->buffer_write_time++; 1622 chip->buffer_write_time++;
1623 1623
1624 /* Done and happy. */ 1624 /* Done and happy. */
@@ -1680,7 +1680,7 @@ static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs,
1680 1680
1681 if (size > len) 1681 if (size > len)
1682 size = len; 1682 size = len;
1683 ret = do_write_buffer(map, &cfi->chips[chipnum], 1683 ret = do_write_buffer(map, &cfi->chips[chipnum],
1684 ofs, &vecs, &vec_seek, size); 1684 ofs, &vecs, &vec_seek, size);
1685 if (ret) 1685 if (ret)
1686 return ret; 1686 return ret;
@@ -1690,7 +1690,7 @@ static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs,
1690 len -= size; 1690 len -= size;
1691 1691
1692 if (ofs >> cfi->chipshift) { 1692 if (ofs >> cfi->chipshift) {
1693 chipnum ++; 1693 chipnum ++;
1694 ofs = 0; 1694 ofs = 0;
1695 if (chipnum == cfi->numchips) 1695 if (chipnum == cfi->numchips)
1696 return 0; 1696 return 0;
@@ -1776,7 +1776,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1776 status = map_read(map, adr); 1776 status = map_read(map, adr);
1777 if (map_word_andequal(map, status, status_OK, status_OK)) 1777 if (map_word_andequal(map, status, status_OK, status_OK))
1778 break; 1778 break;
1779 1779
1780 /* OK Still waiting */ 1780 /* OK Still waiting */
1781 if (time_after(jiffies, timeo)) { 1781 if (time_after(jiffies, timeo)) {
1782 map_write(map, CMD(0x70), adr); 1782 map_write(map, CMD(0x70), adr);
@@ -1786,7 +1786,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1786 ret = -EIO; 1786 ret = -EIO;
1787 goto out; 1787 goto out;
1788 } 1788 }
1789 1789
1790 /* Latency issues. Drop the lock, wait a while and retry */ 1790 /* Latency issues. Drop the lock, wait a while and retry */
1791 UDELAY(map, chip, adr, 1000000/HZ); 1791 UDELAY(map, chip, adr, 1000000/HZ);
1792 } 1792 }
@@ -1849,7 +1849,7 @@ int cfi_intelext_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
1849 1849
1850 instr->state = MTD_ERASE_DONE; 1850 instr->state = MTD_ERASE_DONE;
1851 mtd_erase_callback(instr); 1851 mtd_erase_callback(instr);
1852 1852
1853 return 0; 1853 return 0;
1854} 1854}
1855 1855
@@ -1870,7 +1870,7 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
1870 if (!ret) { 1870 if (!ret) {
1871 chip->oldstate = chip->state; 1871 chip->oldstate = chip->state;
1872 chip->state = FL_SYNCING; 1872 chip->state = FL_SYNCING;
1873 /* No need to wake_up() on this state change - 1873 /* No need to wake_up() on this state change -
1874 * as the whole point is that nobody can do anything 1874 * as the whole point is that nobody can do anything
1875 * with the chip now anyway. 1875 * with the chip now anyway.
1876 */ 1876 */
@@ -1884,7 +1884,7 @@ static void cfi_intelext_sync (struct mtd_info *mtd)
1884 chip = &cfi->chips[i]; 1884 chip = &cfi->chips[i];
1885 1885
1886 spin_lock(chip->mutex); 1886 spin_lock(chip->mutex);
1887 1887
1888 if (chip->state == FL_SYNCING) { 1888 if (chip->state == FL_SYNCING) {
1889 chip->state = chip->oldstate; 1889 chip->state = chip->oldstate;
1890 chip->oldstate = FL_READY; 1890 chip->oldstate = FL_READY;
@@ -1941,7 +1941,7 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1941 1941
1942 ENABLE_VPP(map); 1942 ENABLE_VPP(map);
1943 xip_disable(map, chip, adr); 1943 xip_disable(map, chip, adr);
1944 1944
1945 map_write(map, CMD(0x60), adr); 1945 map_write(map, CMD(0x60), adr);
1946 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) { 1946 if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) {
1947 map_write(map, CMD(0x01), adr); 1947 map_write(map, CMD(0x01), adr);
@@ -1969,7 +1969,7 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1969 status = map_read(map, adr); 1969 status = map_read(map, adr);
1970 if (map_word_andequal(map, status, status_OK, status_OK)) 1970 if (map_word_andequal(map, status, status_OK, status_OK))
1971 break; 1971 break;
1972 1972
1973 /* OK Still waiting */ 1973 /* OK Still waiting */
1974 if (time_after(jiffies, timeo)) { 1974 if (time_after(jiffies, timeo)) {
1975 map_write(map, CMD(0x70), adr); 1975 map_write(map, CMD(0x70), adr);
@@ -1980,11 +1980,11 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
1980 spin_unlock(chip->mutex); 1980 spin_unlock(chip->mutex);
1981 return -EIO; 1981 return -EIO;
1982 } 1982 }
1983 1983
1984 /* Latency issues. Drop the lock, wait a while and retry */ 1984 /* Latency issues. Drop the lock, wait a while and retry */
1985 UDELAY(map, chip, adr, 1); 1985 UDELAY(map, chip, adr, 1);
1986 } 1986 }
1987 1987
1988 /* Done and happy. */ 1988 /* Done and happy. */
1989 chip->state = FL_STATUS; 1989 chip->state = FL_STATUS;
1990 xip_enable(map, chip, adr); 1990 xip_enable(map, chip, adr);
@@ -2004,9 +2004,9 @@ static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
2004 ofs, len, 0); 2004 ofs, len, 0);
2005#endif 2005#endif
2006 2006
2007 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, 2007 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
2008 ofs, len, DO_XXLOCK_ONEBLOCK_LOCK); 2008 ofs, len, DO_XXLOCK_ONEBLOCK_LOCK);
2009 2009
2010#ifdef DEBUG_LOCK_BITS 2010#ifdef DEBUG_LOCK_BITS
2011 printk(KERN_DEBUG "%s: lock status after, ret=%d\n", 2011 printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
2012 __FUNCTION__, ret); 2012 __FUNCTION__, ret);
@@ -2030,20 +2030,20 @@ static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
2030 2030
2031 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock, 2031 ret = cfi_varsize_frob(mtd, do_xxlock_oneblock,
2032 ofs, len, DO_XXLOCK_ONEBLOCK_UNLOCK); 2032 ofs, len, DO_XXLOCK_ONEBLOCK_UNLOCK);
2033 2033
2034#ifdef DEBUG_LOCK_BITS 2034#ifdef DEBUG_LOCK_BITS
2035 printk(KERN_DEBUG "%s: lock status after, ret=%d\n", 2035 printk(KERN_DEBUG "%s: lock status after, ret=%d\n",
2036 __FUNCTION__, ret); 2036 __FUNCTION__, ret);
2037 cfi_varsize_frob(mtd, do_printlockstatus_oneblock, 2037 cfi_varsize_frob(mtd, do_printlockstatus_oneblock,
2038 ofs, len, 0); 2038 ofs, len, 0);
2039#endif 2039#endif
2040 2040
2041 return ret; 2041 return ret;
2042} 2042}
2043 2043
2044#ifdef CONFIG_MTD_OTP 2044#ifdef CONFIG_MTD_OTP
2045 2045
2046typedef int (*otp_op_t)(struct map_info *map, struct flchip *chip, 2046typedef int (*otp_op_t)(struct map_info *map, struct flchip *chip,
2047 u_long data_offset, u_char *buf, u_int size, 2047 u_long data_offset, u_char *buf, u_int size,
2048 u_long prot_offset, u_int groupno, u_int groupsize); 2048 u_long prot_offset, u_int groupno, u_int groupsize);
2049 2049
@@ -2094,7 +2094,7 @@ do_otp_write(struct map_info *map, struct flchip *chip, u_long offset,
2094 2094
2095 datum = map_word_load_partial(map, datum, buf, gap, n); 2095 datum = map_word_load_partial(map, datum, buf, gap, n);
2096 ret = do_write_oneword(map, chip, bus_ofs, datum, FL_OTP_WRITE); 2096 ret = do_write_oneword(map, chip, bus_ofs, datum, FL_OTP_WRITE);
2097 if (ret) 2097 if (ret)
2098 return ret; 2098 return ret;
2099 2099
2100 offset += n; 2100 offset += n;
@@ -2287,7 +2287,7 @@ static int cfi_intelext_lock_user_prot_reg(struct mtd_info *mtd,
2287 NULL, do_otp_lock, 1); 2287 NULL, do_otp_lock, 1);
2288} 2288}
2289 2289
2290static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd, 2290static int cfi_intelext_get_fact_prot_info(struct mtd_info *mtd,
2291 struct otp_info *buf, size_t len) 2291 struct otp_info *buf, size_t len)
2292{ 2292{
2293 size_t retlen; 2293 size_t retlen;
@@ -2330,7 +2330,7 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2330 if (chip->oldstate == FL_READY) { 2330 if (chip->oldstate == FL_READY) {
2331 chip->oldstate = chip->state; 2331 chip->oldstate = chip->state;
2332 chip->state = FL_PM_SUSPENDED; 2332 chip->state = FL_PM_SUSPENDED;
2333 /* No need to wake_up() on this state change - 2333 /* No need to wake_up() on this state change -
2334 * as the whole point is that nobody can do anything 2334 * as the whole point is that nobody can do anything
2335 * with the chip now anyway. 2335 * with the chip now anyway.
2336 */ 2336 */
@@ -2358,9 +2358,9 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2358 if (ret) { 2358 if (ret) {
2359 for (i--; i >=0; i--) { 2359 for (i--; i >=0; i--) {
2360 chip = &cfi->chips[i]; 2360 chip = &cfi->chips[i];
2361 2361
2362 spin_lock(chip->mutex); 2362 spin_lock(chip->mutex);
2363 2363
2364 if (chip->state == FL_PM_SUSPENDED) { 2364 if (chip->state == FL_PM_SUSPENDED) {
2365 /* No need to force it into a known state here, 2365 /* No need to force it into a known state here,
2366 because we're returning failure, and it didn't 2366 because we're returning failure, and it didn't
@@ -2371,8 +2371,8 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2371 } 2371 }
2372 spin_unlock(chip->mutex); 2372 spin_unlock(chip->mutex);
2373 } 2373 }
2374 } 2374 }
2375 2375
2376 return ret; 2376 return ret;
2377} 2377}
2378 2378
@@ -2384,11 +2384,11 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
2384 struct flchip *chip; 2384 struct flchip *chip;
2385 2385
2386 for (i=0; i<cfi->numchips; i++) { 2386 for (i=0; i<cfi->numchips; i++) {
2387 2387
2388 chip = &cfi->chips[i]; 2388 chip = &cfi->chips[i];
2389 2389
2390 spin_lock(chip->mutex); 2390 spin_lock(chip->mutex);
2391 2391
2392 /* Go to known state. Chip may have been power cycled */ 2392 /* Go to known state. Chip may have been power cycled */
2393 if (chip->state == FL_PM_SUSPENDED) { 2393 if (chip->state == FL_PM_SUSPENDED) {
2394 map_write(map, CMD(0xFF), cfi->chips[i].start); 2394 map_write(map, CMD(0xFF), cfi->chips[i].start);
@@ -2410,7 +2410,7 @@ static int cfi_intelext_reset(struct mtd_info *mtd)
2410 struct flchip *chip = &cfi->chips[i]; 2410 struct flchip *chip = &cfi->chips[i];
2411 2411
2412 /* force the completion of any ongoing operation 2412 /* force the completion of any ongoing operation
2413 and switch to array mode so any bootloader in 2413 and switch to array mode so any bootloader in
2414 flash is accessible for soft reboot. */ 2414 flash is accessible for soft reboot. */
2415 spin_lock(chip->mutex); 2415 spin_lock(chip->mutex);
2416 ret = get_chip(map, chip, chip->start, FL_SYNCING); 2416 ret = get_chip(map, chip, chip->start, FL_SYNCING);