• Home
  • Raw
  • Download

Lines Matching refs:mtd

195 static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t len)  in onenand_command()  argument
197 struct onenand_chip *this = mtd->priv; in onenand_command()
304 static int onenand_wait(struct mtd_info *mtd, int state) in onenand_wait() argument
306 struct onenand_chip * this = mtd->priv; in onenand_wait()
338 mtd->ecc_stats.failed++; in onenand_wait()
342 mtd->ecc_stats.corrected++; in onenand_wait()
387 static int onenand_interrupt_wait(struct mtd_info *mtd, int state) in onenand_interrupt_wait() argument
389 struct onenand_chip *this = mtd->priv; in onenand_interrupt_wait()
393 return onenand_wait(mtd, state); in onenand_interrupt_wait()
403 static int onenand_try_interrupt_wait(struct mtd_info *mtd, int state) in onenand_try_interrupt_wait() argument
405 struct onenand_chip *this = mtd->priv; in onenand_try_interrupt_wait()
423 return onenand_wait(mtd, state); in onenand_try_interrupt_wait()
434 static void onenand_setup_wait(struct mtd_info *mtd) in onenand_setup_wait() argument
436 struct onenand_chip *this = mtd->priv; in onenand_setup_wait()
469 static inline int onenand_bufferram_offset(struct mtd_info *mtd, int area) in onenand_bufferram_offset() argument
471 struct onenand_chip *this = mtd->priv; in onenand_bufferram_offset()
478 return mtd->oobsize; in onenand_bufferram_offset()
494 static int onenand_read_bufferram(struct mtd_info *mtd, int area, in onenand_read_bufferram() argument
497 struct onenand_chip *this = mtd->priv; in onenand_read_bufferram()
502 bufferram += onenand_bufferram_offset(mtd, area); in onenand_read_bufferram()
530 static int onenand_sync_read_bufferram(struct mtd_info *mtd, int area, in onenand_sync_read_bufferram() argument
533 struct onenand_chip *this = mtd->priv; in onenand_sync_read_bufferram()
538 bufferram += onenand_bufferram_offset(mtd, area); in onenand_sync_read_bufferram()
540 this->mmcontrol(mtd, ONENAND_SYS_CFG1_SYNC_READ); in onenand_sync_read_bufferram()
555 this->mmcontrol(mtd, 0); in onenand_sync_read_bufferram()
570 static int onenand_write_bufferram(struct mtd_info *mtd, int area, in onenand_write_bufferram() argument
573 struct onenand_chip *this = mtd->priv; in onenand_write_bufferram()
578 bufferram += onenand_bufferram_offset(mtd, area); in onenand_write_bufferram()
609 static int onenand_get_2x_blockpage(struct mtd_info *mtd, loff_t addr) in onenand_get_2x_blockpage() argument
611 struct onenand_chip *this = mtd->priv; in onenand_get_2x_blockpage()
633 static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr) in onenand_check_bufferram() argument
635 struct onenand_chip *this = mtd->priv; in onenand_check_bufferram()
640 blockpage = onenand_get_2x_blockpage(mtd, addr); in onenand_check_bufferram()
675 static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr, in onenand_update_bufferram() argument
678 struct onenand_chip *this = mtd->priv; in onenand_update_bufferram()
683 blockpage = onenand_get_2x_blockpage(mtd, addr); in onenand_update_bufferram()
708 static void onenand_invalidate_bufferram(struct mtd_info *mtd, loff_t addr, in onenand_invalidate_bufferram() argument
711 struct onenand_chip *this = mtd->priv; in onenand_invalidate_bufferram()
730 static int onenand_get_device(struct mtd_info *mtd, int new_state) in onenand_get_device() argument
732 struct onenand_chip *this = mtd->priv; in onenand_get_device()
765 static void onenand_release_device(struct mtd_info *mtd) in onenand_release_device() argument
767 struct onenand_chip *this = mtd->priv; in onenand_release_device()
783 static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf, int column, in onenand_transfer_auto_oob() argument
786 struct onenand_chip *this = mtd->priv; in onenand_transfer_auto_oob()
802 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize); in onenand_transfer_auto_oob()
826 static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from, in onenand_read_ops_nolock() argument
829 struct onenand_chip *this = mtd->priv; in onenand_read_ops_nolock()
845 oobsize = mtd->oobsize; in onenand_read_ops_nolock()
847 oobcolumn = from & (mtd->oobsize - 1); in onenand_read_ops_nolock()
850 if ((from + len) > mtd->size) { in onenand_read_ops_nolock()
857 stats = mtd->ecc_stats; in onenand_read_ops_nolock()
863 if (!onenand_check_bufferram(mtd, from)) { in onenand_read_ops_nolock()
864 this->command(mtd, ONENAND_CMD_READ, from, writesize); in onenand_read_ops_nolock()
865 ret = this->wait(mtd, FL_READING); in onenand_read_ops_nolock()
866 onenand_update_bufferram(mtd, from, !ret); in onenand_read_ops_nolock()
881 this->command(mtd, ONENAND_CMD_READ, from, writesize); in onenand_read_ops_nolock()
896 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen); in onenand_read_ops_nolock()
904 onenand_transfer_auto_oob(mtd, oobbuf, oobcolumn, thisooblen); in onenand_read_ops_nolock()
906 this->read_bufferram(mtd, ONENAND_SPARERAM, oobbuf, oobcolumn, thisooblen); in onenand_read_ops_nolock()
925 ret = this->wait(mtd, FL_READING); in onenand_read_ops_nolock()
926 onenand_update_bufferram(mtd, from, !ret); in onenand_read_ops_nolock()
942 if (mtd->ecc_stats.failed - stats.failed) in onenand_read_ops_nolock()
945 return mtd->ecc_stats.corrected - stats.corrected ? -EUCLEAN : 0; in onenand_read_ops_nolock()
956 static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from, in onenand_read_oob_nolock() argument
959 struct onenand_chip *this = mtd->priv; in onenand_read_oob_nolock()
977 oobsize = mtd->oobsize; in onenand_read_oob_nolock()
979 column = from & (mtd->oobsize - 1); in onenand_read_oob_nolock()
987 if (unlikely(from >= mtd->size || in onenand_read_oob_nolock()
988 column + len > ((mtd->size >> this->page_shift) - in onenand_read_oob_nolock()
994 stats = mtd->ecc_stats; in onenand_read_oob_nolock()
1002 this->command(mtd, ONENAND_CMD_READOOB, from, mtd->oobsize); in onenand_read_oob_nolock()
1004 onenand_update_bufferram(mtd, from, 0); in onenand_read_oob_nolock()
1006 ret = this->wait(mtd, FL_READING); in onenand_read_oob_nolock()
1013 onenand_transfer_auto_oob(mtd, buf, column, thislen); in onenand_read_oob_nolock()
1015 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen); in onenand_read_oob_nolock()
1027 from += mtd->writesize; in onenand_read_oob_nolock()
1037 if (mtd->ecc_stats.failed - stats.failed) in onenand_read_oob_nolock()
1053 static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, in onenand_read() argument
1064 onenand_get_device(mtd, FL_READING); in onenand_read()
1065 ret = onenand_read_ops_nolock(mtd, from, &ops); in onenand_read()
1066 onenand_release_device(mtd); in onenand_read()
1080 static int onenand_read_oob(struct mtd_info *mtd, loff_t from, in onenand_read_oob() argument
1095 onenand_get_device(mtd, FL_READING); in onenand_read_oob()
1097 ret = onenand_read_ops_nolock(mtd, from, ops); in onenand_read_oob()
1099 ret = onenand_read_oob_nolock(mtd, from, ops); in onenand_read_oob()
1100 onenand_release_device(mtd); in onenand_read_oob()
1112 static int onenand_bbt_wait(struct mtd_info *mtd, int state) in onenand_bbt_wait() argument
1114 struct onenand_chip *this = mtd->priv; in onenand_bbt_wait()
1161 int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from, in onenand_bbt_read_oob() argument
1164 struct onenand_chip *this = mtd->priv; in onenand_bbt_read_oob()
1176 if (unlikely((from + len) > mtd->size)) { in onenand_bbt_read_oob()
1182 onenand_get_device(mtd, FL_READING); in onenand_bbt_read_oob()
1184 column = from & (mtd->oobsize - 1); in onenand_bbt_read_oob()
1189 thislen = mtd->oobsize - column; in onenand_bbt_read_oob()
1192 this->command(mtd, ONENAND_CMD_READOOB, from, mtd->oobsize); in onenand_bbt_read_oob()
1194 onenand_update_bufferram(mtd, from, 0); in onenand_bbt_read_oob()
1196 ret = onenand_bbt_wait(mtd, FL_READING); in onenand_bbt_read_oob()
1200 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen); in onenand_bbt_read_oob()
1216 onenand_release_device(mtd); in onenand_bbt_read_oob()
1229 static int onenand_verify_oob(struct mtd_info *mtd, const u_char *buf, loff_t to) in onenand_verify_oob() argument
1231 struct onenand_chip *this = mtd->priv; in onenand_verify_oob()
1235 this->command(mtd, ONENAND_CMD_READOOB, to, mtd->oobsize); in onenand_verify_oob()
1236 onenand_update_bufferram(mtd, to, 0); in onenand_verify_oob()
1237 status = this->wait(mtd, FL_READING); in onenand_verify_oob()
1241 this->read_bufferram(mtd, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize); in onenand_verify_oob()
1242 for (i = 0; i < mtd->oobsize; i++) in onenand_verify_oob()
1256 static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr, size_t len) in onenand_verify() argument
1258 struct onenand_chip *this = mtd->priv; in onenand_verify()
1269 this->command(mtd, ONENAND_CMD_READ, addr, this->writesize); in onenand_verify()
1271 onenand_update_bufferram(mtd, addr, 0); in onenand_verify()
1273 ret = this->wait(mtd, FL_READING); in onenand_verify()
1277 onenand_update_bufferram(mtd, addr, 1); in onenand_verify()
1280 dataram += onenand_bufferram_offset(mtd, ONENAND_DATARAM); in onenand_verify()
1299 static void onenand_panic_wait(struct mtd_info *mtd) in onenand_panic_wait() argument
1301 struct onenand_chip *this = mtd->priv; in onenand_panic_wait()
1323 static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len, in onenand_panic_write() argument
1326 struct onenand_chip *this = mtd->priv; in onenand_panic_write()
1335 onenand_panic_wait(mtd); in onenand_panic_write()
1344 if (unlikely((to + len) > mtd->size)) { in onenand_panic_write()
1355 column = to & (mtd->writesize - 1); in onenand_panic_write()
1359 int thislen = min_t(int, mtd->writesize - column, len - written); in onenand_panic_write()
1362 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen); in onenand_panic_write()
1365 subpage = thislen < mtd->writesize; in onenand_panic_write()
1367 memset(this->page_buf, 0xff, mtd->writesize); in onenand_panic_write()
1372 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize); in onenand_panic_write()
1373 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); in onenand_panic_write()
1375 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize); in onenand_panic_write()
1377 onenand_panic_wait(mtd); in onenand_panic_write()
1380 onenand_update_bufferram(mtd, to, !ret && !subpage); in onenand_panic_write()
1383 onenand_update_bufferram(mtd, to + this->writesize, !ret && !subpage); in onenand_panic_write()
1413 static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf, in onenand_fill_auto_oob() argument
1416 struct onenand_chip *this = mtd->priv; in onenand_fill_auto_oob()
1454 static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to, in onenand_write_ops_nolock() argument
1457 struct onenand_chip *this = mtd->priv; in onenand_write_ops_nolock()
1474 if (unlikely((to + len) > mtd->size)) { in onenand_write_ops_nolock()
1488 oobsize = mtd->oobsize; in onenand_write_ops_nolock()
1490 oobcolumn = to & (mtd->oobsize - 1); in onenand_write_ops_nolock()
1492 column = to & (mtd->writesize - 1); in onenand_write_ops_nolock()
1498 thislen = min_t(int, mtd->writesize - column, len - written); in onenand_write_ops_nolock()
1503 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen); in onenand_write_ops_nolock()
1506 subpage = thislen < mtd->writesize; in onenand_write_ops_nolock()
1508 memset(this->page_buf, 0xff, mtd->writesize); in onenand_write_ops_nolock()
1513 this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize); in onenand_write_ops_nolock()
1520 memset(oobbuf, 0xff, mtd->oobsize); in onenand_write_ops_nolock()
1522 onenand_fill_auto_oob(mtd, oobbuf, oob, oobcolumn, thisooblen); in onenand_write_ops_nolock()
1532 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize); in onenand_write_ops_nolock()
1534 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize); in onenand_write_ops_nolock()
1536 ret = this->wait(mtd, FL_WRITING); in onenand_write_ops_nolock()
1539 onenand_update_bufferram(mtd, to, !ret && !subpage); in onenand_write_ops_nolock()
1542 onenand_update_bufferram(mtd, to + this->writesize, !ret && !subpage); in onenand_write_ops_nolock()
1551 ret = onenand_verify(mtd, buf, to, thislen); in onenand_write_ops_nolock()
1584 static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to, in onenand_write_oob_nolock() argument
1587 struct onenand_chip *this = mtd->priv; in onenand_write_oob_nolock()
1605 oobsize = mtd->oobsize; in onenand_write_oob_nolock()
1607 column = to & (mtd->oobsize - 1); in onenand_write_oob_nolock()
1622 if (unlikely(to >= mtd->size || in onenand_write_oob_nolock()
1623 column + len > ((mtd->size >> this->page_shift) - in onenand_write_oob_nolock()
1637 this->command(mtd, ONENAND_CMD_BUFFERRAM, to, mtd->oobsize); in onenand_write_oob_nolock()
1641 memset(oobbuf, 0xff, mtd->oobsize); in onenand_write_oob_nolock()
1643 onenand_fill_auto_oob(mtd, oobbuf, buf, column, thislen); in onenand_write_oob_nolock()
1646 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize); in onenand_write_oob_nolock()
1648 this->command(mtd, ONENAND_CMD_PROGOOB, to, mtd->oobsize); in onenand_write_oob_nolock()
1650 onenand_update_bufferram(mtd, to, 0); in onenand_write_oob_nolock()
1653 onenand_update_bufferram(mtd, to + this->writesize, 0); in onenand_write_oob_nolock()
1656 ret = this->wait(mtd, FL_WRITING); in onenand_write_oob_nolock()
1662 ret = onenand_verify_oob(mtd, oobbuf, to); in onenand_write_oob_nolock()
1672 to += mtd->writesize; in onenand_write_oob_nolock()
1692 static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len, in onenand_write() argument
1703 onenand_get_device(mtd, FL_WRITING); in onenand_write()
1704 ret = onenand_write_ops_nolock(mtd, to, &ops); in onenand_write()
1705 onenand_release_device(mtd); in onenand_write()
1717 static int onenand_write_oob(struct mtd_info *mtd, loff_t to, in onenand_write_oob() argument
1732 onenand_get_device(mtd, FL_WRITING); in onenand_write_oob()
1734 ret = onenand_write_ops_nolock(mtd, to, ops); in onenand_write_oob()
1736 ret = onenand_write_oob_nolock(mtd, to, ops); in onenand_write_oob()
1737 onenand_release_device(mtd); in onenand_write_oob()
1751 static int onenand_block_isbad_nolock(struct mtd_info *mtd, loff_t ofs, int allowbbt) in onenand_block_isbad_nolock() argument
1753 struct onenand_chip *this = mtd->priv; in onenand_block_isbad_nolock()
1757 return bbm->isbad_bbt(mtd, ofs, allowbbt); in onenand_block_isbad_nolock()
1767 static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) in onenand_erase() argument
1769 struct onenand_chip *this = mtd->priv; in onenand_erase()
1792 if (unlikely((instr->len + instr->addr) > mtd->size)) { in onenand_erase()
1800 onenand_get_device(mtd, FL_ERASING); in onenand_erase()
1812 if (onenand_block_isbad_nolock(mtd, addr, 0)) { in onenand_erase()
1818 this->command(mtd, ONENAND_CMD_ERASE, addr, block_size); in onenand_erase()
1820 onenand_invalidate_bufferram(mtd, addr, block_size); in onenand_erase()
1822 ret = this->wait(mtd, FL_ERASING); in onenand_erase()
1842 onenand_release_device(mtd); in onenand_erase()
1857 static void onenand_sync(struct mtd_info *mtd) in onenand_sync() argument
1862 onenand_get_device(mtd, FL_SYNCING); in onenand_sync()
1865 onenand_release_device(mtd); in onenand_sync()
1875 static int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs) in onenand_block_isbad() argument
1880 if (ofs > mtd->size) in onenand_block_isbad()
1883 onenand_get_device(mtd, FL_READING); in onenand_block_isbad()
1884 ret = onenand_block_isbad_nolock(mtd, ofs, 0); in onenand_block_isbad()
1885 onenand_release_device(mtd); in onenand_block_isbad()
1897 static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) in onenand_default_block_markbad() argument
1899 struct onenand_chip *this = mtd->priv; in onenand_default_block_markbad()
1916 ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); in onenand_default_block_markbad()
1917 return onenand_write_oob_nolock(mtd, ofs, &ops); in onenand_default_block_markbad()
1927 static int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs) in onenand_block_markbad() argument
1929 struct onenand_chip *this = mtd->priv; in onenand_block_markbad()
1932 ret = onenand_block_isbad(mtd, ofs); in onenand_block_markbad()
1940 onenand_get_device(mtd, FL_WRITING); in onenand_block_markbad()
1941 ret = this->block_markbad(mtd, ofs); in onenand_block_markbad()
1942 onenand_release_device(mtd); in onenand_block_markbad()
1955 static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int cmd) in onenand_do_lock_cmd() argument
1957 struct onenand_chip *this = mtd->priv; in onenand_do_lock_cmd()
1976 this->command(mtd, cmd, 0, 0); in onenand_do_lock_cmd()
1979 this->wait(mtd, FL_LOCKING); in onenand_do_lock_cmd()
2005 this->command(mtd, cmd, 0, 0); in onenand_do_lock_cmd()
2008 this->wait(mtd, FL_LOCKING); in onenand_do_lock_cmd()
2032 static int onenand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) in onenand_lock() argument
2036 onenand_get_device(mtd, FL_LOCKING); in onenand_lock()
2037 ret = onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_LOCK); in onenand_lock()
2038 onenand_release_device(mtd); in onenand_lock()
2050 static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) in onenand_unlock() argument
2054 onenand_get_device(mtd, FL_LOCKING); in onenand_unlock()
2055 ret = onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_UNLOCK); in onenand_unlock()
2056 onenand_release_device(mtd); in onenand_unlock()
2099 static void onenand_unlock_all(struct mtd_info *mtd) in onenand_unlock_all() argument
2101 struct onenand_chip *this = mtd->priv; in onenand_unlock_all()
2109 this->command(mtd, ONENAND_CMD_UNLOCK_ALL, 0, 0); in onenand_unlock_all()
2112 this->wait(mtd, FL_LOCKING); in onenand_unlock_all()
2131 onenand_do_lock_cmd(mtd, ofs, len, ONENAND_CMD_UNLOCK); in onenand_unlock_all()
2137 typedef int (*otp_op_t)(struct mtd_info *mtd, loff_t form, size_t len,
2150 static int do_otp_read(struct mtd_info *mtd, loff_t from, size_t len, in do_otp_read() argument
2153 struct onenand_chip *this = mtd->priv; in do_otp_read()
2163 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); in do_otp_read()
2164 this->wait(mtd, FL_OTPING); in do_otp_read()
2166 ret = onenand_read_ops_nolock(mtd, from, &ops); in do_otp_read()
2169 this->command(mtd, ONENAND_CMD_RESET, 0, 0); in do_otp_read()
2170 this->wait(mtd, FL_RESETING); in do_otp_read()
2185 static int do_otp_write(struct mtd_info *mtd, loff_t to, size_t len, in do_otp_write() argument
2188 struct onenand_chip *this = mtd->priv; in do_otp_write()
2194 if (len < mtd->writesize) { in do_otp_write()
2196 memset(this->page_buf + len, 0xff, mtd->writesize - len); in do_otp_write()
2198 len = mtd->writesize; in do_otp_write()
2202 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); in do_otp_write()
2203 this->wait(mtd, FL_OTPING); in do_otp_write()
2209 ret = onenand_write_ops_nolock(mtd, to, &ops); in do_otp_write()
2213 this->command(mtd, ONENAND_CMD_RESET, 0, 0); in do_otp_write()
2214 this->wait(mtd, FL_RESETING); in do_otp_write()
2229 static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len, in do_otp_lock() argument
2232 struct onenand_chip *this = mtd->priv; in do_otp_lock()
2242 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); in do_otp_lock()
2243 this->wait(mtd, FL_OTPING); in do_otp_lock()
2245 ret = onenand_write_oob_nolock(mtd, from, &ops); in do_otp_lock()
2250 this->command(mtd, ONENAND_CMD_RESET, 0, 0); in do_otp_lock()
2251 this->wait(mtd, FL_RESETING); in do_otp_lock()
2268 static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len, in onenand_otp_walk() argument
2272 struct onenand_chip *this = mtd->priv; in onenand_otp_walk()
2286 from += mtd->writesize * otp_pages; in onenand_otp_walk()
2291 if (((mtd->writesize * otp_pages) - (from + len)) < 0) in onenand_otp_walk()
2294 onenand_get_device(mtd, FL_OTPING); in onenand_otp_walk()
2307 otpinfo->length = mtd->writesize; in onenand_otp_walk()
2310 from += mtd->writesize; in onenand_otp_walk()
2317 ret = action(mtd, from, len, &tmp_retlen, buf); in onenand_otp_walk()
2328 onenand_release_device(mtd); in onenand_otp_walk()
2341 static int onenand_get_fact_prot_info(struct mtd_info *mtd, in onenand_get_fact_prot_info() argument
2347 ret = onenand_otp_walk(mtd, 0, len, &retlen, (u_char *) buf, NULL, MTD_OTP_FACTORY); in onenand_get_fact_prot_info()
2362 static int onenand_read_fact_prot_reg(struct mtd_info *mtd, loff_t from, in onenand_read_fact_prot_reg() argument
2365 return onenand_otp_walk(mtd, from, len, retlen, buf, do_otp_read, MTD_OTP_FACTORY); in onenand_read_fact_prot_reg()
2376 static int onenand_get_user_prot_info(struct mtd_info *mtd, in onenand_get_user_prot_info() argument
2382 ret = onenand_otp_walk(mtd, 0, len, &retlen, (u_char *) buf, NULL, MTD_OTP_USER); in onenand_get_user_prot_info()
2397 static int onenand_read_user_prot_reg(struct mtd_info *mtd, loff_t from, in onenand_read_user_prot_reg() argument
2400 return onenand_otp_walk(mtd, from, len, retlen, buf, do_otp_read, MTD_OTP_USER); in onenand_read_user_prot_reg()
2413 static int onenand_write_user_prot_reg(struct mtd_info *mtd, loff_t from, in onenand_write_user_prot_reg() argument
2416 return onenand_otp_walk(mtd, from, len, retlen, buf, do_otp_write, MTD_OTP_USER); in onenand_write_user_prot_reg()
2427 static int onenand_lock_user_prot_reg(struct mtd_info *mtd, loff_t from, in onenand_lock_user_prot_reg() argument
2430 struct onenand_chip *this = mtd->priv; in onenand_lock_user_prot_reg()
2435 memset(oob_buf, 0xff, mtd->oobsize); in onenand_lock_user_prot_reg()
2451 ret = onenand_otp_walk(mtd, from, len, &retlen, oob_buf, do_otp_lock, MTD_OTP_USER); in onenand_lock_user_prot_reg()
2465 static void onenand_check_features(struct mtd_info *mtd) in onenand_check_features() argument
2467 struct onenand_chip *this = mtd->priv; in onenand_check_features()
2567 static int onenand_probe(struct mtd_info *mtd) in onenand_probe() argument
2569 struct onenand_chip *this = mtd->priv; in onenand_probe()
2589 this->wait(mtd, FL_RESETING); in onenand_probe()
2622 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); in onenand_probe()
2623 mtd->oobsize = mtd->writesize >> 5; in onenand_probe()
2625 mtd->erasesize = mtd->writesize << 6; in onenand_probe()
2627 this->erase_shift = ffs(mtd->erasesize) - 1; in onenand_probe()
2628 this->page_shift = ffs(mtd->writesize) - 1; in onenand_probe()
2631 this->writesize = mtd->writesize; in onenand_probe()
2635 mtd->size = this->chipsize; in onenand_probe()
2638 onenand_check_features(mtd); in onenand_probe()
2647 mtd->writesize <<= 1; in onenand_probe()
2648 mtd->erasesize <<= 1; in onenand_probe()
2658 static int onenand_suspend(struct mtd_info *mtd) in onenand_suspend() argument
2660 return onenand_get_device(mtd, FL_PM_SUSPENDED); in onenand_suspend()
2667 static void onenand_resume(struct mtd_info *mtd) in onenand_resume() argument
2669 struct onenand_chip *this = mtd->priv; in onenand_resume()
2672 onenand_release_device(mtd); in onenand_resume()
2688 int onenand_scan(struct mtd_info *mtd, int maxchips) in onenand_scan() argument
2691 struct onenand_chip *this = mtd->priv; in onenand_scan()
2701 onenand_setup_wait(mtd); in onenand_scan()
2713 if (onenand_probe(mtd)) in onenand_scan()
2724 this->page_buf = kzalloc(mtd->writesize, GFP_KERNEL); in onenand_scan()
2732 this->oob_buf = kzalloc(mtd->oobsize, GFP_KERNEL); in onenand_scan()
2751 switch (mtd->oobsize) { in onenand_scan()
2754 mtd->subpage_sft = 2; in onenand_scan()
2759 mtd->subpage_sft = 1; in onenand_scan()
2764 mtd->oobsize); in onenand_scan()
2765 mtd->subpage_sft = 0; in onenand_scan()
2771 this->subpagesize = mtd->writesize >> mtd->subpage_sft; in onenand_scan()
2782 mtd->oobavail = this->ecclayout->oobavail; in onenand_scan()
2784 mtd->ecclayout = this->ecclayout; in onenand_scan()
2787 mtd->type = MTD_NANDFLASH; in onenand_scan()
2788 mtd->flags = MTD_CAP_NANDFLASH; in onenand_scan()
2789 mtd->erase = onenand_erase; in onenand_scan()
2790 mtd->point = NULL; in onenand_scan()
2791 mtd->unpoint = NULL; in onenand_scan()
2792 mtd->read = onenand_read; in onenand_scan()
2793 mtd->write = onenand_write; in onenand_scan()
2794 mtd->read_oob = onenand_read_oob; in onenand_scan()
2795 mtd->write_oob = onenand_write_oob; in onenand_scan()
2796 mtd->panic_write = onenand_panic_write; in onenand_scan()
2798 mtd->get_fact_prot_info = onenand_get_fact_prot_info; in onenand_scan()
2799 mtd->read_fact_prot_reg = onenand_read_fact_prot_reg; in onenand_scan()
2800 mtd->get_user_prot_info = onenand_get_user_prot_info; in onenand_scan()
2801 mtd->read_user_prot_reg = onenand_read_user_prot_reg; in onenand_scan()
2802 mtd->write_user_prot_reg = onenand_write_user_prot_reg; in onenand_scan()
2803 mtd->lock_user_prot_reg = onenand_lock_user_prot_reg; in onenand_scan()
2805 mtd->sync = onenand_sync; in onenand_scan()
2806 mtd->lock = onenand_lock; in onenand_scan()
2807 mtd->unlock = onenand_unlock; in onenand_scan()
2808 mtd->suspend = onenand_suspend; in onenand_scan()
2809 mtd->resume = onenand_resume; in onenand_scan()
2810 mtd->block_isbad = onenand_block_isbad; in onenand_scan()
2811 mtd->block_markbad = onenand_block_markbad; in onenand_scan()
2812 mtd->owner = THIS_MODULE; in onenand_scan()
2815 onenand_unlock_all(mtd); in onenand_scan()
2817 return this->scan_bbt(mtd); in onenand_scan()
2824 void onenand_release(struct mtd_info *mtd) in onenand_release() argument
2826 struct onenand_chip *this = mtd->priv; in onenand_release()
2830 del_mtd_partitions (mtd); in onenand_release()
2833 del_mtd_device (mtd); in onenand_release()