Lines Matching +full:non +full:- +full:interleave

1 // SPDX-License-Identifier: GPL-2.0
9 * - completely revamped method functions so they are aware and
10 * independent of the flash geometry (buswidth, interleave, etc.)
11 * - scalability vs code size is completely set at compile-time
13 * - optimized write buffer method
14 * 06/21/2002 Joern Engel <joern@wh.fh-wedel.de> and others
15 * - modified Intel Command Set 0x0001 to support ST Advanced Architecture
17 * - added a writev function
18 * 07/13/2005 Joern Engel <joern@wh.fh-wedel.de>
19 * - Plugged memory leak in cfi_staa_writev().
69 printk(" Feature/Command Support: %4.4X\n", extp->FeatureSupport); in cfi_tell_features()
70 printk(" - Chip Erase: %s\n", extp->FeatureSupport&1?"supported":"unsupported"); in cfi_tell_features()
71 printk(" - Suspend Erase: %s\n", extp->FeatureSupport&2?"supported":"unsupported"); in cfi_tell_features()
72 printk(" - Suspend Program: %s\n", extp->FeatureSupport&4?"supported":"unsupported"); in cfi_tell_features()
73 printk(" - Legacy Lock/Unlock: %s\n", extp->FeatureSupport&8?"supported":"unsupported"); in cfi_tell_features()
74 printk(" - Queued Erase: %s\n", extp->FeatureSupport&16?"supported":"unsupported"); in cfi_tell_features()
75 printk(" - Instant block lock: %s\n", extp->FeatureSupport&32?"supported":"unsupported"); in cfi_tell_features()
76 printk(" - Protection Bits: %s\n", extp->FeatureSupport&64?"supported":"unsupported"); in cfi_tell_features()
77 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported"); in cfi_tell_features()
78 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported"); in cfi_tell_features()
80 if (extp->FeatureSupport & (1<<i)) in cfi_tell_features()
81 printk(" - Unknown Bit %X: supported\n", i); in cfi_tell_features()
84 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport); in cfi_tell_features()
85 …printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsuppor… in cfi_tell_features()
87 if (extp->SuspendCmdSupport & (1<<i)) in cfi_tell_features()
88 printk(" - Unknown Bit %X: supported\n", i); in cfi_tell_features()
91 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask); in cfi_tell_features()
92 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no"); in cfi_tell_features()
93 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no"); in cfi_tell_features()
95 if (extp->BlkStatusRegMask & (1<<i)) in cfi_tell_features()
96 printk(" - Unknown Bit %X Active: yes\n",i); in cfi_tell_features()
100 extp->VccOptimal >> 8, extp->VccOptimal & 0xf); in cfi_tell_features()
101 if (extp->VppOptimal) in cfi_tell_features()
103 extp->VppOptimal >> 8, extp->VppOptimal & 0xf); in cfi_tell_features()
111 * this module is non-zero, i.e. between inter_module_get and
116 struct cfi_private *cfi = map->fldrv_priv; in cfi_cmdset_0020()
119 if (cfi->cfi_mode) { in cfi_cmdset_0020()
125 __u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR; in cfi_cmdset_0020()
132 if (extp->MajorVersion != '1' || in cfi_cmdset_0020()
133 (extp->MinorVersion < '0' || extp->MinorVersion > '3')) { in cfi_cmdset_0020()
136 extp->MajorVersion, extp->MinorVersion); in cfi_cmdset_0020()
142 extp->FeatureSupport = cfi32_to_cpu(map, extp->FeatureSupport); in cfi_cmdset_0020()
143 extp->BlkStatusRegMask = cfi32_to_cpu(map, in cfi_cmdset_0020()
144 extp->BlkStatusRegMask); in cfi_cmdset_0020()
152 cfi->cmdset_priv = extp; in cfi_cmdset_0020()
155 for (i=0; i< cfi->numchips; i++) { in cfi_cmdset_0020()
156 cfi->chips[i].word_write_time = 128; in cfi_cmdset_0020()
157 cfi->chips[i].buffer_write_time = 128; in cfi_cmdset_0020()
158 cfi->chips[i].erase_time = 1024; in cfi_cmdset_0020()
159 cfi->chips[i].ref_point_counter = 0; in cfi_cmdset_0020()
160 init_waitqueue_head(&(cfi->chips[i].wq)); in cfi_cmdset_0020()
169 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_setup()
173 unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; in cfi_staa_setup()
176 //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); in cfi_staa_setup()
179 kfree(cfi->cmdset_priv); in cfi_staa_setup()
183 mtd->priv = map; in cfi_staa_setup()
184 mtd->type = MTD_NORFLASH; in cfi_staa_setup()
185 mtd->size = devsize * cfi->numchips; in cfi_staa_setup()
187 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; in cfi_staa_setup()
188 mtd->eraseregions = kmalloc_array(mtd->numeraseregions, in cfi_staa_setup()
191 if (!mtd->eraseregions) { in cfi_staa_setup()
192 kfree(cfi->cmdset_priv); in cfi_staa_setup()
197 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { in cfi_staa_setup()
199 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; in cfi_staa_setup()
200 ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1; in cfi_staa_setup()
202 if (mtd->erasesize < ersize) { in cfi_staa_setup()
203 mtd->erasesize = ersize; in cfi_staa_setup()
205 for (j=0; j<cfi->numchips; j++) { in cfi_staa_setup()
206 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset; in cfi_staa_setup()
207 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize; in cfi_staa_setup()
208 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum; in cfi_staa_setup()
216 kfree(mtd->eraseregions); in cfi_staa_setup()
217 kfree(cfi->cmdset_priv); in cfi_staa_setup()
222 for (i=0; i<mtd->numeraseregions;i++){ in cfi_staa_setup()
224 i, (unsigned long long)mtd->eraseregions[i].offset, in cfi_staa_setup()
225 mtd->eraseregions[i].erasesize, in cfi_staa_setup()
226 mtd->eraseregions[i].numblocks); in cfi_staa_setup()
230 mtd->_erase = cfi_staa_erase_varsize; in cfi_staa_setup()
231 mtd->_read = cfi_staa_read; in cfi_staa_setup()
232 mtd->_write = cfi_staa_write_buffers; in cfi_staa_setup()
233 mtd->_writev = cfi_staa_writev; in cfi_staa_setup()
234 mtd->_sync = cfi_staa_sync; in cfi_staa_setup()
235 mtd->_lock = cfi_staa_lock; in cfi_staa_setup()
236 mtd->_unlock = cfi_staa_unlock; in cfi_staa_setup()
237 mtd->_suspend = cfi_staa_suspend; in cfi_staa_setup()
238 mtd->_resume = cfi_staa_resume; in cfi_staa_setup()
239 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; in cfi_staa_setup()
240 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ in cfi_staa_setup()
241 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; in cfi_staa_setup()
242 map->fldrv = &cfi_staa_chipdrv; in cfi_staa_setup()
244 mtd->name = map->name; in cfi_staa_setup()
256 struct cfi_private *cfi = map->fldrv_priv; in do_read_onechip()
258 adr += chip->start; in do_read_onechip()
261 cmd_addr = adr & ~(map_bankwidth(map)-1); in do_read_onechip()
263 /* Let's determine this according to the interleave only once */ in do_read_onechip()
268 mutex_lock(&chip->mutex); in do_read_onechip()
273 switch (chip->state) { in do_read_onechip()
275 if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2)) in do_read_onechip()
282 * mode so we get the right data. --rmk in do_read_onechip()
285 chip->oldstate = FL_ERASING; in do_read_onechip()
286 chip->state = FL_ERASE_SUSPENDING; in do_read_onechip()
298 chip->state = FL_ERASING; in do_read_onechip()
299 wake_up(&chip->wq); in do_read_onechip()
300 mutex_unlock(&chip->mutex); in do_read_onechip()
303 return -EIO; in do_read_onechip()
306 mutex_unlock(&chip->mutex); in do_read_onechip()
308 mutex_lock(&chip->mutex); in do_read_onechip()
313 chip->state = FL_READY; in do_read_onechip()
327 chip->state = FL_STATUS; in do_read_onechip()
333 chip->state = FL_READY; in do_read_onechip()
339 mutex_unlock(&chip->mutex); in do_read_onechip()
341 return -EIO; in do_read_onechip()
345 mutex_unlock(&chip->mutex); in do_read_onechip()
354 add_wait_queue(&chip->wq, &wait); in do_read_onechip()
355 mutex_unlock(&chip->mutex); in do_read_onechip()
357 remove_wait_queue(&chip->wq, &wait); in do_read_onechip()
365 chip->state = chip->oldstate; in do_read_onechip()
368 one in READY mode. That's bad, and caused -EROFS in do_read_onechip()
379 wake_up(&chip->wq); in do_read_onechip()
380 mutex_unlock(&chip->mutex); in do_read_onechip()
386 struct map_info *map = mtd->priv; in cfi_staa_read()
387 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_read()
393 chipnum = (from >> cfi->chipshift); in cfi_staa_read()
394 ofs = from - (chipnum << cfi->chipshift); in cfi_staa_read()
399 if (chipnum >= cfi->numchips) in cfi_staa_read()
402 if ((len + ofs -1) >> cfi->chipshift) in cfi_staa_read()
403 thislen = (1<<cfi->chipshift) - ofs; in cfi_staa_read()
407 ret = do_read_onechip(map, &cfi->chips[chipnum], ofs, thislen, buf); in cfi_staa_read()
412 len -= thislen; in cfi_staa_read()
424 struct cfi_private *cfi = map->fldrv_priv; in do_write_buffer()
430 /* M58LW064A requires bus alignment for buffer wriets -- saw */ in do_write_buffer()
431 if (adr & (map_bankwidth(map)-1)) in do_write_buffer()
432 return -EINVAL; in do_write_buffer()
434 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; in do_write_buffer()
435 adr += chip->start; in do_write_buffer()
436 cmd_adr = adr & ~(wbufsize-1); in do_write_buffer()
438 /* Let's determine this according to the interleave only once */ in do_write_buffer()
445 printk("%s: chip->state[%d]\n", __func__, chip->state); in do_write_buffer()
447 mutex_lock(&chip->mutex); in do_write_buffer()
454 switch (chip->state) { in do_write_buffer()
461 chip->state = FL_STATUS; in do_write_buffer()
472 mutex_unlock(&chip->mutex); in do_write_buffer()
475 return -EIO; in do_write_buffer()
479 mutex_unlock(&chip->mutex); in do_write_buffer()
487 add_wait_queue(&chip->wq, &wait); in do_write_buffer()
488 mutex_unlock(&chip->mutex); in do_write_buffer()
490 remove_wait_queue(&chip->wq, &wait); in do_write_buffer()
497 chip->state = FL_WRITING_TO_BUFFER; in do_write_buffer()
505 mutex_unlock(&chip->mutex); in do_write_buffer()
507 mutex_lock(&chip->mutex); in do_write_buffer()
513 chip->state = FL_STATUS; in do_write_buffer()
514 mutex_unlock(&chip->mutex); in do_write_buffer()
516 return -EIO; in do_write_buffer()
521 map_write(map, CMD(len/map_bankwidth(map)-1), cmd_adr ); in do_write_buffer()
532 chip->state = FL_WRITING; in do_write_buffer()
534 mutex_unlock(&chip->mutex); in do_write_buffer()
535 cfi_udelay(chip->buffer_write_time); in do_write_buffer()
536 mutex_lock(&chip->mutex); in do_write_buffer()
541 if (chip->state != FL_WRITING) { in do_write_buffer()
544 add_wait_queue(&chip->wq, &wait); in do_write_buffer()
545 mutex_unlock(&chip->mutex); in do_write_buffer()
547 remove_wait_queue(&chip->wq, &wait); in do_write_buffer()
549 mutex_lock(&chip->mutex); in do_write_buffer()
563 chip->state = FL_STATUS; in do_write_buffer()
565 mutex_unlock(&chip->mutex); in do_write_buffer()
567 return -EIO; in do_write_buffer()
571 mutex_unlock(&chip->mutex); in do_write_buffer()
574 mutex_lock(&chip->mutex); in do_write_buffer()
577 chip->buffer_write_time--; in do_write_buffer()
578 if (!chip->buffer_write_time) in do_write_buffer()
579 chip->buffer_write_time++; in do_write_buffer()
582 chip->buffer_write_time++; in do_write_buffer()
586 chip->state = FL_STATUS; in do_write_buffer()
588 … /* check for errors: 'lock bit', 'VPP', 'dead cell'/'unerased cell' or 'incorrect cmd' -- saw */ in do_write_buffer()
597 wake_up(&chip->wq); in do_write_buffer()
598 mutex_unlock(&chip->mutex); in do_write_buffer()
599 return map_word_bitsset(map, status, CMD(0x02)) ? -EROFS : -EIO; in do_write_buffer()
601 wake_up(&chip->wq); in do_write_buffer()
602 mutex_unlock(&chip->mutex); in do_write_buffer()
610 struct map_info *map = mtd->priv; in cfi_staa_write_buffers()
611 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_write_buffers()
612 int wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; in cfi_staa_write_buffers()
617 chipnum = to >> cfi->chipshift; in cfi_staa_write_buffers()
618 ofs = to - (chipnum << cfi->chipshift); in cfi_staa_write_buffers()
629 int size = wbufsize - (ofs & (wbufsize-1)); in cfi_staa_write_buffers()
634 ret = do_write_buffer(map, &cfi->chips[chipnum], in cfi_staa_write_buffers()
642 len -= size; in cfi_staa_write_buffers()
644 if (ofs >> cfi->chipshift) { in cfi_staa_write_buffers()
647 if (chipnum == cfi->numchips) in cfi_staa_write_buffers()
656 * Writev for ECC-Flashes is a little more complicated. We need to maintain
660 #define ECCBUF_SIZE (mtd->writesize)
661 #define ECCBUF_DIV(x) ((x) & ~(ECCBUF_SIZE - 1))
662 #define ECCBUF_MOD(x) ((x) & (ECCBUF_SIZE - 1))
677 return -EIO; in cfi_staa_writev()
681 return -ENOMEM; in cfi_staa_writev()
694 memcpy(buffer+buflen, elem_base, ECCBUF_SIZE-buflen); in cfi_staa_writev()
700 elem_len -= thislen-buflen; in cfi_staa_writev()
701 elem_base += thislen-buflen; in cfi_staa_writev()
735 struct cfi_private *cfi = map->fldrv_priv; in do_erase_oneblock()
742 adr += chip->start; in do_erase_oneblock()
744 /* Let's determine this according to the interleave only once */ in do_erase_oneblock()
749 mutex_lock(&chip->mutex); in do_erase_oneblock()
752 switch (chip->state) { in do_erase_oneblock()
757 chip->state = FL_STATUS; in do_erase_oneblock()
766 mutex_unlock(&chip->mutex); in do_erase_oneblock()
768 return -EIO; in do_erase_oneblock()
772 mutex_unlock(&chip->mutex); in do_erase_oneblock()
780 add_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
781 mutex_unlock(&chip->mutex); in do_erase_oneblock()
783 remove_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
795 chip->state = FL_ERASING; in do_erase_oneblock()
797 mutex_unlock(&chip->mutex); in do_erase_oneblock()
799 mutex_lock(&chip->mutex); in do_erase_oneblock()
806 if (chip->state != FL_ERASING) { in do_erase_oneblock()
809 add_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
810 mutex_unlock(&chip->mutex); in do_erase_oneblock()
812 remove_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
814 mutex_lock(&chip->mutex); in do_erase_oneblock()
825 chip->state = FL_STATUS; in do_erase_oneblock()
828 mutex_unlock(&chip->mutex); in do_erase_oneblock()
829 return -EIO; in do_erase_oneblock()
833 mutex_unlock(&chip->mutex); in do_erase_oneblock()
835 mutex_lock(&chip->mutex); in do_erase_oneblock()
843 chip->state = FL_STATUS; in do_erase_oneblock()
853 chipstatus |= status.x[w] >> (cfi->device_type * 8); in do_erase_oneblock()
865 ret = -EIO; in do_erase_oneblock()
868 ret = -EROFS; in do_erase_oneblock()
872 ret = -EIO; in do_erase_oneblock()
874 if (retries--) { in do_erase_oneblock()
877 chip->state = FL_STATUS; in do_erase_oneblock()
878 mutex_unlock(&chip->mutex); in do_erase_oneblock()
882 ret = -EIO; in do_erase_oneblock()
886 wake_up(&chip->wq); in do_erase_oneblock()
887 mutex_unlock(&chip->mutex); in do_erase_oneblock()
893 { struct map_info *map = mtd->priv; in cfi_staa_erase_varsize()
894 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_erase_varsize()
898 struct mtd_erase_region_info *regions = mtd->eraseregions; in cfi_staa_erase_varsize()
912 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset) in cfi_staa_erase_varsize()
914 i--; in cfi_staa_erase_varsize()
922 if (instr->addr & (regions[i].erasesize-1)) in cfi_staa_erase_varsize()
923 return -EINVAL; in cfi_staa_erase_varsize()
932 while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset) in cfi_staa_erase_varsize()
938 i--; in cfi_staa_erase_varsize()
940 if ((instr->addr + instr->len) & (regions[i].erasesize-1)) in cfi_staa_erase_varsize()
941 return -EINVAL; in cfi_staa_erase_varsize()
943 chipnum = instr->addr >> cfi->chipshift; in cfi_staa_erase_varsize()
944 adr = instr->addr - (chipnum << cfi->chipshift); in cfi_staa_erase_varsize()
945 len = instr->len; in cfi_staa_erase_varsize()
950 ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr); in cfi_staa_erase_varsize()
956 len -= regions[i].erasesize; in cfi_staa_erase_varsize()
958 …if (adr % (1<< cfi->chipshift) == (((unsigned long)regions[i].offset + (regions[i].erasesize * reg… in cfi_staa_erase_varsize()
961 if (adr >> cfi->chipshift) { in cfi_staa_erase_varsize()
965 if (chipnum >= cfi->numchips) in cfi_staa_erase_varsize()
975 struct map_info *map = mtd->priv; in cfi_staa_sync()
976 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_sync()
982 for (i=0; !ret && i<cfi->numchips; i++) { in cfi_staa_sync()
983 chip = &cfi->chips[i]; in cfi_staa_sync()
986 mutex_lock(&chip->mutex); in cfi_staa_sync()
988 switch(chip->state) { in cfi_staa_sync()
993 chip->oldstate = chip->state; in cfi_staa_sync()
994 chip->state = FL_SYNCING; in cfi_staa_sync()
995 /* No need to wake_up() on this state change - in cfi_staa_sync()
1001 mutex_unlock(&chip->mutex); in cfi_staa_sync()
1007 add_wait_queue(&chip->wq, &wait); in cfi_staa_sync()
1009 mutex_unlock(&chip->mutex); in cfi_staa_sync()
1011 remove_wait_queue(&chip->wq, &wait); in cfi_staa_sync()
1019 for (i--; i >=0; i--) { in cfi_staa_sync()
1020 chip = &cfi->chips[i]; in cfi_staa_sync()
1022 mutex_lock(&chip->mutex); in cfi_staa_sync()
1024 if (chip->state == FL_SYNCING) { in cfi_staa_sync()
1025 chip->state = chip->oldstate; in cfi_staa_sync()
1026 wake_up(&chip->wq); in cfi_staa_sync()
1028 mutex_unlock(&chip->mutex); in cfi_staa_sync()
1034 struct cfi_private *cfi = map->fldrv_priv; in do_lock_oneblock()
1039 adr += chip->start; in do_lock_oneblock()
1041 /* Let's determine this according to the interleave only once */ in do_lock_oneblock()
1046 mutex_lock(&chip->mutex); in do_lock_oneblock()
1049 switch (chip->state) { in do_lock_oneblock()
1054 chip->state = FL_STATUS; in do_lock_oneblock()
1063 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1065 return -EIO; in do_lock_oneblock()
1069 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1077 add_wait_queue(&chip->wq, &wait); in do_lock_oneblock()
1078 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1080 remove_wait_queue(&chip->wq, &wait); in do_lock_oneblock()
1088 chip->state = FL_LOCKING; in do_lock_oneblock()
1090 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1092 mutex_lock(&chip->mutex); in do_lock_oneblock()
1107 chip->state = FL_STATUS; in do_lock_oneblock()
1110 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1111 return -EIO; in do_lock_oneblock()
1115 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1117 mutex_lock(&chip->mutex); in do_lock_oneblock()
1121 chip->state = FL_STATUS; in do_lock_oneblock()
1123 wake_up(&chip->wq); in do_lock_oneblock()
1124 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1129 struct map_info *map = mtd->priv; in cfi_staa_lock()
1130 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_lock()
1134 int ofs_factor = cfi->interleave * cfi->device_type; in cfi_staa_lock()
1137 if (ofs & (mtd->erasesize - 1)) in cfi_staa_lock()
1138 return -EINVAL; in cfi_staa_lock()
1140 if (len & (mtd->erasesize -1)) in cfi_staa_lock()
1141 return -EINVAL; in cfi_staa_lock()
1143 chipnum = ofs >> cfi->chipshift; in cfi_staa_lock()
1144 adr = ofs - (chipnum << cfi->chipshift); in cfi_staa_lock()
1149 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1151 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1154 ret = do_lock_oneblock(map, &cfi->chips[chipnum], adr); in cfi_staa_lock()
1157 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1159 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1165 adr += mtd->erasesize; in cfi_staa_lock()
1166 len -= mtd->erasesize; in cfi_staa_lock()
1168 if (adr >> cfi->chipshift) { in cfi_staa_lock()
1172 if (chipnum >= cfi->numchips) in cfi_staa_lock()
1180 struct cfi_private *cfi = map->fldrv_priv; in do_unlock_oneblock()
1185 adr += chip->start; in do_unlock_oneblock()
1187 /* Let's determine this according to the interleave only once */ in do_unlock_oneblock()
1192 mutex_lock(&chip->mutex); in do_unlock_oneblock()
1195 switch (chip->state) { in do_unlock_oneblock()
1200 chip->state = FL_STATUS; in do_unlock_oneblock()
1209 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1211 return -EIO; in do_unlock_oneblock()
1215 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1223 add_wait_queue(&chip->wq, &wait); in do_unlock_oneblock()
1224 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1226 remove_wait_queue(&chip->wq, &wait); in do_unlock_oneblock()
1234 chip->state = FL_UNLOCKING; in do_unlock_oneblock()
1236 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1238 mutex_lock(&chip->mutex); in do_unlock_oneblock()
1253 chip->state = FL_STATUS; in do_unlock_oneblock()
1256 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1257 return -EIO; in do_unlock_oneblock()
1261 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1263 mutex_lock(&chip->mutex); in do_unlock_oneblock()
1267 chip->state = FL_STATUS; in do_unlock_oneblock()
1269 wake_up(&chip->wq); in do_unlock_oneblock()
1270 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1275 struct map_info *map = mtd->priv; in cfi_staa_unlock()
1276 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_unlock()
1280 int ofs_factor = cfi->interleave * cfi->device_type; in cfi_staa_unlock()
1283 chipnum = ofs >> cfi->chipshift; in cfi_staa_unlock()
1284 adr = ofs - (chipnum << cfi->chipshift); in cfi_staa_unlock()
1291 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1294 temp_adr += mtd->erasesize; in cfi_staa_unlock()
1295 temp_len -= mtd->erasesize; in cfi_staa_unlock()
1297 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1301 ret = do_unlock_oneblock(map, &cfi->chips[chipnum], adr); in cfi_staa_unlock()
1304 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1306 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1314 struct map_info *map = mtd->priv; in cfi_staa_suspend()
1315 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_suspend()
1320 for (i=0; !ret && i<cfi->numchips; i++) { in cfi_staa_suspend()
1321 chip = &cfi->chips[i]; in cfi_staa_suspend()
1323 mutex_lock(&chip->mutex); in cfi_staa_suspend()
1325 switch(chip->state) { in cfi_staa_suspend()
1330 chip->oldstate = chip->state; in cfi_staa_suspend()
1331 chip->state = FL_PM_SUSPENDED; in cfi_staa_suspend()
1332 /* No need to wake_up() on this state change - in cfi_staa_suspend()
1342 ret = -EAGAIN; in cfi_staa_suspend()
1345 mutex_unlock(&chip->mutex); in cfi_staa_suspend()
1351 for (i--; i >=0; i--) { in cfi_staa_suspend()
1352 chip = &cfi->chips[i]; in cfi_staa_suspend()
1354 mutex_lock(&chip->mutex); in cfi_staa_suspend()
1356 if (chip->state == FL_PM_SUSPENDED) { in cfi_staa_suspend()
1360 chip->state = chip->oldstate; in cfi_staa_suspend()
1361 wake_up(&chip->wq); in cfi_staa_suspend()
1363 mutex_unlock(&chip->mutex); in cfi_staa_suspend()
1372 struct map_info *map = mtd->priv; in cfi_staa_resume()
1373 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_resume()
1377 for (i=0; i<cfi->numchips; i++) { in cfi_staa_resume()
1379 chip = &cfi->chips[i]; in cfi_staa_resume()
1381 mutex_lock(&chip->mutex); in cfi_staa_resume()
1384 if (chip->state == FL_PM_SUSPENDED) { in cfi_staa_resume()
1386 chip->state = FL_READY; in cfi_staa_resume()
1387 wake_up(&chip->wq); in cfi_staa_resume()
1390 mutex_unlock(&chip->mutex); in cfi_staa_resume()
1396 struct map_info *map = mtd->priv; in cfi_staa_destroy()
1397 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_destroy()
1398 kfree(cfi->cmdset_priv); in cfi_staa_destroy()