Lines Matching refs:geo
114 static inline int mxs_nand_calc_mark_offset(struct bch_geometry *geo, in mxs_nand_calc_mark_offset() argument
117 uint32_t chunk_data_size_in_bits = geo->ecc_chunk_size * 8; in mxs_nand_calc_mark_offset()
118 uint32_t chunk_ecc_size_in_bits = geo->ecc_strength * geo->gf_len; in mxs_nand_calc_mark_offset()
157 geo->block_mark_byte_offset = block_mark_bit_offset >> 3; in mxs_nand_calc_mark_offset()
158 geo->block_mark_bit_offset = block_mark_bit_offset & 0x7; in mxs_nand_calc_mark_offset()
163 static inline int mxs_nand_calc_ecc_layout_by_info(struct bch_geometry *geo, in mxs_nand_calc_ecc_layout_by_info() argument
173 geo->gf_len = 13; in mxs_nand_calc_ecc_layout_by_info()
176 geo->gf_len = 14; in mxs_nand_calc_ecc_layout_by_info()
182 geo->ecc_chunk_size = ecc_step; in mxs_nand_calc_ecc_layout_by_info()
183 geo->ecc_strength = round_up(ecc_strength, 2); in mxs_nand_calc_ecc_layout_by_info()
186 if (geo->ecc_chunk_size < mtd->oobsize) in mxs_nand_calc_ecc_layout_by_info()
189 if (geo->ecc_strength > nand_info->max_ecc_strength_supported) in mxs_nand_calc_ecc_layout_by_info()
192 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; in mxs_nand_calc_ecc_layout_by_info()
197 static inline int mxs_nand_calc_ecc_layout(struct bch_geometry *geo, in mxs_nand_calc_ecc_layout() argument
204 geo->gf_len = 13; in mxs_nand_calc_ecc_layout()
207 geo->ecc_chunk_size = 512; in mxs_nand_calc_ecc_layout()
209 if (geo->ecc_chunk_size < mtd->oobsize) { in mxs_nand_calc_ecc_layout()
210 geo->gf_len = 14; in mxs_nand_calc_ecc_layout()
211 geo->ecc_chunk_size *= 2; in mxs_nand_calc_ecc_layout()
214 if (mtd->oobsize > geo->ecc_chunk_size) { in mxs_nand_calc_ecc_layout()
216 geo->ecc_chunk_size); in mxs_nand_calc_ecc_layout()
220 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; in mxs_nand_calc_ecc_layout()
230 geo->ecc_strength = ((mtd->oobsize - MXS_NAND_METADATA_SIZE) * 8) in mxs_nand_calc_ecc_layout()
231 / (geo->gf_len * geo->ecc_chunk_count); in mxs_nand_calc_ecc_layout()
233 geo->ecc_strength = min(round_down(geo->ecc_strength, 2), in mxs_nand_calc_ecc_layout()
374 static void mxs_nand_swap_block_mark(struct bch_geometry *geo, in mxs_nand_swap_block_mark() argument
377 uint32_t bit_offset = geo->block_mark_bit_offset; in mxs_nand_swap_block_mark()
378 uint32_t buf_offset = geo->block_mark_byte_offset; in mxs_nand_swap_block_mark()
558 struct bch_geometry *geo = &nand_info->bch_geometry; in mxs_nand_ecc_read_page() local
657 mxs_nand_swap_block_mark(geo, nand_info->data_buf, nand_info->oob_buf); in mxs_nand_ecc_read_page()
661 for (i = 0; i < geo->ecc_chunk_count; i++) { in mxs_nand_ecc_read_page()
709 struct bch_geometry *geo = &nand_info->bch_geometry; in mxs_nand_ecc_write_page() local
718 mxs_nand_swap_block_mark(geo, nand_info->data_buf, nand_info->oob_buf); in mxs_nand_ecc_write_page()
966 static int mxs_nand_set_geometry(struct mtd_info *mtd, struct bch_geometry *geo) in mxs_nand_set_geometry() argument
973 return mxs_nand_calc_ecc_layout_by_info(geo, mtd, in mxs_nand_set_geometry()
977 mxs_nand_calc_ecc_layout(geo, mtd)) { in mxs_nand_set_geometry()
981 return mxs_nand_calc_ecc_layout_by_info(geo, mtd, in mxs_nand_set_geometry()
1001 struct bch_geometry *geo = &nand_info->bch_geometry; in mxs_nand_setup_ecc() local
1006 ret = mxs_nand_set_geometry(mtd, geo); in mxs_nand_setup_ecc()
1010 mxs_nand_calc_mark_offset(geo, mtd->writesize); in mxs_nand_setup_ecc()
1016 tmp = (geo->ecc_chunk_count - 1) << BCH_FLASHLAYOUT0_NBLOCKS_OFFSET; in mxs_nand_setup_ecc()
1018 tmp |= (geo->ecc_strength >> 1) << BCH_FLASHLAYOUT0_ECC0_OFFSET; in mxs_nand_setup_ecc()
1019 tmp |= geo->ecc_chunk_size >> MXS_NAND_CHUNK_DATA_CHUNK_SIZE_SHIFT; in mxs_nand_setup_ecc()
1020 tmp |= (geo->gf_len == 14 ? 1 : 0) << in mxs_nand_setup_ecc()
1026 tmp |= (geo->ecc_strength >> 1) << BCH_FLASHLAYOUT1_ECCN_OFFSET; in mxs_nand_setup_ecc()
1027 tmp |= geo->ecc_chunk_size >> MXS_NAND_CHUNK_DATA_CHUNK_SIZE_SHIFT; in mxs_nand_setup_ecc()
1028 tmp |= (geo->gf_len == 14 ? 1 : 0) << in mxs_nand_setup_ecc()