Lines Matching refs:docg3

92 static inline u8 doc_readb(struct docg3 *docg3, u16 reg)  in doc_readb()  argument
94 u8 val = readb(docg3->cascade->base + reg); in doc_readb()
100 static inline u16 doc_readw(struct docg3 *docg3, u16 reg) in doc_readw() argument
102 u16 val = readw(docg3->cascade->base + reg); in doc_readw()
108 static inline void doc_writeb(struct docg3 *docg3, u8 val, u16 reg) in doc_writeb() argument
110 writeb(val, docg3->cascade->base + reg); in doc_writeb()
114 static inline void doc_writew(struct docg3 *docg3, u16 val, u16 reg) in doc_writew() argument
116 writew(val, docg3->cascade->base + reg); in doc_writew()
120 static inline void doc_flash_command(struct docg3 *docg3, u8 cmd) in doc_flash_command() argument
122 doc_writeb(docg3, cmd, DOC_FLASHCOMMAND); in doc_flash_command()
125 static inline void doc_flash_sequence(struct docg3 *docg3, u8 seq) in doc_flash_sequence() argument
127 doc_writeb(docg3, seq, DOC_FLASHSEQUENCE); in doc_flash_sequence()
130 static inline void doc_flash_address(struct docg3 *docg3, u8 addr) in doc_flash_address() argument
132 doc_writeb(docg3, addr, DOC_FLASHADDRESS); in doc_flash_address()
137 static int doc_register_readb(struct docg3 *docg3, int reg) in doc_register_readb() argument
141 doc_writew(docg3, reg, DOC_READADDRESS); in doc_register_readb()
142 val = doc_readb(docg3, reg); in doc_register_readb()
147 static int doc_register_readw(struct docg3 *docg3, int reg) in doc_register_readw() argument
151 doc_writew(docg3, reg, DOC_READADDRESS); in doc_register_readw()
152 val = doc_readw(docg3, reg); in doc_register_readw()
168 static void doc_delay(struct docg3 *docg3, int nbNOPs) in doc_delay() argument
174 doc_writeb(docg3, 0, DOC_NOP); in doc_delay()
177 static int is_prot_seq_error(struct docg3 *docg3) in is_prot_seq_error() argument
181 ctrl = doc_register_readb(docg3, DOC_FLASHCONTROL); in is_prot_seq_error()
185 static int doc_is_ready(struct docg3 *docg3) in doc_is_ready() argument
189 ctrl = doc_register_readb(docg3, DOC_FLASHCONTROL); in doc_is_ready()
193 static int doc_wait_ready(struct docg3 *docg3) in doc_wait_ready() argument
198 doc_delay(docg3, 4); in doc_wait_ready()
200 } while (!doc_is_ready(docg3) && maxWaitCycles--); in doc_wait_ready()
201 doc_delay(docg3, 2); in doc_wait_ready()
208 static int doc_reset_seq(struct docg3 *docg3) in doc_reset_seq() argument
212 doc_writeb(docg3, 0x10, DOC_FLASHCONTROL); in doc_reset_seq()
213 doc_flash_sequence(docg3, DOC_SEQ_RESET); in doc_reset_seq()
214 doc_flash_command(docg3, DOC_CMD_RESET); in doc_reset_seq()
215 doc_delay(docg3, 2); in doc_reset_seq()
216 ret = doc_wait_ready(docg3); in doc_reset_seq()
231 static void doc_read_data_area(struct docg3 *docg3, void *buf, int len, in doc_read_data_area() argument
243 doc_writew(docg3, DOC_IOSPACE_DATA, DOC_READADDRESS); in doc_read_data_area()
246 data16 = doc_readw(docg3, DOC_IOSPACE_DATA); in doc_read_data_area()
254 doc_writew(docg3, DOC_IOSPACE_DATA | DOC_READADDR_ONE_BYTE, in doc_read_data_area()
256 doc_delay(docg3, 1); in doc_read_data_area()
259 data8 = doc_readb(docg3, DOC_IOSPACE_DATA); in doc_read_data_area()
276 static void doc_write_data_area(struct docg3 *docg3, const void *buf, int len) in doc_write_data_area() argument
286 doc_writew(docg3, DOC_IOSPACE_DATA, DOC_READADDRESS); in doc_write_data_area()
289 doc_writew(docg3, *src16, DOC_IOSPACE_DATA); in doc_write_data_area()
295 doc_writew(docg3, DOC_IOSPACE_DATA | DOC_READADDR_ONE_BYTE, in doc_write_data_area()
297 doc_writeb(docg3, *src8, DOC_IOSPACE_DATA); in doc_write_data_area()
317 static void doc_set_reliable_mode(struct docg3 *docg3) in doc_set_reliable_mode() argument
321 doc_dbg("doc_set_reliable_mode(%s)\n", strmode[docg3->reliable]); in doc_set_reliable_mode()
322 switch (docg3->reliable) { in doc_set_reliable_mode()
326 doc_flash_sequence(docg3, DOC_SEQ_SET_FASTMODE); in doc_set_reliable_mode()
327 doc_flash_command(docg3, DOC_CMD_FAST_MODE); in doc_set_reliable_mode()
330 doc_flash_sequence(docg3, DOC_SEQ_SET_RELIABLEMODE); in doc_set_reliable_mode()
331 doc_flash_command(docg3, DOC_CMD_FAST_MODE); in doc_set_reliable_mode()
332 doc_flash_command(docg3, DOC_CMD_RELIABLE_MODE); in doc_set_reliable_mode()
338 doc_delay(docg3, 2); in doc_set_reliable_mode()
351 static void doc_set_asic_mode(struct docg3 *docg3, u8 mode) in doc_set_asic_mode() argument
356 doc_readb(docg3, DOC_IOSPACE_IPL); in doc_set_asic_mode()
360 doc_writeb(docg3, mode, DOC_ASICMODE); in doc_set_asic_mode()
361 doc_writeb(docg3, ~mode, DOC_ASICMODECONFIRM); in doc_set_asic_mode()
362 doc_delay(docg3, 1); in doc_set_asic_mode()
373 static void doc_set_device_id(struct docg3 *docg3, int id) in doc_set_device_id() argument
378 doc_writeb(docg3, id, DOC_DEVICESELECT); in doc_set_device_id()
379 ctrl = doc_register_readb(docg3, DOC_FLASHCONTROL); in doc_set_device_id()
383 doc_writeb(docg3, ctrl, DOC_FLASHCONTROL); in doc_set_device_id()
397 static int doc_set_extra_page_mode(struct docg3 *docg3) in doc_set_extra_page_mode() argument
402 doc_flash_sequence(docg3, DOC_SEQ_PAGE_SIZE_532); in doc_set_extra_page_mode()
403 doc_flash_command(docg3, DOC_CMD_PAGE_SIZE_532); in doc_set_extra_page_mode()
404 doc_delay(docg3, 2); in doc_set_extra_page_mode()
406 fctrl = doc_register_readb(docg3, DOC_FLASHCONTROL); in doc_set_extra_page_mode()
418 static void doc_setup_addr_sector(struct docg3 *docg3, int sector) in doc_setup_addr_sector() argument
420 doc_delay(docg3, 1); in doc_setup_addr_sector()
421 doc_flash_address(docg3, sector & 0xff); in doc_setup_addr_sector()
422 doc_flash_address(docg3, (sector >> 8) & 0xff); in doc_setup_addr_sector()
423 doc_flash_address(docg3, (sector >> 16) & 0xff); in doc_setup_addr_sector()
424 doc_delay(docg3, 1); in doc_setup_addr_sector()
433 static void doc_setup_writeaddr_sector(struct docg3 *docg3, int sector, int ofs) in doc_setup_writeaddr_sector() argument
436 doc_delay(docg3, 1); in doc_setup_writeaddr_sector()
437 doc_flash_address(docg3, ofs & 0xff); in doc_setup_writeaddr_sector()
438 doc_flash_address(docg3, sector & 0xff); in doc_setup_writeaddr_sector()
439 doc_flash_address(docg3, (sector >> 8) & 0xff); in doc_setup_writeaddr_sector()
440 doc_flash_address(docg3, (sector >> 16) & 0xff); in doc_setup_writeaddr_sector()
441 doc_delay(docg3, 1); in doc_setup_writeaddr_sector()
456 static int doc_read_seek(struct docg3 *docg3, int block0, int block1, int page, in doc_read_seek() argument
465 doc_flash_sequence(docg3, DOC_SEQ_SET_PLANE1); in doc_read_seek()
466 doc_flash_command(docg3, DOC_CMD_READ_PLANE1); in doc_read_seek()
467 doc_delay(docg3, 2); in doc_read_seek()
469 doc_flash_sequence(docg3, DOC_SEQ_SET_PLANE2); in doc_read_seek()
470 doc_flash_command(docg3, DOC_CMD_READ_PLANE2); in doc_read_seek()
471 doc_delay(docg3, 2); in doc_read_seek()
474 doc_set_reliable_mode(docg3); in doc_read_seek()
476 ret = doc_set_extra_page_mode(docg3); in doc_read_seek()
480 doc_flash_sequence(docg3, DOC_SEQ_READ); in doc_read_seek()
482 doc_flash_command(docg3, DOC_CMD_PROG_BLOCK_ADDR); in doc_read_seek()
483 doc_setup_addr_sector(docg3, sector); in doc_read_seek()
486 doc_flash_command(docg3, DOC_CMD_PROG_BLOCK_ADDR); in doc_read_seek()
487 doc_setup_addr_sector(docg3, sector); in doc_read_seek()
488 doc_delay(docg3, 1); in doc_read_seek()
505 static int doc_write_seek(struct docg3 *docg3, int block0, int block1, int page, in doc_write_seek() argument
513 doc_set_reliable_mode(docg3); in doc_write_seek()
516 doc_flash_sequence(docg3, DOC_SEQ_SET_PLANE1); in doc_write_seek()
517 doc_flash_command(docg3, DOC_CMD_READ_PLANE1); in doc_write_seek()
518 doc_delay(docg3, 2); in doc_write_seek()
520 doc_flash_sequence(docg3, DOC_SEQ_SET_PLANE2); in doc_write_seek()
521 doc_flash_command(docg3, DOC_CMD_READ_PLANE2); in doc_write_seek()
522 doc_delay(docg3, 2); in doc_write_seek()
525 doc_flash_sequence(docg3, DOC_SEQ_PAGE_SETUP); in doc_write_seek()
526 doc_flash_command(docg3, DOC_CMD_PROG_CYCLE1); in doc_write_seek()
529 doc_setup_writeaddr_sector(docg3, sector, ofs); in doc_write_seek()
531 doc_flash_command(docg3, DOC_CMD_PROG_CYCLE3); in doc_write_seek()
532 doc_delay(docg3, 2); in doc_write_seek()
533 ret = doc_wait_ready(docg3); in doc_write_seek()
537 doc_flash_command(docg3, DOC_CMD_PROG_CYCLE1); in doc_write_seek()
539 doc_setup_writeaddr_sector(docg3, sector, ofs); in doc_write_seek()
540 doc_delay(docg3, 1); in doc_write_seek()
557 static int doc_read_page_ecc_init(struct docg3 *docg3, int len) in doc_read_page_ecc_init() argument
559 doc_writew(docg3, DOC_ECCCONF0_READ_MODE in doc_read_page_ecc_init()
563 doc_delay(docg3, 4); in doc_read_page_ecc_init()
564 doc_register_readb(docg3, DOC_FLASHCONTROL); in doc_read_page_ecc_init()
565 return doc_wait_ready(docg3); in doc_read_page_ecc_init()
578 static int doc_write_page_ecc_init(struct docg3 *docg3, int len) in doc_write_page_ecc_init() argument
580 doc_writew(docg3, DOC_ECCCONF0_WRITE_MODE in doc_write_page_ecc_init()
584 doc_delay(docg3, 4); in doc_write_page_ecc_init()
585 doc_register_readb(docg3, DOC_FLASHCONTROL); in doc_write_page_ecc_init()
586 return doc_wait_ready(docg3); in doc_write_page_ecc_init()
596 static void doc_ecc_disable(struct docg3 *docg3) in doc_ecc_disable() argument
598 doc_writew(docg3, DOC_ECCCONF0_READ_MODE, DOC_ECCCONF0); in doc_ecc_disable()
599 doc_delay(docg3, 4); in doc_ecc_disable()
610 static void doc_hamming_ecc_init(struct docg3 *docg3, int nb_bytes) in doc_hamming_ecc_init() argument
614 ecc_conf1 = doc_register_readb(docg3, DOC_ECCCONF1); in doc_hamming_ecc_init()
617 doc_writeb(docg3, ecc_conf1, DOC_ECCCONF1); in doc_hamming_ecc_init()
643 static int doc_ecc_bch_fix_data(struct docg3 *docg3, void *buf, u8 *hwecc) in doc_ecc_bch_fix_data() argument
650 numerrs = decode_bch(docg3->cascade->bch, NULL, in doc_ecc_bch_fix_data()
695 static int doc_read_page_prepare(struct docg3 *docg3, int block0, int block1, in doc_read_page_prepare() argument
707 doc_set_device_id(docg3, docg3->device_id); in doc_read_page_prepare()
708 ret = doc_reset_seq(docg3); in doc_read_page_prepare()
713 ret = doc_read_seek(docg3, block0, block1, page, wear_area, offset); in doc_read_page_prepare()
717 doc_flash_command(docg3, DOC_CMD_READ_ALL_PLANES); in doc_read_page_prepare()
718 doc_delay(docg3, 2); in doc_read_page_prepare()
719 doc_wait_ready(docg3); in doc_read_page_prepare()
721 doc_flash_command(docg3, DOC_CMD_SET_ADDR_READ); in doc_read_page_prepare()
722 doc_delay(docg3, 1); in doc_read_page_prepare()
725 doc_flash_address(docg3, offset >> 2); in doc_read_page_prepare()
726 doc_delay(docg3, 1); in doc_read_page_prepare()
727 doc_wait_ready(docg3); in doc_read_page_prepare()
729 doc_flash_command(docg3, DOC_CMD_READ_FLASH); in doc_read_page_prepare()
733 doc_writeb(docg3, 0, DOC_DATAEND); in doc_read_page_prepare()
734 doc_delay(docg3, 2); in doc_read_page_prepare()
753 static int doc_read_page_getbytes(struct docg3 *docg3, int len, u_char *buf, in doc_read_page_getbytes() argument
757 doc_read_data_area(docg3, buf, 1, first); in doc_read_page_getbytes()
758 doc_read_data_area(docg3, buf ? buf + 1 : buf, len - 1, 0); in doc_read_page_getbytes()
760 doc_read_data_area(docg3, buf, len, first); in doc_read_page_getbytes()
762 doc_delay(docg3, 2); in doc_read_page_getbytes()
773 static void doc_write_page_putbytes(struct docg3 *docg3, int len, in doc_write_page_putbytes() argument
776 doc_write_data_area(docg3, buf, len); in doc_write_page_putbytes()
777 doc_delay(docg3, 2); in doc_write_page_putbytes()
785 static void doc_get_bch_hw_ecc(struct docg3 *docg3, u8 *hwecc) in doc_get_bch_hw_ecc() argument
790 hwecc[i] = doc_register_readb(docg3, DOC_BCH_HW_ECC(i)); in doc_get_bch_hw_ecc()
797 static void doc_page_finish(struct docg3 *docg3) in doc_page_finish() argument
799 doc_writeb(docg3, 0, DOC_DATAEND); in doc_page_finish()
800 doc_delay(docg3, 2); in doc_page_finish()
811 static void doc_read_page_finish(struct docg3 *docg3) in doc_read_page_finish() argument
813 doc_page_finish(docg3); in doc_read_page_finish()
814 doc_set_device_id(docg3, 0); in doc_read_page_finish()
868 struct docg3 *docg3 = mtd->priv; in doc_read_oob() local
897 mutex_lock(&docg3->cascade->lock); in doc_read_oob()
900 docg3->reliable); in doc_read_oob()
903 ret = doc_read_page_prepare(docg3, block0, block1, page, ofs); in doc_read_oob()
906 ret = doc_read_page_ecc_init(docg3, DOC_ECC_BCH_TOTAL_BYTES); in doc_read_oob()
909 ret = doc_read_page_getbytes(docg3, skip, NULL, 1, 0); in doc_read_oob()
912 ret = doc_read_page_getbytes(docg3, nbdata, buf, 0, skip % 2); in doc_read_oob()
915 doc_read_page_getbytes(docg3, in doc_read_oob()
918 ret = doc_read_page_getbytes(docg3, nboob, oobbuf, 0, 0); in doc_read_oob()
921 doc_read_page_getbytes(docg3, DOC_LAYOUT_OOB_SIZE - nboob, in doc_read_oob()
924 doc_get_bch_hw_ecc(docg3, hwecc); in doc_read_oob()
925 eccconf1 = doc_register_readb(docg3, DOC_ECCCONF1); in doc_read_oob()
937 if (is_prot_seq_error(docg3)) in doc_read_oob()
945 ret = doc_ecc_bch_fix_data(docg3, buf, hwecc); in doc_read_oob()
957 doc_read_page_finish(docg3); in doc_read_oob()
969 mutex_unlock(&docg3->cascade->lock); in doc_read_oob()
972 doc_read_page_finish(docg3); in doc_read_oob()
976 static int doc_reload_bbt(struct docg3 *docg3) in doc_reload_bbt() argument
980 u_char *buf = docg3->bbt; in doc_reload_bbt()
982 nbpages = DIV_ROUND_UP(docg3->max_block + 1, 8 * DOC_LAYOUT_PAGE_SIZE); in doc_reload_bbt()
984 ret = doc_read_page_prepare(docg3, block, block + 1, in doc_reload_bbt()
987 ret = doc_read_page_ecc_init(docg3, in doc_reload_bbt()
990 doc_read_page_getbytes(docg3, DOC_LAYOUT_PAGE_SIZE, in doc_reload_bbt()
994 doc_read_page_finish(docg3); in doc_reload_bbt()
1007 struct docg3 *docg3 = mtd->priv; in doc_block_isbad() local
1011 docg3->reliable); in doc_block_isbad()
1017 if (block1 > docg3->max_block) in doc_block_isbad()
1020 is_good = docg3->bbt[block0 >> 3] & (1 << (block0 & 0x7)); in doc_block_isbad()
1035 static int doc_get_erase_count(struct docg3 *docg3, loff_t from)
1044 calc_block_sector(from, &block0, &block1, &page, &ofs, docg3->reliable);
1045 if (block1 > docg3->max_block)
1048 ret = doc_reset_seq(docg3);
1050 ret = doc_read_page_prepare(docg3, block0, block1, page,
1053 ret = doc_read_page_getbytes(docg3, DOC_LAYOUT_WEAR_SIZE,
1055 doc_read_page_finish(docg3);
1076 static int doc_get_op_status(struct docg3 *docg3) in doc_get_op_status() argument
1080 doc_flash_sequence(docg3, DOC_SEQ_PLANES_STATUS); in doc_get_op_status()
1081 doc_flash_command(docg3, DOC_CMD_PLANES_STATUS); in doc_get_op_status()
1082 doc_delay(docg3, 5); in doc_get_op_status()
1084 doc_ecc_disable(docg3); in doc_get_op_status()
1085 doc_read_data_area(docg3, &status, 1, 1); in doc_get_op_status()
1099 static int doc_write_erase_wait_status(struct docg3 *docg3) in doc_write_erase_wait_status() argument
1103 for (i = 0; !doc_is_ready(docg3) && i < 5; i++) in doc_write_erase_wait_status()
1105 if (!doc_is_ready(docg3)) { in doc_write_erase_wait_status()
1111 status = doc_get_op_status(docg3); in doc_write_erase_wait_status()
1119 doc_page_finish(docg3); in doc_write_erase_wait_status()
1134 static int doc_erase_block(struct docg3 *docg3, int block0, int block1) in doc_erase_block() argument
1139 ret = doc_reset_seq(docg3); in doc_erase_block()
1143 doc_set_reliable_mode(docg3); in doc_erase_block()
1144 doc_flash_sequence(docg3, DOC_SEQ_ERASE); in doc_erase_block()
1147 doc_flash_command(docg3, DOC_CMD_PROG_BLOCK_ADDR); in doc_erase_block()
1148 doc_setup_addr_sector(docg3, sector); in doc_erase_block()
1150 doc_flash_command(docg3, DOC_CMD_PROG_BLOCK_ADDR); in doc_erase_block()
1151 doc_setup_addr_sector(docg3, sector); in doc_erase_block()
1152 doc_delay(docg3, 1); in doc_erase_block()
1154 doc_flash_command(docg3, DOC_CMD_ERASECYCLE2); in doc_erase_block()
1155 doc_delay(docg3, 2); in doc_erase_block()
1157 if (is_prot_seq_error(docg3)) { in doc_erase_block()
1162 return doc_write_erase_wait_status(docg3); in doc_erase_block()
1178 struct docg3 *docg3 = mtd->priv; in doc_erase() local
1185 &ofs, docg3->reliable); in doc_erase()
1190 docg3->reliable); in doc_erase()
1191 mutex_lock(&docg3->cascade->lock); in doc_erase()
1192 doc_set_device_id(docg3, docg3->device_id); in doc_erase()
1193 doc_set_reliable_mode(docg3); in doc_erase()
1195 ret = doc_erase_block(docg3, block0, block1); in doc_erase()
1199 mutex_unlock(&docg3->cascade->lock); in doc_erase()
1223 static int doc_write_page(struct docg3 *docg3, loff_t to, const u_char *buf, in doc_write_page() argument
1230 calc_block_sector(to, &block0, &block1, &page, &ofs, docg3->reliable); in doc_write_page()
1232 doc_set_device_id(docg3, docg3->device_id); in doc_write_page()
1233 ret = doc_reset_seq(docg3); in doc_write_page()
1238 ret = doc_write_seek(docg3, block0, block1, page, ofs); in doc_write_page()
1242 doc_write_page_ecc_init(docg3, DOC_ECC_BCH_TOTAL_BYTES); in doc_write_page()
1243 doc_delay(docg3, 2); in doc_write_page()
1244 doc_write_page_putbytes(docg3, DOC_LAYOUT_PAGE_SIZE, buf); in doc_write_page()
1247 doc_write_page_putbytes(docg3, DOC_LAYOUT_OOB_PAGEINFO_SZ, oob); in doc_write_page()
1248 doc_delay(docg3, 2); in doc_write_page()
1251 hamming = doc_register_readb(docg3, DOC_HAMMINGPARITY); in doc_write_page()
1252 doc_delay(docg3, 2); in doc_write_page()
1253 doc_write_page_putbytes(docg3, DOC_LAYOUT_OOB_HAMMING_SZ, in doc_write_page()
1255 doc_delay(docg3, 2); in doc_write_page()
1257 doc_get_bch_hw_ecc(docg3, hwecc); in doc_write_page()
1258 doc_write_page_putbytes(docg3, DOC_LAYOUT_OOB_BCH_SZ, hwecc); in doc_write_page()
1259 doc_delay(docg3, 2); in doc_write_page()
1261 doc_write_page_putbytes(docg3, DOC_LAYOUT_OOB_UNUSED_SZ, oob); in doc_write_page()
1264 doc_write_page_putbytes(docg3, DOC_LAYOUT_OOB_SIZE, oob); in doc_write_page()
1266 doc_delay(docg3, 2); in doc_write_page()
1267 doc_page_finish(docg3); in doc_write_page()
1268 doc_delay(docg3, 2); in doc_write_page()
1269 doc_flash_command(docg3, DOC_CMD_PROG_CYCLE2); in doc_write_page()
1270 doc_delay(docg3, 2); in doc_write_page()
1276 ret = doc_write_erase_wait_status(docg3); in doc_write_page()
1279 doc_read_page_finish(docg3); in doc_write_page()
1336 static int doc_backup_oob(struct docg3 *docg3, loff_t to, in doc_backup_oob() argument
1347 docg3->oob_write_ofs = to; in doc_backup_oob()
1348 docg3->oob_autoecc = autoecc; in doc_backup_oob()
1350 doc_fill_autooob(docg3->oob_write_buf, ops->oobbuf); in doc_backup_oob()
1353 memcpy(docg3->oob_write_buf, ops->oobbuf, DOC_LAYOUT_OOB_SIZE); in doc_backup_oob()
1377 struct docg3 *docg3 = mtd->priv; in doc_write_oob() local
1422 return doc_backup_oob(docg3, ofs, ops); in doc_write_oob()
1428 mutex_lock(&docg3->cascade->lock); in doc_write_oob()
1431 if (ofs == docg3->oob_write_ofs) in doc_write_oob()
1432 memcpy(oob, docg3->oob_write_buf, DOC_LAYOUT_OOB_SIZE); in doc_write_oob()
1437 ret = doc_write_page(docg3, ofs, buf, oob, autoecc); in doc_write_oob()
1450 doc_set_device_id(docg3, 0); in doc_write_oob()
1451 mutex_unlock(&docg3->cascade->lock); in doc_write_oob()
1455 static struct docg3 *sysfs_dev2docg3(struct device *dev, in sysfs_dev2docg3()
1471 struct docg3 *docg3 = sysfs_dev2docg3(dev, attr); in dps0_is_key_locked() local
1474 mutex_lock(&docg3->cascade->lock); in dps0_is_key_locked()
1475 doc_set_device_id(docg3, docg3->device_id); in dps0_is_key_locked()
1476 dps0 = doc_register_readb(docg3, DOC_DPS0_STATUS); in dps0_is_key_locked()
1477 doc_set_device_id(docg3, 0); in dps0_is_key_locked()
1478 mutex_unlock(&docg3->cascade->lock); in dps0_is_key_locked()
1486 struct docg3 *docg3 = sysfs_dev2docg3(dev, attr); in dps1_is_key_locked() local
1489 mutex_lock(&docg3->cascade->lock); in dps1_is_key_locked()
1490 doc_set_device_id(docg3, docg3->device_id); in dps1_is_key_locked()
1491 dps1 = doc_register_readb(docg3, DOC_DPS1_STATUS); in dps1_is_key_locked()
1492 doc_set_device_id(docg3, 0); in dps1_is_key_locked()
1493 mutex_unlock(&docg3->cascade->lock); in dps1_is_key_locked()
1502 struct docg3 *docg3 = sysfs_dev2docg3(dev, attr); in dps0_insert_key() local
1508 mutex_lock(&docg3->cascade->lock); in dps0_insert_key()
1509 doc_set_device_id(docg3, docg3->device_id); in dps0_insert_key()
1511 doc_writeb(docg3, buf[i], DOC_DPS0_KEY); in dps0_insert_key()
1512 doc_set_device_id(docg3, 0); in dps0_insert_key()
1513 mutex_unlock(&docg3->cascade->lock); in dps0_insert_key()
1521 struct docg3 *docg3 = sysfs_dev2docg3(dev, attr); in dps1_insert_key() local
1527 mutex_lock(&docg3->cascade->lock); in dps1_insert_key()
1528 doc_set_device_id(docg3, docg3->device_id); in dps1_insert_key()
1530 doc_writeb(docg3, buf[i], DOC_DPS1_KEY); in dps1_insert_key()
1531 doc_set_device_id(docg3, 0); in dps1_insert_key()
1532 mutex_unlock(&docg3->cascade->lock); in dps1_insert_key()
1594 struct docg3 *docg3 = (struct docg3 *)s->private; in flashcontrol_show() local
1598 mutex_lock(&docg3->cascade->lock); in flashcontrol_show()
1599 fctrl = doc_register_readb(docg3, DOC_FLASHCONTROL); in flashcontrol_show()
1600 mutex_unlock(&docg3->cascade->lock); in flashcontrol_show()
1616 struct docg3 *docg3 = (struct docg3 *)s->private; in asic_mode_show() local
1620 mutex_lock(&docg3->cascade->lock); in asic_mode_show()
1621 pctrl = doc_register_readb(docg3, DOC_ASICMODE); in asic_mode_show()
1623 mutex_unlock(&docg3->cascade->lock); in asic_mode_show()
1653 struct docg3 *docg3 = (struct docg3 *)s->private; in device_id_show() local
1656 mutex_lock(&docg3->cascade->lock); in device_id_show()
1657 id = doc_register_readb(docg3, DOC_DEVICESELECT); in device_id_show()
1658 mutex_unlock(&docg3->cascade->lock); in device_id_show()
1667 struct docg3 *docg3 = (struct docg3 *)s->private; in protection_show() local
1670 mutex_lock(&docg3->cascade->lock); in protection_show()
1671 protect = doc_register_readb(docg3, DOC_PROTECTION); in protection_show()
1672 dps0 = doc_register_readb(docg3, DOC_DPS0_STATUS); in protection_show()
1673 dps0_low = doc_register_readw(docg3, DOC_DPS0_ADDRLOW); in protection_show()
1674 dps0_high = doc_register_readw(docg3, DOC_DPS0_ADDRHIGH); in protection_show()
1675 dps1 = doc_register_readb(docg3, DOC_DPS1_STATUS); in protection_show()
1676 dps1_low = doc_register_readw(docg3, DOC_DPS1_ADDRLOW); in protection_show()
1677 dps1_high = doc_register_readw(docg3, DOC_DPS1_ADDRHIGH); in protection_show()
1678 mutex_unlock(&docg3->cascade->lock); in protection_show()
1720 struct docg3 *docg3 = floor->priv; in doc_dbg_register() local
1730 debugfs_create_file("docg3_flashcontrol", S_IRUSR, root, docg3, in doc_dbg_register()
1732 debugfs_create_file("docg3_asic_mode", S_IRUSR, root, docg3, in doc_dbg_register()
1734 debugfs_create_file("docg3_device_id", S_IRUSR, root, docg3, in doc_dbg_register()
1736 debugfs_create_file("docg3_protection", S_IRUSR, root, docg3, in doc_dbg_register()
1747 struct docg3 *docg3 = mtd->priv; in doc_set_driver_info() local
1750 cfg = doc_register_readb(docg3, DOC_CONFIGURATION); in doc_set_driver_info()
1751 docg3->if_cfg = (cfg & DOC_CONF_IF_CFG ? 1 : 0); in doc_set_driver_info()
1752 docg3->reliable = reliable_mode; in doc_set_driver_info()
1756 mtd->name = devm_kasprintf(docg3->dev, GFP_KERNEL, "docg3.%d", in doc_set_driver_info()
1757 docg3->device_id); in doc_set_driver_info()
1760 docg3->max_block = 2047; in doc_set_driver_info()
1765 mtd->size = (docg3->max_block + 1) * DOC_LAYOUT_BLOCK_SIZE; in doc_set_driver_info()
1766 if (docg3->reliable == 2) in doc_set_driver_info()
1769 if (docg3->reliable == 2) in doc_set_driver_info()
1802 struct docg3 *docg3; in doc_probe_device() local
1806 docg3 = kzalloc(sizeof(struct docg3), GFP_KERNEL); in doc_probe_device()
1807 if (!docg3) in doc_probe_device()
1812 mtd->priv = docg3; in doc_probe_device()
1814 bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1, in doc_probe_device()
1816 docg3->bbt = kcalloc(DOC_LAYOUT_PAGE_SIZE, bbt_nbpages, GFP_KERNEL); in doc_probe_device()
1817 if (!docg3->bbt) in doc_probe_device()
1820 docg3->dev = dev; in doc_probe_device()
1821 docg3->device_id = floor; in doc_probe_device()
1822 docg3->cascade = cascade; in doc_probe_device()
1823 doc_set_device_id(docg3, docg3->device_id); in doc_probe_device()
1825 doc_set_asic_mode(docg3, DOC_ASICMODE_RESET); in doc_probe_device()
1826 doc_set_asic_mode(docg3, DOC_ASICMODE_NORMAL); in doc_probe_device()
1828 chip_id = doc_register_readw(docg3, DOC_CHIPID); in doc_probe_device()
1829 chip_id_inv = doc_register_readw(docg3, DOC_CHIPID_INV); in doc_probe_device()
1839 docg3->cascade->base, floor); in doc_probe_device()
1850 doc_hamming_ecc_init(docg3, DOC_LAYOUT_OOB_PAGEINFO_SZ); in doc_probe_device()
1851 doc_reload_bbt(docg3); in doc_probe_device()
1855 kfree(docg3->bbt); in doc_probe_device()
1859 kfree(docg3); in doc_probe_device()
1870 struct docg3 *docg3 = mtd->priv; in doc_release_device() local
1873 kfree(docg3->bbt); in doc_release_device()
1874 kfree(docg3); in doc_release_device()
1889 struct docg3 *docg3; in docg3_resume() local
1894 docg3 = mtd->priv; in docg3_resume()
1898 doc_readb(docg3, DOC_IOSPACE_IPL); in docg3_resume()
1916 struct docg3 *docg3; in docg3_suspend() local
1925 docg3 = mtd->priv; in docg3_suspend()
1927 doc_writeb(docg3, floor, DOC_DEVICESELECT); in docg3_suspend()
1928 ctrl = doc_register_readb(docg3, DOC_FLASHCONTROL); in docg3_suspend()
1930 doc_writeb(docg3, ctrl, DOC_FLASHCONTROL); in docg3_suspend()
1934 pwr_down = doc_register_readb(docg3, DOC_POWERMODE); in docg3_suspend()
1949 docg3 = mtd->priv; in docg3_suspend()
1950 doc_set_asic_mode(docg3, DOC_ASICMODE_POWERDOWN); in docg3_suspend()
2040 struct docg3 *docg3 = cascade->floors[0]->priv; in docg3_release() local
2048 free_bch(docg3->cascade->bch); in docg3_release()