Lines Matching +full:interleave +full:- +full:mode

8  * 	- completely revamped method functions so they are aware and
9 * independent of the flash geometry (buswidth, interleave, etc.)
10 * - scalability vs code size is completely set at compile-time
12 * - optimized write buffer method
13 * 06/21/2002 Joern Engel <joern@wh.fh-wedel.de> and others
14 * - modified Intel Command Set 0x0001 to support ST Advanced Architecture
16 * - added a writev function
17 * 07/13/2005 Joern Engel <joern@wh.fh-wedel.de>
18 * - Plugged memory leak in cfi_staa_writev().
68 printk(" Feature/Command Support: %4.4X\n", extp->FeatureSupport); in cfi_tell_features()
69 printk(" - Chip Erase: %s\n", extp->FeatureSupport&1?"supported":"unsupported"); in cfi_tell_features()
70 printk(" - Suspend Erase: %s\n", extp->FeatureSupport&2?"supported":"unsupported"); in cfi_tell_features()
71 printk(" - Suspend Program: %s\n", extp->FeatureSupport&4?"supported":"unsupported"); in cfi_tell_features()
72 printk(" - Legacy Lock/Unlock: %s\n", extp->FeatureSupport&8?"supported":"unsupported"); in cfi_tell_features()
73 printk(" - Queued Erase: %s\n", extp->FeatureSupport&16?"supported":"unsupported"); in cfi_tell_features()
74 printk(" - Instant block lock: %s\n", extp->FeatureSupport&32?"supported":"unsupported"); in cfi_tell_features()
75 printk(" - Protection Bits: %s\n", extp->FeatureSupport&64?"supported":"unsupported"); in cfi_tell_features()
76 printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported"); in cfi_tell_features()
77 printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported"); in cfi_tell_features()
79 if (extp->FeatureSupport & (1<<i)) in cfi_tell_features()
80 printk(" - Unknown Bit %X: supported\n", i); in cfi_tell_features()
83 printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport); in cfi_tell_features()
84 …printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsuppor… in cfi_tell_features()
86 if (extp->SuspendCmdSupport & (1<<i)) in cfi_tell_features()
87 printk(" - Unknown Bit %X: supported\n", i); in cfi_tell_features()
90 printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask); in cfi_tell_features()
91 printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no"); in cfi_tell_features()
92 printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no"); in cfi_tell_features()
94 if (extp->BlkStatusRegMask & (1<<i)) in cfi_tell_features()
95 printk(" - Unknown Bit %X Active: yes\n",i); in cfi_tell_features()
99 extp->VccOptimal >> 8, extp->VccOptimal & 0xf); in cfi_tell_features()
100 if (extp->VppOptimal) in cfi_tell_features()
102 extp->VppOptimal >> 8, extp->VppOptimal & 0xf); in cfi_tell_features()
110 * this module is non-zero, i.e. between inter_module_get and
115 struct cfi_private *cfi = map->fldrv_priv; in cfi_cmdset_0020()
118 if (cfi->cfi_mode) { in cfi_cmdset_0020()
124 __u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR; in cfi_cmdset_0020()
131 if (extp->MajorVersion != '1' || in cfi_cmdset_0020()
132 (extp->MinorVersion < '0' || extp->MinorVersion > '3')) { in cfi_cmdset_0020()
135 extp->MajorVersion, extp->MinorVersion); in cfi_cmdset_0020()
141 extp->FeatureSupport = cfi32_to_cpu(map, extp->FeatureSupport); in cfi_cmdset_0020()
142 extp->BlkStatusRegMask = cfi32_to_cpu(map, in cfi_cmdset_0020()
143 extp->BlkStatusRegMask); in cfi_cmdset_0020()
151 cfi->cmdset_priv = extp; in cfi_cmdset_0020()
154 for (i=0; i< cfi->numchips; i++) { in cfi_cmdset_0020()
155 cfi->chips[i].word_write_time = 128; in cfi_cmdset_0020()
156 cfi->chips[i].buffer_write_time = 128; in cfi_cmdset_0020()
157 cfi->chips[i].erase_time = 1024; in cfi_cmdset_0020()
158 cfi->chips[i].ref_point_counter = 0; in cfi_cmdset_0020()
159 init_waitqueue_head(&(cfi->chips[i].wq)); in cfi_cmdset_0020()
168 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_setup()
172 unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; in cfi_staa_setup()
175 //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); in cfi_staa_setup()
178 kfree(cfi->cmdset_priv); in cfi_staa_setup()
182 mtd->priv = map; in cfi_staa_setup()
183 mtd->type = MTD_NORFLASH; in cfi_staa_setup()
184 mtd->size = devsize * cfi->numchips; in cfi_staa_setup()
186 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; in cfi_staa_setup()
187 mtd->eraseregions = kmalloc_array(mtd->numeraseregions, in cfi_staa_setup()
190 if (!mtd->eraseregions) { in cfi_staa_setup()
191 kfree(cfi->cmdset_priv); in cfi_staa_setup()
196 for (i=0; i<cfi->cfiq->NumEraseRegions; i++) { in cfi_staa_setup()
198 ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave; in cfi_staa_setup()
199 ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1; in cfi_staa_setup()
201 if (mtd->erasesize < ersize) { in cfi_staa_setup()
202 mtd->erasesize = ersize; in cfi_staa_setup()
204 for (j=0; j<cfi->numchips; j++) { in cfi_staa_setup()
205 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset; in cfi_staa_setup()
206 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize; in cfi_staa_setup()
207 mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum; in cfi_staa_setup()
215 kfree(mtd->eraseregions); in cfi_staa_setup()
216 kfree(cfi->cmdset_priv); in cfi_staa_setup()
221 for (i=0; i<mtd->numeraseregions;i++){ in cfi_staa_setup()
223 i, (unsigned long long)mtd->eraseregions[i].offset, in cfi_staa_setup()
224 mtd->eraseregions[i].erasesize, in cfi_staa_setup()
225 mtd->eraseregions[i].numblocks); in cfi_staa_setup()
229 mtd->_erase = cfi_staa_erase_varsize; in cfi_staa_setup()
230 mtd->_read = cfi_staa_read; in cfi_staa_setup()
231 mtd->_write = cfi_staa_write_buffers; in cfi_staa_setup()
232 mtd->_writev = cfi_staa_writev; in cfi_staa_setup()
233 mtd->_sync = cfi_staa_sync; in cfi_staa_setup()
234 mtd->_lock = cfi_staa_lock; in cfi_staa_setup()
235 mtd->_unlock = cfi_staa_unlock; in cfi_staa_setup()
236 mtd->_suspend = cfi_staa_suspend; in cfi_staa_setup()
237 mtd->_resume = cfi_staa_resume; in cfi_staa_setup()
238 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; in cfi_staa_setup()
239 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ in cfi_staa_setup()
240 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; in cfi_staa_setup()
241 map->fldrv = &cfi_staa_chipdrv; in cfi_staa_setup()
243 mtd->name = map->name; in cfi_staa_setup()
255 struct cfi_private *cfi = map->fldrv_priv; in do_read_onechip()
257 adr += chip->start; in do_read_onechip()
260 cmd_addr = adr & ~(map_bankwidth(map)-1); in do_read_onechip()
262 /* Let's determine this according to the interleave only once */ in do_read_onechip()
267 mutex_lock(&chip->mutex); in do_read_onechip()
272 switch (chip->state) { in do_read_onechip()
274 if (!(((struct cfi_pri_intelext *)cfi->cmdset_priv)->FeatureSupport & 2)) in do_read_onechip()
280 * 'read' mode. Make sure that we switch to 'read status' in do_read_onechip()
281 * mode so we get the right data. --rmk in do_read_onechip()
284 chip->oldstate = FL_ERASING; in do_read_onechip()
285 chip->state = FL_ERASE_SUSPENDING; in do_read_onechip()
295 /* make sure we're in 'read status' mode */ in do_read_onechip()
297 chip->state = FL_ERASING; in do_read_onechip()
298 wake_up(&chip->wq); in do_read_onechip()
299 mutex_unlock(&chip->mutex); in do_read_onechip()
302 return -EIO; in do_read_onechip()
305 mutex_unlock(&chip->mutex); in do_read_onechip()
307 mutex_lock(&chip->mutex); in do_read_onechip()
312 chip->state = FL_READY; in do_read_onechip()
326 chip->state = FL_STATUS; in do_read_onechip()
332 chip->state = FL_READY; in do_read_onechip()
338 mutex_unlock(&chip->mutex); in do_read_onechip()
340 return -EIO; in do_read_onechip()
344 mutex_unlock(&chip->mutex); in do_read_onechip()
353 add_wait_queue(&chip->wq, &wait); in do_read_onechip()
354 mutex_unlock(&chip->mutex); in do_read_onechip()
356 remove_wait_queue(&chip->wq, &wait); in do_read_onechip()
364 chip->state = chip->oldstate; in do_read_onechip()
367 one in READY mode. That's bad, and caused -EROFS in do_read_onechip()
378 wake_up(&chip->wq); in do_read_onechip()
379 mutex_unlock(&chip->mutex); in do_read_onechip()
385 struct map_info *map = mtd->priv; in cfi_staa_read()
386 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_read()
392 chipnum = (from >> cfi->chipshift); in cfi_staa_read()
393 ofs = from - (chipnum << cfi->chipshift); in cfi_staa_read()
398 if (chipnum >= cfi->numchips) in cfi_staa_read()
401 if ((len + ofs -1) >> cfi->chipshift) in cfi_staa_read()
402 thislen = (1<<cfi->chipshift) - ofs; in cfi_staa_read()
406 ret = do_read_onechip(map, &cfi->chips[chipnum], ofs, thislen, buf); in cfi_staa_read()
411 len -= thislen; in cfi_staa_read()
423 struct cfi_private *cfi = map->fldrv_priv; in do_write_buffer()
429 /* M58LW064A requires bus alignment for buffer wriets -- saw */ in do_write_buffer()
430 if (adr & (map_bankwidth(map)-1)) in do_write_buffer()
431 return -EINVAL; in do_write_buffer()
433 wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; in do_write_buffer()
434 adr += chip->start; in do_write_buffer()
435 cmd_adr = adr & ~(wbufsize-1); in do_write_buffer()
437 /* Let's determine this according to the interleave only once */ in do_write_buffer()
444 printk("%s: chip->state[%d]\n", __func__, chip->state); in do_write_buffer()
446 mutex_lock(&chip->mutex); in do_write_buffer()
453 switch (chip->state) { in do_write_buffer()
460 chip->state = FL_STATUS; in do_write_buffer()
471 mutex_unlock(&chip->mutex); in do_write_buffer()
474 return -EIO; in do_write_buffer()
478 mutex_unlock(&chip->mutex); in do_write_buffer()
486 add_wait_queue(&chip->wq, &wait); in do_write_buffer()
487 mutex_unlock(&chip->mutex); in do_write_buffer()
489 remove_wait_queue(&chip->wq, &wait); in do_write_buffer()
496 chip->state = FL_WRITING_TO_BUFFER; in do_write_buffer()
504 mutex_unlock(&chip->mutex); in do_write_buffer()
506 mutex_lock(&chip->mutex); in do_write_buffer()
512 chip->state = FL_STATUS; in do_write_buffer()
513 mutex_unlock(&chip->mutex); in do_write_buffer()
515 return -EIO; in do_write_buffer()
520 map_write(map, CMD(len/map_bankwidth(map)-1), cmd_adr ); in do_write_buffer()
531 chip->state = FL_WRITING; in do_write_buffer()
533 mutex_unlock(&chip->mutex); in do_write_buffer()
534 cfi_udelay(chip->buffer_write_time); in do_write_buffer()
535 mutex_lock(&chip->mutex); in do_write_buffer()
540 if (chip->state != FL_WRITING) { in do_write_buffer()
543 add_wait_queue(&chip->wq, &wait); in do_write_buffer()
544 mutex_unlock(&chip->mutex); in do_write_buffer()
546 remove_wait_queue(&chip->wq, &wait); in do_write_buffer()
548 mutex_lock(&chip->mutex); in do_write_buffer()
560 /* put back into read status register mode */ in do_write_buffer()
562 chip->state = FL_STATUS; in do_write_buffer()
564 mutex_unlock(&chip->mutex); in do_write_buffer()
566 return -EIO; in do_write_buffer()
570 mutex_unlock(&chip->mutex); in do_write_buffer()
573 mutex_lock(&chip->mutex); in do_write_buffer()
576 chip->buffer_write_time--; in do_write_buffer()
577 if (!chip->buffer_write_time) in do_write_buffer()
578 chip->buffer_write_time++; in do_write_buffer()
581 chip->buffer_write_time++; in do_write_buffer()
585 chip->state = FL_STATUS; in do_write_buffer()
587 … /* check for errors: 'lock bit', 'VPP', 'dead cell'/'unerased cell' or 'incorrect cmd' -- saw */ in do_write_buffer()
594 /* put back into read status register mode */ in do_write_buffer()
596 wake_up(&chip->wq); in do_write_buffer()
597 mutex_unlock(&chip->mutex); in do_write_buffer()
598 return map_word_bitsset(map, status, CMD(0x02)) ? -EROFS : -EIO; in do_write_buffer()
600 wake_up(&chip->wq); in do_write_buffer()
601 mutex_unlock(&chip->mutex); in do_write_buffer()
609 struct map_info *map = mtd->priv; in cfi_staa_write_buffers()
610 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_write_buffers()
611 int wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; in cfi_staa_write_buffers()
616 chipnum = to >> cfi->chipshift; in cfi_staa_write_buffers()
617 ofs = to - (chipnum << cfi->chipshift); in cfi_staa_write_buffers()
628 int size = wbufsize - (ofs & (wbufsize-1)); in cfi_staa_write_buffers()
633 ret = do_write_buffer(map, &cfi->chips[chipnum], in cfi_staa_write_buffers()
641 len -= size; in cfi_staa_write_buffers()
643 if (ofs >> cfi->chipshift) { in cfi_staa_write_buffers()
646 if (chipnum == cfi->numchips) in cfi_staa_write_buffers()
655 * Writev for ECC-Flashes is a little more complicated. We need to maintain
659 #define ECCBUF_SIZE (mtd->writesize)
660 #define ECCBUF_DIV(x) ((x) & ~(ECCBUF_SIZE - 1))
661 #define ECCBUF_MOD(x) ((x) & (ECCBUF_SIZE - 1))
676 return -EIO; in cfi_staa_writev()
680 return -ENOMEM; in cfi_staa_writev()
693 memcpy(buffer+buflen, elem_base, ECCBUF_SIZE-buflen); in cfi_staa_writev()
699 elem_len -= thislen-buflen; in cfi_staa_writev()
700 elem_base += thislen-buflen; in cfi_staa_writev()
734 struct cfi_private *cfi = map->fldrv_priv; in do_erase_oneblock()
741 adr += chip->start; in do_erase_oneblock()
743 /* Let's determine this according to the interleave only once */ in do_erase_oneblock()
748 mutex_lock(&chip->mutex); in do_erase_oneblock()
751 switch (chip->state) { in do_erase_oneblock()
756 chip->state = FL_STATUS; in do_erase_oneblock()
765 mutex_unlock(&chip->mutex); in do_erase_oneblock()
767 return -EIO; in do_erase_oneblock()
771 mutex_unlock(&chip->mutex); in do_erase_oneblock()
779 add_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
780 mutex_unlock(&chip->mutex); in do_erase_oneblock()
782 remove_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
794 chip->state = FL_ERASING; in do_erase_oneblock()
796 mutex_unlock(&chip->mutex); in do_erase_oneblock()
798 mutex_lock(&chip->mutex); in do_erase_oneblock()
805 if (chip->state != FL_ERASING) { in do_erase_oneblock()
808 add_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
809 mutex_unlock(&chip->mutex); in do_erase_oneblock()
811 remove_wait_queue(&chip->wq, &wait); in do_erase_oneblock()
813 mutex_lock(&chip->mutex); in do_erase_oneblock()
824 chip->state = FL_STATUS; in do_erase_oneblock()
827 mutex_unlock(&chip->mutex); in do_erase_oneblock()
828 return -EIO; in do_erase_oneblock()
832 mutex_unlock(&chip->mutex); in do_erase_oneblock()
834 mutex_lock(&chip->mutex); in do_erase_oneblock()
842 chip->state = FL_STATUS; in do_erase_oneblock()
852 chipstatus |= status.x[w] >> (cfi->device_type * 8); in do_erase_oneblock()
864 ret = -EIO; in do_erase_oneblock()
867 ret = -EROFS; in do_erase_oneblock()
871 ret = -EIO; in do_erase_oneblock()
873 if (retries--) { in do_erase_oneblock()
876 chip->state = FL_STATUS; in do_erase_oneblock()
877 mutex_unlock(&chip->mutex); in do_erase_oneblock()
881 ret = -EIO; in do_erase_oneblock()
885 wake_up(&chip->wq); in do_erase_oneblock()
886 mutex_unlock(&chip->mutex); in do_erase_oneblock()
892 { struct map_info *map = mtd->priv; in cfi_staa_erase_varsize()
893 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_erase_varsize()
897 struct mtd_erase_region_info *regions = mtd->eraseregions; in cfi_staa_erase_varsize()
911 while (i < mtd->numeraseregions && instr->addr >= regions[i].offset) in cfi_staa_erase_varsize()
913 i--; in cfi_staa_erase_varsize()
921 if (instr->addr & (regions[i].erasesize-1)) in cfi_staa_erase_varsize()
922 return -EINVAL; in cfi_staa_erase_varsize()
931 while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset) in cfi_staa_erase_varsize()
937 i--; in cfi_staa_erase_varsize()
939 if ((instr->addr + instr->len) & (regions[i].erasesize-1)) in cfi_staa_erase_varsize()
940 return -EINVAL; in cfi_staa_erase_varsize()
942 chipnum = instr->addr >> cfi->chipshift; in cfi_staa_erase_varsize()
943 adr = instr->addr - (chipnum << cfi->chipshift); in cfi_staa_erase_varsize()
944 len = instr->len; in cfi_staa_erase_varsize()
949 ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr); in cfi_staa_erase_varsize()
955 len -= regions[i].erasesize; in cfi_staa_erase_varsize()
957 …if (adr % (1<< cfi->chipshift) == (((unsigned long)regions[i].offset + (regions[i].erasesize * reg… in cfi_staa_erase_varsize()
960 if (adr >> cfi->chipshift) { in cfi_staa_erase_varsize()
964 if (chipnum >= cfi->numchips) in cfi_staa_erase_varsize()
974 struct map_info *map = mtd->priv; in cfi_staa_sync()
975 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_sync()
981 for (i=0; !ret && i<cfi->numchips; i++) { in cfi_staa_sync()
982 chip = &cfi->chips[i]; in cfi_staa_sync()
985 mutex_lock(&chip->mutex); in cfi_staa_sync()
987 switch(chip->state) { in cfi_staa_sync()
992 chip->oldstate = chip->state; in cfi_staa_sync()
993 chip->state = FL_SYNCING; in cfi_staa_sync()
994 /* No need to wake_up() on this state change - in cfi_staa_sync()
1000 mutex_unlock(&chip->mutex); in cfi_staa_sync()
1006 add_wait_queue(&chip->wq, &wait); in cfi_staa_sync()
1008 mutex_unlock(&chip->mutex); in cfi_staa_sync()
1010 remove_wait_queue(&chip->wq, &wait); in cfi_staa_sync()
1018 for (i--; i >=0; i--) { in cfi_staa_sync()
1019 chip = &cfi->chips[i]; in cfi_staa_sync()
1021 mutex_lock(&chip->mutex); in cfi_staa_sync()
1023 if (chip->state == FL_SYNCING) { in cfi_staa_sync()
1024 chip->state = chip->oldstate; in cfi_staa_sync()
1025 wake_up(&chip->wq); in cfi_staa_sync()
1027 mutex_unlock(&chip->mutex); in cfi_staa_sync()
1033 struct cfi_private *cfi = map->fldrv_priv; in do_lock_oneblock()
1038 adr += chip->start; in do_lock_oneblock()
1040 /* Let's determine this according to the interleave only once */ in do_lock_oneblock()
1045 mutex_lock(&chip->mutex); in do_lock_oneblock()
1048 switch (chip->state) { in do_lock_oneblock()
1053 chip->state = FL_STATUS; in do_lock_oneblock()
1062 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1064 return -EIO; in do_lock_oneblock()
1068 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1076 add_wait_queue(&chip->wq, &wait); in do_lock_oneblock()
1077 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1079 remove_wait_queue(&chip->wq, &wait); in do_lock_oneblock()
1087 chip->state = FL_LOCKING; in do_lock_oneblock()
1089 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1091 mutex_lock(&chip->mutex); in do_lock_oneblock()
1106 chip->state = FL_STATUS; in do_lock_oneblock()
1109 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1110 return -EIO; in do_lock_oneblock()
1114 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1116 mutex_lock(&chip->mutex); in do_lock_oneblock()
1120 chip->state = FL_STATUS; in do_lock_oneblock()
1122 wake_up(&chip->wq); in do_lock_oneblock()
1123 mutex_unlock(&chip->mutex); in do_lock_oneblock()
1128 struct map_info *map = mtd->priv; in cfi_staa_lock()
1129 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_lock()
1133 int ofs_factor = cfi->interleave * cfi->device_type; in cfi_staa_lock()
1136 if (ofs & (mtd->erasesize - 1)) in cfi_staa_lock()
1137 return -EINVAL; in cfi_staa_lock()
1139 if (len & (mtd->erasesize -1)) in cfi_staa_lock()
1140 return -EINVAL; in cfi_staa_lock()
1142 chipnum = ofs >> cfi->chipshift; in cfi_staa_lock()
1143 adr = ofs - (chipnum << cfi->chipshift); in cfi_staa_lock()
1148 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1150 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1153 ret = do_lock_oneblock(map, &cfi->chips[chipnum], adr); in cfi_staa_lock()
1156 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1158 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_lock()
1164 adr += mtd->erasesize; in cfi_staa_lock()
1165 len -= mtd->erasesize; in cfi_staa_lock()
1167 if (adr >> cfi->chipshift) { in cfi_staa_lock()
1171 if (chipnum >= cfi->numchips) in cfi_staa_lock()
1179 struct cfi_private *cfi = map->fldrv_priv; in do_unlock_oneblock()
1184 adr += chip->start; in do_unlock_oneblock()
1186 /* Let's determine this according to the interleave only once */ in do_unlock_oneblock()
1191 mutex_lock(&chip->mutex); in do_unlock_oneblock()
1194 switch (chip->state) { in do_unlock_oneblock()
1199 chip->state = FL_STATUS; in do_unlock_oneblock()
1208 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1210 return -EIO; in do_unlock_oneblock()
1214 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1222 add_wait_queue(&chip->wq, &wait); in do_unlock_oneblock()
1223 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1225 remove_wait_queue(&chip->wq, &wait); in do_unlock_oneblock()
1233 chip->state = FL_UNLOCKING; in do_unlock_oneblock()
1235 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1237 mutex_lock(&chip->mutex); in do_unlock_oneblock()
1252 chip->state = FL_STATUS; in do_unlock_oneblock()
1255 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1256 return -EIO; in do_unlock_oneblock()
1260 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1262 mutex_lock(&chip->mutex); in do_unlock_oneblock()
1266 chip->state = FL_STATUS; in do_unlock_oneblock()
1268 wake_up(&chip->wq); in do_unlock_oneblock()
1269 mutex_unlock(&chip->mutex); in do_unlock_oneblock()
1274 struct map_info *map = mtd->priv; in cfi_staa_unlock()
1275 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_unlock()
1279 int ofs_factor = cfi->interleave * cfi->device_type; in cfi_staa_unlock()
1282 chipnum = ofs >> cfi->chipshift; in cfi_staa_unlock()
1283 adr = ofs - (chipnum << cfi->chipshift); in cfi_staa_unlock()
1290 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1293 temp_adr += mtd->erasesize; in cfi_staa_unlock()
1294 temp_len -= mtd->erasesize; in cfi_staa_unlock()
1296 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1300 ret = do_unlock_oneblock(map, &cfi->chips[chipnum], adr); in cfi_staa_unlock()
1303 cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1305 cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL); in cfi_staa_unlock()
1313 struct map_info *map = mtd->priv; in cfi_staa_suspend()
1314 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_suspend()
1319 for (i=0; !ret && i<cfi->numchips; i++) { in cfi_staa_suspend()
1320 chip = &cfi->chips[i]; in cfi_staa_suspend()
1322 mutex_lock(&chip->mutex); in cfi_staa_suspend()
1324 switch(chip->state) { in cfi_staa_suspend()
1329 chip->oldstate = chip->state; in cfi_staa_suspend()
1330 chip->state = FL_PM_SUSPENDED; in cfi_staa_suspend()
1331 /* No need to wake_up() on this state change - in cfi_staa_suspend()
1341 ret = -EAGAIN; in cfi_staa_suspend()
1344 mutex_unlock(&chip->mutex); in cfi_staa_suspend()
1350 for (i--; i >=0; i--) { in cfi_staa_suspend()
1351 chip = &cfi->chips[i]; in cfi_staa_suspend()
1353 mutex_lock(&chip->mutex); in cfi_staa_suspend()
1355 if (chip->state == FL_PM_SUSPENDED) { in cfi_staa_suspend()
1359 chip->state = chip->oldstate; in cfi_staa_suspend()
1360 wake_up(&chip->wq); in cfi_staa_suspend()
1362 mutex_unlock(&chip->mutex); in cfi_staa_suspend()
1371 struct map_info *map = mtd->priv; in cfi_staa_resume()
1372 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_resume()
1376 for (i=0; i<cfi->numchips; i++) { in cfi_staa_resume()
1378 chip = &cfi->chips[i]; in cfi_staa_resume()
1380 mutex_lock(&chip->mutex); in cfi_staa_resume()
1383 if (chip->state == FL_PM_SUSPENDED) { in cfi_staa_resume()
1385 chip->state = FL_READY; in cfi_staa_resume()
1386 wake_up(&chip->wq); in cfi_staa_resume()
1389 mutex_unlock(&chip->mutex); in cfi_staa_resume()
1395 struct map_info *map = mtd->priv; in cfi_staa_destroy()
1396 struct cfi_private *cfi = map->fldrv_priv; in cfi_staa_destroy()
1397 kfree(cfi->cmdset_priv); in cfi_staa_destroy()