Lines Matching refs:ecc
1716 void *ecc, int ecclen, in nand_check_erased_ecc_chunk() argument
1729 ecc_bitflips = nand_check_erased_buf(ecc, ecclen, bitflips_threshold); in nand_check_erased_ecc_chunk()
1744 memset(ecc, 0xff, ecclen); in nand_check_erased_ecc_chunk()
1796 int eccsize = chip->ecc.size; in nand_read_page_raw_syndrome()
1797 int eccbytes = chip->ecc.bytes; in nand_read_page_raw_syndrome()
1801 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_read_page_raw_syndrome()
1808 if (chip->ecc.prepad) { in nand_read_page_raw_syndrome()
1809 ret = nand_read_data_op(chip, oob, chip->ecc.prepad, in nand_read_page_raw_syndrome()
1814 oob += chip->ecc.prepad; in nand_read_page_raw_syndrome()
1823 if (chip->ecc.postpad) { in nand_read_page_raw_syndrome()
1824 ret = nand_read_data_op(chip, oob, chip->ecc.postpad, in nand_read_page_raw_syndrome()
1829 oob += chip->ecc.postpad; in nand_read_page_raw_syndrome()
1854 int i, eccsize = chip->ecc.size; in nand_read_page_swecc()
1855 int eccbytes = chip->ecc.bytes; in nand_read_page_swecc()
1856 int eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1860 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_swecc()
1863 chip->ecc.read_page_raw(mtd, chip, buf, 1, page); in nand_read_page_swecc()
1866 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_swecc()
1868 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_swecc()
1871 eccsteps = chip->ecc.steps; in nand_read_page_swecc()
1877 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_swecc()
1902 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_subpage()
1912 start_step = data_offs / chip->ecc.size; in nand_read_subpage()
1913 end_step = (data_offs + readlen - 1) / chip->ecc.size; in nand_read_subpage()
1915 index = start_step * chip->ecc.bytes; in nand_read_subpage()
1918 datafrag_len = num_steps * chip->ecc.size; in nand_read_subpage()
1919 eccfrag_len = num_steps * chip->ecc.bytes; in nand_read_subpage()
1921 data_col_addr = start_step * chip->ecc.size; in nand_read_subpage()
1932 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) in nand_read_subpage()
1933 chip->ecc.calculate(mtd, p, &chip->buffers->ecccalc[i]); in nand_read_subpage()
1960 if (eccpos[index + (num_steps * chip->ecc.bytes)] & (busw - 1)) in nand_read_subpage()
1975 for (i = 0; i < eccfrag_len ; i += chip->ecc.bytes, p += chip->ecc.size) { in nand_read_subpage()
1978 stat = chip->ecc.correct(mtd, p, in nand_read_subpage()
1981 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_subpage()
1983 stat = nand_check_erased_ecc_chunk(p, chip->ecc.size, in nand_read_subpage()
1985 chip->ecc.bytes, in nand_read_subpage()
1987 chip->ecc.strength); in nand_read_subpage()
2013 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc()
2014 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc()
2015 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
2019 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc()
2024 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc()
2030 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc()
2037 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc()
2040 eccsteps = chip->ecc.steps; in nand_read_page_hwecc()
2046 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); in nand_read_page_hwecc()
2048 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_page_hwecc()
2053 chip->ecc.strength); in nand_read_page_hwecc()
2083 int i, eccsize = chip->ecc.size; in nand_read_page_hwecc_oob_first()
2084 int eccbytes = chip->ecc.bytes; in nand_read_page_hwecc_oob_first()
2085 int eccsteps = chip->ecc.steps; in nand_read_page_hwecc_oob_first()
2088 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_read_page_hwecc_oob_first()
2102 for (i = 0; i < chip->ecc.total; i++) in nand_read_page_hwecc_oob_first()
2108 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_hwecc_oob_first()
2114 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_read_page_hwecc_oob_first()
2116 stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL); in nand_read_page_hwecc_oob_first()
2118 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_page_hwecc_oob_first()
2123 chip->ecc.strength); in nand_read_page_hwecc_oob_first()
2150 int ret, i, eccsize = chip->ecc.size; in nand_read_page_syndrome()
2151 int eccbytes = chip->ecc.bytes; in nand_read_page_syndrome()
2152 int eccsteps = chip->ecc.steps; in nand_read_page_syndrome()
2153 int eccpadbytes = eccbytes + chip->ecc.prepad + chip->ecc.postpad; in nand_read_page_syndrome()
2161 chip->ecc.hwctl(mtd, NAND_ECC_READ); in nand_read_page_syndrome()
2167 if (chip->ecc.prepad) { in nand_read_page_syndrome()
2168 ret = nand_read_data_op(chip, oob, chip->ecc.prepad, in nand_read_page_syndrome()
2173 oob += chip->ecc.prepad; in nand_read_page_syndrome()
2176 chip->ecc.hwctl(mtd, NAND_ECC_READSYN); in nand_read_page_syndrome()
2182 stat = chip->ecc.correct(mtd, p, oob, NULL); in nand_read_page_syndrome()
2186 if (chip->ecc.postpad) { in nand_read_page_syndrome()
2187 ret = nand_read_data_op(chip, oob, chip->ecc.postpad, in nand_read_page_syndrome()
2192 oob += chip->ecc.postpad; in nand_read_page_syndrome()
2196 (chip->ecc.options & NAND_ECC_GENERIC_ERASED_CHECK)) { in nand_read_page_syndrome()
2198 stat = nand_check_erased_ecc_chunk(p, chip->ecc.size, in nand_read_page_syndrome()
2202 chip->ecc.strength); in nand_read_page_syndrome()
2242 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_transfer_oob()
2356 if (nand_standard_page_accessors(&chip->ecc)) { in nand_do_read_ops()
2367 ret = chip->ecc.read_page_raw(mtd, chip, bufpoi, in nand_do_read_ops()
2372 ret = chip->ecc.read_subpage(mtd, chip, in nand_do_read_ops()
2376 ret = chip->ecc.read_page(mtd, chip, bufpoi, in nand_do_read_ops()
2508 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_read_oob_syndrome()
2509 int eccsize = chip->ecc.size; in nand_read_oob_syndrome()
2513 ret = nand_read_page_op(chip, page, chip->ecc.size, NULL, 0); in nand_read_oob_syndrome()
2517 for (i = 0; i < chip->ecc.steps; i++) { in nand_read_oob_syndrome()
2575 int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad; in nand_write_oob_syndrome()
2576 int eccsize = chip->ecc.size, length = mtd->oobsize; in nand_write_oob_syndrome()
2577 int ret, i, len, pos, sndcmd = 0, steps = chip->ecc.steps; in nand_write_oob_syndrome()
2585 if (!chip->ecc.prepad && !chip->ecc.postpad) { in nand_write_oob_syndrome()
2691 ret = chip->ecc.read_oob_raw(mtd, chip, page); in nand_do_read_oob()
2693 ret = chip->ecc.read_oob(mtd, chip, page); in nand_do_read_oob()
2826 int eccsize = chip->ecc.size; in nand_write_page_raw_syndrome()
2827 int eccbytes = chip->ecc.bytes; in nand_write_page_raw_syndrome()
2831 for (steps = chip->ecc.steps; steps > 0; steps--) { in nand_write_page_raw_syndrome()
2838 if (chip->ecc.prepad) { in nand_write_page_raw_syndrome()
2839 ret = nand_write_data_op(chip, oob, chip->ecc.prepad, in nand_write_page_raw_syndrome()
2844 oob += chip->ecc.prepad; in nand_write_page_raw_syndrome()
2853 if (chip->ecc.postpad) { in nand_write_page_raw_syndrome()
2854 ret = nand_write_data_op(chip, oob, chip->ecc.postpad, in nand_write_page_raw_syndrome()
2859 oob += chip->ecc.postpad; in nand_write_page_raw_syndrome()
2884 int i, eccsize = chip->ecc.size; in nand_write_page_swecc()
2885 int eccbytes = chip->ecc.bytes; in nand_write_page_swecc()
2886 int eccsteps = chip->ecc.steps; in nand_write_page_swecc()
2889 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_swecc()
2893 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_swecc()
2895 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_swecc()
2898 return chip->ecc.write_page_raw(mtd, chip, buf, 1, page); in nand_write_page_swecc()
2913 int i, eccsize = chip->ecc.size; in nand_write_page_hwecc()
2914 int eccbytes = chip->ecc.bytes; in nand_write_page_hwecc()
2915 int eccsteps = chip->ecc.steps; in nand_write_page_hwecc()
2918 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_page_hwecc()
2922 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_hwecc()
2928 chip->ecc.calculate(mtd, p, &ecc_calc[i]); in nand_write_page_hwecc()
2931 for (i = 0; i < chip->ecc.total; i++) in nand_write_page_hwecc()
2959 int ecc_size = chip->ecc.size; in nand_write_subpage_hwecc()
2960 int ecc_bytes = chip->ecc.bytes; in nand_write_subpage_hwecc()
2961 int ecc_steps = chip->ecc.steps; in nand_write_subpage_hwecc()
2962 uint32_t *eccpos = chip->ecc.layout->eccpos; in nand_write_subpage_hwecc()
2971 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_subpage_hwecc()
2982 chip->ecc.calculate(mtd, buf, ecc_calc); in nand_write_subpage_hwecc()
2997 for (i = 0; i < chip->ecc.total; i++) in nand_write_subpage_hwecc()
3025 int i, eccsize = chip->ecc.size; in nand_write_page_syndrome()
3026 int eccbytes = chip->ecc.bytes; in nand_write_page_syndrome()
3027 int eccsteps = chip->ecc.steps; in nand_write_page_syndrome()
3033 chip->ecc.hwctl(mtd, NAND_ECC_WRITE); in nand_write_page_syndrome()
3039 if (chip->ecc.prepad) { in nand_write_page_syndrome()
3040 ret = nand_write_data_op(chip, oob, chip->ecc.prepad, in nand_write_page_syndrome()
3045 oob += chip->ecc.prepad; in nand_write_page_syndrome()
3048 chip->ecc.calculate(mtd, p, oob); in nand_write_page_syndrome()
3056 if (chip->ecc.postpad) { in nand_write_page_syndrome()
3057 ret = nand_write_data_op(chip, oob, chip->ecc.postpad, in nand_write_page_syndrome()
3062 oob += chip->ecc.postpad; in nand_write_page_syndrome()
3095 chip->ecc.write_subpage) in nand_write_page()
3100 if (nand_standard_page_accessors(&chip->ecc)) { in nand_write_page()
3107 status = chip->ecc.write_page_raw(mtd, chip, buf, in nand_write_page()
3110 status = chip->ecc.write_subpage(mtd, chip, offset, data_len, in nand_write_page()
3113 status = chip->ecc.write_page(mtd, chip, buf, oob_required, in nand_write_page()
3119 if (nand_standard_page_accessors(&chip->ecc)) in nand_write_page()
3151 struct nand_oobfree *free = chip->ecc.layout->oobfree; in nand_fill_oob()
3414 status = chip->ecc.write_oob_raw(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
3416 status = chip->ecc.write_oob(mtd, chip, page & chip->pagemask); in nand_do_write_oob()
3797 struct onfi_ext_ecc_info *ecc; in nand_flash_detect_ext_param_page() local
3850 ecc = (struct onfi_ext_ecc_info *)cursor; in nand_flash_detect_ext_param_page()
3852 if (!ecc->codeword_size) { in nand_flash_detect_ext_param_page()
3857 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_ext_param_page()
3858 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_ext_param_page()
4012 struct jedec_ecc_info *ecc; in nand_flash_detect_jedec() local
4076 ecc = &p->ecc_info[0]; in nand_flash_detect_jedec()
4078 if (ecc->codeword_size >= 9) { in nand_flash_detect_jedec()
4079 chip->ecc_strength_ds = ecc->ecc_bits; in nand_flash_detect_jedec()
4080 chip->ecc_step_ds = 1 << ecc->codeword_size; in nand_flash_detect_jedec()
4614 chip->ecc.mode = ecc_mode; in nand_dt_init()
4617 chip->ecc.strength = ecc_strength; in nand_dt_init()
4620 chip->ecc.size = ecc_step; in nand_dt_init()
4623 chip->ecc.options |= NAND_ECC_MAXIMIZE; in nand_dt_init()
4738 int preset_step = chip->ecc.size; in nand_check_ecc_caps()
4739 int preset_strength = chip->ecc.strength; in nand_check_ecc_caps()
4772 chip->ecc.bytes = ecc_bytes; in nand_check_ecc_caps()
4862 chip->ecc.size = best_step; in nand_match_ecc_req()
4863 chip->ecc.strength = best_strength; in nand_match_ecc_req()
4864 chip->ecc.bytes = best_ecc_bytes; in nand_match_ecc_req()
4898 if (chip->ecc.size && step_size != chip->ecc.size) in nand_maximize_ecc()
4935 chip->ecc.size = best_step; in nand_maximize_ecc()
4936 chip->ecc.strength = best_strength; in nand_maximize_ecc()
4937 chip->ecc.bytes = best_ecc_bytes; in nand_maximize_ecc()
4960 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_ecc_strength_good() local
4963 if (ecc->size == 0 || chip->ecc_step_ds == 0) in nand_ecc_strength_good()
4971 corr = (mtd->writesize * ecc->strength) / ecc->size; in nand_ecc_strength_good()
4974 return corr >= ds_corr && ecc->strength >= chip->ecc_strength_ds; in nand_ecc_strength_good()
4979 struct nand_ecc_ctrl *ecc = &chip->ecc; in invalid_ecc_page_accessors() local
4981 if (nand_standard_page_accessors(ecc)) in invalid_ecc_page_accessors()
4990 return (!ecc->read_page || !ecc->write_page || in invalid_ecc_page_accessors()
4991 !ecc->read_page_raw || !ecc->write_page_raw || in invalid_ecc_page_accessors()
4992 (NAND_HAS_SUBPAGE_READ(chip) && !ecc->read_subpage) || in invalid_ecc_page_accessors()
4993 (NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage && in invalid_ecc_page_accessors()
4994 ecc->hwctl && ecc->calculate)); in invalid_ecc_page_accessors()
5009 struct nand_ecc_ctrl *ecc = &chip->ecc; in nand_scan_tail() local
5035 if (!ecc->layout && (ecc->mode != NAND_ECC_SOFT_BCH)) { in nand_scan_tail()
5039 ecc->layout = &nand_oob_8; in nand_scan_tail()
5042 ecc->layout = &nand_oob_16; in nand_scan_tail()
5045 ecc->layout = &nand_oob_64; in nand_scan_tail()
5048 ecc->layout = &nand_oob_128; in nand_scan_tail()
5066 switch (ecc->mode) { in nand_scan_tail()
5069 if (!ecc->calculate || !ecc->correct || !ecc->hwctl) { in nand_scan_tail()
5073 if (!ecc->read_page) in nand_scan_tail()
5074 ecc->read_page = nand_read_page_hwecc_oob_first; in nand_scan_tail()
5078 if (!ecc->read_page) in nand_scan_tail()
5079 ecc->read_page = nand_read_page_hwecc; in nand_scan_tail()
5080 if (!ecc->write_page) in nand_scan_tail()
5081 ecc->write_page = nand_write_page_hwecc; in nand_scan_tail()
5082 if (!ecc->read_page_raw) in nand_scan_tail()
5083 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
5084 if (!ecc->write_page_raw) in nand_scan_tail()
5085 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
5086 if (!ecc->read_oob) in nand_scan_tail()
5087 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
5088 if (!ecc->write_oob) in nand_scan_tail()
5089 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
5090 if (!ecc->read_subpage) in nand_scan_tail()
5091 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
5092 if (!ecc->write_subpage && ecc->hwctl && ecc->calculate) in nand_scan_tail()
5093 ecc->write_subpage = nand_write_subpage_hwecc; in nand_scan_tail()
5096 if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) && in nand_scan_tail()
5097 (!ecc->read_page || in nand_scan_tail()
5098 ecc->read_page == nand_read_page_hwecc || in nand_scan_tail()
5099 !ecc->write_page || in nand_scan_tail()
5100 ecc->write_page == nand_write_page_hwecc)) { in nand_scan_tail()
5105 if (!ecc->read_page) in nand_scan_tail()
5106 ecc->read_page = nand_read_page_syndrome; in nand_scan_tail()
5107 if (!ecc->write_page) in nand_scan_tail()
5108 ecc->write_page = nand_write_page_syndrome; in nand_scan_tail()
5109 if (!ecc->read_page_raw) in nand_scan_tail()
5110 ecc->read_page_raw = nand_read_page_raw_syndrome; in nand_scan_tail()
5111 if (!ecc->write_page_raw) in nand_scan_tail()
5112 ecc->write_page_raw = nand_write_page_raw_syndrome; in nand_scan_tail()
5113 if (!ecc->read_oob) in nand_scan_tail()
5114 ecc->read_oob = nand_read_oob_syndrome; in nand_scan_tail()
5115 if (!ecc->write_oob) in nand_scan_tail()
5116 ecc->write_oob = nand_write_oob_syndrome; in nand_scan_tail()
5118 if (mtd->writesize >= ecc->size) { in nand_scan_tail()
5119 if (!ecc->strength) { in nand_scan_tail()
5126 ecc->size, mtd->writesize); in nand_scan_tail()
5127 ecc->mode = NAND_ECC_SOFT; in nand_scan_tail()
5130 ecc->calculate = nand_calculate_ecc; in nand_scan_tail()
5131 ecc->correct = nand_correct_data; in nand_scan_tail()
5132 ecc->read_page = nand_read_page_swecc; in nand_scan_tail()
5133 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
5134 ecc->write_page = nand_write_page_swecc; in nand_scan_tail()
5135 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
5136 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
5137 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
5138 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
5139 if (!ecc->size) in nand_scan_tail()
5140 ecc->size = 256; in nand_scan_tail()
5141 ecc->bytes = 3; in nand_scan_tail()
5142 ecc->strength = 1; in nand_scan_tail()
5150 ecc->calculate = nand_bch_calculate_ecc; in nand_scan_tail()
5151 ecc->correct = nand_bch_correct_data; in nand_scan_tail()
5152 ecc->read_page = nand_read_page_swecc; in nand_scan_tail()
5153 ecc->read_subpage = nand_read_subpage; in nand_scan_tail()
5154 ecc->write_page = nand_write_page_swecc; in nand_scan_tail()
5155 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
5156 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
5157 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
5158 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
5164 if (!ecc->size && (mtd->oobsize >= 64)) { in nand_scan_tail()
5165 ecc->size = 512; in nand_scan_tail()
5166 ecc->strength = 4; in nand_scan_tail()
5170 ecc->bytes = 0; in nand_scan_tail()
5171 ecc->priv = nand_bch_init(mtd); in nand_scan_tail()
5172 if (!ecc->priv) { in nand_scan_tail()
5180 ecc->read_page = nand_read_page_raw; in nand_scan_tail()
5181 ecc->write_page = nand_write_page_raw; in nand_scan_tail()
5182 ecc->read_oob = nand_read_oob_std; in nand_scan_tail()
5183 ecc->read_page_raw = nand_read_page_raw; in nand_scan_tail()
5184 ecc->write_page_raw = nand_write_page_raw; in nand_scan_tail()
5185 ecc->write_oob = nand_write_oob_std; in nand_scan_tail()
5186 ecc->size = mtd->writesize; in nand_scan_tail()
5187 ecc->bytes = 0; in nand_scan_tail()
5188 ecc->strength = 0; in nand_scan_tail()
5192 pr_warn("Invalid NAND_ECC_MODE %d\n", ecc->mode); in nand_scan_tail()
5197 if (!ecc->read_oob_raw) in nand_scan_tail()
5198 ecc->read_oob_raw = ecc->read_oob; in nand_scan_tail()
5199 if (!ecc->write_oob_raw) in nand_scan_tail()
5200 ecc->write_oob_raw = ecc->write_oob; in nand_scan_tail()
5207 if (ecc->layout) { in nand_scan_tail()
5208 for (i = 0; ecc->layout->oobfree[i].length; i++) in nand_scan_tail()
5209 mtd->oobavail += ecc->layout->oobfree[i].length; in nand_scan_tail()
5221 ecc->steps = mtd->writesize / ecc->size; in nand_scan_tail()
5222 if (ecc->steps * ecc->size != mtd->writesize) { in nand_scan_tail()
5226 ecc->total = ecc->steps * ecc->bytes; in nand_scan_tail()
5230 switch (ecc->steps) { in nand_scan_tail()
5250 switch (ecc->mode) { in nand_scan_tail()
5278 mtd->ecclayout = ecc->layout; in nand_scan_tail()
5279 mtd->ecc_strength = ecc->strength; in nand_scan_tail()
5280 mtd->ecc_step_size = ecc->size; in nand_scan_tail()