Lines Matching refs:nand

201 			  struct atmel_nand *nand);
203 int (*setup_interface)(struct atmel_nand *nand, int csline,
205 int (*exec_op)(struct atmel_nand *nand,
471 static void atmel_nand_data_in(struct atmel_nand *nand, void *buf, in atmel_nand_data_in() argument
476 nc = to_nand_controller(nand->base.controller); in atmel_nand_data_in()
485 !atmel_nand_dma_transfer(nc, buf, nand->activecs->io.dma, len, in atmel_nand_data_in()
489 if ((nand->base.options & NAND_BUSWIDTH_16) && !force_8bit) in atmel_nand_data_in()
490 ioread16_rep(nand->activecs->io.virt, buf, len / 2); in atmel_nand_data_in()
492 ioread8_rep(nand->activecs->io.virt, buf, len); in atmel_nand_data_in()
495 static void atmel_nand_data_out(struct atmel_nand *nand, const void *buf, in atmel_nand_data_out() argument
500 nc = to_nand_controller(nand->base.controller); in atmel_nand_data_out()
509 !atmel_nand_dma_transfer(nc, (void *)buf, nand->activecs->io.dma, in atmel_nand_data_out()
513 if ((nand->base.options & NAND_BUSWIDTH_16) && !force_8bit) in atmel_nand_data_out()
514 iowrite16_rep(nand->activecs->io.virt, buf, len / 2); in atmel_nand_data_out()
516 iowrite8_rep(nand->activecs->io.virt, buf, len); in atmel_nand_data_out()
519 static int atmel_nand_waitrdy(struct atmel_nand *nand, unsigned int timeout_ms) in atmel_nand_waitrdy() argument
521 if (nand->activecs->rb.type == ATMEL_NAND_NO_RB) in atmel_nand_waitrdy()
522 return nand_soft_waitrdy(&nand->base, timeout_ms); in atmel_nand_waitrdy()
524 return nand_gpio_waitrdy(&nand->base, nand->activecs->rb.gpio, in atmel_nand_waitrdy()
528 static int atmel_hsmc_nand_waitrdy(struct atmel_nand *nand, in atmel_hsmc_nand_waitrdy() argument
534 if (nand->activecs->rb.type != ATMEL_NAND_NATIVE_RB) in atmel_hsmc_nand_waitrdy()
535 return atmel_nand_waitrdy(nand, timeout_ms); in atmel_hsmc_nand_waitrdy()
537 nc = to_hsmc_nand_controller(nand->base.controller); in atmel_hsmc_nand_waitrdy()
538 mask = ATMEL_HSMC_NFC_SR_RBEDGE(nand->activecs->rb.id); in atmel_hsmc_nand_waitrdy()
544 static void atmel_nand_select_target(struct atmel_nand *nand, in atmel_nand_select_target() argument
547 nand->activecs = &nand->cs[cs]; in atmel_nand_select_target()
550 static void atmel_hsmc_nand_select_target(struct atmel_nand *nand, in atmel_hsmc_nand_select_target() argument
553 struct mtd_info *mtd = nand_to_mtd(&nand->base); in atmel_hsmc_nand_select_target()
559 nand->activecs = &nand->cs[cs]; in atmel_hsmc_nand_select_target()
560 nc = to_hsmc_nand_controller(nand->base.controller); in atmel_hsmc_nand_select_target()
573 static int atmel_smc_nand_exec_instr(struct atmel_nand *nand, in atmel_smc_nand_exec_instr() argument
579 nc = to_nand_controller(nand->base.controller); in atmel_smc_nand_exec_instr()
583 nand->activecs->io.virt + nc->caps->cle_offs); in atmel_smc_nand_exec_instr()
588 nand->activecs->io.virt + nc->caps->ale_offs); in atmel_smc_nand_exec_instr()
591 atmel_nand_data_in(nand, instr->ctx.data.buf.in, in atmel_smc_nand_exec_instr()
596 atmel_nand_data_out(nand, instr->ctx.data.buf.out, in atmel_smc_nand_exec_instr()
601 return atmel_nand_waitrdy(nand, in atmel_smc_nand_exec_instr()
610 static int atmel_smc_nand_exec_op(struct atmel_nand *nand, in atmel_smc_nand_exec_op() argument
620 atmel_nand_select_target(nand, op->cs); in atmel_smc_nand_exec_op()
621 gpiod_set_value(nand->activecs->csgpio, 0); in atmel_smc_nand_exec_op()
623 ret = atmel_smc_nand_exec_instr(nand, &op->instrs[i]); in atmel_smc_nand_exec_op()
627 gpiod_set_value(nand->activecs->csgpio, 1); in atmel_smc_nand_exec_op()
635 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_hsmc_exec_cmd_addr() local
641 nc->op.cs = nand->activecs->id; in atmel_hsmc_exec_cmd_addr()
664 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_hsmc_exec_rw() local
667 atmel_nand_data_in(nand, instr->ctx.data.buf.in, in atmel_hsmc_exec_rw()
671 atmel_nand_data_out(nand, instr->ctx.data.buf.out, in atmel_hsmc_exec_rw()
682 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_hsmc_exec_waitrdy() local
684 return atmel_hsmc_nand_waitrdy(nand, instr->ctx.waitrdy.timeout_ms); in atmel_hsmc_exec_waitrdy()
700 static int atmel_hsmc_nand_exec_op(struct atmel_nand *nand, in atmel_hsmc_nand_exec_op() argument
707 return nand_op_parser_exec_op(&nand->base, in atmel_hsmc_nand_exec_op()
710 atmel_hsmc_nand_select_target(nand, op->cs); in atmel_hsmc_nand_exec_op()
711 ret = nand_op_parser_exec_op(&nand->base, &atmel_hsmc_op_parser, op, in atmel_hsmc_nand_exec_op()
790 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_pmecc_enable() local
799 ret = atmel_pmecc_enable(nand->pmecc, op); in atmel_nand_pmecc_enable()
809 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_pmecc_disable() local
812 atmel_pmecc_disable(nand->pmecc); in atmel_nand_pmecc_disable()
817 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_pmecc_generate_eccbytes() local
829 ret = atmel_pmecc_wait_rdy(nand->pmecc); in atmel_nand_pmecc_generate_eccbytes()
841 atmel_pmecc_get_generated_eccbytes(nand->pmecc, i, in atmel_nand_pmecc_generate_eccbytes()
852 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_pmecc_correct_data() local
864 ret = atmel_pmecc_wait_rdy(nand->pmecc); in atmel_nand_pmecc_correct_data()
877 ret = atmel_pmecc_correct_sector(nand->pmecc, i, databuf, in atmel_nand_pmecc_correct_data()
879 if (ret < 0 && !atmel_pmecc_correct_erased_chunks(nand->pmecc)) in atmel_nand_pmecc_correct_data()
905 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_pmecc_write_pg() local
918 atmel_pmecc_disable(nand->pmecc); in atmel_nand_pmecc_write_pg()
987 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_hsmc_nand_pmecc_write_pg() local
991 atmel_hsmc_nand_select_target(nand, chip->cur_cs); in atmel_hsmc_nand_pmecc_write_pg()
999 nc->op.cs = nand->activecs->id; in atmel_hsmc_nand_pmecc_write_pg()
1048 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_hsmc_nand_pmecc_read_pg() local
1052 atmel_hsmc_nand_select_target(nand, chip->cur_cs); in atmel_hsmc_nand_pmecc_read_pg()
1060 if (nand->activecs->rb.type != ATMEL_NAND_NATIVE_RB) in atmel_hsmc_nand_pmecc_read_pg()
1070 nc->op.cs = nand->activecs->id; in atmel_hsmc_nand_pmecc_read_pg()
1116 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_pmecc_init() local
1167 nand->pmecc = atmel_pmecc_create_user(nc->pmecc, &req); in atmel_nand_pmecc_init()
1168 if (IS_ERR(nand->pmecc)) in atmel_nand_pmecc_init()
1169 return PTR_ERR(nand->pmecc); in atmel_nand_pmecc_init()
1239 static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand, in atmel_smc_nand_prepare_smcconf() argument
1247 nc = to_nand_controller(nand->base.controller); in atmel_smc_nand_prepare_smcconf()
1459 if (nand->base.options & NAND_BUSWIDTH_16) in atmel_smc_nand_prepare_smcconf()
1469 static int atmel_smc_nand_setup_interface(struct atmel_nand *nand, in atmel_smc_nand_setup_interface() argument
1478 nc = to_nand_controller(nand->base.controller); in atmel_smc_nand_setup_interface()
1480 ret = atmel_smc_nand_prepare_smcconf(nand, conf, &smcconf); in atmel_smc_nand_setup_interface()
1487 cs = &nand->cs[csline]; in atmel_smc_nand_setup_interface()
1494 static int atmel_hsmc_nand_setup_interface(struct atmel_nand *nand, in atmel_hsmc_nand_setup_interface() argument
1503 nc = to_hsmc_nand_controller(nand->base.controller); in atmel_hsmc_nand_setup_interface()
1505 ret = atmel_smc_nand_prepare_smcconf(nand, conf, &smcconf); in atmel_hsmc_nand_setup_interface()
1512 cs = &nand->cs[csline]; in atmel_hsmc_nand_setup_interface()
1527 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_setup_interface() local
1535 nc = to_nand_controller(nand->base.controller); in atmel_nand_setup_interface()
1537 if (csline >= nand->numcs || in atmel_nand_setup_interface()
1541 return nc->caps->ops->setup_interface(nand, csline, conf); in atmel_nand_setup_interface()
1548 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_exec_op() local
1551 nc = to_nand_controller(nand->base.controller); in atmel_nand_exec_op()
1553 return nc->caps->ops->exec_op(nand, op, check_only); in atmel_nand_exec_op()
1557 struct atmel_nand *nand) in atmel_nand_init() argument
1559 struct nand_chip *chip = &nand->base; in atmel_nand_init()
1563 nand->base.controller = &nc->base; in atmel_nand_init()
1581 struct atmel_nand *nand) in atmel_smc_nand_init() argument
1583 struct nand_chip *chip = &nand->base; in atmel_smc_nand_init()
1587 atmel_nand_init(nc, nand); in atmel_smc_nand_init()
1594 for (i = 0; i < nand->numcs; i++) in atmel_smc_nand_init()
1597 BIT(nand->cs[i].id), BIT(nand->cs[i].id)); in atmel_smc_nand_init()
1606 static int atmel_nand_controller_remove_nand(struct atmel_nand *nand) in atmel_nand_controller_remove_nand() argument
1608 struct nand_chip *chip = &nand->base; in atmel_nand_controller_remove_nand()
1617 list_del(&nand->node); in atmel_nand_controller_remove_nand()
1626 struct atmel_nand *nand; in atmel_nand_create() local
1637 nand = devm_kzalloc(nc->dev, struct_size(nand, cs, numcs), GFP_KERNEL); in atmel_nand_create()
1638 if (!nand) in atmel_nand_create()
1641 nand->numcs = numcs; in atmel_nand_create()
1653 nand->cdgpio = gpio; in atmel_nand_create()
1674 nand->cs[i].id = val; in atmel_nand_create()
1676 nand->cs[i].io.dma = res.start; in atmel_nand_create()
1677 nand->cs[i].io.virt = devm_ioremap_resource(nc->dev, &res); in atmel_nand_create()
1678 if (IS_ERR(nand->cs[i].io.virt)) in atmel_nand_create()
1679 return ERR_CAST(nand->cs[i].io.virt); in atmel_nand_create()
1685 nand->cs[i].rb.type = ATMEL_NAND_NATIVE_RB; in atmel_nand_create()
1686 nand->cs[i].rb.id = val; in atmel_nand_create()
1700 nand->cs[i].rb.type = ATMEL_NAND_GPIO_RB; in atmel_nand_create()
1701 nand->cs[i].rb.gpio = gpio; in atmel_nand_create()
1717 nand->cs[i].csgpio = gpio; in atmel_nand_create()
1720 nand_set_flash_node(&nand->base, np); in atmel_nand_create()
1722 return nand; in atmel_nand_create()
1727 struct atmel_nand *nand) in atmel_nand_controller_add_nand() argument
1729 struct nand_chip *chip = &nand->base; in atmel_nand_controller_add_nand()
1734 if (nand->cdgpio && gpiod_get_value(nand->cdgpio)) { in atmel_nand_controller_add_nand()
1739 nc->caps->ops->nand_init(nc, nand); in atmel_nand_controller_add_nand()
1741 ret = nand_scan(chip, nand->numcs); in atmel_nand_controller_add_nand()
1754 list_add_tail(&nand->node, &nc->chips); in atmel_nand_controller_add_nand()
1762 struct atmel_nand *nand, *tmp; in atmel_nand_controller_remove_nands() local
1765 list_for_each_entry_safe(nand, tmp, &nc->chips, node) { in atmel_nand_controller_remove_nands()
1766 ret = atmel_nand_controller_remove_nand(nand); in atmel_nand_controller_remove_nands()
1779 struct atmel_nand *nand; in atmel_nand_controller_legacy_add_nands() local
1787 nand = devm_kzalloc(nc->dev, sizeof(*nand) + sizeof(*nand->cs), in atmel_nand_controller_legacy_add_nands()
1789 if (!nand) in atmel_nand_controller_legacy_add_nands()
1792 nand->numcs = 1; in atmel_nand_controller_legacy_add_nands()
1794 nand->cs[0].io.virt = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in atmel_nand_controller_legacy_add_nands()
1795 if (IS_ERR(nand->cs[0].io.virt)) in atmel_nand_controller_legacy_add_nands()
1796 return PTR_ERR(nand->cs[0].io.virt); in atmel_nand_controller_legacy_add_nands()
1798 nand->cs[0].io.dma = res->start; in atmel_nand_controller_legacy_add_nands()
1808 nand->cs[0].id = 3; in atmel_nand_controller_legacy_add_nands()
1819 nand->cs[0].rb.type = ATMEL_NAND_GPIO_RB; in atmel_nand_controller_legacy_add_nands()
1820 nand->cs[0].rb.gpio = gpio; in atmel_nand_controller_legacy_add_nands()
1831 nand->cs[0].csgpio = gpio; in atmel_nand_controller_legacy_add_nands()
1842 nand->cdgpio = gpio; in atmel_nand_controller_legacy_add_nands()
1844 nand_set_flash_node(&nand->base, nc->dev->of_node); in atmel_nand_controller_legacy_add_nands()
1846 return atmel_nand_controller_add_nand(nc, nand); in atmel_nand_controller_legacy_add_nands()
1879 struct atmel_nand *nand; in atmel_nand_controller_add_nands() local
1881 nand = atmel_nand_create(nc, nand_np, reg_cells); in atmel_nand_controller_add_nands()
1882 if (IS_ERR(nand)) { in atmel_nand_controller_add_nands()
1883 ret = PTR_ERR(nand); in atmel_nand_controller_add_nands()
1887 ret = atmel_nand_controller_add_nand(nc, nand); in atmel_nand_controller_add_nands()
1980 struct atmel_nand *nand = to_atmel_nand(chip); in atmel_nand_attach_chip() local
2008 nand->cs[0].id); in atmel_nand_attach_chip()
2638 struct atmel_nand *nand; in atmel_nand_controller_resume() local
2643 list_for_each_entry(nand, &nc->chips, node) { in atmel_nand_controller_resume()
2646 for (i = 0; i < nand->numcs; i++) in atmel_nand_controller_resume()
2647 nand_reset(&nand->base, i); in atmel_nand_controller_resume()