Lines Matching full:ecc
3 * Generic Error-Correcting Code (ECC) engine
10 * This file describes the abstraction of any NAND ECC engine. It has been
13 * There are three main situations where instantiating this ECC engine makes
15 * - external: The ECC engine is outside the NAND pipeline, typically this
16 * is a software ECC engine, or an hardware engine that is
18 * - pipelined: The ECC engine is inside the NAND pipeline, ie. on the
20 * controllers. In the pipeline case, the ECC bytes are
23 * - ondie: The ECC engine is inside the NAND pipeline, on the chip's side.
28 * - prepare: Prepare an I/O request. Enable/disable the ECC engine based on
30 * engine, this step may involve to derive the ECC bytes and place
41 * - ecc: Correction enabled
51 * [external ECC engine]
56 * - external + prepare + ecc + read: do nothing
57 * - external + finish + ecc + read: calculate expected ECC bytes, extract
58 * ECC bytes from OOB buffer, correct
60 * - external + prepare + ecc + write: calculate ECC bytes and store them at
63 * - external + finish + ecc + write: do nothing
65 * [pipelined ECC engine]
66 * - pipelined + prepare + raw + read: disable the controller's ECC engine if
69 * - pipelined + prepare + raw + write: disable the controller's ECC engine if
72 * - pipelined + prepare + ecc + read: enable the controller's ECC engine if
74 * - pipelined + finish + ecc + read: check the status, report any
76 * - pipelined + prepare + ecc + write: enable the controller's ECC engine if
78 * - pipelined + finish + ecc + write: do nothing
80 * [ondie ECC engine]
81 * - ondie + prepare + raw + read: send commands to disable the on-chip ECC
84 * - ondie + prepare + raw + write: send commands to disable the on-chip ECC
87 * - ondie + prepare + ecc + read: send commands to enable the on-chip ECC
89 * - ondie + finish + ecc + read: send commands to check the status, report
91 * - ondie + prepare + ecc + write: send commands to enable the on-chip ECC
93 * - ondie + finish + ecc + write: do nothing
107 * nand_ecc_init_ctx - Init the ECC engine context
114 if (!nand->ecc.engine || !nand->ecc.engine->ops->init_ctx) in nand_ecc_init_ctx()
117 return nand->ecc.engine->ops->init_ctx(nand); in nand_ecc_init_ctx()
122 * nand_ecc_cleanup_ctx - Cleanup the ECC engine context
127 if (nand->ecc.engine && nand->ecc.engine->ops->cleanup_ctx) in nand_ecc_cleanup_ctx()
128 nand->ecc.engine->ops->cleanup_ctx(nand); in nand_ecc_cleanup_ctx()
140 if (!nand->ecc.engine || !nand->ecc.engine->ops->prepare_io_req) in nand_ecc_prepare_io_req()
143 return nand->ecc.engine->ops->prepare_io_req(nand, req); in nand_ecc_prepare_io_req()
155 if (!nand->ecc.engine || !nand->ecc.engine->ops->finish_io_req) in nand_ecc_finish_io_req()
158 return nand->ecc.engine->ops->finish_io_req(nand, req); in nand_ecc_finish_io_req()
167 unsigned int total_ecc_bytes = nand->ecc.ctx.total; in nand_ooblayout_ecc_sp()
213 .ecc = nand_ooblayout_ecc_sp,
227 unsigned int total_ecc_bytes = nand->ecc.ctx.total; in nand_ooblayout_ecc_lp()
242 unsigned int total_ecc_bytes = nand->ecc.ctx.total; in nand_ooblayout_free_lp()
254 .ecc = nand_ooblayout_ecc_lp,
265 * Support the old "large page" layout used for 1-bit Hamming ECC where ECC
272 unsigned int total_ecc_bytes = nand->ecc.ctx.total; in nand_ooblayout_ecc_lp_hamming()
299 unsigned int total_ecc_bytes = nand->ecc.ctx.total; in nand_ooblayout_free_lp_hamming()
328 .ecc = nand_ooblayout_ecc_lp_hamming,
343 if (of_property_read_bool(np, "nand-no-ecc-engine")) in of_get_nand_ecc_engine_type()
346 if (of_property_read_bool(np, "nand-use-soft-ecc-engine")) in of_get_nand_ecc_engine_type()
349 eng_np = of_parse_phandle(np, "nand-ecc-engine", 0); in of_get_nand_ecc_engine_type()
373 err = of_property_read_string(np, "nand-ecc-placement", &pm); in of_get_nand_ecc_placement()
397 err = of_property_read_string(np, "nand-ecc-algo", &pm); in of_get_nand_ecc_algo()
415 ret = of_property_read_u32(np, "nand-ecc-step-size", &val); in of_get_nand_ecc_step_size()
424 ret = of_property_read_u32(np, "nand-ecc-strength", &val); in of_get_nand_ecc_strength()
433 nand->ecc.user_conf.engine_type = of_get_nand_ecc_engine_type(dn); in of_get_nand_ecc_user_config()
434 nand->ecc.user_conf.algo = of_get_nand_ecc_algo(dn); in of_get_nand_ecc_user_config()
435 nand->ecc.user_conf.placement = of_get_nand_ecc_placement(dn); in of_get_nand_ecc_user_config()
439 nand->ecc.user_conf.strength = strength; in of_get_nand_ecc_user_config()
443 nand->ecc.user_conf.step_size = size; in of_get_nand_ecc_user_config()
445 if (of_property_read_bool(dn, "nand-ecc-maximize")) in of_get_nand_ecc_user_config()
446 nand->ecc.user_conf.flags |= NAND_ECC_MAXIMIZE_STRENGTH; in of_get_nand_ecc_user_config()
489 /* ECC engine driver internal helpers */
596 unsigned int algo = nand->ecc.user_conf.algo; in nand_ecc_get_sw_engine()
599 algo = nand->ecc.defaults.algo; in nand_ecc_get_sw_engine()
616 return nand->ecc.ondie_engine; in nand_ecc_get_on_die_hw_engine()
674 /* Check for an explicit nand-ecc-engine property */ in nand_ecc_get_on_host_hw_engine()
675 np = of_parse_phandle(dev->of_node, "nand-ecc-engine", 0); in nand_ecc_get_on_host_hw_engine()
698 put_device(nand->ecc.engine->dev); in nand_ecc_put_on_host_hw_engine()
703 * In the case of a pipelined engine, the device registering the ECC
704 * engine is not necessarily the ECC engine itself but may be a host controller.
706 * which actually represents the ECC engine.
715 * it in order to get the right ECC engine device we are looking for. in nand_ecc_get_engine_dev()
717 np = of_parse_phandle(host->of_node, "nand-ecc-engine", 0); in nand_ecc_get_engine_dev()
735 MODULE_DESCRIPTION("Generic ECC engine");