Lines Matching full:chip
109 struct nand_chip *chip = mtd_to_nand(mtd); in check_offs_len() local
113 if (ofs & ((1ULL << chip->phys_erase_shift) - 1)) { in check_offs_len()
119 if (len & ((1ULL << chip->phys_erase_shift) - 1)) { in check_offs_len()
128 * nand_release_device - [GENERIC] release chip
131 * Release chip lock and wake up anyone waiting on the device.
135 struct nand_chip *chip = mtd_to_nand(mtd); in nand_release_device() local
138 chip->select_chip(mtd, -1); in nand_release_device()
142 * nand_read_byte - [DEFAULT] read one byte from the chip
149 struct nand_chip *chip = mtd_to_nand(mtd); in nand_read_byte() local
150 return readb(chip->IO_ADDR_R); in nand_read_byte()
154 * nand_read_byte16 - [DEFAULT] read one byte endianness aware from the chip
162 struct nand_chip *chip = mtd_to_nand(mtd); in nand_read_byte16() local
163 return (uint8_t) cpu_to_le16(readw(chip->IO_ADDR_R)); in nand_read_byte16()
167 * nand_read_word - [DEFAULT] read one word from the chip
174 struct nand_chip *chip = mtd_to_nand(mtd); in nand_read_word() local
175 return readw(chip->IO_ADDR_R); in nand_read_word()
183 * Default select function for 1 chip devices.
187 struct nand_chip *chip = mtd_to_nand(mtd); in nand_select_chip() local
191 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); in nand_select_chip()
202 * nand_write_byte - [DEFAULT] write single byte to chip
210 struct nand_chip *chip = mtd_to_nand(mtd); in nand_write_byte() local
212 chip->write_buf(mtd, &byte, 1); in nand_write_byte()
216 * nand_write_byte16 - [DEFAULT] write single byte to a chip with width 16
220 * Default function to write a byte to I/O[7:0] on a 16-bit wide chip.
224 struct nand_chip *chip = mtd_to_nand(mtd); in nand_write_byte16() local
243 chip->write_buf(mtd, (uint8_t *)&word, 2); in nand_write_byte16()
280 * nand_write_buf - [DEFAULT] write buffer to chip
289 struct nand_chip *chip = mtd_to_nand(mtd); in nand_write_buf() local
291 iowrite8_rep(chip->IO_ADDR_W, buf, len); in nand_write_buf()
295 * nand_read_buf - [DEFAULT] read chip data into buffer
304 struct nand_chip *chip = mtd_to_nand(mtd); in nand_read_buf() local
306 ioread8_rep(chip->IO_ADDR_R, buf, len); in nand_read_buf()
310 * nand_write_buf16 - [DEFAULT] write buffer to chip
319 struct nand_chip *chip = mtd_to_nand(mtd); in nand_write_buf16() local
322 iowrite16_rep(chip->IO_ADDR_W, p, len >> 1); in nand_write_buf16()
326 * nand_read_buf16 - [DEFAULT] read chip data into buffer
335 struct nand_chip *chip = mtd_to_nand(mtd); in nand_read_buf16() local
338 ioread16_rep(chip->IO_ADDR_R, p, len >> 1); in nand_read_buf16()
342 * nand_block_bad - [DEFAULT] Read bad block marker from the chip
351 struct nand_chip *chip = mtd_to_nand(mtd); in nand_block_bad() local
354 if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) in nand_block_bad()
357 page = (int)(ofs >> chip->page_shift) & chip->pagemask; in nand_block_bad()
360 if (chip->options & NAND_BUSWIDTH_16) { in nand_block_bad()
361 chip->cmdfunc(mtd, NAND_CMD_READOOB, in nand_block_bad()
362 chip->badblockpos & 0xFE, page); in nand_block_bad()
363 bad = cpu_to_le16(chip->read_word(mtd)); in nand_block_bad()
364 if (chip->badblockpos & 0x1) in nand_block_bad()
369 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, in nand_block_bad()
371 bad = chip->read_byte(mtd); in nand_block_bad()
374 if (likely(chip->badblockbits == 8)) in nand_block_bad()
377 res = hweight8(bad) < chip->badblockbits; in nand_block_bad()
379 page = (int)(ofs >> chip->page_shift) & chip->pagemask; in nand_block_bad()
381 } while (!res && i < 2 && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE)); in nand_block_bad()
397 struct nand_chip *chip = mtd_to_nand(mtd); in nand_default_block_markbad() local
404 ops.ooboffs = chip->badblockpos; in nand_default_block_markbad()
405 if (chip->options & NAND_BUSWIDTH_16) { in nand_default_block_markbad()
414 if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) in nand_default_block_markbad()
423 } while ((chip->bbt_options & NAND_BBT_SCAN2NDPAGE) && i < 2); in nand_default_block_markbad()
435 * specify how to write bad block markers to OOB (chip->block_markbad).
447 struct nand_chip *chip = mtd_to_nand(mtd); in nand_block_markbad_lowlevel() local
450 if (!(chip->bbt_options & NAND_BBT_NO_OOB_BBM)) { in nand_block_markbad_lowlevel()
457 einfo.len = 1ULL << chip->phys_erase_shift; in nand_block_markbad_lowlevel()
462 ret = chip->block_markbad(mtd, ofs); in nand_block_markbad_lowlevel()
467 if (chip->bbt) { in nand_block_markbad_lowlevel()
480 * nand_check_wp - [GENERIC] check if the chip is write protected
488 struct nand_chip *chip = mtd_to_nand(mtd); in nand_check_wp() local
491 if (chip->options & NAND_BROKEN_XD) in nand_check_wp()
495 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); in nand_check_wp()
496 return (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; in nand_check_wp()
508 struct nand_chip *chip = mtd_to_nand(mtd); in nand_block_isreserved() local
510 if (!chip->bbt) in nand_block_isreserved()
527 struct nand_chip *chip = mtd_to_nand(mtd); in nand_block_checkbad() local
529 if (!(chip->options & NAND_SKIP_BBTSCAN) && in nand_block_checkbad()
530 !(chip->options & NAND_BBT_SCANNED)) { in nand_block_checkbad()
531 chip->options |= NAND_BBT_SCANNED; in nand_block_checkbad()
532 chip->scan_bbt(mtd); in nand_block_checkbad()
535 if (!chip->bbt) in nand_block_checkbad()
536 return chip->block_bad(mtd, ofs); in nand_block_checkbad()
550 struct nand_chip *chip = mtd_to_nand(mtd); in nand_wait_ready() local
557 if (chip->dev_ready) in nand_wait_ready()
558 if (chip->dev_ready(mtd)) in nand_wait_ready()
562 if (!chip->dev_ready(mtd)) in nand_wait_ready()
563 pr_warn("timeout while waiting for chip to become ready\n"); in nand_wait_ready()
576 register struct nand_chip *chip = mtd_to_nand(mtd); in nand_wait_status_ready() local
582 if ((chip->read_byte(mtd) & NAND_STATUS_READY)) in nand_wait_status_ready()
601 register struct nand_chip *chip = mtd_to_nand(mtd); in nand_command() local
619 chip->cmd_ctrl(mtd, readcmd, ctrl); in nand_command()
622 chip->cmd_ctrl(mtd, command, ctrl); in nand_command()
629 if (chip->options & NAND_BUSWIDTH_16 && in nand_command()
632 chip->cmd_ctrl(mtd, column, ctrl); in nand_command()
636 chip->cmd_ctrl(mtd, page_addr, ctrl); in nand_command()
638 chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); in nand_command()
639 if (chip->options & NAND_ROW_ADDR_3) in nand_command()
640 chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); in nand_command()
642 chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); in nand_command()
660 if (chip->dev_ready) in nand_command()
662 udelay(chip->chip_delay); in nand_command()
663 chip->cmd_ctrl(mtd, NAND_CMD_STATUS, in nand_command()
665 chip->cmd_ctrl(mtd, in nand_command()
677 if (!chip->dev_ready) { in nand_command()
678 udelay(chip->chip_delay); in nand_command()
705 register struct nand_chip *chip = mtd_to_nand(mtd); in nand_command_lp() local
714 chip->cmd_ctrl(mtd, command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); in nand_command_lp()
722 if (chip->options & NAND_BUSWIDTH_16 && in nand_command_lp()
725 chip->cmd_ctrl(mtd, column, ctrl); in nand_command_lp()
727 chip->cmd_ctrl(mtd, column >> 8, ctrl); in nand_command_lp()
730 chip->cmd_ctrl(mtd, page_addr, ctrl); in nand_command_lp()
731 chip->cmd_ctrl(mtd, page_addr >> 8, in nand_command_lp()
733 if (chip->options & NAND_ROW_ADDR_3) in nand_command_lp()
734 chip->cmd_ctrl(mtd, page_addr >> 16, in nand_command_lp()
738 chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); in nand_command_lp()
758 if (chip->dev_ready) in nand_command_lp()
760 udelay(chip->chip_delay); in nand_command_lp()
761 chip->cmd_ctrl(mtd, NAND_CMD_STATUS, in nand_command_lp()
763 chip->cmd_ctrl(mtd, NAND_CMD_NONE, in nand_command_lp()
771 chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, in nand_command_lp()
773 chip->cmd_ctrl(mtd, NAND_CMD_NONE, in nand_command_lp()
778 chip->cmd_ctrl(mtd, NAND_CMD_READSTART, in nand_command_lp()
780 chip->cmd_ctrl(mtd, NAND_CMD_NONE, in nand_command_lp()
789 if (!chip->dev_ready) { in nand_command_lp()
790 udelay(chip->chip_delay); in nand_command_lp()
805 * panic_nand_get_device - [GENERIC] Get chip for selected access
806 * @chip: the nand chip descriptor
812 static void panic_nand_get_device(struct nand_chip *chip, in panic_nand_get_device() argument
816 chip->controller->active = chip; in panic_nand_get_device()
817 chip->state = new_state; in panic_nand_get_device()
821 * nand_get_device - [GENERIC] Get chip for selected access
830 struct nand_chip *chip = mtd_to_nand(mtd); in nand_get_device() local
831 chip->state = new_state; in nand_get_device()
838 * @chip: NAND chip structure
845 static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip, in panic_nand_wait() argument
850 if (chip->dev_ready) { in panic_nand_wait()
851 if (chip->dev_ready(mtd)) in panic_nand_wait()
854 if (chip->read_byte(mtd) & NAND_STATUS_READY) in panic_nand_wait()
864 * @chip: NAND chip structure
868 static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) in nand_wait() argument
881 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); in nand_wait()
888 if (chip->dev_ready) { in nand_wait()
889 if (chip->dev_ready(mtd)) in nand_wait()
892 if (chip->read_byte(mtd) & NAND_STATUS_READY) in nand_wait()
898 status = (int)chip->read_byte(mtd); in nand_wait()
906 * @chip: The NAND chip
913 static int nand_reset_data_interface(struct nand_chip *chip, int chipnr) in nand_reset_data_interface() argument
915 struct mtd_info *mtd = nand_to_mtd(chip); in nand_reset_data_interface()
919 if (!chip->setup_data_interface) in nand_reset_data_interface()
937 ret = chip->setup_data_interface(mtd, chipnr, conf); in nand_reset_data_interface()
946 * @chip: The NAND chip
950 * the chip and the driver.
952 * and if the NAND chip does not support ONFI, relies on the
957 static int nand_setup_data_interface(struct nand_chip *chip, int chipnr) in nand_setup_data_interface() argument
959 struct mtd_info *mtd = nand_to_mtd(chip); in nand_setup_data_interface()
962 if (!chip->setup_data_interface || !chip->data_interface) in nand_setup_data_interface()
966 * Ensure the timing mode has been changed on the chip side in nand_setup_data_interface()
969 if (chip->onfi_version) { in nand_setup_data_interface()
971 chip->onfi_timing_mode_default, in nand_setup_data_interface()
974 ret = chip->onfi_set_features(mtd, chip, in nand_setup_data_interface()
981 ret = chip->setup_data_interface(mtd, chipnr, chip->data_interface); in nand_setup_data_interface()
988 * @chip: The NAND chip
990 * Find the best data interface and NAND timings supported by the chip
993 * and if the NAND chip does not support ONFI, relies on the
1000 static int nand_init_data_interface(struct nand_chip *chip) in nand_init_data_interface() argument
1002 struct mtd_info *mtd = nand_to_mtd(chip); in nand_init_data_interface()
1005 if (!chip->setup_data_interface) in nand_init_data_interface()
1013 modes = onfi_get_async_timing_mode(chip); in nand_init_data_interface()
1015 if (!chip->onfi_timing_mode_default) in nand_init_data_interface()
1018 modes = GENMASK(chip->onfi_timing_mode_default, 0); in nand_init_data_interface()
1021 chip->data_interface = kzalloc(sizeof(*chip->data_interface), in nand_init_data_interface()
1023 if (!chip->data_interface) in nand_init_data_interface()
1027 ret = onfi_init_data_interface(chip, chip->data_interface, in nand_init_data_interface()
1033 ret = chip->setup_data_interface(mtd, in nand_init_data_interface()
1035 chip->data_interface); in nand_init_data_interface()
1037 chip->onfi_timing_mode_default = mode; in nand_init_data_interface()
1045 static void __maybe_unused nand_release_data_interface(struct nand_chip *chip) in nand_release_data_interface() argument
1047 kfree(chip->data_interface); in nand_release_data_interface()
1052 * @chip: The NAND chip
1057 int nand_reset(struct nand_chip *chip, int chipnr) in nand_reset() argument
1059 struct mtd_info *mtd = nand_to_mtd(chip); in nand_reset()
1062 ret = nand_reset_data_interface(chip, chipnr); in nand_reset()
1070 chip->select_chip(mtd, chipnr); in nand_reset()
1071 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); in nand_reset()
1072 chip->select_chip(mtd, -1); in nand_reset()
1074 chip->select_chip(mtd, chipnr); in nand_reset()
1075 ret = nand_setup_data_interface(chip, chipnr); in nand_reset()
1076 chip->select_chip(mtd, -1); in nand_reset()
1213 * @chip: nand chip info structure
1215 * @oob_required: caller requires OOB data read to chip->oob_poi
1220 static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_raw() argument
1223 chip->read_buf(mtd, buf, mtd->writesize); in nand_read_page_raw()
1225 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_page_raw()
1232 * @chip: nand chip info structure
1234 * @oob_required: caller requires OOB data read to chip->oob_poi
1240 struct nand_chip *chip, uint8_t *buf, in nand_read_page_raw_syndrome() argument
1243 int eccsize = chip->ecc.size; in nand_read_page_raw_syndrome()
1244 int eccbytes = chip->ecc.bytes; in nand_read_page_raw_syndrome()
1245 uint8_t *oob = chip->oob_poi; in nand_read_page_raw_syndrome()
1248 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_read_page_raw_syndrome()
1249 chip->read_buf(mtd, buf, eccsize); in nand_read_page_raw_syndrome()
1252 if (chip->ecc.prepad) { in nand_read_page_raw_syndrome()
1253 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_raw_syndrome()
1254 oob += chip->ecc.prepad; in nand_read_page_raw_syndrome()
1257 chip->read_buf(mtd, oob, eccbytes); in nand_read_page_raw_syndrome()
1260 if (chip->ecc.postpad) { in nand_read_page_raw_syndrome()
1261 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_raw_syndrome()
1262 oob += chip->ecc.postpad; in nand_read_page_raw_syndrome()
1266 size = mtd->oobsize - (oob - chip->oob_poi); in nand_read_page_raw_syndrome()
1268 chip->read_buf(mtd, oob, size); in nand_read_page_raw_syndrome()
1276 * @chip: nand chip info structure
1278 * @oob_required: caller requires OOB data read to chip->oob_poi
1281 static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_swecc() argument
1284 int i, eccsize = chip->ecc.size; in nand_read_page_swecc()
1285 int eccbytes = chip->ecc.bytes; in nand_read_page_swecc()
1286 int eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1288 uint8_t *ecc_calc = chip->buffers->ecccalc; in nand_read_page_swecc()
1289 uint8_t *ecc_code = chip->buffers->ecccode; in nand_read_page_swecc()
1290 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_swecc()
1293 chip->ecc.read_page_raw(mtd, chip, buf, 1, page); in nand_read_page_swecc()
1296 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_swecc()
1298 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_swecc()
1299 ecc_code[i] = chip->oob_poi[eccpos[i]]; in nand_read_page_swecc()
1301 eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1307 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_swecc()
1321 * @chip: nand chip info structure
1327 static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_subpage() argument
1332 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_subpage()
1336 int busw = (chip->options & NAND_BUSWIDTH_16) ? 2 : 1; in nand_read_subpage()
1341 start_step = data_offs / chip->ecc.size; in nand_read_subpage()
1342 end_step = (data_offs + readlen - 1) / chip->ecc.size; in nand_read_subpage()
1344 index = start_step * chip->ecc.bytes; in nand_read_subpage()
1347 datafrag_len = num_steps * chip->ecc.size; in nand_read_subpage()
1348 eccfrag_len = num_steps * chip->ecc.bytes; in nand_read_subpage()
1350 data_col_addr = start_step * chip->ecc.size; in nand_read_subpage()
1353 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1); in nand_read_subpage()
1356 chip->read_buf(mtd, p, datafrag_len); in nand_read_subpage()
1359 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) in nand_read_subpage()
1360 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); in nand_read_subpage()
1373 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); in nand_read_subpage()
1374 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_subpage()
1384 if (eccpos[index + (num_steps * chip->ecc.bytes)] & (busw - 1)) in nand_read_subpage()
1387 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, in nand_read_subpage()
1389 chip->read_buf(mtd, &chip->oob_poi[aligned_pos], aligned_len); in nand_read_subpage()
1393 chip->buffers->ecccode[i] = chip->oob_poi[eccpos[i + index]]; in nand_read_subpage()
1396 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) { in nand_read_subpage()
1399 stat = chip->ecc.correct(mtd, p, in nand_read_subpage()
1400 &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]); in nand_read_subpage()
1402 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_subpage()
1404 stat = nand_check_erased_ecc_chunk(p, chip->ecc.size, in nand_read_subpage()
1405 &chip->buffers->ecccode[i], in nand_read_subpage()
1406 chip->ecc.bytes, in nand_read_subpage()
1408 chip->ecc.strength); in nand_read_subpage()
1424 * @chip: nand chip info structure
1426 * @oob_required: caller requires OOB data read to chip->oob_poi
1431 static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_hwecc() argument
1434 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc()
1435 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc()
1436 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
1438 uint8_t *ecc_calc = chip->buffers->ecccalc; in nand_read_page_hwecc()
1439 uint8_t *ecc_code = chip->buffers->ecccode; in nand_read_page_hwecc()
1440 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc()
1444 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc()
1445 chip->read_buf(mtd, p, eccsize); in nand_read_page_hwecc()
1446 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc()
1448 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_page_hwecc()
1450 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc()
1451 ecc_code[i] = chip->oob_poi[eccpos[i]]; in nand_read_page_hwecc()
1453 eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
1459 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_hwecc()
1461 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_page_hwecc()
1466 chip->ecc.strength); in nand_read_page_hwecc()
1482 * @chip: nand chip info structure
1484 * @oob_required: caller requires OOB data read to chip->oob_poi
1494 struct nand_chip *chip, uint8_t *buf, int oob_required, int page) in nand_read_page_hwecc_oob_first() argument
1496 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc_oob_first()
1497 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc_oob_first()
1498 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc_oob_first()
1500 uint8_t *ecc_code = chip->buffers->ecccode; in nand_read_page_hwecc_oob_first()
1501 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc_oob_first()
1502 uint8_t *ecc_calc = chip->buffers->ecccalc; in nand_read_page_hwecc_oob_first()
1506 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); in nand_read_page_hwecc_oob_first()
1507 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_page_hwecc_oob_first()
1508 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); in nand_read_page_hwecc_oob_first()
1510 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc_oob_first()
1511 ecc_code[i] = chip->oob_poi[eccpos[i]]; in nand_read_page_hwecc_oob_first()
1516 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc_oob_first()
1517 chip->read_buf(mtd, p, eccsize); in nand_read_page_hwecc_oob_first()
1518 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc_oob_first()
1520 stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL); in nand_read_page_hwecc_oob_first()
1522 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_page_hwecc_oob_first()
1527 chip->ecc.strength); in nand_read_page_hwecc_oob_first()
1543 * @chip: nand chip info structure
1545 * @oob_required: caller requires OOB data read to chip->oob_poi
1551 static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_syndrome() argument
1554 int i, eccsize = chip->ecc.size; in nand_read_page_syndrome()
1555 int eccbytes = chip->ecc.bytes; in nand_read_page_syndrome()
1556 int eccsteps = chip->ecc.steps; in nand_read_page_syndrome()
1557 int eccpadbytes = eccbytes + chip->ecc.prepad + chip->ecc.postpad; in nand_read_page_syndrome()
1559 uint8_t *oob = chip->oob_poi; in nand_read_page_syndrome()
1565 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_syndrome()
1566 chip->read_buf(mtd, p, eccsize); in nand_read_page_syndrome()
1568 if (chip->ecc.prepad) { in nand_read_page_syndrome()
1569 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_syndrome()
1570 oob += chip->ecc.prepad; in nand_read_page_syndrome()
1573 chip->ecc.hwctl(mtd, NAND_ECC_READSYN); in nand_read_page_syndrome()
1574 chip->read_buf(mtd, oob, eccbytes); in nand_read_page_syndrome()
1575 stat = chip->ecc.correct(mtd, p, oob, NULL); in nand_read_page_syndrome()
1579 if (chip->ecc.postpad) { in nand_read_page_syndrome()
1580 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_syndrome()
1581 oob += chip->ecc.postpad; in nand_read_page_syndrome()
1585 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_page_syndrome()
1587 stat = nand_check_erased_ecc_chunk(p, chip->ecc.size, in nand_read_page_syndrome()
1591 chip->ecc.strength); in nand_read_page_syndrome()
1603 i = mtd->oobsize - (oob - chip->oob_poi); in nand_read_page_syndrome()
1605 chip->read_buf(mtd, oob, i); in nand_read_page_syndrome()
1612 * @chip: nand chip structure
1617 static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob, in nand_transfer_oob() argument
1624 memcpy(oob, chip->oob_poi + ops->ooboffs, len); in nand_transfer_oob()
1628 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_transfer_oob()
1647 memcpy(oob, chip->oob_poi + boffs, bytes); in nand_transfer_oob()
1669 struct nand_chip *chip = mtd_to_nand(mtd); in nand_setup_read_retry() local
1673 if (retry_mode >= chip->read_retries) in nand_setup_read_retry()
1676 if (!chip->setup_read_retry) in nand_setup_read_retry()
1679 return chip->setup_read_retry(mtd, retry_mode); in nand_setup_read_retry()
1688 * Internal function. Called with chip held.
1694 struct nand_chip *chip = mtd_to_nand(mtd); in nand_do_read_ops() local
1706 chipnr = (int)(from >> chip->chip_shift); in nand_do_read_ops()
1707 chip->select_chip(mtd, chipnr); in nand_do_read_ops()
1709 realpage = (int)(from >> chip->page_shift); in nand_do_read_ops()
1710 page = realpage & chip->pagemask; in nand_do_read_ops()
1727 else if (chip->options & NAND_USE_BOUNCE_BUFFER) in nand_do_read_ops()
1729 chip->buf_align); in nand_do_read_ops()
1734 if (realpage != chip->pagebuf || oob) { in nand_do_read_ops()
1735 bufpoi = use_bufpoi ? chip->buffers->databuf : buf; in nand_do_read_ops()
1742 if (nand_standard_page_accessors(&chip->ecc)) in nand_do_read_ops()
1743 chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); in nand_do_read_ops()
1750 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, in nand_do_read_ops()
1753 else if (!aligned && NAND_HAS_SUBPAGE_READ(chip) && in nand_do_read_ops()
1755 ret = chip->ecc.read_subpage(mtd, chip, in nand_do_read_ops()
1759 ret = chip->ecc.read_page(mtd, chip, bufpoi, in nand_do_read_ops()
1764 chip->pagebuf = -1; in nand_do_read_ops()
1772 if (!NAND_HAS_SUBPAGE_READ(chip) && !oob && in nand_do_read_ops()
1775 chip->pagebuf = realpage; in nand_do_read_ops()
1776 chip->pagebuf_bitflips = ret; in nand_do_read_ops()
1779 chip->pagebuf = -1; in nand_do_read_ops()
1781 memcpy(buf, chip->buffers->databuf + col, bytes); in nand_do_read_ops()
1788 oob = nand_transfer_oob(chip, in nand_do_read_ops()
1794 if (chip->options & NAND_NEED_READRDY) { in nand_do_read_ops()
1796 if (!chip->dev_ready) in nand_do_read_ops()
1797 udelay(chip->chip_delay); in nand_do_read_ops()
1803 if (retry_mode + 1 < chip->read_retries) { in nand_do_read_ops()
1821 memcpy(buf, chip->buffers->databuf + col, bytes); in nand_do_read_ops()
1824 chip->pagebuf_bitflips); in nand_do_read_ops()
1845 page = realpage & chip->pagemask; in nand_do_read_ops()
1846 /* Check, if we cross a chip boundary */ in nand_do_read_ops()
1849 chip->select_chip(mtd, -1); in nand_do_read_ops()
1850 chip->select_chip(mtd, chipnr); in nand_do_read_ops()
1853 chip->select_chip(mtd, -1); in nand_do_read_ops()
1871 * @chip: nand chip info structure
1874 static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_oob_std() argument
1877 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); in nand_read_oob_std()
1878 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_oob_std()
1886 * @chip: nand chip info structure
1889 static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_oob_syndrome() argument
1893 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_read_oob_syndrome()
1894 int eccsize = chip->ecc.size; in nand_read_oob_syndrome()
1895 uint8_t *bufpoi = chip->oob_poi; in nand_read_oob_syndrome()
1898 chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page); in nand_read_oob_syndrome()
1899 for (i = 0; i < chip->ecc.steps; i++) { in nand_read_oob_syndrome()
1903 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, pos, -1); in nand_read_oob_syndrome()
1905 chip->cmdfunc(mtd, NAND_CMD_READ0, pos, page); in nand_read_oob_syndrome()
1909 chip->read_buf(mtd, bufpoi, toread); in nand_read_oob_syndrome()
1914 chip->read_buf(mtd, bufpoi, length); in nand_read_oob_syndrome()
1922 * @chip: nand chip info structure
1925 static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_oob_std() argument
1929 const uint8_t *buf = chip->oob_poi; in nand_write_oob_std()
1932 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); in nand_write_oob_std()
1933 chip->write_buf(mtd, buf, length); in nand_write_oob_std()
1935 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_oob_std()
1937 status = chip->waitfunc(mtd, chip); in nand_write_oob_std()
1946 * @chip: nand chip info structure
1950 struct nand_chip *chip, int page) in nand_write_oob_syndrome() argument
1952 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_write_oob_syndrome()
1953 int eccsize = chip->ecc.size, length = mtd->oobsize; in nand_write_oob_syndrome()
1954 int i, len, pos, status = 0, sndcmd = 0, steps = chip->ecc.steps; in nand_write_oob_syndrome()
1955 const uint8_t *bufpoi = chip->oob_poi; in nand_write_oob_syndrome()
1962 if (!chip->ecc.prepad && !chip->ecc.postpad) { in nand_write_oob_syndrome()
1968 chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page); in nand_write_oob_syndrome()
1977 chip->write_buf(mtd, (uint8_t *)&fill, in nand_write_oob_syndrome()
1983 chip->cmdfunc(mtd, NAND_CMD_RNDIN, pos, -1); in nand_write_oob_syndrome()
1988 chip->write_buf(mtd, bufpoi, len); in nand_write_oob_syndrome()
1993 chip->write_buf(mtd, bufpoi, length); in nand_write_oob_syndrome()
1995 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_oob_syndrome()
1996 status = chip->waitfunc(mtd, chip); in nand_write_oob_syndrome()
2013 struct nand_chip *chip = mtd_to_nand(mtd); in nand_do_read_oob() local
2035 ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) - in nand_do_read_oob()
2036 (from >> chip->page_shift)) * len)) { in nand_do_read_oob()
2042 chipnr = (int)(from >> chip->chip_shift); in nand_do_read_oob()
2043 chip->select_chip(mtd, chipnr); in nand_do_read_oob()
2046 realpage = (int)(from >> chip->page_shift); in nand_do_read_oob()
2047 page = realpage & chip->pagemask; in nand_do_read_oob()
2053 ret = chip->ecc.read_oob_raw(mtd, chip, page); in nand_do_read_oob()
2055 ret = chip->ecc.read_oob(mtd, chip, page); in nand_do_read_oob()
2061 buf = nand_transfer_oob(chip, buf, ops, len); in nand_do_read_oob()
2063 if (chip->options & NAND_NEED_READRDY) { in nand_do_read_oob()
2065 if (!chip->dev_ready) in nand_do_read_oob()
2066 udelay(chip->chip_delay); in nand_do_read_oob()
2078 page = realpage & chip->pagemask; in nand_do_read_oob()
2079 /* Check, if we cross a chip boundary */ in nand_do_read_oob()
2082 chip->select_chip(mtd, -1); in nand_do_read_oob()
2083 chip->select_chip(mtd, chipnr); in nand_do_read_oob()
2086 chip->select_chip(mtd, -1); in nand_do_read_oob()
2147 * @chip: nand chip info structure
2149 * @oob_required: must write chip->oob_poi to OOB
2154 static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page_raw() argument
2157 chip->write_buf(mtd, buf, mtd->writesize); in nand_write_page_raw()
2159 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_write_page_raw()
2167 * @chip: nand chip info structure
2169 * @oob_required: must write chip->oob_poi to OOB
2175 struct nand_chip *chip, in nand_write_page_raw_syndrome() argument
2179 int eccsize = chip->ecc.size; in nand_write_page_raw_syndrome()
2180 int eccbytes = chip->ecc.bytes; in nand_write_page_raw_syndrome()
2181 uint8_t *oob = chip->oob_poi; in nand_write_page_raw_syndrome()
2184 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_write_page_raw_syndrome()
2185 chip->write_buf(mtd, buf, eccsize); in nand_write_page_raw_syndrome()
2188 if (chip->ecc.prepad) { in nand_write_page_raw_syndrome()
2189 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_raw_syndrome()
2190 oob += chip->ecc.prepad; in nand_write_page_raw_syndrome()
2193 chip->write_buf(mtd, oob, eccbytes); in nand_write_page_raw_syndrome()
2196 if (chip->ecc.postpad) { in nand_write_page_raw_syndrome()
2197 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_raw_syndrome()
2198 oob += chip->ecc.postpad; in nand_write_page_raw_syndrome()
2202 size = mtd->oobsize - (oob - chip->oob_poi); in nand_write_page_raw_syndrome()
2204 chip->write_buf(mtd, oob, size); in nand_write_page_raw_syndrome()
2211 * @chip: nand chip info structure
2213 * @oob_required: must write chip->oob_poi to OOB
2216 static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page_swecc() argument
2220 int i, eccsize = chip->ecc.size; in nand_write_page_swecc()
2221 int eccbytes = chip->ecc.bytes; in nand_write_page_swecc()
2222 int eccsteps = chip->ecc.steps; in nand_write_page_swecc()
2223 uint8_t *ecc_calc = chip->buffers->ecccalc; in nand_write_page_swecc()
2225 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_swecc()
2229 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_swecc()
2231 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_swecc()
2232 chip->oob_poi[eccpos[i]] = ecc_calc[i]; in nand_write_page_swecc()
2234 return chip->ecc.write_page_raw(mtd, chip, buf, 1, page); in nand_write_page_swecc()
2240 * @chip: nand chip info structure
2242 * @oob_required: must write chip->oob_poi to OOB
2245 static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page_hwecc() argument
2249 int i, eccsize = chip->ecc.size; in nand_write_page_hwecc()
2250 int eccbytes = chip->ecc.bytes; in nand_write_page_hwecc()
2251 int eccsteps = chip->ecc.steps; in nand_write_page_hwecc()
2252 uint8_t *ecc_calc = chip->buffers->ecccalc; in nand_write_page_hwecc()
2254 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_hwecc()
2257 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_hwecc()
2258 chip->write_buf(mtd, p, eccsize); in nand_write_page_hwecc()
2259 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_hwecc()
2262 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_hwecc()
2263 chip->oob_poi[eccpos[i]] = ecc_calc[i]; in nand_write_page_hwecc()
2265 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_write_page_hwecc()
2274 * @chip: nand chip info structure
2278 * @oob_required: must write chip->oob_poi to OOB
2282 struct nand_chip *chip, uint32_t offset, in nand_write_subpage_hwecc() argument
2286 uint8_t *oob_buf = chip->oob_poi; in nand_write_subpage_hwecc()
2287 uint8_t *ecc_calc = chip->buffers->ecccalc; in nand_write_subpage_hwecc()
2288 int ecc_size = chip->ecc.size; in nand_write_subpage_hwecc()
2289 int ecc_bytes = chip->ecc.bytes; in nand_write_subpage_hwecc()
2290 int ecc_steps = chip->ecc.steps; in nand_write_subpage_hwecc()
2291 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_subpage_hwecc()
2299 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_subpage_hwecc()
2302 chip->write_buf(mtd, buf, ecc_size); in nand_write_subpage_hwecc()
2308 chip->ecc.calculate(mtd, buf, ecc_calc); in nand_write_subpage_hwecc()
2320 /* copy calculated ECC for whole page to chip->buffer->oob */ in nand_write_subpage_hwecc()
2322 ecc_calc = chip->buffers->ecccalc; in nand_write_subpage_hwecc()
2323 for (i = 0; i < chip->ecc.total; i++) in nand_write_subpage_hwecc()
2324 chip->oob_poi[eccpos[i]] = ecc_calc[i]; in nand_write_subpage_hwecc()
2327 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_write_subpage_hwecc()
2336 * @chip: nand chip info structure
2338 * @oob_required: must write chip->oob_poi to OOB
2345 struct nand_chip *chip, in nand_write_page_syndrome() argument
2349 int i, eccsize = chip->ecc.size; in nand_write_page_syndrome()
2350 int eccbytes = chip->ecc.bytes; in nand_write_page_syndrome()
2351 int eccsteps = chip->ecc.steps; in nand_write_page_syndrome()
2353 uint8_t *oob = chip->oob_poi; in nand_write_page_syndrome()
2357 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_syndrome()
2358 chip->write_buf(mtd, p, eccsize); in nand_write_page_syndrome()
2360 if (chip->ecc.prepad) { in nand_write_page_syndrome()
2361 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_syndrome()
2362 oob += chip->ecc.prepad; in nand_write_page_syndrome()
2365 chip->ecc.calculate(mtd, p, oob); in nand_write_page_syndrome()
2366 chip->write_buf(mtd, oob, eccbytes); in nand_write_page_syndrome()
2369 if (chip->ecc.postpad) { in nand_write_page_syndrome()
2370 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_syndrome()
2371 oob += chip->ecc.postpad; in nand_write_page_syndrome()
2376 i = mtd->oobsize - (oob - chip->oob_poi); in nand_write_page_syndrome()
2378 chip->write_buf(mtd, oob, i); in nand_write_page_syndrome()
2386 * @chip: NAND chip descriptor
2390 * @oob_required: must write chip->oob_poi to OOB
2394 static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page() argument
2400 if (!(chip->options & NAND_NO_SUBPAGE_WRITE) && in nand_write_page()
2401 chip->ecc.write_subpage) in nand_write_page()
2406 if (nand_standard_page_accessors(&chip->ecc)) in nand_write_page()
2407 chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); in nand_write_page()
2410 status = chip->ecc.write_page_raw(mtd, chip, buf, in nand_write_page()
2413 status = chip->ecc.write_subpage(mtd, chip, offset, data_len, in nand_write_page()
2416 status = chip->ecc.write_page(mtd, chip, buf, oob_required, in nand_write_page()
2422 if (nand_standard_page_accessors(&chip->ecc)) { in nand_write_page()
2423 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_page()
2425 status = chip->waitfunc(mtd, chip); in nand_write_page()
2443 struct nand_chip *chip = mtd_to_nand(mtd); in nand_fill_oob() local
2449 memset(chip->oob_poi, 0xff, mtd->oobsize); in nand_fill_oob()
2455 memcpy(chip->oob_poi + ops->ooboffs, oob, len); in nand_fill_oob()
2459 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_fill_oob()
2478 memcpy(chip->oob_poi + boffs, oob, bytes); in nand_fill_oob()
2489 #define NOTALIGNED(x) ((x & (chip->subpagesize - 1)) != 0)
2503 struct nand_chip *chip = mtd_to_nand(mtd); in nand_do_write_ops() local
2527 chipnr = (int)(to >> chip->chip_shift); in nand_do_write_ops()
2528 chip->select_chip(mtd, chipnr); in nand_do_write_ops()
2536 realpage = (int)(to >> chip->page_shift); in nand_do_write_ops()
2537 page = realpage & chip->pagemask; in nand_do_write_ops()
2540 if (to <= ((loff_t)chip->pagebuf << chip->page_shift) && in nand_do_write_ops()
2541 ((loff_t)chip->pagebuf << chip->page_shift) < (to + ops->len)) in nand_do_write_ops()
2542 chip->pagebuf = -1; in nand_do_write_ops()
2558 else if (chip->options & NAND_USE_BOUNCE_BUFFER) in nand_do_write_ops()
2560 chip->buf_align); in nand_do_write_ops()
2571 chip->pagebuf = -1; in nand_do_write_ops()
2572 memset(chip->buffers->databuf, 0xff, mtd->writesize); in nand_do_write_ops()
2573 memcpy(&chip->buffers->databuf[column], buf, bytes); in nand_do_write_ops()
2574 wbuf = chip->buffers->databuf; in nand_do_write_ops()
2583 memset(chip->oob_poi, 0xff, mtd->oobsize); in nand_do_write_ops()
2585 ret = chip->write_page(mtd, chip, column, bytes, wbuf, in nand_do_write_ops()
2599 page = realpage & chip->pagemask; in nand_do_write_ops()
2600 /* Check, if we cross a chip boundary */ in nand_do_write_ops()
2603 chip->select_chip(mtd, -1); in nand_do_write_ops()
2604 chip->select_chip(mtd, chipnr); in nand_do_write_ops()
2613 chip->select_chip(mtd, -1); in nand_do_write_ops()
2631 struct nand_chip *chip = mtd_to_nand(mtd); in panic_nand_write() local
2636 panic_nand_wait(mtd, chip, 400); in panic_nand_write()
2639 panic_nand_get_device(chip, mtd, FL_WRITING); in panic_nand_write()
2664 struct nand_chip *chip = mtd_to_nand(mtd); in nand_do_write_oob() local
2687 ((mtd->size >> chip->page_shift) - in nand_do_write_oob()
2688 (to >> chip->page_shift)) * len)) { in nand_do_write_oob()
2694 chipnr = (int)(to >> chip->chip_shift); in nand_do_write_oob()
2697 * Reset the chip. Some chips (like the Toshiba TC5832DC found in one in nand_do_write_oob()
2702 nand_reset(chip, chipnr); in nand_do_write_oob()
2704 chip->select_chip(mtd, chipnr); in nand_do_write_oob()
2707 page = (int)(to >> chip->page_shift); in nand_do_write_oob()
2711 chip->select_chip(mtd, -1); in nand_do_write_oob()
2716 if (page == chip->pagebuf) in nand_do_write_oob()
2717 chip->pagebuf = -1; in nand_do_write_oob()
2722 status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
2724 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
2726 chip->select_chip(mtd, -1); in nand_do_write_oob()
2787 struct nand_chip *chip = mtd_to_nand(mtd); in single_erase() local
2789 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); in single_erase()
2790 chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); in single_erase()
2792 return chip->waitfunc(mtd, chip); in single_erase()
2819 struct nand_chip *chip = mtd_to_nand(mtd); in nand_erase_nand() local
2833 page = (int)(instr->addr >> chip->page_shift); in nand_erase_nand()
2834 chipnr = (int)(instr->addr >> chip->chip_shift); in nand_erase_nand()
2837 pages_per_block = 1 << (chip->phys_erase_shift - chip->page_shift); in nand_erase_nand()
2840 chip->select_chip(mtd, chipnr); in nand_erase_nand()
2860 chip->page_shift, allowbbt)) { in nand_erase_nand()
2871 if (page <= chip->pagebuf && chip->pagebuf < in nand_erase_nand()
2873 chip->pagebuf = -1; in nand_erase_nand()
2875 status = chip->erase(mtd, page & chip->pagemask); in nand_erase_nand()
2883 ((loff_t)page << chip->page_shift); in nand_erase_nand()
2888 len -= (1ULL << chip->phys_erase_shift); in nand_erase_nand()
2891 /* Check, if we cross a chip boundary */ in nand_erase_nand()
2892 if (len && !(page & chip->pagemask)) { in nand_erase_nand()
2894 chip->select_chip(mtd, -1); in nand_erase_nand()
2895 chip->select_chip(mtd, chipnr); in nand_erase_nand()
2905 chip->select_chip(mtd, -1); in nand_erase_nand()
2920 * Sync is actually a wait for chip ready function.
2939 struct nand_chip *chip = mtd_to_nand(mtd); in nand_block_isbad() local
2940 int chipnr = (int)(offs >> chip->chip_shift); in nand_block_isbad()
2945 chip->select_chip(mtd, chipnr); in nand_block_isbad()
2949 chip->select_chip(mtd, -1); in nand_block_isbad()
2978 * @chip: nand chip info structure
2982 static int nand_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, in nand_onfi_set_features() argument
2989 if (!chip->onfi_version || in nand_onfi_set_features()
2990 !(le16_to_cpu(chip->onfi_params.opt_cmd) in nand_onfi_set_features()
2995 chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, -1); in nand_onfi_set_features()
2997 chip->write_byte(mtd, subfeature_param[i]); in nand_onfi_set_features()
2999 status = chip->waitfunc(mtd, chip); in nand_onfi_set_features()
3008 * @chip: nand chip info structure
3012 static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip, in nand_onfi_get_features() argument
3018 if (!chip->onfi_version || in nand_onfi_get_features()
3019 !(le16_to_cpu(chip->onfi_params.opt_cmd) in nand_onfi_get_features()
3024 chip->cmdfunc(mtd, NAND_CMD_GET_FEATURES, addr, -1); in nand_onfi_get_features()
3026 *subfeature_param++ = chip->read_byte(mtd); in nand_onfi_get_features()
3031 static void nand_set_defaults(struct nand_chip *chip, int busw) in nand_set_defaults() argument
3034 if (!chip->chip_delay) in nand_set_defaults()
3035 chip->chip_delay = 20; in nand_set_defaults()
3038 if (chip->cmdfunc == NULL) in nand_set_defaults()
3039 chip->cmdfunc = nand_command; in nand_set_defaults()
3042 if (chip->waitfunc == NULL) in nand_set_defaults()
3043 chip->waitfunc = nand_wait; in nand_set_defaults()
3045 if (!chip->select_chip) in nand_set_defaults()
3046 chip->select_chip = nand_select_chip; in nand_set_defaults()
3049 if (!chip->onfi_set_features) in nand_set_defaults()
3050 chip->onfi_set_features = nand_onfi_set_features; in nand_set_defaults()
3051 if (!chip->onfi_get_features) in nand_set_defaults()
3052 chip->onfi_get_features = nand_onfi_get_features; in nand_set_defaults()
3055 if (!chip->read_byte || chip->read_byte == nand_read_byte) in nand_set_defaults()
3056 chip->read_byte = busw ? nand_read_byte16 : nand_read_byte; in nand_set_defaults()
3057 if (!chip->read_word) in nand_set_defaults()
3058 chip->read_word = nand_read_word; in nand_set_defaults()
3059 if (!chip->block_bad) in nand_set_defaults()
3060 chip->block_bad = nand_block_bad; in nand_set_defaults()
3061 if (!chip->block_markbad) in nand_set_defaults()
3062 chip->block_markbad = nand_default_block_markbad; in nand_set_defaults()
3063 if (!chip->write_buf || chip->write_buf == nand_write_buf) in nand_set_defaults()
3064 chip->write_buf = busw ? nand_write_buf16 : nand_write_buf; in nand_set_defaults()
3065 if (!chip->write_byte || chip->write_byte == nand_write_byte) in nand_set_defaults()
3066 chip->write_byte = busw ? nand_write_byte16 : nand_write_byte; in nand_set_defaults()
3067 if (!chip->read_buf || chip->read_buf == nand_read_buf) in nand_set_defaults()
3068 chip->read_buf = busw ? nand_read_buf16 : nand_read_buf; in nand_set_defaults()
3069 if (!chip->scan_bbt) in nand_set_defaults()
3070 chip->scan_bbt = nand_default_bbt; in nand_set_defaults()
3072 if (!chip->controller) { in nand_set_defaults()
3073 chip->controller = &chip->hwcontrol; in nand_set_defaults()
3074 spin_lock_init(&chip->controller->lock); in nand_set_defaults()
3075 init_waitqueue_head(&chip->controller->wq); in nand_set_defaults()
3078 if (!chip->buf_align) in nand_set_defaults()
3079 chip->buf_align = 1; in nand_set_defaults()
3115 struct nand_chip *chip, struct nand_onfi_params *p) in nand_flash_detect_ext_param_page() argument
3131 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1); in nand_flash_detect_ext_param_page()
3134 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, in nand_flash_detect_ext_param_page()
3138 chip->read_buf(mtd, (uint8_t *)ep, len); in nand_flash_detect_ext_param_page()
3175 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_ext_param_page()
3176 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_ext_param_page()
3186 struct nand_chip *chip = mtd_to_nand(mtd); in nand_setup_read_retry_micron() local
3189 return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY, in nand_setup_read_retry_micron()
3194 * Configure chip properties from Micron vendor-specific ONFI table
3196 static void nand_onfi_detect_micron(struct nand_chip *chip, in nand_onfi_detect_micron() argument
3204 chip->read_retries = micron->read_retry_options; in nand_onfi_detect_micron()
3205 chip->setup_read_retry = nand_setup_read_retry_micron; in nand_onfi_detect_micron()
3209 * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise.
3211 static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, in nand_flash_detect_onfi() argument
3214 struct nand_onfi_params *p = &chip->onfi_params; in nand_flash_detect_onfi()
3218 /* Try ONFI for unknown chip or LP */ in nand_flash_detect_onfi()
3219 chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1); in nand_flash_detect_onfi()
3220 if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' || in nand_flash_detect_onfi()
3221 chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I') in nand_flash_detect_onfi()
3224 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1); in nand_flash_detect_onfi()
3227 ((uint8_t *)p)[j] = chip->read_byte(mtd); in nand_flash_detect_onfi()
3242 chip->onfi_version = 23; in nand_flash_detect_onfi()
3244 chip->onfi_version = 22; in nand_flash_detect_onfi()
3246 chip->onfi_version = 21; in nand_flash_detect_onfi()
3248 chip->onfi_version = 20; in nand_flash_detect_onfi()
3250 chip->onfi_version = 10; in nand_flash_detect_onfi()
3252 if (!chip->onfi_version) { in nand_flash_detect_onfi()
3275 chip->chipsize = 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1); in nand_flash_detect_onfi()
3276 chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count; in nand_flash_detect_onfi()
3277 chip->bits_per_cell = p->bits_per_cell; in nand_flash_detect_onfi()
3279 if (onfi_feature(chip) & ONFI_FEATURE_16_BIT_BUS) in nand_flash_detect_onfi()
3285 chip->ecc_strength_ds = p->ecc_bits; in nand_flash_detect_onfi()
3286 chip->ecc_step_ds = 512; in nand_flash_detect_onfi()
3287 } else if (chip->onfi_version >= 21 && in nand_flash_detect_onfi()
3288 (onfi_feature(chip) & ONFI_FEATURE_EXT_PARAM_PAGE)) { in nand_flash_detect_onfi()
3293 * by the chip->cmdfunc. So try to update the chip->cmdfunc in nand_flash_detect_onfi()
3296 if (mtd->writesize > 512 && chip->cmdfunc == nand_command) in nand_flash_detect_onfi()
3297 chip->cmdfunc = nand_command_lp; in nand_flash_detect_onfi()
3300 if (nand_flash_detect_ext_param_page(mtd, chip, p)) in nand_flash_detect_onfi()
3307 nand_onfi_detect_micron(chip, p); in nand_flash_detect_onfi()
3312 static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip, in nand_flash_detect_onfi() argument
3320 * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise.
3322 static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip, in nand_flash_detect_jedec() argument
3325 struct nand_jedec_params *p = &chip->jedec_params; in nand_flash_detect_jedec()
3330 /* Try JEDEC for unknown chip or LP */ in nand_flash_detect_jedec()
3331 chip->cmdfunc(mtd, NAND_CMD_READID, 0x40, -1); in nand_flash_detect_jedec()
3332 if (chip->read_byte(mtd) != 'J' || chip->read_byte(mtd) != 'E' || in nand_flash_detect_jedec()
3333 chip->read_byte(mtd) != 'D' || chip->read_byte(mtd) != 'E' || in nand_flash_detect_jedec()
3334 chip->read_byte(mtd) != 'C') in nand_flash_detect_jedec()
3337 chip->cmdfunc(mtd, NAND_CMD_PARAM, 0x40, -1); in nand_flash_detect_jedec()
3340 ((uint8_t *)p)[j] = chip->read_byte(mtd); in nand_flash_detect_jedec()
3355 chip->jedec_version = 10; in nand_flash_detect_jedec()
3357 chip->jedec_version = 1; /* vendor specific version */ in nand_flash_detect_jedec()
3359 if (!chip->jedec_version) { in nand_flash_detect_jedec()
3378 chip->chipsize = 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1); in nand_flash_detect_jedec()
3379 chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count; in nand_flash_detect_jedec()
3380 chip->bits_per_cell = p->bits_per_cell; in nand_flash_detect_jedec()
3382 if (jedec_feature(chip) & JEDEC_FEATURE_16_BIT_BUS) in nand_flash_detect_jedec()
3391 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_jedec()
3392 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_jedec()
3471 * chip. The rest of the parameters must be decoded according to generic or
3474 static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip, in nand_decode_ext_id() argument
3479 chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); in nand_decode_ext_id()
3495 !nand_is_slc(chip) && id_data[5] != 0x00) { in nand_decode_ext_id()
3530 !nand_is_slc(chip)) { in nand_decode_ext_id()
3593 nand_is_slc(chip) && in nand_decode_ext_id()
3603 * Old devices have chip data hardcoded in the device ID table. nand_decode_id
3605 * the chip.
3607 static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip, in nand_decode_id() argument
3619 chip->bits_per_cell = 1; in nand_decode_id()
3641 struct nand_chip *chip, u8 id_data[8]) in nand_decode_bbm_options() argument
3646 if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16)) in nand_decode_bbm_options()
3647 chip->badblockpos = NAND_LARGE_BADBLOCK_POS; in nand_decode_bbm_options()
3649 chip->badblockpos = NAND_SMALL_BADBLOCK_POS; in nand_decode_bbm_options()
3657 if (!nand_is_slc(chip) && in nand_decode_bbm_options()
3660 chip->bbt_options |= NAND_BBT_SCANLASTPAGE; in nand_decode_bbm_options()
3661 else if ((nand_is_slc(chip) && in nand_decode_bbm_options()
3669 chip->bbt_options |= NAND_BBT_SCAN2NDPAGE; in nand_decode_bbm_options()
3677 static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, in find_full_id_nand() argument
3685 chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]); in find_full_id_nand()
3686 chip->chipsize = (uint64_t)type->chipsize << 20; in find_full_id_nand()
3687 chip->options |= type->options; in find_full_id_nand()
3688 chip->ecc_strength_ds = NAND_ECC_STRENGTH(type); in find_full_id_nand()
3689 chip->ecc_step_ds = NAND_ECC_STEP(type); in find_full_id_nand()
3690 chip->onfi_timing_mode_default = in find_full_id_nand()
3707 struct nand_chip *chip, in nand_get_flash_type() argument
3716 * Reset the chip, required by some chips (e.g. Micron MT29FxGxxxxx) in nand_get_flash_type()
3719 nand_reset(chip, 0); in nand_get_flash_type()
3722 chip->select_chip(mtd, 0); in nand_get_flash_type()
3725 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); in nand_get_flash_type()
3728 *maf_id = chip->read_byte(mtd); in nand_get_flash_type()
3729 *dev_id = chip->read_byte(mtd); in nand_get_flash_type()
3738 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); in nand_get_flash_type()
3742 id_data[i] = chip->read_byte(mtd); in nand_get_flash_type()
3755 if (find_full_id_nand(mtd, chip, type, id_data, &busw)) in nand_get_flash_type()
3762 chip->onfi_version = 0; in nand_get_flash_type()
3764 /* Check if the chip is ONFI compliant */ in nand_get_flash_type()
3765 if (nand_flash_detect_onfi(mtd, chip, &busw)) in nand_get_flash_type()
3768 /* Check if the chip is JEDEC compliant */ in nand_get_flash_type()
3769 if (nand_flash_detect_jedec(mtd, chip, &busw)) in nand_get_flash_type()
3779 chip->chipsize = (uint64_t)type->chipsize << 20; in nand_get_flash_type()
3783 nand_decode_ext_id(mtd, chip, id_data, &busw); in nand_get_flash_type()
3785 nand_decode_id(mtd, chip, type, id_data, &busw); in nand_get_flash_type()
3787 /* Get chip options */ in nand_get_flash_type()
3788 chip->options |= type->options; in nand_get_flash_type()
3791 * Check if chip is not a Samsung device. Do not clear the in nand_get_flash_type()
3795 chip->options &= ~NAND_SAMSUNG_LP_OPTIONS; in nand_get_flash_type()
3804 if (chip->options & NAND_BUSWIDTH_AUTO) { in nand_get_flash_type()
3805 WARN_ON(chip->options & NAND_BUSWIDTH_16); in nand_get_flash_type()
3806 chip->options |= busw; in nand_get_flash_type()
3807 nand_set_defaults(chip, busw); in nand_get_flash_type()
3808 } else if (busw != (chip->options & NAND_BUSWIDTH_16)) { in nand_get_flash_type()
3811 * chip correct! in nand_get_flash_type()
3813 pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", in nand_get_flash_type()
3817 (chip->options & NAND_BUSWIDTH_16) ? 16 : 8, in nand_get_flash_type()
3822 nand_decode_bbm_options(mtd, chip, id_data); in nand_get_flash_type()
3825 chip->page_shift = ffs(mtd->writesize) - 1; in nand_get_flash_type()
3826 /* Convert chipsize to number of pages per chip -1 */ in nand_get_flash_type()
3827 chip->pagemask = (chip->chipsize >> chip->page_shift) - 1; in nand_get_flash_type()
3829 chip->bbt_erase_shift = chip->phys_erase_shift = in nand_get_flash_type()
3831 if (chip->chipsize & 0xffffffff) in nand_get_flash_type()
3832 chip->chip_shift = ffs((unsigned)chip->chipsize) - 1; in nand_get_flash_type()
3834 chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32)); in nand_get_flash_type()
3835 chip->chip_shift += 32 - 1; in nand_get_flash_type()
3838 if (chip->chip_shift - chip->page_shift > 16) in nand_get_flash_type()
3839 chip->options |= NAND_ROW_ADDR_3; in nand_get_flash_type()
3841 chip->badblockbits = 8; in nand_get_flash_type()
3842 chip->erase = single_erase; in nand_get_flash_type()
3845 if (mtd->writesize > 512 && chip->cmdfunc == nand_command) in nand_get_flash_type()
3846 chip->cmdfunc = nand_command_lp; in nand_get_flash_type()
3848 pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", in nand_get_flash_type()
3852 if (chip->onfi_version) in nand_get_flash_type()
3854 chip->onfi_params.model); in nand_get_flash_type()
3855 else if (chip->jedec_version) in nand_get_flash_type()
3857 chip->jedec_params.model); in nand_get_flash_type()
3862 if (chip->jedec_version) in nand_get_flash_type()
3864 chip->jedec_params.model); in nand_get_flash_type()
3874 (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC", in nand_get_flash_type()
3883 static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, int node) in nand_dt_init() argument
3891 chip->options |= NAND_BUSWIDTH_16; in nand_dt_init()
3894 chip->bbt_options |= NAND_BBT_USE_FLASH; in nand_dt_init()
3923 chip->ecc.mode = ecc_mode; in nand_dt_init()
3926 chip->ecc.strength = ecc_strength; in nand_dt_init()
3929 chip->ecc.size = ecc_step; in nand_dt_init()
3932 chip->ecc.options |= NAND_ECC_MAXIMIZE; in nand_dt_init()
3937 static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, int node) in nand_dt_init() argument
3957 struct nand_chip *chip = mtd_to_nand(mtd); in nand_scan_ident() local
3961 if (chip->flash_node) { in nand_scan_ident()
3962 ret = nand_dt_init(mtd, chip, chip->flash_node); in nand_scan_ident()
3968 nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); in nand_scan_ident()
3971 type = nand_get_flash_type(mtd, chip, &nand_maf_id, in nand_scan_ident()
3975 if (!(chip->options & NAND_SCAN_SILENT_NODEV)) in nand_scan_ident()
3977 chip->select_chip(mtd, -1); in nand_scan_ident()
3982 ret = nand_init_data_interface(chip); in nand_scan_ident()
3987 * Setup the data interface correctly on the chip and controller side. in nand_scan_ident()
3994 ret = nand_setup_data_interface(chip, 0); in nand_scan_ident()
3998 chip->select_chip(mtd, -1); in nand_scan_ident()
4000 /* Check for a chip array */ in nand_scan_ident()
4003 nand_reset(chip, i); in nand_scan_ident()
4005 chip->select_chip(mtd, i); in nand_scan_ident()
4007 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); in nand_scan_ident()
4009 if (nand_maf_id != chip->read_byte(mtd) || in nand_scan_ident()
4010 nand_dev_id != chip->read_byte(mtd)) { in nand_scan_ident()
4011 chip->select_chip(mtd, -1); in nand_scan_ident()
4014 chip->select_chip(mtd, -1); in nand_scan_ident()
4023 chip->numchips = i; in nand_scan_ident()
4024 mtd->size = i * chip->chipsize; in nand_scan_ident()
4032 * @chip: nand chip info structure
4037 * by the controller and the calculated ECC bytes fit within the chip's OOB.
4040 int nand_check_ecc_caps(struct nand_chip *chip, in nand_check_ecc_caps() argument
4043 struct mtd_info *mtd = nand_to_mtd(chip); in nand_check_ecc_caps()
4045 int preset_step = chip->ecc.size; in nand_check_ecc_caps()
4046 int preset_strength = chip->ecc.strength; in nand_check_ecc_caps()
4079 chip->ecc.bytes = ecc_bytes; in nand_check_ecc_caps()
4093 * nand_match_ecc_req - meet the chip's requirement with least ECC bytes
4094 * @chip: nand chip info structure
4098 * If a chip's ECC requirement is provided, try to meet it with the least
4102 int nand_match_ecc_req(struct nand_chip *chip, in nand_match_ecc_req() argument
4105 struct mtd_info *mtd = nand_to_mtd(chip); in nand_match_ecc_req()
4107 int req_step = chip->ecc_step_ds; in nand_match_ecc_req()
4108 int req_strength = chip->ecc_strength_ds; in nand_match_ecc_req()
4117 /* No information provided by the NAND chip */ in nand_match_ecc_req()
4121 /* number of correctable bits the chip requires in a page */ in nand_match_ecc_req()
4133 * chip's requirement, it is not easy to compare the in nand_match_ecc_req()
4154 * We assume the best is to meet the chip's requrement in nand_match_ecc_req()
4169 chip->ecc.size = best_step; in nand_match_ecc_req()
4170 chip->ecc.strength = best_strength; in nand_match_ecc_req()
4171 chip->ecc.bytes = best_ecc_bytes; in nand_match_ecc_req()
4179 * @chip: nand chip info structure
4184 * within the chip's OOB. On success, the chosen ECC settings are set.
4186 int nand_maximize_ecc(struct nand_chip *chip, in nand_maximize_ecc() argument
4189 struct mtd_info *mtd = nand_to_mtd(chip); in nand_maximize_ecc()
4204 /* If chip->ecc.size is already set, respect it */ in nand_maximize_ecc()
4205 if (chip->ecc.size && step_size != chip->ecc.size) in nand_maximize_ecc()
4242 chip->ecc.size = best_step; in nand_maximize_ecc()
4243 chip->ecc.strength = best_strength; in nand_maximize_ecc()
4244 chip->ecc.bytes = best_ecc_bytes; in nand_maximize_ecc()
4251 * Check if the chip configuration meet the datasheet requirements.
4266 struct nand_chip *chip = mtd_to_nand(mtd); in nand_ecc_strength_good() local
4267 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_ecc_strength_good()
4270 if (ecc->size == 0 || chip->ecc_step_ds == 0) in nand_ecc_strength_good()
4279 ds_corr = (mtd->writesize * chip->ecc_strength_ds) / chip->ecc_step_ds; in nand_ecc_strength_good()
4281 return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds; in nand_ecc_strength_good()
4284 static bool invalid_ecc_page_accessors(struct nand_chip *chip) in invalid_ecc_page_accessors() argument
4286 struct nand_ecc_ctrl *ecc = &chip->ecc; in invalid_ecc_page_accessors()
4299 (NAND_HAS_SUBPAGE_READ(chip) && !ecc->read_subpage) || in invalid_ecc_page_accessors()
4300 (NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage && in invalid_ecc_page_accessors()
4315 struct nand_chip *chip = mtd_to_nand(mtd); in nand_scan_tail() local
4316 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_scan_tail()
4320 BUG_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) && in nand_scan_tail()
4321 !(chip->bbt_options & NAND_BBT_USE_FLASH)); in nand_scan_tail()
4323 if (invalid_ecc_page_accessors(chip)) { in nand_scan_tail()
4328 if (!(chip->options & NAND_OWN_BUFFERS)) { in nand_scan_tail()
4330 chip->buffers = nbuf; in nand_scan_tail()
4332 if (!chip->buffers) in nand_scan_tail()
4337 chip->oob_poi = chip->buffers->databuf + mtd->writesize; in nand_scan_tail()
4365 if (!chip->write_page) in nand_scan_tail()
4366 chip->write_page = nand_write_page; in nand_scan_tail()
4521 …NING: %s: the ECC used on your system is too weak compared to the one required by the NAND chip\n", in nand_scan_tail()
4536 if (!(chip->options & NAND_NO_SUBPAGE_WRITE) && nand_is_slc(chip)) { in nand_scan_tail()
4548 chip->subpagesize = mtd->writesize >> mtd->subpage_sft; in nand_scan_tail()
4551 chip->state = FL_READY; in nand_scan_tail()
4554 chip->pagebuf = -1; in nand_scan_tail()
4560 if (chip->page_shift > 9) in nand_scan_tail()
4561 chip->options |= NAND_SUBPAGE_READ; in nand_scan_tail()
4569 mtd->type = nand_is_slc(chip) ? MTD_NANDFLASH : MTD_MLCNANDFLASH; in nand_scan_tail()
4570 mtd->flags = (chip->options & NAND_ROM) ? MTD_CAP_ROM : in nand_scan_tail()
4606 * The flash ID is read and the mtd/chip structures are filled with the