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()
205 struct nand_device *nand = spinand_to_nand(spinand); in spinand_check_ecc_status() local
220 return nanddev_get_ecc_conf(nand)->strength; in spinand_check_ecc_status()
256 static int spinand_ondie_ecc_init_ctx(struct nand_device *nand) in spinand_ondie_ecc_init_ctx() argument
258 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_ondie_ecc_init_ctx()
259 struct mtd_info *mtd = nanddev_to_mtd(nand); in spinand_ondie_ecc_init_ctx()
262 nand->ecc.ctx.conf.engine_type = NAND_ECC_ENGINE_TYPE_ON_DIE; in spinand_ondie_ecc_init_ctx()
263 nand->ecc.ctx.conf.step_size = nand->ecc.requirements.step_size; in spinand_ondie_ecc_init_ctx()
264 nand->ecc.ctx.conf.strength = nand->ecc.requirements.strength; in spinand_ondie_ecc_init_ctx()
270 nand->ecc.ctx.priv = engine_conf; in spinand_ondie_ecc_init_ctx()
280 static void spinand_ondie_ecc_cleanup_ctx(struct nand_device *nand) in spinand_ondie_ecc_cleanup_ctx() argument
282 kfree(nand->ecc.ctx.priv); in spinand_ondie_ecc_cleanup_ctx()
285 static int spinand_ondie_ecc_prepare_io_req(struct nand_device *nand, in spinand_ondie_ecc_prepare_io_req() argument
288 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_ondie_ecc_prepare_io_req()
291 memset(spinand->oobbuf, 0xff, nanddev_per_page_oobsize(nand)); in spinand_ondie_ecc_prepare_io_req()
297 static int spinand_ondie_ecc_finish_io_req(struct nand_device *nand, in spinand_ondie_ecc_finish_io_req() argument
300 struct spinand_ondie_ecc_conf *engine_conf = nand->ecc.ctx.priv; in spinand_ondie_ecc_finish_io_req()
301 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_ondie_ecc_finish_io_req()
333 static void spinand_ondie_ecc_save_status(struct nand_device *nand, u8 status) in spinand_ondie_ecc_save_status() argument
335 struct spinand_ondie_ecc_conf *engine_conf = nand->ecc.ctx.priv; in spinand_ondie_ecc_save_status()
337 if (nand->ecc.ctx.conf.engine_type == NAND_ECC_ENGINE_TYPE_ON_DIE && in spinand_ondie_ecc_save_status()
352 struct nand_device *nand = spinand_to_nand(spinand); in spinand_load_page_op() local
353 unsigned int row = nanddev_pos_to_row(nand, &req->pos); in spinand_load_page_op()
362 struct nand_device *nand = spinand_to_nand(spinand); in spinand_read_from_cache_op() local
372 nbytes = nanddev_page_size(nand); in spinand_read_from_cache_op()
377 nbytes += nanddev_per_page_oobsize(nand); in spinand_read_from_cache_op()
380 column = nanddev_page_size(nand); in spinand_read_from_cache_op()
420 struct nand_device *nand = spinand_to_nand(spinand); in spinand_write_to_cache_op() local
437 nbytes = nanddev_page_size(nand) + nanddev_per_page_oobsize(nand); in spinand_write_to_cache_op()
438 memset(spinand->databuf, 0xff, nanddev_page_size(nand)); in spinand_write_to_cache_op()
476 struct nand_device *nand = spinand_to_nand(spinand); in spinand_program_op() local
477 unsigned int row = nanddev_pos_to_row(nand, &req->pos); in spinand_program_op()
486 struct nand_device *nand = spinand_to_nand(spinand); in spinand_erase_op() local
487 unsigned int row = nanddev_pos_to_row(nand, pos); in spinand_erase_op()
566 struct nand_device *nand = spinand_to_nand(spinand); in spinand_read_page() local
570 ret = nand_ecc_prepare_io_req(nand, (struct nand_page_io_req *)req); in spinand_read_page()
585 spinand_ondie_ecc_save_status(nand, status); in spinand_read_page()
591 return nand_ecc_finish_io_req(nand, (struct nand_page_io_req *)req); in spinand_read_page()
597 struct nand_device *nand = spinand_to_nand(spinand); in spinand_write_page() local
601 ret = nand_ecc_prepare_io_req(nand, (struct nand_page_io_req *)req); in spinand_write_page()
624 return nand_ecc_finish_io_req(nand, (struct nand_page_io_req *)req); in spinand_write_page()
631 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_read() local
643 nanddev_io_for_each_page(nand, NAND_PAGE_READ, from, ops, &iter) { in spinand_mtd_read()
677 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_write() local
687 nanddev_io_for_each_page(nand, NAND_PAGE_WRITE, to, ops, &iter) { in spinand_mtd_write()
708 static bool spinand_isbad(struct nand_device *nand, const struct nand_pos *pos) in spinand_isbad() argument
710 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_isbad()
730 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_block_isbad() local
731 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_mtd_block_isbad()
735 nanddev_offs_to_pos(nand, offs, &pos); in spinand_mtd_block_isbad()
737 ret = nanddev_isbad(nand, &pos); in spinand_mtd_block_isbad()
743 static int spinand_markbad(struct nand_device *nand, const struct nand_pos *pos) in spinand_markbad() argument
745 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_markbad()
769 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_block_markbad() local
770 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_mtd_block_markbad()
774 nanddev_offs_to_pos(nand, offs, &pos); in spinand_mtd_block_markbad()
776 ret = nanddev_markbad(nand, &pos); in spinand_mtd_block_markbad()
782 static int spinand_erase(struct nand_device *nand, const struct nand_pos *pos) in spinand_erase() argument
784 struct spinand_device *spinand = nand_to_spinand(nand); in spinand_erase()
827 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_mtd_block_isreserved() local
831 nanddev_offs_to_pos(nand, offs, &pos); in spinand_mtd_block_isreserved()
833 ret = nanddev_isreserved(nand, &pos); in spinand_mtd_block_isreserved()
842 struct nand_device *nand = spinand_to_nand(spinand); in spinand_create_dirmap() local
844 .length = nanddev_page_size(nand) + in spinand_create_dirmap()
845 nanddev_per_page_oobsize(nand), in spinand_create_dirmap()
850 info.offset = plane << fls(nand->memorg.pagesize); in spinand_create_dirmap()
873 struct nand_device *nand = spinand_to_nand(spinand); in spinand_create_dirmaps() local
878 nand->memorg.planes_per_lun, in spinand_create_dirmaps()
883 for (i = 0; i < nand->memorg.planes_per_lun; i++) { in spinand_create_dirmaps()
982 struct nand_device *nand = spinand_to_nand(spinand); in spinand_select_op_variant() local
990 nbytes = nanddev_per_page_oobsize(nand) + in spinand_select_op_variant()
991 nanddev_page_size(nand); in spinand_select_op_variant()
1015 * @spinand: SPI NAND object
1016 * @table: SPI NAND device description table
1021 * entry in the SPI NAND description table. If a match is found, the spinand
1033 struct nand_device *nand = spinand_to_nand(spinand); in spinand_match_and_init() local
1046 nand->memorg = table[i].memorg; in spinand_match_and_init()
1047 nanddev_set_ecc_requirements(nand, &table[i].eccreq); in spinand_match_and_init()
1080 struct nand_device *nand = spinand_to_nand(spinand); in spinand_detect() local
1094 if (nand->memorg.ntargets > 1 && !spinand->select_target) { in spinand_detect()
1101 "%s SPI NAND was found.\n", spinand->manufacturer->name); in spinand_detect()
1104 nanddev_size(nand) >> 20, nanddev_eraseblock_size(nand) >> 10, in spinand_detect()
1105 nanddev_page_size(nand), nanddev_per_page_oobsize(nand)); in spinand_detect()
1113 struct nand_device *nand = spinand_to_nand(spinand); in spinand_init_flash() local
1131 "Failed to initialize the SPI NAND chip (err = %d)\n", in spinand_init_flash()
1137 for (i = 0; i < nand->memorg.ntargets; i++) { in spinand_init_flash()
1173 struct nand_device *nand = mtd_to_nanddev(mtd); in spinand_init() local
1193 spinand->databuf = kzalloc(nanddev_page_size(nand) + in spinand_init()
1194 nanddev_per_page_oobsize(nand), in spinand_init()
1201 spinand->oobbuf = spinand->databuf + nanddev_page_size(nand); in spinand_init()
1219 ret = nanddev_init(nand, &spinand_ops, THIS_MODULE); in spinand_init()
1223 /* SPI-NAND default ECC engine is on-die */ in spinand_init()
1224 nand->ecc.defaults.engine_type = NAND_ECC_ENGINE_TYPE_ON_DIE; in spinand_init()
1225 nand->ecc.ondie_engine = &spinand_ondie_ecc_engine; in spinand_init()
1228 ret = nanddev_ecc_engine_init(nand); in spinand_init()
1241 if (nand->ecc.engine) { in spinand_init()
1250 mtd->ecc_strength = nanddev_get_ecc_conf(nand)->strength; in spinand_init()
1251 mtd->ecc_step_size = nanddev_get_ecc_conf(nand)->step_size; in spinand_init()
1256 nanddev_ecc_engine_cleanup(nand); in spinand_init()
1259 nanddev_cleanup(nand); in spinand_init()
1272 struct nand_device *nand = spinand_to_nand(spinand); in spinand_cleanup() local
1274 nanddev_cleanup(nand); in spinand_cleanup()
1333 { .name = "spi-nand" },
1340 { .compatible = "spi-nand" },
1350 .name = "spi-nand",
1359 MODULE_DESCRIPTION("SPI NAND framework");