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
524 (page & 0xFF) << (8 * (anand->caddr_cycles)) | in anfc_write_page_hw_ecc()
525 (((page >> 8) & 0xFF) << (8 * (1 + anand->caddr_cycles))), in anfc_write_page_hw_ecc()
528 ADDR2_STRENGTH(anand->strength) | in anfc_write_page_hw_ecc()
533 CMD_PAGE_SIZE(anand->page_sz) | in anfc_write_page_hw_ecc()
535 CMD_NADDRS(anand->caddr_cycles + in anfc_write_page_hw_ecc()
536 anand->raddr_cycles) | in anfc_write_page_hw_ecc()
541 writel_relaxed(anand->ecc_conf, nfc->base + ECC_CONF_REG); in anfc_write_page_hw_ecc()
543 ECC_SP_ADDRS(anand->caddr_cycles), in anfc_write_page_hw_ecc()
588 struct anand *anand = to_anand(chip); in anfc_parse_instructions() local
596 nfc_op->cmd_reg = CMD_PAGE_SIZE(anand->page_sz); in anfc_parse_instructions()
965 struct anand *anand = to_anand(chip); in anfc_setup_interface() local
1001 anand->data_iface = DIFACE_SDR | in anfc_setup_interface()
1003 anand->timings = 0; in anfc_setup_interface()
1005 anand->data_iface = DIFACE_NVDDR | in anfc_setup_interface()
1041 anand->timings = tccs_min | fast_tcad | in anfc_setup_interface()
1047 anand->clk = ANFC_XLNX_SDR_DFLT_CORE_CLK; in anfc_setup_interface()
1050 anand->clk = div_u64((u64)NSEC_PER_SEC * 1000, in anfc_setup_interface()
1062 anand->clk = ANFC_XLNX_SDR_HS_CORE_CLK; in anfc_setup_interface()
1113 struct anand *anand = to_anand(chip); in anfc_init_hw_ecc_controller() local
1137 anand->strength = 0x1; in anfc_init_hw_ecc_controller()
1140 anand->strength = 0x2; in anfc_init_hw_ecc_controller()
1143 anand->strength = 0x3; in anfc_init_hw_ecc_controller()
1146 anand->strength = 0x4; in anfc_init_hw_ecc_controller()
1171 anand->ecc_bits = bch_gf_mag * ecc->strength; in anfc_init_hw_ecc_controller()
1172 ecc->bytes = DIV_ROUND_UP(anand->ecc_bits, 8); in anfc_init_hw_ecc_controller()
1173 anand->ecc_total = DIV_ROUND_UP(anand->ecc_bits * ecc->steps, 8); in anfc_init_hw_ecc_controller()
1174 ecc_offset = mtd->writesize + mtd->oobsize - anand->ecc_total; in anfc_init_hw_ecc_controller()
1175 anand->ecc_conf = ECC_CONF_COL(ecc_offset) | in anfc_init_hw_ecc_controller()
1176 ECC_CONF_LEN(anand->ecc_total) | in anfc_init_hw_ecc_controller()
1179 anand->errloc = devm_kmalloc_array(nfc->dev, ecc->strength, in anfc_init_hw_ecc_controller()
1180 sizeof(*anand->errloc), GFP_KERNEL); in anfc_init_hw_ecc_controller()
1181 if (!anand->errloc) in anfc_init_hw_ecc_controller()
1184 anand->hw_ecc = devm_kmalloc(nfc->dev, ecc->bytes, GFP_KERNEL); in anfc_init_hw_ecc_controller()
1185 if (!anand->hw_ecc) in anfc_init_hw_ecc_controller()
1189 anand->bch = bch_init(bch_gf_mag, ecc->strength, bch_prim_poly, true); in anfc_init_hw_ecc_controller()
1190 if (!anand->bch) in anfc_init_hw_ecc_controller()
1201 struct anand *anand = to_anand(chip); in anfc_attach_chip() local
1207 anand->caddr_cycles = 1; in anfc_attach_chip()
1209 anand->caddr_cycles = 2; in anfc_attach_chip()
1212 anand->raddr_cycles = 3; in anfc_attach_chip()
1214 anand->raddr_cycles = 2; in anfc_attach_chip()
1218 anand->page_sz = 0; in anfc_attach_chip()
1221 anand->page_sz = 5; in anfc_attach_chip()
1224 anand->page_sz = 1; in anfc_attach_chip()
1227 anand->page_sz = 2; in anfc_attach_chip()
1230 anand->page_sz = 3; in anfc_attach_chip()
1233 anand->page_sz = 4; in anfc_attach_chip()
1262 struct anand *anand = to_anand(chip); in anfc_detach_chip() local
1264 if (anand->bch) in anfc_detach_chip()
1265 bch_free(anand->bch); in anfc_detach_chip()
1277 struct anand *anand; in anfc_chip_init() local
1282 anand = devm_kzalloc(nfc->dev, sizeof(*anand), GFP_KERNEL); in anfc_chip_init()
1283 if (!anand) in anfc_chip_init()
1287 anand->ncs_idx = of_property_count_elems_of_size(np, "reg", sizeof(u32)); in anfc_chip_init()
1288 if (anand->ncs_idx <= 0 || anand->ncs_idx > nfc->ncs) { in anfc_chip_init()
1293 anand->cs_idx = devm_kcalloc(nfc->dev, anand->ncs_idx, in anfc_chip_init()
1294 sizeof(*anand->cs_idx), GFP_KERNEL); in anfc_chip_init()
1295 if (!anand->cs_idx) in anfc_chip_init()
1298 for (i = 0; i < anand->ncs_idx; i++) { in anfc_chip_init()
1300 &anand->cs_idx[i]); in anfc_chip_init()
1317 anand->rb = rb; in anfc_chip_init()
1319 chip = &anand->chip; in anfc_chip_init()
1332 ret = nand_scan(chip, anand->ncs_idx); in anfc_chip_init()
1344 list_add_tail(&anand->node, &nfc->chips); in anfc_chip_init()
1351 struct anand *anand, *tmp; in anfc_chips_cleanup() local
1355 list_for_each_entry_safe(anand, tmp, &nfc->chips, node) { in anfc_chips_cleanup()
1356 chip = &anand->chip; in anfc_chips_cleanup()
1360 list_del(&anand->node); in anfc_chips_cleanup()