Lines Matching refs:mtd

165 						   struct mtd_info *mtd,  in mxs_nand_calc_ecc_layout_by_info()  argument
169 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_calc_ecc_layout_by_info()
187 if (geo->ecc_chunk_size < mtd->oobsize) in mxs_nand_calc_ecc_layout_by_info()
193 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; in mxs_nand_calc_ecc_layout_by_info()
199 struct mtd_info *mtd) in mxs_nand_calc_ecc_layout() argument
201 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_calc_ecc_layout()
210 if (geo->ecc_chunk_size < mtd->oobsize) { in mxs_nand_calc_ecc_layout()
215 if (mtd->oobsize > geo->ecc_chunk_size) { in mxs_nand_calc_ecc_layout()
221 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; in mxs_nand_calc_ecc_layout()
231 geo->ecc_strength = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8) in mxs_nand_calc_ecc_layout()
266 static void mxs_nand_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl) in mxs_nand_cmd_ctrl() argument
268 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_cmd_ctrl()
345 static int mxs_nand_device_ready(struct mtd_info *mtd) in mxs_nand_device_ready() argument
347 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_device_ready()
360 static void mxs_nand_select_chip(struct mtd_info *mtd, int chip) in mxs_nand_select_chip() argument
362 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_select_chip()
407 static void mxs_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int length) in mxs_nand_read_buf() argument
409 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_read_buf()
490 static void mxs_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, in mxs_nand_write_buf() argument
493 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_write_buf()
544 static uint8_t mxs_nand_read_byte(struct mtd_info *mtd) in mxs_nand_read_byte() argument
547 mxs_nand_read_buf(mtd, &buf, 1); in mxs_nand_read_byte()
554 static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_ecc_read_page() argument
596 (mtd->writesize + mtd->oobsize); in mxs_nand_ecc_read_page()
602 d->cmd.pio_words[3] = mtd->writesize + mtd->oobsize; in mxs_nand_ecc_read_page()
622 (mtd->writesize + mtd->oobsize); in mxs_nand_ecc_read_page()
678 mtd->ecc_stats.failed += failed; in mxs_nand_ecc_read_page()
679 mtd->ecc_stats.corrected += corrected; in mxs_nand_ecc_read_page()
690 memset(nand->oob_poi, 0xff, mtd->oobsize); in mxs_nand_ecc_read_page()
694 memcpy(buf, nand_info->data_buf, mtd->writesize); in mxs_nand_ecc_read_page()
705 static int mxs_nand_ecc_write_page(struct mtd_info *mtd, in mxs_nand_ecc_write_page() argument
715 memcpy(nand_info->data_buf, buf, mtd->writesize); in mxs_nand_ecc_write_page()
716 memcpy(nand_info->oob_buf, nand->oob_poi, mtd->oobsize); in mxs_nand_ecc_write_page()
740 d->cmd.pio_words[3] = (mtd->writesize + mtd->oobsize); in mxs_nand_ecc_write_page()
773 static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from, in mxs_nand_hook_read_oob() argument
776 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_hook_read_oob()
785 ret = nand_info->hooked_read_oob(mtd, from, ops); in mxs_nand_hook_read_oob()
798 static int mxs_nand_hook_write_oob(struct mtd_info *mtd, loff_t to, in mxs_nand_hook_write_oob() argument
801 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_hook_write_oob()
810 ret = nand_info->hooked_write_oob(mtd, to, ops); in mxs_nand_hook_write_oob()
823 static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs) in mxs_nand_hook_block_markbad() argument
825 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_hook_block_markbad()
831 ret = nand_info->hooked_block_markbad(mtd, ofs); in mxs_nand_hook_block_markbad()
882 static int mxs_nand_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_ecc_read_oob() argument
897 nand->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); in mxs_nand_ecc_read_oob()
898 nand->read_buf(mtd, nand->oob_poi, mtd->oobsize); in mxs_nand_ecc_read_oob()
904 memset(nand->oob_poi, 0xff, mtd->oobsize); in mxs_nand_ecc_read_oob()
906 nand->cmdfunc(mtd, NAND_CMD_READ0, mtd->writesize, page); in mxs_nand_ecc_read_oob()
907 mxs_nand_read_buf(mtd, nand->oob_poi, 1); in mxs_nand_ecc_read_oob()
917 static int mxs_nand_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *nand, in mxs_nand_ecc_write_oob() argument
938 nand->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); in mxs_nand_ecc_write_oob()
939 nand->write_buf(mtd, &block_mark, 1); in mxs_nand_ecc_write_oob()
940 nand->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); in mxs_nand_ecc_write_oob()
943 if (nand->waitfunc(mtd, nand) & NAND_STATUS_FAIL) in mxs_nand_ecc_write_oob()
962 static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs) in mxs_nand_block_bad() argument
967 static int mxs_nand_set_geometry(struct mtd_info *mtd, struct bch_geometry *geo) in mxs_nand_set_geometry() argument
969 struct nand_chip *chip = mtd_to_nand(mtd); in mxs_nand_set_geometry()
970 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_set_geometry()
974 return mxs_nand_calc_ecc_layout_by_info(geo, mtd, in mxs_nand_set_geometry()
978 mxs_nand_calc_ecc_layout(geo, mtd)) { in mxs_nand_set_geometry()
982 return mxs_nand_calc_ecc_layout_by_info(geo, mtd, in mxs_nand_set_geometry()
998 int mxs_nand_setup_ecc(struct mtd_info *mtd) in mxs_nand_setup_ecc() argument
1000 struct nand_chip *nand = mtd_to_nand(mtd); in mxs_nand_setup_ecc()
1007 ret = mxs_nand_set_geometry(mtd, geo); in mxs_nand_setup_ecc()
1011 mxs_nand_calc_mark_offset(geo, mtd->writesize); in mxs_nand_setup_ecc()
1025 tmp = (mtd->writesize + mtd->oobsize) in mxs_nand_setup_ecc()
1040 if (mtd->_read_oob != mxs_nand_hook_read_oob) { in mxs_nand_setup_ecc()
1041 nand_info->hooked_read_oob = mtd->_read_oob; in mxs_nand_setup_ecc()
1042 mtd->_read_oob = mxs_nand_hook_read_oob; in mxs_nand_setup_ecc()
1045 if (mtd->_write_oob != mxs_nand_hook_write_oob) { in mxs_nand_setup_ecc()
1046 nand_info->hooked_write_oob = mtd->_write_oob; in mxs_nand_setup_ecc()
1047 mtd->_write_oob = mxs_nand_hook_write_oob; in mxs_nand_setup_ecc()
1050 if (mtd->_block_markbad != mxs_nand_hook_block_markbad) { in mxs_nand_setup_ecc()
1051 nand_info->hooked_block_markbad = mtd->_block_markbad; in mxs_nand_setup_ecc()
1052 mtd->_block_markbad = mxs_nand_hook_block_markbad; in mxs_nand_setup_ecc()
1201 struct mtd_info *mtd; in mxs_nand_init_ctrl() local
1206 mtd = nand_to_mtd(nand); in mxs_nand_init_ctrl()
1239 if (nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL)) in mxs_nand_init_ctrl()
1242 if (mxs_nand_setup_ecc(mtd)) in mxs_nand_init_ctrl()
1256 err = nand_scan_tail(mtd); in mxs_nand_init_ctrl()
1260 err = nand_register(0, mtd); in mxs_nand_init_ctrl()