aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips/cfi_cmdset_0002.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2005-11-07 06:15:37 -0500
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-07 08:45:15 -0500
commit1f948b43f7b5cf721cf0d03f507843efc1a9bfad (patch)
tree58f9f4b1baa374ee80f2641a44f87b361a628e6d /drivers/mtd/chips/cfi_cmdset_0002.c
parente4f0648fb400a05adb7c640ce8766a7011d472d3 (diff)
[MTD] chips: Clean up trailing white spaces
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/chips/cfi_cmdset_0002.c')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c130
1 files changed, 65 insertions, 65 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 50dd7d2f096d..88c5f5a34cb7 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -10,14 +10,14 @@
10 * 10 *
11 * 4_by_16 work by Carolyn J. Smith 11 * 4_by_16 work by Carolyn J. Smith
12 * 12 *
13 * XIP support hooks by Vitaly Wool (based on code for Intel flash 13 * XIP support hooks by Vitaly Wool (based on code for Intel flash
14 * by Nicolas Pitre) 14 * by Nicolas Pitre)
15 * 15 *
16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com 16 * Occasionally maintained by Thayne Harbaugh tharbaugh at lnxi dot com
17 * 17 *
18 * This code is GPL 18 * This code is GPL
19 * 19 *
20 * $Id: cfi_cmdset_0002.c,v 1.121 2005/11/07 09:00:01 gleixner Exp $ 20 * $Id: cfi_cmdset_0002.c,v 1.122 2005/11/07 11:14:22 gleixner Exp $
21 * 21 *
22 */ 22 */
23 23
@@ -93,7 +93,7 @@ static void cfi_tell_features(struct cfi_pri_amdstd *extp)
93 }; 93 };
94 94
95 printk(" Silicon revision: %d\n", extp->SiliconRevision >> 1); 95 printk(" Silicon revision: %d\n", extp->SiliconRevision >> 1);
96 printk(" Address sensitive unlock: %s\n", 96 printk(" Address sensitive unlock: %s\n",
97 (extp->SiliconRevision & 1) ? "Not required" : "Required"); 97 (extp->SiliconRevision & 1) ? "Not required" : "Required");
98 98
99 if (extp->EraseSuspend < ARRAY_SIZE(erase_suspend)) 99 if (extp->EraseSuspend < ARRAY_SIZE(erase_suspend))
@@ -118,9 +118,9 @@ static void cfi_tell_features(struct cfi_pri_amdstd *extp)
118 else 118 else
119 printk(" Page mode: %d word page\n", extp->PageMode << 2); 119 printk(" Page mode: %d word page\n", extp->PageMode << 2);
120 120
121 printk(" Vpp Supply Minimum Program/Erase Voltage: %d.%d V\n", 121 printk(" Vpp Supply Minimum Program/Erase Voltage: %d.%d V\n",
122 extp->VppMin >> 4, extp->VppMin & 0xf); 122 extp->VppMin >> 4, extp->VppMin & 0xf);
123 printk(" Vpp Supply Maximum Program/Erase Voltage: %d.%d V\n", 123 printk(" Vpp Supply Maximum Program/Erase Voltage: %d.%d V\n",
124 extp->VppMax >> 4, extp->VppMax & 0xf); 124 extp->VppMax >> 4, extp->VppMax & 0xf);
125 125
126 if (extp->TopBottom < ARRAY_SIZE(top_bottom)) 126 if (extp->TopBottom < ARRAY_SIZE(top_bottom))
@@ -177,7 +177,7 @@ static void fixup_use_erase_chip(struct mtd_info *mtd, void *param)
177 ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) { 177 ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) {
178 mtd->erase = cfi_amdstd_erase_chip; 178 mtd->erase = cfi_amdstd_erase_chip;
179 } 179 }
180 180
181} 181}
182 182
183static struct cfi_fixup cfi_fixup_table[] = { 183static struct cfi_fixup cfi_fixup_table[] = {
@@ -239,7 +239,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
239 239
240 if (cfi->cfi_mode==CFI_MODE_CFI){ 240 if (cfi->cfi_mode==CFI_MODE_CFI){
241 unsigned char bootloc; 241 unsigned char bootloc;
242 /* 242 /*
243 * It's a real CFI chip, not one for which the probe 243 * It's a real CFI chip, not one for which the probe
244 * routine faked a CFI structure. So we read the feature 244 * routine faked a CFI structure. So we read the feature
245 * table from it. 245 * table from it.
@@ -264,7 +264,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
264 } 264 }
265 265
266 /* Install our own private info structure */ 266 /* Install our own private info structure */
267 cfi->cmdset_priv = extp; 267 cfi->cmdset_priv = extp;
268 268
269 /* Apply cfi device specific fixups */ 269 /* Apply cfi device specific fixups */
270 cfi_fixup(mtd, cfi_fixup_table); 270 cfi_fixup(mtd, cfi_fixup_table);
@@ -272,7 +272,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
272#ifdef DEBUG_CFI_FEATURES 272#ifdef DEBUG_CFI_FEATURES
273 /* Tell the user about it in lots of lovely detail */ 273 /* Tell the user about it in lots of lovely detail */
274 cfi_tell_features(extp); 274 cfi_tell_features(extp);
275#endif 275#endif
276 276
277 bootloc = extp->TopBottom; 277 bootloc = extp->TopBottom;
278 if ((bootloc != 2) && (bootloc != 3)) { 278 if ((bootloc != 2) && (bootloc != 3)) {
@@ -283,11 +283,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
283 283
284 if (bootloc == 3 && cfi->cfiq->NumEraseRegions > 1) { 284 if (bootloc == 3 && cfi->cfiq->NumEraseRegions > 1) {
285 printk(KERN_WARNING "%s: Swapping erase regions for broken CFI table.\n", map->name); 285 printk(KERN_WARNING "%s: Swapping erase regions for broken CFI table.\n", map->name);
286 286
287 for (i=0; i<cfi->cfiq->NumEraseRegions / 2; i++) { 287 for (i=0; i<cfi->cfiq->NumEraseRegions / 2; i++) {
288 int j = (cfi->cfiq->NumEraseRegions-1)-i; 288 int j = (cfi->cfiq->NumEraseRegions-1)-i;
289 __u32 swap; 289 __u32 swap;
290 290
291 swap = cfi->cfiq->EraseRegionInfo[i]; 291 swap = cfi->cfiq->EraseRegionInfo[i];
292 cfi->cfiq->EraseRegionInfo[i] = cfi->cfiq->EraseRegionInfo[j]; 292 cfi->cfiq->EraseRegionInfo[i] = cfi->cfiq->EraseRegionInfo[j];
293 cfi->cfiq->EraseRegionInfo[j] = swap; 293 cfi->cfiq->EraseRegionInfo[j] = swap;
@@ -298,11 +298,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
298 cfi->addr_unlock2 = 0x2aa; 298 cfi->addr_unlock2 = 0x2aa;
299 /* Modify the unlock address if we are in compatibility mode */ 299 /* Modify the unlock address if we are in compatibility mode */
300 if ( /* x16 in x8 mode */ 300 if ( /* x16 in x8 mode */
301 ((cfi->device_type == CFI_DEVICETYPE_X8) && 301 ((cfi->device_type == CFI_DEVICETYPE_X8) &&
302 (cfi->cfiq->InterfaceDesc == 2)) || 302 (cfi->cfiq->InterfaceDesc == 2)) ||
303 /* x32 in x16 mode */ 303 /* x32 in x16 mode */
304 ((cfi->device_type == CFI_DEVICETYPE_X16) && 304 ((cfi->device_type == CFI_DEVICETYPE_X16) &&
305 (cfi->cfiq->InterfaceDesc == 4))) 305 (cfi->cfiq->InterfaceDesc == 4)))
306 { 306 {
307 cfi->addr_unlock1 = 0xaaa; 307 cfi->addr_unlock1 = 0xaaa;
308 cfi->addr_unlock2 = 0x555; 308 cfi->addr_unlock2 = 0x555;
@@ -320,10 +320,10 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
320 cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; 320 cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
321 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; 321 cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
322 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; 322 cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
323 } 323 }
324 324
325 map->fldrv = &cfi_amdstd_chipdrv; 325 map->fldrv = &cfi_amdstd_chipdrv;
326 326
327 return cfi_amdstd_setup(mtd); 327 return cfi_amdstd_setup(mtd);
328} 328}
329 329
@@ -336,24 +336,24 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
336 unsigned long offset = 0; 336 unsigned long offset = 0;
337 int i,j; 337 int i,j;
338 338
339 printk(KERN_NOTICE "number of %s chips: %d\n", 339 printk(KERN_NOTICE "number of %s chips: %d\n",
340 (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips); 340 (cfi->cfi_mode == CFI_MODE_CFI)?"CFI":"JEDEC",cfi->numchips);
341 /* Select the correct geometry setup */ 341 /* Select the correct geometry setup */
342 mtd->size = devsize * cfi->numchips; 342 mtd->size = devsize * cfi->numchips;
343 343
344 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; 344 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
345 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) 345 mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
346 * mtd->numeraseregions, GFP_KERNEL); 346 * mtd->numeraseregions, GFP_KERNEL);
347 if (!mtd->eraseregions) { 347 if (!mtd->eraseregions) {
348 printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n"); 348 printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n");
349 goto setup_err; 349 goto setup_err;
350 } 350 }
351 351
352 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { 352 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
353 unsigned long ernum, ersize; 353 unsigned long ernum, ersize;
354 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; 354 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
355 ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1; 355 ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1;
356 356
357 if (mtd->erasesize < ersize) { 357 if (mtd->erasesize < ersize) {
358 mtd->erasesize = ersize; 358 mtd->erasesize = ersize;
359 } 359 }
@@ -440,7 +440,7 @@ static int __xipram chip_good(struct map_info *map, unsigned long addr, map_word
440 oldd = map_read(map, addr); 440 oldd = map_read(map, addr);
441 curd = map_read(map, addr); 441 curd = map_read(map, addr);
442 442
443 return map_word_equal(map, oldd, curd) && 443 return map_word_equal(map, oldd, curd) &&
444 map_word_equal(map, curd, expected); 444 map_word_equal(map, curd, expected);
445} 445}
446 446
@@ -472,7 +472,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
472 /* Someone else might have been playing with it. */ 472 /* Someone else might have been playing with it. */
473 goto retry; 473 goto retry;
474 } 474 }
475 475
476 case FL_READY: 476 case FL_READY:
477 case FL_CFI_QUERY: 477 case FL_CFI_QUERY:
478 case FL_JEDEC_QUERY: 478 case FL_JEDEC_QUERY:
@@ -515,7 +515,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
515 printk(KERN_ERR "MTD %s(): chip not ready after erase suspend\n", __func__); 515 printk(KERN_ERR "MTD %s(): chip not ready after erase suspend\n", __func__);
516 return -EIO; 516 return -EIO;
517 } 517 }
518 518
519 spin_unlock(chip->mutex); 519 spin_unlock(chip->mutex);
520 cfi_udelay(1); 520 cfi_udelay(1);
521 spin_lock(chip->mutex); 521 spin_lock(chip->mutex);
@@ -618,7 +618,7 @@ static void __xipram xip_enable(struct map_info *map, struct flchip *chip,
618 * When a delay is required for the flash operation to complete, the 618 * When a delay is required for the flash operation to complete, the
619 * xip_udelay() function is polling for both the given timeout and pending 619 * xip_udelay() function is polling for both the given timeout and pending
620 * (but still masked) hardware interrupts. Whenever there is an interrupt 620 * (but still masked) hardware interrupts. Whenever there is an interrupt
621 * pending then the flash erase operation is suspended, array mode restored 621 * pending then the flash erase operation is suspended, array mode restored
622 * and interrupts unmasked. Task scheduling might also happen at that 622 * and interrupts unmasked. Task scheduling might also happen at that
623 * point. The CPU eventually returns from the interrupt or the call to 623 * point. The CPU eventually returns from the interrupt or the call to
624 * schedule() and the suspended flash operation is resumed for the remaining 624 * schedule() and the suspended flash operation is resumed for the remaining
@@ -642,9 +642,9 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip,
642 ((chip->state == FL_ERASING && (extp->EraseSuspend & 2))) && 642 ((chip->state == FL_ERASING && (extp->EraseSuspend & 2))) &&
643 (cfi_interleave_is_1(cfi) || chip->oldstate == FL_READY)) { 643 (cfi_interleave_is_1(cfi) || chip->oldstate == FL_READY)) {
644 /* 644 /*
645 * Let's suspend the erase operation when supported. 645 * Let's suspend the erase operation when supported.
646 * Note that we currently don't try to suspend 646 * Note that we currently don't try to suspend
647 * interleaved chips if there is already another 647 * interleaved chips if there is already another
648 * operation suspended (imagine what happens 648 * operation suspended (imagine what happens
649 * when one chip was already done with the current 649 * when one chip was already done with the current
650 * operation while another chip suspended it, then 650 * operation while another chip suspended it, then
@@ -780,8 +780,8 @@ static inline int do_read_onechip(struct map_info *map, struct flchip *chip, lof
780 780
781 adr += chip->start; 781 adr += chip->start;
782 782
783 /* Ensure cmd read/writes are aligned. */ 783 /* Ensure cmd read/writes are aligned. */
784 cmd_addr = adr & ~(map_bankwidth(map)-1); 784 cmd_addr = adr & ~(map_bankwidth(map)-1);
785 785
786 spin_lock(chip->mutex); 786 spin_lock(chip->mutex);
787 ret = get_chip(map, chip, cmd_addr, FL_READY); 787 ret = get_chip(map, chip, cmd_addr, FL_READY);
@@ -861,7 +861,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
861#endif 861#endif
862 set_current_state(TASK_UNINTERRUPTIBLE); 862 set_current_state(TASK_UNINTERRUPTIBLE);
863 add_wait_queue(&chip->wq, &wait); 863 add_wait_queue(&chip->wq, &wait);
864 864
865 spin_unlock(chip->mutex); 865 spin_unlock(chip->mutex);
866 866
867 schedule(); 867 schedule();
@@ -873,7 +873,7 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
873 timeo = jiffies + HZ; 873 timeo = jiffies + HZ;
874 874
875 goto retry; 875 goto retry;
876 } 876 }
877 877
878 adr += chip->start; 878 adr += chip->start;
879 879
@@ -882,14 +882,14 @@ static inline int do_read_secsi_onechip(struct map_info *map, struct flchip *chi
882 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 882 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
883 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 883 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
884 cfi_send_gen_cmd(0x88, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 884 cfi_send_gen_cmd(0x88, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
885 885
886 map_copy_from(map, buf, adr, len); 886 map_copy_from(map, buf, adr, len);
887 887
888 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 888 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
889 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 889 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
890 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 890 cfi_send_gen_cmd(0x90, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
891 cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 891 cfi_send_gen_cmd(0x00, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
892 892
893 wake_up(&chip->wq); 893 wake_up(&chip->wq);
894 spin_unlock(chip->mutex); 894 spin_unlock(chip->mutex);
895 895
@@ -998,7 +998,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
998 chip->word_write_time); 998 chip->word_write_time);
999 999
1000 /* See comment above for timeout value. */ 1000 /* See comment above for timeout value. */
1001 timeo = jiffies + uWriteTimeout; 1001 timeo = jiffies + uWriteTimeout;
1002 for (;;) { 1002 for (;;) {
1003 if (chip->state != FL_WRITING) { 1003 if (chip->state != FL_WRITING) {
1004 /* Someone's suspended the write. Sleep */ 1004 /* Someone's suspended the write. Sleep */
@@ -1033,7 +1033,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1033 map_write( map, CMD(0xF0), chip->start ); 1033 map_write( map, CMD(0xF0), chip->start );
1034 /* FIXME - should have reset delay before continuing */ 1034 /* FIXME - should have reset delay before continuing */
1035 1035
1036 if (++retry_cnt <= MAX_WORD_RETRIES) 1036 if (++retry_cnt <= MAX_WORD_RETRIES)
1037 goto retry; 1037 goto retry;
1038 1038
1039 ret = -EIO; 1039 ret = -EIO;
@@ -1101,27 +1101,27 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1101 1101
1102 /* Number of bytes to copy from buffer */ 1102 /* Number of bytes to copy from buffer */
1103 n = min_t(int, len, map_bankwidth(map)-i); 1103 n = min_t(int, len, map_bankwidth(map)-i);
1104 1104
1105 tmp_buf = map_word_load_partial(map, tmp_buf, buf, i, n); 1105 tmp_buf = map_word_load_partial(map, tmp_buf, buf, i, n);
1106 1106
1107 ret = do_write_oneword(map, &cfi->chips[chipnum], 1107 ret = do_write_oneword(map, &cfi->chips[chipnum],
1108 bus_ofs, tmp_buf); 1108 bus_ofs, tmp_buf);
1109 if (ret) 1109 if (ret)
1110 return ret; 1110 return ret;
1111 1111
1112 ofs += n; 1112 ofs += n;
1113 buf += n; 1113 buf += n;
1114 (*retlen) += n; 1114 (*retlen) += n;
1115 len -= n; 1115 len -= n;
1116 1116
1117 if (ofs >> cfi->chipshift) { 1117 if (ofs >> cfi->chipshift) {
1118 chipnum ++; 1118 chipnum ++;
1119 ofs = 0; 1119 ofs = 0;
1120 if (chipnum == cfi->numchips) 1120 if (chipnum == cfi->numchips)
1121 return 0; 1121 return 0;
1122 } 1122 }
1123 } 1123 }
1124 1124
1125 /* We are now aligned, write as much as possible */ 1125 /* We are now aligned, write as much as possible */
1126 while(len >= map_bankwidth(map)) { 1126 while(len >= map_bankwidth(map)) {
1127 map_word datum; 1127 map_word datum;
@@ -1139,7 +1139,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1139 len -= map_bankwidth(map); 1139 len -= map_bankwidth(map);
1140 1140
1141 if (ofs >> cfi->chipshift) { 1141 if (ofs >> cfi->chipshift) {
1142 chipnum ++; 1142 chipnum ++;
1143 ofs = 0; 1143 ofs = 0;
1144 if (chipnum == cfi->numchips) 1144 if (chipnum == cfi->numchips)
1145 return 0; 1145 return 0;
@@ -1177,12 +1177,12 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1177 spin_unlock(cfi->chips[chipnum].mutex); 1177 spin_unlock(cfi->chips[chipnum].mutex);
1178 1178
1179 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len); 1179 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len);
1180 1180
1181 ret = do_write_oneword(map, &cfi->chips[chipnum], 1181 ret = do_write_oneword(map, &cfi->chips[chipnum],
1182 ofs, tmp_buf); 1182 ofs, tmp_buf);
1183 if (ret) 1183 if (ret)
1184 return ret; 1184 return ret;
1185 1185
1186 (*retlen) += len; 1186 (*retlen) += len;
1187 } 1187 }
1188 1188
@@ -1194,7 +1194,7 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1194 * FIXME: interleaved mode not tested, and probably not supported! 1194 * FIXME: interleaved mode not tested, and probably not supported!
1195 */ 1195 */
1196static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, 1196static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1197 unsigned long adr, const u_char *buf, 1197 unsigned long adr, const u_char *buf,
1198 int len) 1198 int len)
1199{ 1199{
1200 struct cfi_private *cfi = map->fldrv_priv; 1200 struct cfi_private *cfi = map->fldrv_priv;
@@ -1224,7 +1224,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1224 XIP_INVAL_CACHED_RANGE(map, adr, len); 1224 XIP_INVAL_CACHED_RANGE(map, adr, len);
1225 ENABLE_VPP(map); 1225 ENABLE_VPP(map);
1226 xip_disable(map, chip, cmd_adr); 1226 xip_disable(map, chip, cmd_adr);
1227 1227
1228 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1228 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
1229 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL); 1229 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
1230 //cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); 1230 //cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
@@ -1258,8 +1258,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1258 adr, map_bankwidth(map), 1258 adr, map_bankwidth(map),
1259 chip->word_write_time); 1259 chip->word_write_time);
1260 1260
1261 timeo = jiffies + uWriteTimeout; 1261 timeo = jiffies + uWriteTimeout;
1262 1262
1263 for (;;) { 1263 for (;;) {
1264 if (chip->state != FL_WRITING) { 1264 if (chip->state != FL_WRITING) {
1265 /* Someone's suspended the write. Sleep */ 1265 /* Someone's suspended the write. Sleep */
@@ -1353,7 +1353,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1353 if (size % map_bankwidth(map)) 1353 if (size % map_bankwidth(map))
1354 size -= size % map_bankwidth(map); 1354 size -= size % map_bankwidth(map);
1355 1355
1356 ret = do_write_buffer(map, &cfi->chips[chipnum], 1356 ret = do_write_buffer(map, &cfi->chips[chipnum],
1357 ofs, buf, size); 1357 ofs, buf, size);
1358 if (ret) 1358 if (ret)
1359 return ret; 1359 return ret;
@@ -1364,7 +1364,7 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1364 len -= size; 1364 len -= size;
1365 1365
1366 if (ofs >> cfi->chipshift) { 1366 if (ofs >> cfi->chipshift) {
1367 chipnum ++; 1367 chipnum ++;
1368 ofs = 0; 1368 ofs = 0;
1369 if (chipnum == cfi->numchips) 1369 if (chipnum == cfi->numchips)
1370 return 0; 1370 return 0;
@@ -1581,7 +1581,7 @@ int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
1581 1581
1582 instr->state = MTD_ERASE_DONE; 1582 instr->state = MTD_ERASE_DONE;
1583 mtd_erase_callback(instr); 1583 mtd_erase_callback(instr);
1584 1584
1585 return 0; 1585 return 0;
1586} 1586}
1587 1587
@@ -1604,7 +1604,7 @@ static int cfi_amdstd_erase_chip(struct mtd_info *mtd, struct erase_info *instr)
1604 1604
1605 instr->state = MTD_ERASE_DONE; 1605 instr->state = MTD_ERASE_DONE;
1606 mtd_erase_callback(instr); 1606 mtd_erase_callback(instr);
1607 1607
1608 return 0; 1608 return 0;
1609} 1609}
1610 1610
@@ -1631,7 +1631,7 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1631 case FL_JEDEC_QUERY: 1631 case FL_JEDEC_QUERY:
1632 chip->oldstate = chip->state; 1632 chip->oldstate = chip->state;
1633 chip->state = FL_SYNCING; 1633 chip->state = FL_SYNCING;
1634 /* No need to wake_up() on this state change - 1634 /* No need to wake_up() on this state change -
1635 * as the whole point is that nobody can do anything 1635 * as the whole point is that nobody can do anything
1636 * with the chip now anyway. 1636 * with the chip now anyway.
1637 */ 1637 */
@@ -1642,13 +1642,13 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1642 default: 1642 default:
1643 /* Not an idle state */ 1643 /* Not an idle state */
1644 add_wait_queue(&chip->wq, &wait); 1644 add_wait_queue(&chip->wq, &wait);
1645 1645
1646 spin_unlock(chip->mutex); 1646 spin_unlock(chip->mutex);
1647 1647
1648 schedule(); 1648 schedule();
1649 1649
1650 remove_wait_queue(&chip->wq, &wait); 1650 remove_wait_queue(&chip->wq, &wait);
1651 1651
1652 goto retry; 1652 goto retry;
1653 } 1653 }
1654 } 1654 }
@@ -1659,7 +1659,7 @@ static void cfi_amdstd_sync (struct mtd_info *mtd)
1659 chip = &cfi->chips[i]; 1659 chip = &cfi->chips[i];
1660 1660
1661 spin_lock(chip->mutex); 1661 spin_lock(chip->mutex);
1662 1662
1663 if (chip->state == FL_SYNCING) { 1663 if (chip->state == FL_SYNCING) {
1664 chip->state = chip->oldstate; 1664 chip->state = chip->oldstate;
1665 wake_up(&chip->wq); 1665 wake_up(&chip->wq);
@@ -1689,7 +1689,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1689 case FL_JEDEC_QUERY: 1689 case FL_JEDEC_QUERY:
1690 chip->oldstate = chip->state; 1690 chip->oldstate = chip->state;
1691 chip->state = FL_PM_SUSPENDED; 1691 chip->state = FL_PM_SUSPENDED;
1692 /* No need to wake_up() on this state change - 1692 /* No need to wake_up() on this state change -
1693 * as the whole point is that nobody can do anything 1693 * as the whole point is that nobody can do anything
1694 * with the chip now anyway. 1694 * with the chip now anyway.
1695 */ 1695 */
@@ -1710,7 +1710,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1710 chip = &cfi->chips[i]; 1710 chip = &cfi->chips[i];
1711 1711
1712 spin_lock(chip->mutex); 1712 spin_lock(chip->mutex);
1713 1713
1714 if (chip->state == FL_PM_SUSPENDED) { 1714 if (chip->state == FL_PM_SUSPENDED) {
1715 chip->state = chip->oldstate; 1715 chip->state = chip->oldstate;
1716 wake_up(&chip->wq); 1716 wake_up(&chip->wq);
@@ -1718,7 +1718,7 @@ static int cfi_amdstd_suspend(struct mtd_info *mtd)
1718 spin_unlock(chip->mutex); 1718 spin_unlock(chip->mutex);
1719 } 1719 }
1720 } 1720 }
1721 1721
1722 return ret; 1722 return ret;
1723} 1723}
1724 1724
@@ -1731,11 +1731,11 @@ static void cfi_amdstd_resume(struct mtd_info *mtd)
1731 struct flchip *chip; 1731 struct flchip *chip;
1732 1732
1733 for (i=0; i<cfi->numchips; i++) { 1733 for (i=0; i<cfi->numchips; i++) {
1734 1734
1735 chip = &cfi->chips[i]; 1735 chip = &cfi->chips[i];
1736 1736
1737 spin_lock(chip->mutex); 1737 spin_lock(chip->mutex);
1738 1738
1739 if (chip->state == FL_PM_SUSPENDED) { 1739 if (chip->state == FL_PM_SUSPENDED) {
1740 chip->state = FL_READY; 1740 chip->state = FL_READY;
1741 map_write(map, CMD(0xF0), chip->start); 1741 map_write(map, CMD(0xF0), chip->start);