Lines Matching full:nc

199 	int (*remove)(struct atmel_nand_controller *nc);
200 void (*nand_init)(struct atmel_nand_controller *nc,
288 struct atmel_hsmc_nand_controller *nc = data; in atmel_nfc_interrupt() local
292 regmap_read(nc->base.smc, ATMEL_HSMC_NFC_SR, &sr); in atmel_nfc_interrupt()
294 rcvd = sr & (nc->op.wait | ATMEL_HSMC_NFC_SR_ERRORS); in atmel_nfc_interrupt()
295 done = atmel_nfc_op_done(&nc->op, sr); in atmel_nfc_interrupt()
298 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_IDR, rcvd); in atmel_nfc_interrupt()
301 complete(&nc->complete); in atmel_nfc_interrupt()
306 static int atmel_nfc_wait(struct atmel_hsmc_nand_controller *nc, bool poll, in atmel_nfc_wait() argument
317 ret = regmap_read_poll_timeout(nc->base.smc, in atmel_nfc_wait()
319 atmel_nfc_op_done(&nc->op, in atmel_nfc_wait()
323 init_completion(&nc->complete); in atmel_nfc_wait()
324 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_IER, in atmel_nfc_wait()
325 nc->op.wait | ATMEL_HSMC_NFC_SR_ERRORS); in atmel_nfc_wait()
326 ret = wait_for_completion_timeout(&nc->complete, in atmel_nfc_wait()
333 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_IDR, 0xffffffff); in atmel_nfc_wait()
336 if (nc->op.errors & ATMEL_HSMC_NFC_SR_DTOE) { in atmel_nfc_wait()
337 dev_err(nc->base.dev, "Waiting NAND R/B Timeout\n"); in atmel_nfc_wait()
341 if (nc->op.errors & ATMEL_HSMC_NFC_SR_UNDEF) { in atmel_nfc_wait()
342 dev_err(nc->base.dev, "Access to an undefined area\n"); in atmel_nfc_wait()
346 if (nc->op.errors & ATMEL_HSMC_NFC_SR_AWB) { in atmel_nfc_wait()
347 dev_err(nc->base.dev, "Access while busy\n"); in atmel_nfc_wait()
351 if (nc->op.errors & ATMEL_HSMC_NFC_SR_NFCASE) { in atmel_nfc_wait()
352 dev_err(nc->base.dev, "Wrong access size\n"); in atmel_nfc_wait()
366 static int atmel_nand_dma_transfer(struct atmel_nand_controller *nc, in atmel_nand_dma_transfer() argument
375 buf_dma = dma_map_single(nc->dev, buf, len, dir); in atmel_nand_dma_transfer()
376 if (dma_mapping_error(nc->dev, dev_dma)) { in atmel_nand_dma_transfer()
377 dev_err(nc->dev, in atmel_nand_dma_transfer()
390 tx = dmaengine_prep_dma_memcpy(nc->dmac, dst_dma, src_dma, len, in atmel_nand_dma_transfer()
393 dev_err(nc->dev, "Failed to prepare DMA memcpy\n"); in atmel_nand_dma_transfer()
402 dev_err(nc->dev, "Failed to do DMA tx_submit\n"); in atmel_nand_dma_transfer()
406 dma_async_issue_pending(nc->dmac); in atmel_nand_dma_transfer()
408 dma_unmap_single(nc->dev, buf_dma, len, dir); in atmel_nand_dma_transfer()
413 dma_unmap_single(nc->dev, buf_dma, len, dir); in atmel_nand_dma_transfer()
416 dev_dbg(nc->dev, "Fall back to CPU I/O\n"); in atmel_nand_dma_transfer()
421 static int atmel_nfc_exec_op(struct atmel_hsmc_nand_controller *nc, bool poll) in atmel_nfc_exec_op() argument
423 u8 *addrs = nc->op.addrs; in atmel_nfc_exec_op()
428 nc->op.wait = ATMEL_HSMC_NFC_SR_CMDDONE; in atmel_nfc_exec_op()
430 for (i = 0; i < nc->op.ncmds; i++) in atmel_nfc_exec_op()
431 op |= ATMEL_NFC_CMD(i, nc->op.cmds[i]); in atmel_nfc_exec_op()
433 if (nc->op.naddrs == ATMEL_NFC_MAX_ADDR_CYCLES) in atmel_nfc_exec_op()
434 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_ADDR, *addrs++); in atmel_nfc_exec_op()
436 op |= ATMEL_NFC_CSID(nc->op.cs) | in atmel_nfc_exec_op()
437 ATMEL_NFC_ACYCLE(nc->op.naddrs); in atmel_nfc_exec_op()
439 if (nc->op.ncmds > 1) in atmel_nfc_exec_op()
445 if (nc->op.data != ATMEL_NFC_NO_DATA) { in atmel_nfc_exec_op()
447 nc->op.wait |= ATMEL_HSMC_NFC_SR_XFRDONE; in atmel_nfc_exec_op()
449 if (nc->op.data == ATMEL_NFC_WRITE_DATA) in atmel_nfc_exec_op()
454 regmap_read(nc->base.smc, ATMEL_HSMC_NFC_SR, &val); in atmel_nfc_exec_op()
457 regmap_write(nc->io, op, addr); in atmel_nfc_exec_op()
459 ret = atmel_nfc_wait(nc, poll, 0); in atmel_nfc_exec_op()
461 dev_err(nc->base.dev, in atmel_nfc_exec_op()
466 memset(&nc->op, 0, sizeof(nc->op)); in atmel_nfc_exec_op()
474 struct atmel_nand_controller *nc; in atmel_nand_data_in() local
476 nc = to_nand_controller(nand->base.controller); in atmel_nand_data_in()
483 if (nc->dmac && virt_addr_valid(buf) && in atmel_nand_data_in()
485 !atmel_nand_dma_transfer(nc, buf, nand->activecs->io.dma, len, in atmel_nand_data_in()
498 struct atmel_nand_controller *nc; in atmel_nand_data_out() local
500 nc = to_nand_controller(nand->base.controller); in atmel_nand_data_out()
507 if (nc->dmac && virt_addr_valid(buf) && in atmel_nand_data_out()
509 !atmel_nand_dma_transfer(nc, (void *)buf, nand->activecs->io.dma, in atmel_nand_data_out()
531 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_nand_waitrdy() local
537 nc = to_hsmc_nand_controller(nand->base.controller); in atmel_hsmc_nand_waitrdy()
539 return regmap_read_poll_timeout_atomic(nc->base.smc, ATMEL_HSMC_NFC_SR, in atmel_hsmc_nand_waitrdy()
554 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_nand_select_target() local
560 nc = to_hsmc_nand_controller(nand->base.controller); in atmel_hsmc_nand_select_target()
561 if (nc->cfg == cfg) in atmel_hsmc_nand_select_target()
564 regmap_update_bits(nc->base.smc, ATMEL_HSMC_NFC_CFG, in atmel_hsmc_nand_select_target()
570 nc->cfg = cfg; in atmel_hsmc_nand_select_target()
576 struct atmel_nand_controller *nc; in atmel_smc_nand_exec_instr() local
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()
636 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_exec_cmd_addr() local
639 nc = to_hsmc_nand_controller(chip->controller); in atmel_hsmc_exec_cmd_addr()
641 nc->op.cs = nand->activecs->id; in atmel_hsmc_exec_cmd_addr()
646 nc->op.cmds[nc->op.ncmds++] = instr->ctx.cmd.opcode; in atmel_hsmc_exec_cmd_addr()
652 nc->op.addrs[nc->op.naddrs] = instr->ctx.addr.addrs[j]; in atmel_hsmc_exec_cmd_addr()
653 nc->op.naddrs++; in atmel_hsmc_exec_cmd_addr()
657 return atmel_nfc_exec_op(nc, true); in atmel_hsmc_exec_cmd_addr()
721 struct atmel_hsmc_nand_controller *nc; in atmel_nfc_copy_to_sram() local
724 nc = to_hsmc_nand_controller(chip->controller); in atmel_nfc_copy_to_sram()
726 if (nc->base.dmac) in atmel_nfc_copy_to_sram()
727 ret = atmel_nand_dma_transfer(&nc->base, (void *)buf, in atmel_nfc_copy_to_sram()
728 nc->sram.dma, mtd->writesize, in atmel_nfc_copy_to_sram()
733 memcpy_toio(nc->sram.virt, buf, mtd->writesize); in atmel_nfc_copy_to_sram()
736 memcpy_toio(nc->sram.virt + mtd->writesize, chip->oob_poi, in atmel_nfc_copy_to_sram()
744 struct atmel_hsmc_nand_controller *nc; in atmel_nfc_copy_from_sram() local
747 nc = to_hsmc_nand_controller(chip->controller); in atmel_nfc_copy_from_sram()
749 if (nc->base.dmac) in atmel_nfc_copy_from_sram()
750 ret = atmel_nand_dma_transfer(&nc->base, buf, nc->sram.dma, in atmel_nfc_copy_from_sram()
755 memcpy_fromio(buf, nc->sram.virt, mtd->writesize); in atmel_nfc_copy_from_sram()
758 memcpy_fromio(chip->oob_poi, nc->sram.virt + mtd->writesize, in atmel_nfc_copy_from_sram()
765 struct atmel_hsmc_nand_controller *nc; in atmel_nfc_set_op_addr() local
767 nc = to_hsmc_nand_controller(chip->controller); in atmel_nfc_set_op_addr()
770 nc->op.addrs[nc->op.naddrs++] = column; in atmel_nfc_set_op_addr()
776 nc->op.addrs[nc->op.naddrs++] = column >> 8; in atmel_nfc_set_op_addr()
780 nc->op.addrs[nc->op.naddrs++] = page; in atmel_nfc_set_op_addr()
781 nc->op.addrs[nc->op.naddrs++] = page >> 8; in atmel_nfc_set_op_addr()
784 nc->op.addrs[nc->op.naddrs++] = page >> 16; in atmel_nfc_set_op_addr()
791 struct atmel_nand_controller *nc; in atmel_nand_pmecc_enable() local
794 nc = to_nand_controller(chip->controller); in atmel_nand_pmecc_enable()
801 dev_err(nc->dev, in atmel_nand_pmecc_enable()
819 struct atmel_nand_controller *nc; in atmel_nand_pmecc_generate_eccbytes() local
824 nc = to_nand_controller(chip->controller); in atmel_nand_pmecc_generate_eccbytes()
831 dev_err(nc->dev, in atmel_nand_pmecc_generate_eccbytes()
854 struct atmel_nand_controller *nc; in atmel_nand_pmecc_correct_data() local
859 nc = to_nand_controller(chip->controller); in atmel_nand_pmecc_correct_data()
866 dev_err(nc->dev, in atmel_nand_pmecc_correct_data()
988 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_nand_pmecc_write_pg() local
992 nc = to_hsmc_nand_controller(chip->controller); in atmel_hsmc_nand_pmecc_write_pg()
996 nc->op.cmds[0] = NAND_CMD_SEQIN; in atmel_hsmc_nand_pmecc_write_pg()
997 nc->op.ncmds = 1; in atmel_hsmc_nand_pmecc_write_pg()
999 nc->op.cs = nand->activecs->id; in atmel_hsmc_nand_pmecc_write_pg()
1000 nc->op.data = ATMEL_NFC_WRITE_DATA; in atmel_hsmc_nand_pmecc_write_pg()
1006 ret = atmel_nfc_exec_op(nc, false); in atmel_hsmc_nand_pmecc_write_pg()
1009 dev_err(nc->base.dev, in atmel_hsmc_nand_pmecc_write_pg()
1049 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_nand_pmecc_read_pg() local
1053 nc = to_hsmc_nand_controller(chip->controller); in atmel_hsmc_nand_pmecc_read_pg()
1064 nc->op.cmds[nc->op.ncmds++] = NAND_CMD_READ0; in atmel_hsmc_nand_pmecc_read_pg()
1067 nc->op.cmds[nc->op.ncmds++] = NAND_CMD_READSTART; in atmel_hsmc_nand_pmecc_read_pg()
1070 nc->op.cs = nand->activecs->id; in atmel_hsmc_nand_pmecc_read_pg()
1071 nc->op.data = ATMEL_NFC_READ_DATA; in atmel_hsmc_nand_pmecc_read_pg()
1077 ret = atmel_nfc_exec_op(nc, false); in atmel_hsmc_nand_pmecc_read_pg()
1080 dev_err(nc->base.dev, in atmel_hsmc_nand_pmecc_read_pg()
1117 struct atmel_nand_controller *nc; in atmel_nand_pmecc_init() local
1120 nc = to_nand_controller(chip->controller); in atmel_nand_pmecc_init()
1122 if (!nc->pmecc) { in atmel_nand_pmecc_init()
1123 dev_err(nc->dev, "HW ECC not supported\n"); in atmel_nand_pmecc_init()
1127 if (nc->caps->legacy_of_bindings) { in atmel_nand_pmecc_init()
1130 if (!of_property_read_u32(nc->dev->of_node, "atmel,pmecc-cap", in atmel_nand_pmecc_init()
1134 if (!of_property_read_u32(nc->dev->of_node, in atmel_nand_pmecc_init()
1167 nand->pmecc = atmel_pmecc_create_user(nc->pmecc, &req); in atmel_nand_pmecc_init()
1185 struct atmel_nand_controller *nc; in atmel_nand_ecc_init() local
1188 nc = to_nand_controller(chip->controller); in atmel_nand_ecc_init()
1211 dev_err(nc->dev, "Unsupported ECC mode: %d\n", in atmel_nand_ecc_init()
1244 struct atmel_nand_controller *nc; in atmel_smc_nand_prepare_smcconf() local
1247 nc = to_nand_controller(nand->base.controller); in atmel_smc_nand_prepare_smcconf()
1262 mckperiodps = NSEC_PER_SEC / clk_get_rate(nc->mck); in atmel_smc_nand_prepare_smcconf()
1473 struct atmel_nand_controller *nc; in atmel_smc_nand_setup_interface() local
1478 nc = to_nand_controller(nand->base.controller); in atmel_smc_nand_setup_interface()
1489 atmel_smc_cs_conf_apply(nc->smc, cs->id, &cs->smcconf); in atmel_smc_nand_setup_interface()
1498 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_nand_setup_interface() local
1503 nc = to_hsmc_nand_controller(nand->base.controller); in atmel_hsmc_nand_setup_interface()
1518 atmel_hsmc_cs_conf_apply(nc->base.smc, nc->hsmc_layout, cs->id, in atmel_hsmc_nand_setup_interface()
1529 struct atmel_nand_controller *nc; in atmel_nand_setup_interface() local
1535 nc = to_nand_controller(nand->base.controller); in atmel_nand_setup_interface()
1541 return nc->caps->ops->setup_interface(nand, csline, conf); in atmel_nand_setup_interface()
1549 struct atmel_nand_controller *nc; 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()
1556 static void atmel_nand_init(struct atmel_nand_controller *nc, in atmel_nand_init() argument
1562 mtd->dev.parent = nc->dev; in atmel_nand_init()
1563 nand->base.controller = &nc->base; in atmel_nand_init()
1565 if (!nc->mck || !nc->caps->ops->setup_interface) in atmel_nand_init()
1572 if (nc->dmac) in atmel_nand_init()
1576 if (nc->pmecc) in atmel_nand_init()
1580 static void atmel_smc_nand_init(struct atmel_nand_controller *nc, in atmel_smc_nand_init() argument
1587 atmel_nand_init(nc, nand); in atmel_smc_nand_init()
1622 static struct atmel_nand *atmel_nand_create(struct atmel_nand_controller *nc, in atmel_nand_create() argument
1633 dev_err(nc->dev, "Missing or invalid reg property\n"); in atmel_nand_create()
1637 nand = devm_kzalloc(nc->dev, struct_size(nand, cs, numcs), GFP_KERNEL); in atmel_nand_create()
1643 gpio = devm_fwnode_gpiod_get(nc->dev, of_fwnode_handle(np), in atmel_nand_create()
1646 dev_err(nc->dev, in atmel_nand_create()
1661 dev_err(nc->dev, "Invalid reg property (err = %d)\n", in atmel_nand_create()
1669 dev_err(nc->dev, "Invalid reg property (err = %d)\n", in atmel_nand_create()
1677 nand->cs[i].io.virt = devm_ioremap_resource(nc->dev, &res); in atmel_nand_create()
1688 gpio = devm_fwnode_gpiod_get_index(nc->dev, in atmel_nand_create()
1693 dev_err(nc->dev, in atmel_nand_create()
1705 gpio = devm_fwnode_gpiod_get_index(nc->dev, in atmel_nand_create()
1710 dev_err(nc->dev, in atmel_nand_create()
1726 atmel_nand_controller_add_nand(struct atmel_nand_controller *nc, in atmel_nand_controller_add_nand() argument
1735 dev_info(nc->dev, "No SmartMedia card inserted.\n"); in atmel_nand_controller_add_nand()
1739 nc->caps->ops->nand_init(nc, nand); in atmel_nand_controller_add_nand()
1743 dev_err(nc->dev, "NAND scan failed: %d\n", ret); in atmel_nand_controller_add_nand()
1749 dev_err(nc->dev, "Failed to register mtd device: %d\n", ret); in atmel_nand_controller_add_nand()
1754 list_add_tail(&nand->node, &nc->chips); in atmel_nand_controller_add_nand()
1760 atmel_nand_controller_remove_nands(struct atmel_nand_controller *nc) in atmel_nand_controller_remove_nands() argument
1765 list_for_each_entry_safe(nand, tmp, &nc->chips, node) { in atmel_nand_controller_remove_nands()
1775 atmel_nand_controller_legacy_add_nands(struct atmel_nand_controller *nc) in atmel_nand_controller_legacy_add_nands() argument
1777 struct device *dev = nc->dev; in atmel_nand_controller_legacy_add_nands()
1787 nand = devm_kzalloc(nc->dev, sizeof(*nand) + sizeof(*nand->cs), in atmel_nand_controller_legacy_add_nands()
1835 gpio = devm_gpiod_get_index_optional(nc->dev, NULL, 2, GPIOD_IN); in atmel_nand_controller_legacy_add_nands()
1845 nand_set_flash_node(&nand->base, nc->dev->of_node); in atmel_nand_controller_legacy_add_nands()
1847 return atmel_nand_controller_add_nand(nc, nand); in atmel_nand_controller_legacy_add_nands()
1850 static int atmel_nand_controller_add_nands(struct atmel_nand_controller *nc) in atmel_nand_controller_add_nands() argument
1853 struct device *dev = nc->dev; in atmel_nand_controller_add_nands()
1858 if (nc->caps->legacy_of_bindings) in atmel_nand_controller_add_nands()
1859 return atmel_nand_controller_legacy_add_nands(nc); in atmel_nand_controller_add_nands()
1882 nand = atmel_nand_create(nc, nand_np, reg_cells); in atmel_nand_controller_add_nands()
1888 ret = atmel_nand_controller_add_nand(nc, nand); in atmel_nand_controller_add_nands()
1896 atmel_nand_controller_remove_nands(nc); in atmel_nand_controller_add_nands()
1901 static void atmel_nand_controller_cleanup(struct atmel_nand_controller *nc) in atmel_nand_controller_cleanup() argument
1903 if (nc->dmac) in atmel_nand_controller_cleanup()
1904 dma_release_channel(nc->dmac); in atmel_nand_controller_cleanup()
1906 clk_put(nc->mck); in atmel_nand_controller_cleanup()
1980 struct atmel_nand_controller *nc = to_nand_controller(chip->controller); in atmel_nand_attach_chip() local
1985 ret = nc->caps->ops->ecc_init(chip); in atmel_nand_attach_chip()
1989 if (nc->caps->legacy_of_bindings || !nc->dev->of_node) { in atmel_nand_attach_chip()
2007 mtd->name = devm_kasprintf(nc->dev, GFP_KERNEL, in atmel_nand_attach_chip()
2008 "%s:nand.%d", dev_name(nc->dev), in atmel_nand_attach_chip()
2011 dev_err(nc->dev, "Failed to allocate mtd->name\n"); in atmel_nand_attach_chip()
2025 static int atmel_nand_controller_init(struct atmel_nand_controller *nc, in atmel_nand_controller_init() argument
2033 nand_controller_init(&nc->base); in atmel_nand_controller_init()
2034 nc->base.ops = &atmel_nand_controller_ops; in atmel_nand_controller_init()
2035 INIT_LIST_HEAD(&nc->chips); in atmel_nand_controller_init()
2036 nc->dev = dev; in atmel_nand_controller_init()
2037 nc->caps = caps; in atmel_nand_controller_init()
2039 platform_set_drvdata(pdev, nc); in atmel_nand_controller_init()
2041 nc->pmecc = devm_atmel_pmecc_get(dev); in atmel_nand_controller_init()
2042 if (IS_ERR(nc->pmecc)) in atmel_nand_controller_init()
2043 return dev_err_probe(dev, PTR_ERR(nc->pmecc), in atmel_nand_controller_init()
2046 if (nc->caps->has_dma && !atmel_nand_avoid_dma) { in atmel_nand_controller_init()
2052 nc->dmac = dma_request_channel(mask, NULL, NULL); in atmel_nand_controller_init()
2053 if (!nc->dmac) in atmel_nand_controller_init()
2054 dev_err(nc->dev, "Failed to request DMA channel\n"); in atmel_nand_controller_init()
2058 if (nc->caps->legacy_of_bindings) in atmel_nand_controller_init()
2061 nc->mck = of_clk_get(dev->parent->of_node, 0); in atmel_nand_controller_init()
2062 if (IS_ERR(nc->mck)) { in atmel_nand_controller_init()
2064 ret = PTR_ERR(nc->mck); in atmel_nand_controller_init()
2075 nc->smc = syscon_node_to_regmap(np); in atmel_nand_controller_init()
2077 if (IS_ERR(nc->smc)) { in atmel_nand_controller_init()
2078 ret = PTR_ERR(nc->smc); in atmel_nand_controller_init()
2086 if (nc->dmac) in atmel_nand_controller_init()
2087 dma_release_channel(nc->dmac); in atmel_nand_controller_init()
2093 atmel_smc_nand_controller_init(struct atmel_smc_nand_controller *nc) in atmel_smc_nand_controller_init() argument
2095 struct device *dev = nc->base.dev; in atmel_smc_nand_controller_init()
2101 if (nc->base.caps->legacy_of_bindings) in atmel_smc_nand_controller_init()
2105 nc->base.caps->ebi_csa_regmap_name, 0); in atmel_smc_nand_controller_init()
2115 nc->ebi_csa_regmap = syscon_node_to_regmap(np); in atmel_smc_nand_controller_init()
2117 if (IS_ERR(nc->ebi_csa_regmap)) { in atmel_smc_nand_controller_init()
2118 ret = PTR_ERR(nc->ebi_csa_regmap); in atmel_smc_nand_controller_init()
2123 nc->ebi_csa = (struct atmel_smc_nand_ebi_csa_cfg *)match->data; in atmel_smc_nand_controller_init()
2131 nc->ebi_csa->offs += 4; in atmel_smc_nand_controller_init()
2137 atmel_hsmc_nand_controller_legacy_init(struct atmel_hsmc_nand_controller *nc) in atmel_hsmc_nand_controller_legacy_init() argument
2145 struct device *dev = nc->base.dev; in atmel_hsmc_nand_controller_legacy_init()
2158 nc->clk = of_clk_get(nfc_np, 0); in atmel_hsmc_nand_controller_legacy_init()
2159 if (IS_ERR(nc->clk)) { in atmel_hsmc_nand_controller_legacy_init()
2160 ret = PTR_ERR(nc->clk); in atmel_hsmc_nand_controller_legacy_init()
2166 ret = clk_prepare_enable(nc->clk); in atmel_hsmc_nand_controller_legacy_init()
2173 nc->irq = of_irq_get(nand_np, 0); in atmel_hsmc_nand_controller_legacy_init()
2174 if (nc->irq <= 0) { in atmel_hsmc_nand_controller_legacy_init()
2175 ret = nc->irq ?: -ENXIO; in atmel_hsmc_nand_controller_legacy_init()
2197 nc->io = devm_regmap_init_mmio(dev, iomem, &regmap_conf); in atmel_hsmc_nand_controller_legacy_init()
2198 if (IS_ERR(nc->io)) { in atmel_hsmc_nand_controller_legacy_init()
2199 ret = PTR_ERR(nc->io); in atmel_hsmc_nand_controller_legacy_init()
2220 nc->base.smc = devm_regmap_init_mmio(dev, iomem, &regmap_conf); in atmel_hsmc_nand_controller_legacy_init()
2221 if (IS_ERR(nc->base.smc)) { in atmel_hsmc_nand_controller_legacy_init()
2222 ret = PTR_ERR(nc->base.smc); in atmel_hsmc_nand_controller_legacy_init()
2235 nc->sram.virt = devm_ioremap_resource(dev, &res); in atmel_hsmc_nand_controller_legacy_init()
2236 if (IS_ERR(nc->sram.virt)) { in atmel_hsmc_nand_controller_legacy_init()
2237 ret = PTR_ERR(nc->sram.virt); in atmel_hsmc_nand_controller_legacy_init()
2241 nc->sram.dma = res.start; in atmel_hsmc_nand_controller_legacy_init()
2250 atmel_hsmc_nand_controller_init(struct atmel_hsmc_nand_controller *nc) in atmel_hsmc_nand_controller_init() argument
2252 struct device *dev = nc->base.dev; in atmel_hsmc_nand_controller_init()
2262 nc->hsmc_layout = atmel_hsmc_get_reg_layout(np); in atmel_hsmc_nand_controller_init()
2264 nc->irq = of_irq_get(np, 0); in atmel_hsmc_nand_controller_init()
2266 if (nc->irq <= 0) { in atmel_hsmc_nand_controller_init()
2267 ret = nc->irq ?: -ENXIO; in atmel_hsmc_nand_controller_init()
2280 nc->io = syscon_node_to_regmap(np); in atmel_hsmc_nand_controller_init()
2282 if (IS_ERR(nc->io)) { in atmel_hsmc_nand_controller_init()
2283 ret = PTR_ERR(nc->io); in atmel_hsmc_nand_controller_init()
2288 nc->sram.pool = of_gen_pool_get(nc->base.dev->of_node, in atmel_hsmc_nand_controller_init()
2290 if (!nc->sram.pool) { in atmel_hsmc_nand_controller_init()
2291 dev_err(nc->base.dev, "Missing SRAM\n"); in atmel_hsmc_nand_controller_init()
2295 nc->sram.virt = (void __iomem *)gen_pool_dma_alloc(nc->sram.pool, in atmel_hsmc_nand_controller_init()
2297 &nc->sram.dma); in atmel_hsmc_nand_controller_init()
2298 if (!nc->sram.virt) { in atmel_hsmc_nand_controller_init()
2299 dev_err(nc->base.dev, in atmel_hsmc_nand_controller_init()
2308 atmel_hsmc_nand_controller_remove(struct atmel_nand_controller *nc) in atmel_hsmc_nand_controller_remove() argument
2313 ret = atmel_nand_controller_remove_nands(nc); in atmel_hsmc_nand_controller_remove()
2317 hsmc_nc = container_of(nc, struct atmel_hsmc_nand_controller, base); in atmel_hsmc_nand_controller_remove()
2331 atmel_nand_controller_cleanup(nc); in atmel_hsmc_nand_controller_remove()
2340 struct atmel_hsmc_nand_controller *nc; in atmel_hsmc_nand_controller_probe() local
2343 nc = devm_kzalloc(dev, sizeof(*nc), GFP_KERNEL); in atmel_hsmc_nand_controller_probe()
2344 if (!nc) in atmel_hsmc_nand_controller_probe()
2347 ret = atmel_nand_controller_init(&nc->base, pdev, caps); in atmel_hsmc_nand_controller_probe()
2352 ret = atmel_hsmc_nand_controller_legacy_init(nc); in atmel_hsmc_nand_controller_probe()
2354 ret = atmel_hsmc_nand_controller_init(nc); in atmel_hsmc_nand_controller_probe()
2360 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_IDR, 0xffffffff); in atmel_hsmc_nand_controller_probe()
2361 ret = devm_request_irq(dev, nc->irq, atmel_nfc_interrupt, in atmel_hsmc_nand_controller_probe()
2362 IRQF_SHARED, "nfc", nc); in atmel_hsmc_nand_controller_probe()
2371 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_CFG, in atmel_hsmc_nand_controller_probe()
2373 regmap_write(nc->base.smc, ATMEL_HSMC_NFC_CTRL, in atmel_hsmc_nand_controller_probe()
2376 ret = atmel_nand_controller_add_nands(&nc->base); in atmel_hsmc_nand_controller_probe()
2383 atmel_hsmc_nand_controller_remove(&nc->base); in atmel_hsmc_nand_controller_probe()
2417 struct atmel_smc_nand_controller *nc; in atmel_smc_nand_controller_probe() local
2420 nc = devm_kzalloc(dev, sizeof(*nc), GFP_KERNEL); in atmel_smc_nand_controller_probe()
2421 if (!nc) in atmel_smc_nand_controller_probe()
2424 ret = atmel_nand_controller_init(&nc->base, pdev, caps); in atmel_smc_nand_controller_probe()
2428 ret = atmel_smc_nand_controller_init(nc); in atmel_smc_nand_controller_probe()
2432 return atmel_nand_controller_add_nands(&nc->base); in atmel_smc_nand_controller_probe()
2436 atmel_smc_nand_controller_remove(struct atmel_nand_controller *nc) in atmel_smc_nand_controller_remove() argument
2440 ret = atmel_nand_controller_remove_nands(nc); in atmel_smc_nand_controller_remove()
2444 atmel_nand_controller_cleanup(nc); in atmel_smc_nand_controller_remove()
2631 struct atmel_nand_controller *nc = platform_get_drvdata(pdev); in atmel_nand_controller_remove() local
2633 WARN_ON(nc->caps->ops->remove(nc)); in atmel_nand_controller_remove()
2640 struct atmel_nand_controller *nc = dev_get_drvdata(dev); in atmel_nand_controller_resume() local
2643 if (nc->pmecc) in atmel_nand_controller_resume()
2644 atmel_pmecc_reset(nc->pmecc); in atmel_nand_controller_resume()
2646 list_for_each_entry(nand, &nc->chips, node) { in atmel_nand_controller_resume()