Lines Matching refs:mtd

120 					      struct mtd_info *mtd,  in mxs_nand_bbm_in_data_chunk()  argument
126 dev_err(mtd->dev, "The size of chunk0 must equal to chunkn\n"); in mxs_nand_bbm_in_data_chunk()
130 i = (mtd->writesize * 8 - MXS_NAND_METADATA_SIZE * 8) / in mxs_nand_bbm_in_data_chunk()
134 j = (mtd->writesize * 8 - MXS_NAND_METADATA_SIZE * 8) - in mxs_nand_bbm_in_data_chunk()
140 dev_dbg(mtd->dev, "Set ecc to %d and bbm in chunk %d\n", in mxs_nand_bbm_in_data_chunk()
149 struct mtd_info *mtd, in mxs_nand_calc_ecc_layout_by_info() argument
153 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_calc_ecc_layout_by_info()
173 if (geo->ecc_chunkn_size < mtd->oobsize) in mxs_nand_calc_ecc_layout_by_info()
179 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunkn_size; in mxs_nand_calc_ecc_layout_by_info()
182 block_mark_bit_offset = mtd->writesize * 8 - in mxs_nand_calc_ecc_layout_by_info()
193 struct mtd_info *mtd) in mxs_nand_legacy_calc_ecc_layout() argument
195 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_legacy_calc_ecc_layout()
206 if (geo->ecc_chunkn_size < mtd->oobsize) { in mxs_nand_legacy_calc_ecc_layout()
212 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunkn_size; in mxs_nand_legacy_calc_ecc_layout()
222 geo->ecc_strength = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8) in mxs_nand_legacy_calc_ecc_layout()
228 block_mark_bit_offset = mtd->writesize * 8 - in mxs_nand_legacy_calc_ecc_layout()
239 struct mtd_info *mtd) in mxs_nand_calc_ecc_for_large_oob() argument
241 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_calc_ecc_for_large_oob()
257 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunkn_size; in mxs_nand_calc_ecc_for_large_oob()
258 max_ecc = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8) in mxs_nand_calc_ecc_for_large_oob()
268 if (mxs_nand_bbm_in_data_chunk(geo, mtd, &bbm_chunk)) in mxs_nand_calc_ecc_for_large_oob()
279 geo->ecc_chunk_count = (mtd->writesize / geo->ecc_chunkn_size) + 1; in mxs_nand_calc_ecc_for_large_oob()
282 if (mtd->oobsize * 8 < MXS_NAND_METADATA_SIZE * 8 + in mxs_nand_calc_ecc_for_large_oob()
290 bbm_chunk = (mtd->writesize * 8 - MXS_NAND_METADATA_SIZE * 8 - in mxs_nand_calc_ecc_for_large_oob()
297 i = (mtd->writesize / geo->ecc_chunkn_size) - bbm_chunk + 1; in mxs_nand_calc_ecc_for_large_oob()
299 block_mark_bit_offset = mtd->writesize * 8 - in mxs_nand_calc_ecc_for_large_oob()
335 static void mxs_nand_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl) in mxs_nand_cmd_ctrl() argument
337 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_cmd_ctrl()
414 static int mxs_nand_device_ready(struct mtd_info *mtd) in mxs_nand_device_ready() argument
416 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_device_ready()
429 static void mxs_nand_select_chip(struct mtd_info *mtd, int chip) in mxs_nand_select_chip() argument
431 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_select_chip()
476 static void mxs_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int length) in mxs_nand_read_buf() argument
478 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_read_buf()
559 static void mxs_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, in mxs_nand_write_buf() argument
562 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_write_buf()
613 static uint8_t mxs_nand_read_byte(struct mtd_info *mtd) in mxs_nand_read_byte() argument
616 mxs_nand_read_buf(mtd, &buf, 1); in mxs_nand_read_byte()
620 static bool mxs_nand_erased_page(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_erased_page() argument
641 nand->cmdfunc(mtd, NAND_CMD_READ0, 0, page); in mxs_nand_erased_page()
642 nand->read_buf(mtd, buf, mtd->writesize); in mxs_nand_erased_page()
644 for (i = 0; i < mtd->writesize / 4; i++) { in mxs_nand_erased_page()
650 mtd->ecc_stats.corrected += flip_bits; in mxs_nand_erased_page()
652 memset(buf, 0xff, mtd->writesize); in mxs_nand_erased_page()
662 static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_ecc_read_page() argument
706 (mtd->writesize + mtd->oobsize); in mxs_nand_ecc_read_page()
712 d->cmd.pio_words[3] = mtd->writesize + mtd->oobsize; in mxs_nand_ecc_read_page()
738 (mtd->writesize + mtd->oobsize); in mxs_nand_ecc_read_page()
794 if (mxs_nand_erased_page(mtd, nand, in mxs_nand_ecc_read_page()
805 mtd->ecc_stats.failed += failed; in mxs_nand_ecc_read_page()
806 mtd->ecc_stats.corrected += corrected; in mxs_nand_ecc_read_page()
817 memset(nand->oob_poi, 0xff, mtd->oobsize); in mxs_nand_ecc_read_page()
821 memcpy(buf, nand_info->data_buf, mtd->writesize); in mxs_nand_ecc_read_page()
824 memset(buf, 0xff, mtd->writesize); in mxs_nand_ecc_read_page()
834 static int mxs_nand_ecc_write_page(struct mtd_info *mtd, in mxs_nand_ecc_write_page() argument
844 memcpy(nand_info->data_buf, buf, mtd->writesize); in mxs_nand_ecc_write_page()
845 memcpy(nand_info->oob_buf, nand->oob_poi, mtd->oobsize); in mxs_nand_ecc_write_page()
869 d->cmd.pio_words[3] = (mtd->writesize + mtd->oobsize); in mxs_nand_ecc_write_page()
915 static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from, in mxs_nand_hook_read_oob() argument
918 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_hook_read_oob()
927 ret = nand_info->hooked_read_oob(mtd, from, ops); in mxs_nand_hook_read_oob()
940 static int mxs_nand_hook_write_oob(struct mtd_info *mtd, loff_t to, in mxs_nand_hook_write_oob() argument
943 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_hook_write_oob()
952 ret = nand_info->hooked_write_oob(mtd, to, ops); in mxs_nand_hook_write_oob()
965 static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs) in mxs_nand_hook_block_markbad() argument
967 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_hook_block_markbad()
973 ret = nand_info->hooked_block_markbad(mtd, ofs); in mxs_nand_hook_block_markbad()
1024 static int mxs_nand_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_ecc_read_oob() argument
1039 nand->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); in mxs_nand_ecc_read_oob()
1040 nand->read_buf(mtd, nand->oob_poi, mtd->oobsize); in mxs_nand_ecc_read_oob()
1046 memset(nand->oob_poi, 0xff, mtd->oobsize); in mxs_nand_ecc_read_oob()
1048 nand->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); in mxs_nand_ecc_read_oob()
1049 mxs_nand_read_buf(mtd, nand->oob_poi, 1); in mxs_nand_ecc_read_oob()
1059 static int mxs_nand_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_ecc_write_oob() argument
1080 nand->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); in mxs_nand_ecc_write_oob()
1081 nand->write_buf(mtd, &block_mark, 1); in mxs_nand_ecc_write_oob()
1082 nand->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in mxs_nand_ecc_write_oob()
1085 if (nand->waitfunc(mtd, nand) & NAND_STATUS_FAIL) in mxs_nand_ecc_write_oob()
1104 static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs) in mxs_nand_block_bad() argument
1109 static int mxs_nand_set_geometry(struct mtd_info *mtd, struct bch_geometry *geo) in mxs_nand_set_geometry() argument
1111 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_set_geometry()
1112 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_set_geometry()
1122 mtd->oobsize < 1024) || nand_info->legacy_bch_geometry) { in mxs_nand_set_geometry()
1123 dev_warn(mtd->dev, "use legacy bch geometry\n"); in mxs_nand_set_geometry()
1124 return mxs_nand_legacy_calc_ecc_layout(geo, mtd); in mxs_nand_set_geometry()
1127 if (mtd->oobsize > 1024 || chip->ecc_step_ds < mtd->oobsize) in mxs_nand_set_geometry()
1128 return mxs_nand_calc_ecc_for_large_oob(geo, mtd); in mxs_nand_set_geometry()
1130 return mxs_nand_calc_ecc_layout_by_info(geo, mtd, in mxs_nand_set_geometry()
1145 int mxs_nand_setup_ecc(struct mtd_info *mtd) in mxs_nand_setup_ecc() argument
1147 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_setup_ecc()
1155 nand_info->oobsize = mtd->oobsize; in mxs_nand_setup_ecc()
1156 nand_info->writesize = mtd->writesize; in mxs_nand_setup_ecc()
1158 ret = mxs_nand_set_geometry(mtd, geo); in mxs_nand_setup_ecc()
1175 tmp = (mtd->writesize + mtd->oobsize) in mxs_nand_setup_ecc()
1197 if (mtd->_read_oob != mxs_nand_hook_read_oob) { in mxs_nand_setup_ecc()
1198 nand_info->hooked_read_oob = mtd->_read_oob; in mxs_nand_setup_ecc()
1199 mtd->_read_oob = mxs_nand_hook_read_oob; in mxs_nand_setup_ecc()
1202 if (mtd->_write_oob != mxs_nand_hook_write_oob) { in mxs_nand_setup_ecc()
1203 nand_info->hooked_write_oob = mtd->_write_oob; in mxs_nand_setup_ecc()
1204 mtd->_write_oob = mxs_nand_hook_write_oob; in mxs_nand_setup_ecc()
1207 if (mtd->_block_markbad != mxs_nand_hook_block_markbad) { in mxs_nand_setup_ecc()
1208 nand_info->hooked_block_markbad = mtd->_block_markbad; in mxs_nand_setup_ecc()
1209 mtd->_block_markbad = mxs_nand_hook_block_markbad; in mxs_nand_setup_ecc()
1358 struct mtd_info *mtd; in mxs_nand_init_ctrl() local
1363 mtd = nand_to_mtd(nand); in mxs_nand_init_ctrl()
1396 if (nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL)) in mxs_nand_init_ctrl()
1399 if (mxs_nand_setup_ecc(mtd)) in mxs_nand_init_ctrl()
1413 err = nand_scan_tail(mtd); in mxs_nand_init_ctrl()
1417 err = nand_register(0, mtd); in mxs_nand_init_ctrl()
1468 void mxs_nand_get_layout(struct mtd_info *mtd, struct mxs_nand_layout *l) in mxs_nand_get_layout() argument
1495 void mxs_nand_mode_fcb_62bit(struct mtd_info *mtd) in mxs_nand_mode_fcb_62bit() argument
1499 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_mode_fcb_62bit()
1504 mtd->writesize = 1024; in mxs_nand_mode_fcb_62bit()
1505 mtd->oobsize = 1862 - 1024; in mxs_nand_mode_fcb_62bit()
1531 void mxs_nand_mode_fcb_40bit(struct mtd_info *mtd) in mxs_nand_mode_fcb_40bit() argument
1535 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_mode_fcb_40bit()
1541 mtd->writesize = 1024; in mxs_nand_mode_fcb_40bit()
1542 mtd->oobsize = 1576 - 1024; in mxs_nand_mode_fcb_40bit()
1568 void mxs_nand_mode_normal(struct mtd_info *mtd) in mxs_nand_mode_normal() argument
1571 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_mode_normal()
1576 mtd->writesize = nand_info->writesize; in mxs_nand_mode_normal()
1577 mtd->oobsize = nand_info->oobsize; in mxs_nand_mode_normal()
1583 uint32_t mxs_nand_mark_byte_offset(struct mtd_info *mtd) in mxs_nand_mark_byte_offset() argument
1585 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_mark_byte_offset()
1592 uint32_t mxs_nand_mark_bit_offset(struct mtd_info *mtd) in mxs_nand_mark_bit_offset() argument
1594 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_mark_bit_offset()