• Home
  • Raw
  • Download

Lines Matching refs:mtd

85 static int nand_get_device(struct nand_chip *chip, struct mtd_info *mtd,
88 static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
103 static void nand_release_device(struct mtd_info *mtd) in nand_release_device() argument
105 struct nand_chip *chip = mtd->priv; in nand_release_device()
108 chip->select_chip(mtd, -1); in nand_release_device()
124 static uint8_t nand_read_byte(struct mtd_info *mtd) in nand_read_byte() argument
126 struct nand_chip *chip = mtd->priv; in nand_read_byte()
137 static uint8_t nand_read_byte16(struct mtd_info *mtd) in nand_read_byte16() argument
139 struct nand_chip *chip = mtd->priv; in nand_read_byte16()
150 static u16 nand_read_word(struct mtd_info *mtd) in nand_read_word() argument
152 struct nand_chip *chip = mtd->priv; in nand_read_word()
163 static void nand_select_chip(struct mtd_info *mtd, int chipnr) in nand_select_chip() argument
165 struct nand_chip *chip = mtd->priv; in nand_select_chip()
169 chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE); in nand_select_chip()
187 static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) in nand_write_buf() argument
190 struct nand_chip *chip = mtd->priv; in nand_write_buf()
204 static void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) in nand_read_buf() argument
207 struct nand_chip *chip = mtd->priv; in nand_read_buf()
221 static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len) in nand_verify_buf() argument
224 struct nand_chip *chip = mtd->priv; in nand_verify_buf()
240 static void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) in nand_write_buf16() argument
243 struct nand_chip *chip = mtd->priv; in nand_write_buf16()
260 static void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len) in nand_read_buf16() argument
263 struct nand_chip *chip = mtd->priv; in nand_read_buf16()
279 static int nand_verify_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) in nand_verify_buf16() argument
282 struct nand_chip *chip = mtd->priv; in nand_verify_buf16()
301 static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) in nand_block_bad() argument
304 struct nand_chip *chip = mtd->priv; in nand_block_bad()
312 nand_get_device(chip, mtd, FL_READING); in nand_block_bad()
315 chip->select_chip(mtd, chipnr); in nand_block_bad()
319 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE, in nand_block_bad()
321 bad = cpu_to_le16(chip->read_word(mtd)); in nand_block_bad()
327 chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos, page); in nand_block_bad()
328 if (chip->read_byte(mtd) != 0xff) in nand_block_bad()
333 nand_release_device(mtd); in nand_block_bad()
346 static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) in nand_default_block_markbad() argument
348 struct nand_chip *chip = mtd->priv; in nand_default_block_markbad()
359 ret = nand_update_bbt(mtd, ofs); in nand_default_block_markbad()
364 nand_get_device(chip, mtd, FL_WRITING); in nand_default_block_markbad()
365 ofs += mtd->oobsize; in nand_default_block_markbad()
371 ret = nand_do_write_oob(mtd, ofs, &chip->ops); in nand_default_block_markbad()
372 nand_release_device(mtd); in nand_default_block_markbad()
375 mtd->ecc_stats.badblocks++; in nand_default_block_markbad()
387 static int nand_check_wp(struct mtd_info *mtd) in nand_check_wp() argument
389 struct nand_chip *chip = mtd->priv; in nand_check_wp()
391 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); in nand_check_wp()
392 return (chip->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; in nand_check_wp()
405 static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, in nand_block_checkbad() argument
408 struct nand_chip *chip = mtd->priv; in nand_block_checkbad()
411 return chip->block_bad(mtd, ofs, getchip); in nand_block_checkbad()
414 return nand_isbad_bbt(mtd, ofs, allowbbt); in nand_block_checkbad()
421 void nand_wait_ready(struct mtd_info *mtd) in nand_wait_ready() argument
423 struct nand_chip *chip = mtd->priv; in nand_wait_ready()
429 if (chip->dev_ready(mtd)) in nand_wait_ready()
447 static void nand_command(struct mtd_info *mtd, unsigned int command, in nand_command() argument
450 register struct nand_chip *chip = mtd->priv; in nand_command()
459 if (column >= mtd->writesize) { in nand_command()
461 column -= mtd->writesize; in nand_command()
470 chip->cmd_ctrl(mtd, readcmd, ctrl); in nand_command()
473 chip->cmd_ctrl(mtd, command, ctrl); in nand_command()
484 chip->cmd_ctrl(mtd, column, ctrl); in nand_command()
488 chip->cmd_ctrl(mtd, page_addr, ctrl); in nand_command()
490 chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); in nand_command()
493 chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); in nand_command()
495 chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); in nand_command()
514 chip->cmd_ctrl(mtd, NAND_CMD_STATUS, in nand_command()
516 chip->cmd_ctrl(mtd, in nand_command()
518 while (!(chip->read_byte(mtd) & NAND_STATUS_READY)) ; in nand_command()
536 nand_wait_ready(mtd); in nand_command()
550 static void nand_command_lp(struct mtd_info *mtd, unsigned int command, in nand_command_lp() argument
553 register struct nand_chip *chip = mtd->priv; in nand_command_lp()
557 column += mtd->writesize; in nand_command_lp()
562 chip->cmd_ctrl(mtd, command & 0xff, in nand_command_lp()
573 chip->cmd_ctrl(mtd, column, ctrl); in nand_command_lp()
575 chip->cmd_ctrl(mtd, column >> 8, ctrl); in nand_command_lp()
578 chip->cmd_ctrl(mtd, page_addr, ctrl); in nand_command_lp()
579 chip->cmd_ctrl(mtd, page_addr >> 8, in nand_command_lp()
583 chip->cmd_ctrl(mtd, page_addr >> 16, in nand_command_lp()
587 chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); in nand_command_lp()
620 chip->cmd_ctrl(mtd, NAND_CMD_STATUS, in nand_command_lp()
622 chip->cmd_ctrl(mtd, NAND_CMD_NONE, in nand_command_lp()
624 while (!(chip->read_byte(mtd) & NAND_STATUS_READY)) ; in nand_command_lp()
629 chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, in nand_command_lp()
631 chip->cmd_ctrl(mtd, NAND_CMD_NONE, in nand_command_lp()
636 chip->cmd_ctrl(mtd, NAND_CMD_READSTART, in nand_command_lp()
638 chip->cmd_ctrl(mtd, NAND_CMD_NONE, in nand_command_lp()
657 nand_wait_ready(mtd); in nand_command_lp()
669 nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state) in nand_get_device() argument
708 static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) in nand_wait() argument
726 chip->cmdfunc(mtd, NAND_CMD_STATUS_MULTI, -1, -1); in nand_wait()
728 chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); in nand_wait()
732 if (chip->dev_ready(mtd)) in nand_wait()
735 if (chip->read_byte(mtd) & NAND_STATUS_READY) in nand_wait()
742 status = (int)chip->read_byte(mtd); in nand_wait()
752 static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_raw() argument
755 chip->read_buf(mtd, buf, mtd->writesize); in nand_read_page_raw()
756 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_page_raw()
766 static int nand_read_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_swecc() argument
777 chip->ecc.read_page_raw(mtd, chip, buf); in nand_read_page_swecc()
780 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_swecc()
791 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_swecc()
793 mtd->ecc_stats.failed++; in nand_read_page_swecc()
795 mtd->ecc_stats.corrected += stat; in nand_read_page_swecc()
808 static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, uint32_t data_offs, uint… in nand_read_subpage() argument
829 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_col_addr, -1); in nand_read_subpage()
832 chip->read_buf(mtd, p, datafrag_len); in nand_read_subpage()
836 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); in nand_read_subpage()
849 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize, -1); in nand_read_subpage()
850 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_subpage()
861 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, mtd->writesize + aligned_pos, -1); in nand_read_subpage()
862 chip->read_buf(mtd, &chip->oob_poi[aligned_pos], aligned_len); in nand_read_subpage()
872 stat = chip->ecc.correct(mtd, p, &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]); in nand_read_subpage()
874 mtd->ecc_stats.failed++; in nand_read_subpage()
876 mtd->ecc_stats.corrected += stat; in nand_read_subpage()
889 static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_hwecc() argument
901 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc()
902 chip->read_buf(mtd, p, eccsize); in nand_read_page_hwecc()
903 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc()
905 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_page_hwecc()
916 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_hwecc()
918 mtd->ecc_stats.failed++; in nand_read_page_hwecc()
920 mtd->ecc_stats.corrected += stat; in nand_read_page_hwecc()
934 static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_page_syndrome() argument
946 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_syndrome()
947 chip->read_buf(mtd, p, eccsize); in nand_read_page_syndrome()
950 chip->read_buf(mtd, oob, chip->ecc.prepad); in nand_read_page_syndrome()
954 chip->ecc.hwctl(mtd, NAND_ECC_READSYN); in nand_read_page_syndrome()
955 chip->read_buf(mtd, oob, eccbytes); in nand_read_page_syndrome()
956 stat = chip->ecc.correct(mtd, p, oob, NULL); in nand_read_page_syndrome()
959 mtd->ecc_stats.failed++; in nand_read_page_syndrome()
961 mtd->ecc_stats.corrected += stat; in nand_read_page_syndrome()
966 chip->read_buf(mtd, oob, chip->ecc.postpad); in nand_read_page_syndrome()
972 i = mtd->oobsize - (oob - chip->oob_poi); in nand_read_page_syndrome()
974 chip->read_buf(mtd, oob, i); in nand_read_page_syndrome()
1036 static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, in nand_do_read_ops() argument
1040 struct nand_chip *chip = mtd->priv; in nand_do_read_ops()
1049 stats = mtd->ecc_stats; in nand_do_read_ops()
1052 chip->select_chip(mtd, chipnr); in nand_do_read_ops()
1057 col = (int)(from & (mtd->writesize - 1)); in nand_do_read_ops()
1063 bytes = min(mtd->writesize - col, readlen); in nand_do_read_ops()
1064 aligned = (bytes == mtd->writesize); in nand_do_read_ops()
1071 chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); in nand_do_read_ops()
1077 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi); in nand_do_read_ops()
1079 ret = chip->ecc.read_subpage(mtd, chip, col, bytes, bufpoi); in nand_do_read_ops()
1081 ret = chip->ecc.read_page(mtd, chip, bufpoi); in nand_do_read_ops()
1106 buf, ops, mtd->oobsize); in nand_do_read_ops()
1120 nand_wait_ready(mtd); in nand_do_read_ops()
1141 chip->select_chip(mtd, -1); in nand_do_read_ops()
1142 chip->select_chip(mtd, chipnr); in nand_do_read_ops()
1159 if (mtd->ecc_stats.failed - stats.failed) in nand_do_read_ops()
1162 return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0; in nand_do_read_ops()
1175 static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, in nand_read() argument
1178 struct nand_chip *chip = mtd->priv; in nand_read()
1182 if ((from + len) > mtd->size) in nand_read()
1187 nand_get_device(chip, mtd, FL_READING); in nand_read()
1193 ret = nand_do_read_ops(mtd, from, &chip->ops); in nand_read()
1197 nand_release_device(mtd); in nand_read()
1209 static int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_oob_std() argument
1213 chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); in nand_read_oob_std()
1216 chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_read_oob_std()
1228 static int nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, in nand_read_oob_syndrome() argument
1232 int length = mtd->oobsize; in nand_read_oob_syndrome()
1238 chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page); in nand_read_oob_syndrome()
1242 if (mtd->writesize > 512) in nand_read_oob_syndrome()
1243 chip->cmdfunc(mtd, NAND_CMD_RNDOUT, pos, -1); in nand_read_oob_syndrome()
1245 chip->cmdfunc(mtd, NAND_CMD_READ0, pos, page); in nand_read_oob_syndrome()
1249 chip->read_buf(mtd, bufpoi, toread); in nand_read_oob_syndrome()
1254 chip->read_buf(mtd, bufpoi, length); in nand_read_oob_syndrome()
1265 static int nand_write_oob_std(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_oob_std() argument
1270 int length = mtd->oobsize; in nand_write_oob_std()
1272 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); in nand_write_oob_std()
1273 chip->write_buf(mtd, buf, length); in nand_write_oob_std()
1275 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_oob_std()
1277 status = chip->waitfunc(mtd, chip); in nand_write_oob_std()
1289 static int nand_write_oob_syndrome(struct mtd_info *mtd, in nand_write_oob_syndrome() argument
1293 int eccsize = chip->ecc.size, length = mtd->oobsize; in nand_write_oob_syndrome()
1308 chip->cmdfunc(mtd, NAND_CMD_SEQIN, pos, page); in nand_write_oob_syndrome()
1311 if (mtd->writesize <= 512) { in nand_write_oob_syndrome()
1317 chip->write_buf(mtd, (uint8_t *)&fill, in nand_write_oob_syndrome()
1323 chip->cmdfunc(mtd, NAND_CMD_RNDIN, pos, -1); in nand_write_oob_syndrome()
1328 chip->write_buf(mtd, bufpoi, len); in nand_write_oob_syndrome()
1333 chip->write_buf(mtd, bufpoi, length); in nand_write_oob_syndrome()
1335 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_oob_syndrome()
1336 status = chip->waitfunc(mtd, chip); in nand_write_oob_syndrome()
1349 static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, in nand_do_read_oob() argument
1353 struct nand_chip *chip = mtd->priv; in nand_do_read_oob()
1365 len = mtd->oobsize; in nand_do_read_oob()
1374 if (unlikely(from >= mtd->size || in nand_do_read_oob()
1375 ops->ooboffs + readlen > ((mtd->size >> chip->page_shift) - in nand_do_read_oob()
1383 chip->select_chip(mtd, chipnr); in nand_do_read_oob()
1390 sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd); in nand_do_read_oob()
1405 nand_wait_ready(mtd); in nand_do_read_oob()
1419 chip->select_chip(mtd, -1); in nand_do_read_oob()
1420 chip->select_chip(mtd, chipnr); in nand_do_read_oob()
1442 static int nand_read_oob(struct mtd_info *mtd, loff_t from, in nand_read_oob() argument
1445 struct nand_chip *chip = mtd->priv; in nand_read_oob()
1451 if (ops->datbuf && (from + ops->len) > mtd->size) { in nand_read_oob()
1457 nand_get_device(chip, mtd, FL_READING); in nand_read_oob()
1470 ret = nand_do_read_oob(mtd, from, ops); in nand_read_oob()
1472 ret = nand_do_read_ops(mtd, from, ops); in nand_read_oob()
1475 nand_release_device(mtd); in nand_read_oob()
1486 static void nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page_raw() argument
1489 chip->write_buf(mtd, buf, mtd->writesize); in nand_write_page_raw()
1490 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_write_page_raw()
1499 static void nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page_swecc() argument
1511 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_swecc()
1516 chip->ecc.write_page_raw(mtd, chip, buf); in nand_write_page_swecc()
1525 static void nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page_hwecc() argument
1536 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_hwecc()
1537 chip->write_buf(mtd, p, eccsize); in nand_write_page_hwecc()
1538 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_hwecc()
1544 chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); in nand_write_page_hwecc()
1556 static void nand_write_page_syndrome(struct mtd_info *mtd, in nand_write_page_syndrome() argument
1567 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_syndrome()
1568 chip->write_buf(mtd, p, eccsize); in nand_write_page_syndrome()
1571 chip->write_buf(mtd, oob, chip->ecc.prepad); in nand_write_page_syndrome()
1575 chip->ecc.calculate(mtd, p, oob); in nand_write_page_syndrome()
1576 chip->write_buf(mtd, oob, eccbytes); in nand_write_page_syndrome()
1580 chip->write_buf(mtd, oob, chip->ecc.postpad); in nand_write_page_syndrome()
1586 i = mtd->oobsize - (oob - chip->oob_poi); in nand_write_page_syndrome()
1588 chip->write_buf(mtd, oob, i); in nand_write_page_syndrome()
1600 static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, in nand_write_page() argument
1605 chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); in nand_write_page()
1608 chip->ecc.write_page_raw(mtd, chip, buf); in nand_write_page()
1610 chip->ecc.write_page(mtd, chip, buf); in nand_write_page()
1620 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in nand_write_page()
1621 status = chip->waitfunc(mtd, chip); in nand_write_page()
1627 status = chip->errstat(mtd, chip, FL_WRITING, status, in nand_write_page()
1633 chip->cmdfunc(mtd, NAND_CMD_CACHEDPROG, -1, -1); in nand_write_page()
1634 status = chip->waitfunc(mtd, chip); in nand_write_page()
1639 chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); in nand_write_page()
1641 if (chip->verify_buf(mtd, buf, mtd->writesize)) in nand_write_page()
1706 static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, in nand_do_write_ops() argument
1710 struct nand_chip *chip = mtd->priv; in nand_do_write_ops()
1727 column = to & (mtd->writesize - 1); in nand_do_write_ops()
1728 subpage = column || (writelen & (mtd->writesize - 1)); in nand_do_write_ops()
1734 chip->select_chip(mtd, chipnr); in nand_do_write_ops()
1737 if (nand_check_wp(mtd)) in nand_do_write_ops()
1751 memset(chip->oob_poi, 0xff, mtd->oobsize); in nand_do_write_ops()
1754 int bytes = mtd->writesize; in nand_do_write_ops()
1759 if (unlikely(column || writelen < (mtd->writesize - 1))) { in nand_do_write_ops()
1763 memset(chip->buffers->databuf, 0xff, mtd->writesize); in nand_do_write_ops()
1771 ret = chip->write_page(mtd, chip, wbuf, page, cached, in nand_do_write_ops()
1788 chip->select_chip(mtd, -1); in nand_do_write_ops()
1789 chip->select_chip(mtd, chipnr); in nand_do_write_ops()
1809 static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, in nand_write() argument
1812 struct nand_chip *chip = mtd->priv; in nand_write()
1816 if ((to + len) > mtd->size) in nand_write()
1821 nand_get_device(chip, mtd, FL_WRITING); in nand_write()
1827 ret = nand_do_write_ops(mtd, to, &chip->ops); in nand_write()
1831 nand_release_device(mtd); in nand_write()
1844 static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, in nand_do_write_oob() argument
1848 struct nand_chip *chip = mtd->priv; in nand_do_write_oob()
1856 len = mtd->oobsize; in nand_do_write_oob()
1872 if (unlikely(to >= mtd->size || in nand_do_write_oob()
1874 ((mtd->size >> chip->page_shift) - in nand_do_write_oob()
1882 chip->select_chip(mtd, chipnr); in nand_do_write_oob()
1893 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); in nand_do_write_oob()
1896 if (nand_check_wp(mtd)) in nand_do_write_oob()
1903 memset(chip->oob_poi, 0xff, mtd->oobsize); in nand_do_write_oob()
1905 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
1906 memset(chip->oob_poi, 0xff, mtd->oobsize); in nand_do_write_oob()
1922 static int nand_write_oob(struct mtd_info *mtd, loff_t to, in nand_write_oob() argument
1925 struct nand_chip *chip = mtd->priv; in nand_write_oob()
1931 if (ops->datbuf && (to + ops->len) > mtd->size) { in nand_write_oob()
1937 nand_get_device(chip, mtd, FL_WRITING); in nand_write_oob()
1950 ret = nand_do_write_oob(mtd, to, ops); in nand_write_oob()
1952 ret = nand_do_write_ops(mtd, to, ops); in nand_write_oob()
1955 nand_release_device(mtd); in nand_write_oob()
1966 static void single_erase_cmd(struct mtd_info *mtd, int page) in single_erase_cmd() argument
1968 struct nand_chip *chip = mtd->priv; in single_erase_cmd()
1970 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); in single_erase_cmd()
1971 chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); in single_erase_cmd()
1982 static void multi_erase_cmd(struct mtd_info *mtd, int page) in multi_erase_cmd() argument
1984 struct nand_chip *chip = mtd->priv; in multi_erase_cmd()
1986 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); in multi_erase_cmd()
1987 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); in multi_erase_cmd()
1988 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); in multi_erase_cmd()
1989 chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); in multi_erase_cmd()
1990 chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); in multi_erase_cmd()
2000 static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) in nand_erase() argument
2002 return nand_erase_nand(mtd, instr, 0); in nand_erase()
2014 int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, in nand_erase_nand() argument
2018 struct nand_chip *chip = mtd->priv; in nand_erase_nand()
2040 if ((instr->len + instr->addr) > mtd->size) { in nand_erase_nand()
2049 nand_get_device(chip, mtd, FL_ERASING); in nand_erase_nand()
2059 chip->select_chip(mtd, chipnr); in nand_erase_nand()
2062 if (nand_check_wp(mtd)) { in nand_erase_nand()
2087 if (nand_block_checkbad(mtd, ((loff_t) page) << in nand_erase_nand()
2103 chip->erase_cmd(mtd, page & chip->pagemask); in nand_erase_nand()
2105 status = chip->waitfunc(mtd, chip); in nand_erase_nand()
2112 status = chip->errstat(mtd, chip, FL_ERASING, in nand_erase_nand()
2141 chip->select_chip(mtd, -1); in nand_erase_nand()
2142 chip->select_chip(mtd, chipnr); in nand_erase_nand()
2161 nand_release_device(mtd); in nand_erase_nand()
2181 nand_update_bbt(mtd, rewrite_bbt[chipnr]); in nand_erase_nand()
2194 static void nand_sync(struct mtd_info *mtd) in nand_sync() argument
2196 struct nand_chip *chip = mtd->priv; in nand_sync()
2201 nand_get_device(chip, mtd, FL_SYNCING); in nand_sync()
2203 nand_release_device(mtd); in nand_sync()
2211 static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) in nand_block_isbad() argument
2214 if (offs > mtd->size) in nand_block_isbad()
2217 return nand_block_checkbad(mtd, offs, 1, 0); in nand_block_isbad()
2225 static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs) in nand_block_markbad() argument
2227 struct nand_chip *chip = mtd->priv; in nand_block_markbad()
2230 if ((ret = nand_block_isbad(mtd, ofs))) { in nand_block_markbad()
2237 return chip->block_markbad(mtd, ofs); in nand_block_markbad()
2244 static int nand_suspend(struct mtd_info *mtd) in nand_suspend() argument
2246 struct nand_chip *chip = mtd->priv; in nand_suspend()
2248 return nand_get_device(chip, mtd, FL_PM_SUSPENDED); in nand_suspend()
2255 static void nand_resume(struct mtd_info *mtd) in nand_resume() argument
2257 struct nand_chip *chip = mtd->priv; in nand_resume()
2260 nand_release_device(mtd); in nand_resume()
2313 static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, in nand_get_flash_type() argument
2322 chip->select_chip(mtd, 0); in nand_get_flash_type()
2328 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); in nand_get_flash_type()
2331 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); in nand_get_flash_type()
2334 *maf_id = chip->read_byte(mtd); in nand_get_flash_type()
2335 dev_id = chip->read_byte(mtd); in nand_get_flash_type()
2343 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); in nand_get_flash_type()
2347 tmp_manf = chip->read_byte(mtd); in nand_get_flash_type()
2348 tmp_id = chip->read_byte(mtd); in nand_get_flash_type()
2368 if (!mtd->name) in nand_get_flash_type()
2369 mtd->name = type->name; in nand_get_flash_type()
2377 chip->cellinfo = chip->read_byte(mtd); in nand_get_flash_type()
2379 extid = chip->read_byte(mtd); in nand_get_flash_type()
2381 mtd->writesize = 1024 << (extid & 0x3); in nand_get_flash_type()
2384 mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9); in nand_get_flash_type()
2387 mtd->erasesize = (64 * 1024) << (extid & 0x03); in nand_get_flash_type()
2396 mtd->erasesize = type->erasesize; in nand_get_flash_type()
2397 mtd->writesize = type->pagesize; in nand_get_flash_type()
2398 mtd->oobsize = mtd->writesize / 32; in nand_get_flash_type()
2415 dev_id, nand_manuf_ids[maf_idx].name, mtd->name); in nand_get_flash_type()
2423 chip->page_shift = ffs(mtd->writesize) - 1; in nand_get_flash_type()
2428 ffs(mtd->erasesize) - 1; in nand_get_flash_type()
2435 chip->badblockpos = mtd->writesize > 512 ? in nand_get_flash_type()
2460 if (mtd->writesize > 512 && chip->cmdfunc == nand_command) in nand_get_flash_type()
2480 int nand_scan_ident(struct mtd_info *mtd, int maxchips) in nand_scan_ident() argument
2483 struct nand_chip *chip = mtd->priv; in nand_scan_ident()
2492 type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id); in nand_scan_ident()
2496 chip->select_chip(mtd, -1); in nand_scan_ident()
2502 chip->select_chip(mtd, i); in nand_scan_ident()
2504 chip->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); in nand_scan_ident()
2506 chip->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); in nand_scan_ident()
2508 if (nand_maf_id != chip->read_byte(mtd) || in nand_scan_ident()
2509 type->id != chip->read_byte(mtd)) in nand_scan_ident()
2517 mtd->size = i * chip->chipsize; in nand_scan_ident()
2522 static void nand_panic_wait(struct mtd_info *mtd) in nand_panic_wait() argument
2524 struct nand_chip *chip = mtd->priv; in nand_panic_wait()
2529 if (chip->dev_ready(mtd)) in nand_panic_wait()
2536 static int nand_panic_write(struct mtd_info *mtd, loff_t to, size_t len, in nand_panic_write() argument
2539 struct nand_chip *chip = mtd->priv; in nand_panic_write()
2543 if ((to + len) > mtd->size) in nand_panic_write()
2548 nand_panic_wait(mtd); in nand_panic_write()
2554 ret = nand_do_write_ops(mtd, to, &chip->ops); in nand_panic_write()
2569 int nand_scan_tail(struct mtd_info *mtd) in nand_scan_tail() argument
2572 struct nand_chip *chip = mtd->priv; in nand_scan_tail()
2580 chip->oob_poi = chip->buffers->databuf + mtd->writesize; in nand_scan_tail()
2586 switch (mtd->oobsize) { in nand_scan_tail()
2598 "oobsize %d\n", mtd->oobsize); in nand_scan_tail()
2648 if (mtd->writesize >= chip->ecc.size) in nand_scan_tail()
2652 chip->ecc.size, mtd->writesize); in nand_scan_tail()
2674 chip->ecc.size = mtd->writesize; in nand_scan_tail()
2692 mtd->oobavail = chip->ecc.layout->oobavail; in nand_scan_tail()
2698 chip->ecc.steps = mtd->writesize / chip->ecc.size; in nand_scan_tail()
2699 if(chip->ecc.steps * chip->ecc.size != mtd->writesize) { in nand_scan_tail()
2713 mtd->subpage_sft = 1; in nand_scan_tail()
2717 mtd->subpage_sft = 2; in nand_scan_tail()
2721 chip->subpagesize = mtd->writesize >> mtd->subpage_sft; in nand_scan_tail()
2727 chip->select_chip(mtd, -1); in nand_scan_tail()
2733 mtd->type = MTD_NANDFLASH; in nand_scan_tail()
2734 mtd->flags = MTD_CAP_NANDFLASH; in nand_scan_tail()
2735 mtd->erase = nand_erase; in nand_scan_tail()
2736 mtd->point = NULL; in nand_scan_tail()
2737 mtd->unpoint = NULL; in nand_scan_tail()
2738 mtd->read = nand_read; in nand_scan_tail()
2739 mtd->write = nand_write; in nand_scan_tail()
2740 mtd->read_oob = nand_read_oob; in nand_scan_tail()
2741 mtd->write_oob = nand_write_oob; in nand_scan_tail()
2742 mtd->panic_write = nand_panic_write; in nand_scan_tail()
2743 mtd->sync = nand_sync; in nand_scan_tail()
2744 mtd->lock = NULL; in nand_scan_tail()
2745 mtd->unlock = NULL; in nand_scan_tail()
2746 mtd->suspend = nand_suspend; in nand_scan_tail()
2747 mtd->resume = nand_resume; in nand_scan_tail()
2748 mtd->block_isbad = nand_block_isbad; in nand_scan_tail()
2749 mtd->block_markbad = nand_block_markbad; in nand_scan_tail()
2752 mtd->ecclayout = chip->ecc.layout; in nand_scan_tail()
2759 return chip->scan_bbt(mtd); in nand_scan_tail()
2784 int nand_scan(struct mtd_info *mtd, int maxchips) in nand_scan() argument
2789 if (!mtd->owner && caller_is_module()) { in nand_scan()
2794 ret = nand_scan_ident(mtd, maxchips); in nand_scan()
2796 ret = nand_scan_tail(mtd); in nand_scan()
2804 void nand_release(struct mtd_info *mtd) in nand_release() argument
2806 struct nand_chip *chip = mtd->priv; in nand_release()
2810 del_mtd_partitions(mtd); in nand_release()
2813 del_mtd_device(mtd); in nand_release()