Lines Matching refs:anand

171 struct anand {  struct
224 static struct anand *to_anand(struct nand_chip *nand) in to_anand()
226 return container_of(nand, struct anand, chip); in to_anand()
255 struct anand *anand = to_anand(chip); in anfc_wait_for_rb() local
261 val & BIT(anand->rb), in anfc_wait_for_rb()
309 static int anfc_relative_to_absolute_cs(struct anand *anand, int num) in anfc_relative_to_absolute_cs() argument
311 return anand->cs_idx[num]; in anfc_relative_to_absolute_cs()
337 struct anand *anand = to_anand(chip); in anfc_select_target() local
339 unsigned int nfc_cs_idx = anfc_relative_to_absolute_cs(anand, target); in anfc_select_target()
345 writel_relaxed(anand->data_iface, nfc->base + DATA_INTERFACE_REG); in anfc_select_target()
346 writel_relaxed(anand->timings, nfc->base + TIMING_REG); in anfc_select_target()
349 if (nfc->cur_clk != anand->clk) { in anfc_select_target()
351 ret = clk_set_rate(nfc->bus_clk, anand->clk); in anfc_select_target()
364 nfc->cur_clk = anand->clk; in anfc_select_target()
397 struct anand *anand = to_anand(chip); in anfc_read_page_hw_ecc() local
407 (page & 0xFF) << (8 * (anand->caddr_cycles)) | in anfc_read_page_hw_ecc()
408 (((page >> 8) & 0xFF) << (8 * (1 + anand->caddr_cycles))), in anfc_read_page_hw_ecc()
411 ADDR2_STRENGTH(anand->strength) | in anfc_read_page_hw_ecc()
416 CMD_PAGE_SIZE(anand->page_sz) | in anfc_read_page_hw_ecc()
418 CMD_NADDRS(anand->caddr_cycles + in anfc_read_page_hw_ecc()
419 anand->raddr_cycles), in anfc_read_page_hw_ecc()
458 memset(anand->hw_ecc, 0, chip->ecc.bytes); in anfc_read_page_hw_ecc()
459 nand_extract_bits(anand->hw_ecc, 0, in anfc_read_page_hw_ecc()
460 &chip->oob_poi[mtd->oobsize - anand->ecc_total], in anfc_read_page_hw_ecc()
461 anand->ecc_bits * step, anand->ecc_bits); in anfc_read_page_hw_ecc()
463 bf = bch_decode(anand->bch, raw_buf, chip->ecc.size, in anfc_read_page_hw_ecc()
464 anand->hw_ecc, NULL, NULL, anand->errloc); in anfc_read_page_hw_ecc()
470 if (anand->errloc[i] < (chip->ecc.size * 8)) { in anfc_read_page_hw_ecc()
471 bit = BIT(anand->errloc[i] & 7); in anfc_read_page_hw_ecc()
472 byte = anand->errloc[i] >> 3; in anfc_read_page_hw_ecc()
513 struct anand *anand = to_anand(chip); in anfc_write_page_hw_ecc() local
525 (page & 0xFF) << (8 * (anand->caddr_cycles)) | in anfc_write_page_hw_ecc()
526 (((page >> 8) & 0xFF) << (8 * (1 + anand->caddr_cycles))), in anfc_write_page_hw_ecc()
529 ADDR2_STRENGTH(anand->strength) | in anfc_write_page_hw_ecc()
534 CMD_PAGE_SIZE(anand->page_sz) | in anfc_write_page_hw_ecc()
536 CMD_NADDRS(anand->caddr_cycles + in anfc_write_page_hw_ecc()
537 anand->raddr_cycles) | in anfc_write_page_hw_ecc()
542 writel_relaxed(anand->ecc_conf, nfc->base + ECC_CONF_REG); in anfc_write_page_hw_ecc()
544 ECC_SP_ADDRS(anand->caddr_cycles), in anfc_write_page_hw_ecc()
600 struct anand *anand = to_anand(chip); in anfc_parse_instructions() local
608 nfc_op->cmd_reg = CMD_PAGE_SIZE(anand->page_sz); in anfc_parse_instructions()
977 struct anand *anand = to_anand(chip); in anfc_setup_interface() local
998 anand->data_iface = DIFACE_SDR | in anfc_setup_interface()
1000 anand->timings = 0; in anfc_setup_interface()
1002 anand->data_iface = DIFACE_NVDDR | in anfc_setup_interface()
1038 anand->timings = tccs_min | fast_tcad | in anfc_setup_interface()
1044 anand->clk = ANFC_XLNX_SDR_DFLT_CORE_CLK; in anfc_setup_interface()
1047 anand->clk = div_u64((u64)NSEC_PER_SEC * 1000, in anfc_setup_interface()
1059 anand->clk = ANFC_XLNX_SDR_HS_CORE_CLK; in anfc_setup_interface()
1110 struct anand *anand = to_anand(chip); in anfc_init_hw_ecc_controller() local
1134 anand->strength = 0x1; in anfc_init_hw_ecc_controller()
1137 anand->strength = 0x2; in anfc_init_hw_ecc_controller()
1140 anand->strength = 0x3; in anfc_init_hw_ecc_controller()
1143 anand->strength = 0x4; in anfc_init_hw_ecc_controller()
1168 anand->ecc_bits = bch_gf_mag * ecc->strength; in anfc_init_hw_ecc_controller()
1169 ecc->bytes = DIV_ROUND_UP(anand->ecc_bits, 8); in anfc_init_hw_ecc_controller()
1170 anand->ecc_total = DIV_ROUND_UP(anand->ecc_bits * ecc->steps, 8); in anfc_init_hw_ecc_controller()
1171 ecc_offset = mtd->writesize + mtd->oobsize - anand->ecc_total; in anfc_init_hw_ecc_controller()
1172 anand->ecc_conf = ECC_CONF_COL(ecc_offset) | in anfc_init_hw_ecc_controller()
1173 ECC_CONF_LEN(anand->ecc_total) | in anfc_init_hw_ecc_controller()
1176 anand->errloc = devm_kmalloc_array(nfc->dev, ecc->strength, in anfc_init_hw_ecc_controller()
1177 sizeof(*anand->errloc), GFP_KERNEL); in anfc_init_hw_ecc_controller()
1178 if (!anand->errloc) in anfc_init_hw_ecc_controller()
1181 anand->hw_ecc = devm_kmalloc(nfc->dev, ecc->bytes, GFP_KERNEL); in anfc_init_hw_ecc_controller()
1182 if (!anand->hw_ecc) in anfc_init_hw_ecc_controller()
1186 anand->bch = bch_init(bch_gf_mag, ecc->strength, bch_prim_poly, true); in anfc_init_hw_ecc_controller()
1187 if (!anand->bch) in anfc_init_hw_ecc_controller()
1198 struct anand *anand = to_anand(chip); in anfc_attach_chip() local
1204 anand->caddr_cycles = 1; in anfc_attach_chip()
1206 anand->caddr_cycles = 2; in anfc_attach_chip()
1209 anand->raddr_cycles = 3; in anfc_attach_chip()
1211 anand->raddr_cycles = 2; in anfc_attach_chip()
1215 anand->page_sz = 0; in anfc_attach_chip()
1218 anand->page_sz = 5; in anfc_attach_chip()
1221 anand->page_sz = 1; in anfc_attach_chip()
1224 anand->page_sz = 2; in anfc_attach_chip()
1227 anand->page_sz = 3; in anfc_attach_chip()
1230 anand->page_sz = 4; in anfc_attach_chip()
1259 struct anand *anand = to_anand(chip); in anfc_detach_chip() local
1261 if (anand->bch) in anfc_detach_chip()
1262 bch_free(anand->bch); in anfc_detach_chip()
1274 struct anand *anand; in anfc_chip_init() local
1279 anand = devm_kzalloc(nfc->dev, sizeof(*anand), GFP_KERNEL); in anfc_chip_init()
1280 if (!anand) in anfc_chip_init()
1284 anand->ncs_idx = of_property_count_elems_of_size(np, "reg", sizeof(u32)); in anfc_chip_init()
1285 if (anand->ncs_idx <= 0 || anand->ncs_idx > nfc->ncs) { in anfc_chip_init()
1290 anand->cs_idx = devm_kcalloc(nfc->dev, anand->ncs_idx, in anfc_chip_init()
1291 sizeof(*anand->cs_idx), GFP_KERNEL); in anfc_chip_init()
1292 if (!anand->cs_idx) in anfc_chip_init()
1295 for (i = 0; i < anand->ncs_idx; i++) { in anfc_chip_init()
1297 &anand->cs_idx[i]); in anfc_chip_init()
1314 anand->rb = rb; in anfc_chip_init()
1316 chip = &anand->chip; in anfc_chip_init()
1329 ret = nand_scan(chip, anand->ncs_idx); in anfc_chip_init()
1341 list_add_tail(&anand->node, &nfc->chips); in anfc_chip_init()
1348 struct anand *anand, *tmp; in anfc_chips_cleanup() local
1352 list_for_each_entry_safe(anand, tmp, &nfc->chips, node) { in anfc_chips_cleanup()
1353 chip = &anand->chip; in anfc_chips_cleanup()
1357 list_del(&anand->node); in anfc_chips_cleanup()