Lines Matching full:nand
10 #define pr_fmt(fmt) "spi-nand: " fmt
53 struct nand_device *nand = spinand_to_nand(spinand); in spinand_get_cfg() local
56 spinand->cur_target >= nand->memorg.ntargets)) in spinand_get_cfg()
65 struct nand_device *nand = spinand_to_nand(spinand); in spinand_set_cfg() local
69 spinand->cur_target >= nand->memorg.ntargets)) in spinand_set_cfg()
109 * spinand_select_target() - Select a specific NAND target/die
119 struct nand_device *nand = spinand_to_nand(spinand); in spinand_select_target() local
122 if (WARN_ON(target >= nand->memorg.ntargets)) in spinand_select_target()
128 if (nand->memorg.ntargets == 1) { in spinand_select_target()
143 struct nand_device *nand = spinand_to_nand(spinand); in spinand_read_cfg() local
147 for (target = 0; target < nand->memorg.ntargets; target++) { in spinand_read_cfg()
167 struct nand_device *nand = spinand_to_nand(spinand); in spinand_init_cfg_cache() local
171 nand->memorg.ntargets, in spinand_init_cfg_cache()
211 struct nand_device *nand = spinand_to_nand(spinand); in spinand_check_ecc_status() local
226 return nanddev_get_ecc_conf(nand)->strength; in spinand_check_ecc_status()
262 static int spinand_ondie_ecc_init_ctx(struct nand_device *nand) in spinand_ondie_ecc_init_ctx() argument
264 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_ondie_ecc_init_ctx()
265 struct mtd_info *mtd = nanddev_to_mtd(nand); in spinand_ondie_ecc_init_ctx()
268 nand->ecc.ctx.conf.engine_type = NAND_ECC_ENGINE_TYPE_ON_DIE; in spinand_ondie_ecc_init_ctx()
269 nand->ecc.ctx.conf.step_size = nand->ecc.requirements.step_size; in spinand_ondie_ecc_init_ctx()
270 nand->ecc.ctx.conf.strength = nand->ecc.requirements.strength; in spinand_ondie_ecc_init_ctx()
276 nand->ecc.ctx.priv = engine_conf; in spinand_ondie_ecc_init_ctx()
286 static void spinand_ondie_ecc_cleanup_ctx(struct nand_device *nand) in spinand_ondie_ecc_cleanup_ctx() argument
288 kfree(nand->ecc.ctx.priv); in spinand_ondie_ecc_cleanup_ctx()
291 static int spinand_ondie_ecc_prepare_io_req(struct nand_device *nand, in spinand_ondie_ecc_prepare_io_req() argument
294 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_ondie_ecc_prepare_io_req()
297 memset(spinand->oobbuf, 0xff, nanddev_per_page_oobsize(nand)); in spinand_ondie_ecc_prepare_io_req()
303 static int spinand_ondie_ecc_finish_io_req(struct nand_device *nand, in spinand_ondie_ecc_finish_io_req() argument
306 struct spinand_ondie_ecc_conf *engine_conf = nand->ecc.ctx.priv; in spinand_ondie_ecc_finish_io_req()
307 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_ondie_ecc_finish_io_req()
332 pages = req->datalen / nanddev_page_size(nand); in spinand_ondie_ecc_finish_io_req()
351 static void spinand_ondie_ecc_save_status(struct nand_device *nand, u8 status) in spinand_ondie_ecc_save_status() argument
353 struct spinand_ondie_ecc_conf *engine_conf = nand->ecc.ctx.priv; in spinand_ondie_ecc_save_status()
355 if (nand->ecc.ctx.conf.engine_type == NAND_ECC_ENGINE_TYPE_ON_DIE && in spinand_ondie_ecc_save_status()
370 struct nand_device *nand = spinand_to_nand(spinand); in spinand_load_page_op() local
371 unsigned int row = nanddev_pos_to_row(nand, &req->pos); in spinand_load_page_op()
380 struct nand_device *nand = spinand_to_nand(spinand); in spinand_read_from_cache_op() local
391 nbytes = nanddev_page_size(nand); in spinand_read_from_cache_op()
394 nanddev_page_size(nand)); in spinand_read_from_cache_op()
399 nbytes += nanddev_per_page_oobsize(nand); in spinand_read_from_cache_op()
402 column = nanddev_page_size(nand); in spinand_read_from_cache_op()
412 column |= req->pos.plane << fls(nanddev_page_size(nand)); in spinand_read_from_cache_op()
455 struct nand_device *nand = spinand_to_nand(spinand); in spinand_write_to_cache_op() local
472 nbytes = nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); in spinand_write_to_cache_op()
473 memset(spinand->databuf, 0xff, nanddev_page_size(nand)); in spinand_write_to_cache_op()
496 column |= req->pos.plane << fls(nanddev_page_size(nand)); in spinand_write_to_cache_op()
517 struct nand_device *nand = spinand_to_nand(spinand); in spinand_program_op() local
518 unsigned int row = nanddev_pos_to_row(nand, &req->pos); in spinand_program_op()
527 struct nand_device *nand = spinand_to_nand(spinand); in spinand_erase_op() local
528 unsigned int row = nanddev_pos_to_row(nand, pos); in spinand_erase_op()
607 struct nand_device *nand = spinand_to_nand(spinand); in spinand_read_page() local
611 ret = nand_ecc_prepare_io_req(nand, (struct nand_page_io_req *)req); in spinand_read_page()
626 spinand_ondie_ecc_save_status(nand, status); in spinand_read_page()
632 return nand_ecc_finish_io_req(nand, (struct nand_page_io_req *)req); in spinand_read_page()
638 struct nand_device *nand = spinand_to_nand(spinand); in spinand_write_page() local
642 ret = nand_ecc_prepare_io_req(nand, (struct nand_page_io_req *)req); in spinand_write_page()
665 return nand_ecc_finish_io_req(nand, (struct nand_page_io_req *)req); in spinand_write_page()
673 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_regular_page_read() local
682 nanddev_io_for_each_page(nand, NAND_PAGE_READ, from, ops, &iter) { in spinand_mtd_regular_page_read()
715 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_continuous_page_read() local
732 nanddev_io_for_each_block(nand, NAND_PAGE_READ, from, ops, &iter) { in spinand_mtd_continuous_page_read()
737 ret = nand_ecc_prepare_io_req(nand, &iter.req); in spinand_mtd_continuous_page_read()
760 spinand_ondie_ecc_save_status(nand, status); in spinand_mtd_continuous_page_read()
762 ret = nand_ecc_finish_io_req(nand, &iter.req); in spinand_mtd_continuous_page_read()
785 struct nand_device *nand = spinand_to_nand(spinand); in spinand_cont_read_init() local
786 enum nand_ecc_engine_type engine_type = nand->ecc.ctx.conf.engine_type; in spinand_cont_read_init()
799 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_use_cont_read() local
800 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_use_cont_read()
810 nanddev_offs_to_pos(nand, from, &start_pos); in spinand_use_cont_read()
811 nanddev_offs_to_pos(nand, from + ops->len - 1, &end_pos); in spinand_use_cont_read()
862 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_write() local
872 nanddev_io_for_each_page(nand, NAND_PAGE_WRITE, to, ops, &iter) { in spinand_mtd_write()
893 static bool spinand_isbad(struct nand_device *nand, const struct nand_pos *pos) in spinand_isbad() argument
895 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_isbad()
915 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_block_isbad() local
916 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_mtd_block_isbad()
920 nanddev_offs_to_pos(nand, offs, &pos); in spinand_mtd_block_isbad()
922 ret = nanddev_isbad(nand, &pos); in spinand_mtd_block_isbad()
928 static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos) in spinand_markbad() argument
930 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_markbad()
954 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_block_markbad() local
955 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_mtd_block_markbad()
959 nanddev_offs_to_pos(nand, offs, &pos); in spinand_mtd_block_markbad()
961 ret = nanddev_markbad(nand, &pos); in spinand_mtd_block_markbad()
967 static int spinand_erase(struct nand_device *nand, const struct nand_pos *pos) in spinand_erase() argument
969 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_erase()
1012 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_block_isreserved() local
1016 nanddev_offs_to_pos(nand, offs, &pos); in spinand_mtd_block_isreserved()
1018 ret = nanddev_isreserved(nand, &pos); in spinand_mtd_block_isreserved()
1027 struct nand_device *nand = spinand_to_nand(spinand); in spinand_create_dirmap() local
1029 .length = nanddev_page_size(nand) + in spinand_create_dirmap()
1030 nanddev_per_page_oobsize(nand), in spinand_create_dirmap()
1035 info.length = nanddev_eraseblock_size(nand); in spinand_create_dirmap()
1038 info.offset = plane << fls(nand->memorg.pagesize); in spinand_create_dirmap()
1056 if (nand->ecc.engine->integration != NAND_ECC_ENGINE_INTEGRATION_PIPELINED) { in spinand_create_dirmap()
1086 struct nand_device *nand = spinand_to_nand(spinand); in spinand_create_dirmaps() local
1091 nand->memorg.planes_per_lun, in spinand_create_dirmaps()
1096 for (i = 0; i < nand->memorg.planes_per_lun; i++) { in spinand_create_dirmaps()
1200 struct nand_device *nand = spinand_to_nand(spinand); in spinand_select_op_variant() local
1208 nbytes = nanddev_per_page_oobsize(nand) + in spinand_select_op_variant()
1209 nanddev_page_size(nand); in spinand_select_op_variant()
1233 * @spinand: SPI NAND object
1234 * @table: SPI NAND device description table
1239 * entry in the SPI NAND description table. If a match is found, the spinand
1251 struct nand_device *nand = spinand_to_nand(spinand); in spinand_match_and_init() local
1264 nand->memorg = table[i].memorg; in spinand_match_and_init()
1265 nanddev_set_ecc_requirements(nand, &table[i].eccreq); in spinand_match_and_init()
1299 struct nand_device *nand = spinand_to_nand(spinand); in spinand_detect() local
1313 if (nand->memorg.ntargets > 1 && !spinand->select_target) { in spinand_detect()
1320 "%s SPI NAND was found.\n", spinand->manufacturer->name); in spinand_detect()
1323 nanddev_size(nand) >> 20, nanddev_eraseblock_size(nand) >> 10, in spinand_detect()
1324 nanddev_page_size(nand), nanddev_per_page_oobsize(nand)); in spinand_detect()
1332 struct nand_device *nand = spinand_to_nand(spinand); in spinand_init_flash() local
1350 "Failed to initialize the SPI NAND chip (err = %d)\n", in spinand_init_flash()
1356 for (i = 0; i < nand->memorg.ntargets; i++) { in spinand_init_flash()
1392 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_init() local
1412 spinand->databuf = kzalloc(nanddev_eraseblock_size(nand), in spinand_init()
1419 spinand->oobbuf = spinand->databuf + nanddev_page_size(nand); in spinand_init()
1429 ret = nanddev_init(nand, &spinand_ops, THIS_MODULE); in spinand_init()
1433 /* SPI-NAND default ECC engine is on-die */ in spinand_init()
1434 nand->ecc.defaults.engine_type = NAND_ECC_ENGINE_TYPE_ON_DIE; in spinand_init()
1435 nand->ecc.ondie_engine = &spinand_ondie_ecc_engine; in spinand_init()
1438 ret = nanddev_ecc_engine_init(nand); in spinand_init()
1457 if (nand->ecc.engine) { in spinand_init()
1466 mtd->ecc_strength = nanddev_get_ecc_conf(nand)->strength; in spinand_init()
1467 mtd->ecc_step_size = nanddev_get_ecc_conf(nand)->step_size; in spinand_init()
1481 nanddev_ecc_engine_cleanup(nand); in spinand_init()
1484 nanddev_cleanup(nand); in spinand_init()
1497 struct nand_device *nand = spinand_to_nand(spinand); in spinand_cleanup() local
1499 nanddev_cleanup(nand); in spinand_cleanup()
1558 { .name = "spi-nand" },
1565 { .compatible = "spi-nand" },
1575 .name = "spi-nand",
1584 MODULE_DESCRIPTION("SPI NAND framework");