Lines Matching +full:nand +full:- +full:ecc +full:- +full:placement
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * NXP LPC32XX NAND SLC driver
24 #include <linux/dma-mapping.h>
30 #include <linux/mtd/nand-ecc-sw-hamming.h>
32 #define LPC32XX_MODNAME "lpc32xx-nand"
35 * SLC NAND controller register offsets
57 #define SLCCTRL_SW_RESET (1 << 2) /* Reset the NAND controller bit */
58 #define SLCCTRL_ECC_CLEAR (1 << 1) /* Reset ECC bit */
65 #define SLCCFG_DMA_ECC (1 << 4) /* Enable DMA ECC bit */
66 #define SLCCFG_ECC_EN (1 << 3) /* ECC enable bit */
76 #define SLCSTAT_NAND_READY (1 << 0) /* NAND device is ready bit */
88 #define SLCTAC_CLOCKS(c, n, s) (min_t(u32, DIV_ROUND_UP(c, n) - 1, 0xF) << s)
110 /* ECC line party fetch macro */
115 * DMA requires storage space for the DMA local buffer and the hardware ECC
122 /* Number of bytes used for ECC stored in NAND per 256 bytes */
126 * If the NAND base clock frequency can't be fetched, this frequency will be
128 * used for NAND accesses.
136 * NAND ECC Layout for small page NAND devices
143 return -ERANGE; in lpc32xx_ooblayout_ecc()
145 oobregion->length = 6; in lpc32xx_ooblayout_ecc()
146 oobregion->offset = 10; in lpc32xx_ooblayout_ecc()
155 return -ERANGE; in lpc32xx_ooblayout_free()
158 oobregion->offset = 0; in lpc32xx_ooblayout_free()
159 oobregion->length = 4; in lpc32xx_ooblayout_free()
161 oobregion->offset = 6; in lpc32xx_ooblayout_free()
162 oobregion->length = 4; in lpc32xx_ooblayout_free()
169 .ecc = lpc32xx_ooblayout_ecc,
201 * NAND platform configuration structure
231 * DMA and CPU addresses of ECC work area and data buffer
243 writel(SLCCTRL_SW_RESET, SLC_CTRL(host->io_base)); in lpc32xx_nand_setup()
247 writel(0, SLC_CFG(host->io_base)); in lpc32xx_nand_setup()
248 writel(0, SLC_IEN(host->io_base)); in lpc32xx_nand_setup()
250 SLC_ICR(host->io_base)); in lpc32xx_nand_setup()
253 clkrate = clk_get_rate(host->clk); in lpc32xx_nand_setup()
258 tmp = SLCTAC_WDR(host->ncfg->wdr_clks) | in lpc32xx_nand_setup()
259 SLCTAC_WWIDTH(clkrate, host->ncfg->wwidth) | in lpc32xx_nand_setup()
260 SLCTAC_WHOLD(clkrate, host->ncfg->whold) | in lpc32xx_nand_setup()
261 SLCTAC_WSETUP(clkrate, host->ncfg->wsetup) | in lpc32xx_nand_setup()
262 SLCTAC_RDR(host->ncfg->rdr_clks) | in lpc32xx_nand_setup()
263 SLCTAC_RWIDTH(clkrate, host->ncfg->rwidth) | in lpc32xx_nand_setup()
264 SLCTAC_RHOLD(clkrate, host->ncfg->rhold) | in lpc32xx_nand_setup()
265 SLCTAC_RSETUP(clkrate, host->ncfg->rsetup); in lpc32xx_nand_setup()
266 writel(tmp, SLC_TAC(host->io_base)); in lpc32xx_nand_setup()
279 tmp = readl(SLC_CFG(host->io_base)); in lpc32xx_nand_cmd_ctrl()
284 writel(tmp, SLC_CFG(host->io_base)); in lpc32xx_nand_cmd_ctrl()
288 writel(cmd, SLC_CMD(host->io_base)); in lpc32xx_nand_cmd_ctrl()
290 writel(cmd, SLC_ADDR(host->io_base)); in lpc32xx_nand_cmd_ctrl()
302 if ((readl(SLC_STAT(host->io_base)) & SLCSTAT_NAND_READY) != 0) in lpc32xx_nand_device_ready()
309 * Enable NAND write protect
313 if (gpio_is_valid(host->ncfg->wp_gpio)) in lpc32xx_wp_enable()
314 gpio_set_value(host->ncfg->wp_gpio, 0); in lpc32xx_wp_enable()
318 * Disable NAND write protect
322 if (gpio_is_valid(host->ncfg->wp_gpio)) in lpc32xx_wp_disable()
323 gpio_set_value(host->ncfg->wp_gpio, 1); in lpc32xx_wp_disable()
327 * Prepares SLC for transfers with H/W ECC enabled
331 /* Hardware ECC is enabled automatically in hardware as needed */ in lpc32xx_nand_ecc_enable()
335 * Calculates the ECC for the data
342 * ECC is calculated automatically in hardware during syndrome read in lpc32xx_nand_ecc_calculate()
357 chip->ecc.size, false); in lpc32xx_nand_ecc_correct()
361 * Read a single byte from NAND device
367 return (uint8_t)readl(SLC_DATA(host->io_base)); in lpc32xx_nand_read_byte()
371 * Simple device read without ECC
377 /* Direct device read with no ECC */ in lpc32xx_nand_read_buf()
378 while (len-- > 0) in lpc32xx_nand_read_buf()
379 *buf++ = (uint8_t)readl(SLC_DATA(host->io_base)); in lpc32xx_nand_read_buf()
383 * Simple device write without ECC
390 /* Direct device write with no ECC */ in lpc32xx_nand_write_buf()
391 while (len-- > 0) in lpc32xx_nand_write_buf()
392 writel((uint32_t)*buf++, SLC_DATA(host->io_base)); in lpc32xx_nand_write_buf()
396 * Read the OOB data from the device without ECC using FIFO method
402 return nand_read_oob_op(chip, page, 0, chip->oob_poi, mtd->oobsize); in lpc32xx_nand_read_oob_syndrome()
406 * Write the OOB data to the device without ECC using FIFO method
412 return nand_prog_page_op(chip, page, mtd->writesize, chip->oob_poi, in lpc32xx_nand_write_oob_syndrome()
413 mtd->oobsize); in lpc32xx_nand_write_oob_syndrome()
417 * Fills in the ECC fields in the OOB buffer with the hardware generated ECC
419 static void lpc32xx_slc_ecc_copy(uint8_t *spare, const uint32_t *ecc, int count) in lpc32xx_slc_ecc_copy() argument
424 uint32_t ce = ecc[i / 3]; in lpc32xx_slc_ecc_copy()
448 host->dma_slave_config.direction = dir; in lpc32xx_xmit_dma()
449 host->dma_slave_config.src_addr = dma; in lpc32xx_xmit_dma()
450 host->dma_slave_config.dst_addr = dma; in lpc32xx_xmit_dma()
451 host->dma_slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in lpc32xx_xmit_dma()
452 host->dma_slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in lpc32xx_xmit_dma()
453 host->dma_slave_config.src_maxburst = 4; in lpc32xx_xmit_dma()
454 host->dma_slave_config.dst_maxburst = 4; in lpc32xx_xmit_dma()
456 host->dma_slave_config.device_fc = false; in lpc32xx_xmit_dma()
457 if (dmaengine_slave_config(host->dma_chan, &host->dma_slave_config)) { in lpc32xx_xmit_dma()
458 dev_err(mtd->dev.parent, "Failed to setup DMA slave\n"); in lpc32xx_xmit_dma()
459 return -ENXIO; in lpc32xx_xmit_dma()
462 sg_init_one(&host->sgl, mem, len); in lpc32xx_xmit_dma()
464 res = dma_map_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
467 dev_err(mtd->dev.parent, "Failed to map sg list\n"); in lpc32xx_xmit_dma()
468 return -ENXIO; in lpc32xx_xmit_dma()
470 desc = dmaengine_prep_slave_sg(host->dma_chan, &host->sgl, 1, dir, in lpc32xx_xmit_dma()
473 dev_err(mtd->dev.parent, "Failed to prepare slave sg\n"); in lpc32xx_xmit_dma()
477 init_completion(&host->comp); in lpc32xx_xmit_dma()
478 desc->callback = lpc32xx_dma_complete_func; in lpc32xx_xmit_dma()
479 desc->callback_param = &host->comp; in lpc32xx_xmit_dma()
482 dma_async_issue_pending(host->dma_chan); in lpc32xx_xmit_dma()
484 wait_for_completion_timeout(&host->comp, msecs_to_jiffies(1000)); in lpc32xx_xmit_dma()
486 dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
491 dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
493 return -ENXIO; in lpc32xx_xmit_dma()
497 * DMA read/write transfers with ECC support
516 dma_buf = host->data_buf; in lpc32xx_xfer()
519 memcpy(host->data_buf, buf, mtd->writesize); in lpc32xx_xfer()
523 writel(readl(SLC_CFG(host->io_base)) | in lpc32xx_xfer()
525 SLCCFG_DMA_BURST, SLC_CFG(host->io_base)); in lpc32xx_xfer()
527 writel((readl(SLC_CFG(host->io_base)) | in lpc32xx_xfer()
530 SLC_CFG(host->io_base)); in lpc32xx_xfer()
533 /* Clear initial ECC */ in lpc32xx_xfer()
534 writel(SLCCTRL_ECC_CLEAR, SLC_CTRL(host->io_base)); in lpc32xx_xfer()
537 writel(mtd->writesize, SLC_TC(host->io_base)); in lpc32xx_xfer()
539 /* Start transfer in the NAND controller */ in lpc32xx_xfer()
540 writel(readl(SLC_CTRL(host->io_base)) | SLCCTRL_DMA_START, in lpc32xx_xfer()
541 SLC_CTRL(host->io_base)); in lpc32xx_xfer()
543 for (i = 0; i < chip->ecc.steps; i++) { in lpc32xx_xfer()
545 res = lpc32xx_xmit_dma(mtd, SLC_DMA_DATA(host->io_base_dma), in lpc32xx_xfer()
546 dma_buf + i * chip->ecc.size, in lpc32xx_xfer()
547 mtd->writesize / chip->ecc.steps, dir); in lpc32xx_xfer()
551 /* Always _read_ ECC */ in lpc32xx_xfer()
552 if (i == chip->ecc.steps - 1) in lpc32xx_xfer()
554 if (!read) /* ECC availability delayed on write */ in lpc32xx_xfer()
556 res = lpc32xx_xmit_dma(mtd, SLC_ECC(host->io_base_dma), in lpc32xx_xfer()
557 &host->ecc_buf[i], 4, DMA_DEV_TO_MEM); in lpc32xx_xfer()
563 * According to NXP, the DMA can be finished here, but the NAND in lpc32xx_xfer()
565 * dmaengine DMA driver (amba-pl080), the condition (DMA_FIFO empty) in lpc32xx_xfer()
569 if (readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO) { in lpc32xx_xfer()
570 dev_warn(mtd->dev.parent, "FIFO not empty!\n"); in lpc32xx_xfer()
572 while ((readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO) && in lpc32xx_xfer()
576 dev_err(mtd->dev.parent, "FIFO held data too long\n"); in lpc32xx_xfer()
577 status = -EIO; in lpc32xx_xfer()
581 /* Read last calculated ECC value */ in lpc32xx_xfer()
584 host->ecc_buf[chip->ecc.steps - 1] = in lpc32xx_xfer()
585 readl(SLC_ECC(host->io_base)); in lpc32xx_xfer()
588 dmaengine_terminate_all(host->dma_chan); in lpc32xx_xfer()
590 if (readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO || in lpc32xx_xfer()
591 readl(SLC_TC(host->io_base))) { in lpc32xx_xfer()
593 dev_err(mtd->dev.parent, "DMA FIFO failure\n"); in lpc32xx_xfer()
594 status = -EIO; in lpc32xx_xfer()
597 /* Stop DMA & HW ECC */ in lpc32xx_xfer()
598 writel(readl(SLC_CTRL(host->io_base)) & ~SLCCTRL_DMA_START, in lpc32xx_xfer()
599 SLC_CTRL(host->io_base)); in lpc32xx_xfer()
600 writel(readl(SLC_CFG(host->io_base)) & in lpc32xx_xfer()
602 SLCCFG_DMA_BURST), SLC_CFG(host->io_base)); in lpc32xx_xfer()
605 memcpy(buf, host->data_buf, mtd->writesize); in lpc32xx_xfer()
611 * Read the data and OOB data from the device, use ECC correction with the
612 * data, disable ECC for the OOB data
626 /* Read data and oob, calculate ECC */ in lpc32xx_nand_read_page_syndrome()
627 status = lpc32xx_xfer(mtd, buf, chip->ecc.steps, 1); in lpc32xx_nand_read_page_syndrome()
630 chip->legacy.read_buf(chip, chip->oob_poi, mtd->oobsize); in lpc32xx_nand_read_page_syndrome()
632 /* Convert to stored ECC format */ in lpc32xx_nand_read_page_syndrome()
633 lpc32xx_slc_ecc_copy(tmpecc, (uint32_t *) host->ecc_buf, chip->ecc.steps); in lpc32xx_nand_read_page_syndrome()
635 /* Pointer to ECC data retrieved from NAND spare area */ in lpc32xx_nand_read_page_syndrome()
640 oobecc = chip->oob_poi + oobregion.offset; in lpc32xx_nand_read_page_syndrome()
642 for (i = 0; i < chip->ecc.steps; i++) { in lpc32xx_nand_read_page_syndrome()
643 stat = chip->ecc.correct(chip, buf, oobecc, in lpc32xx_nand_read_page_syndrome()
644 &tmpecc[i * chip->ecc.bytes]); in lpc32xx_nand_read_page_syndrome()
646 mtd->ecc_stats.failed++; in lpc32xx_nand_read_page_syndrome()
648 mtd->ecc_stats.corrected += stat; in lpc32xx_nand_read_page_syndrome()
650 buf += chip->ecc.size; in lpc32xx_nand_read_page_syndrome()
651 oobecc += chip->ecc.bytes; in lpc32xx_nand_read_page_syndrome()
658 * Read the data and OOB data from the device, no ECC correction with the
671 chip->legacy.read_buf(chip, buf, chip->ecc.size * chip->ecc.steps); in lpc32xx_nand_read_page_raw_syndrome()
672 chip->legacy.read_buf(chip, chip->oob_poi, mtd->oobsize); in lpc32xx_nand_read_page_raw_syndrome()
678 * Write the data and OOB data to the device, use ECC with the data,
679 * disable ECC for the OOB data
693 /* Write data, calculate ECC on outbound data */ in lpc32xx_nand_write_page_syndrome()
694 error = lpc32xx_xfer(mtd, (uint8_t *)buf, chip->ecc.steps, 0); in lpc32xx_nand_write_page_syndrome()
699 * The calculated ECC needs some manual work done to it before in lpc32xx_nand_write_page_syndrome()
700 * committing it to NAND. Process the calculated ECC and place in lpc32xx_nand_write_page_syndrome()
706 pb = chip->oob_poi + oobregion.offset; in lpc32xx_nand_write_page_syndrome()
707 lpc32xx_slc_ecc_copy(pb, (uint32_t *)host->ecc_buf, chip->ecc.steps); in lpc32xx_nand_write_page_syndrome()
709 /* Write ECC data to device */ in lpc32xx_nand_write_page_syndrome()
710 chip->legacy.write_buf(chip, chip->oob_poi, mtd->oobsize); in lpc32xx_nand_write_page_syndrome()
716 * Write the data and OOB data to the device, no ECC correction with the
727 chip->ecc.size * chip->ecc.steps); in lpc32xx_nand_write_page_raw_syndrome()
728 chip->legacy.write_buf(chip, chip->oob_poi, mtd->oobsize); in lpc32xx_nand_write_page_raw_syndrome()
735 struct mtd_info *mtd = nand_to_mtd(&host->nand_chip); in lpc32xx_nand_dma_setup()
738 if (!host->pdata || !host->pdata->dma_filter) { in lpc32xx_nand_dma_setup()
739 dev_err(mtd->dev.parent, "no DMA platform data\n"); in lpc32xx_nand_dma_setup()
740 return -ENOENT; in lpc32xx_nand_dma_setup()
745 host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter, in lpc32xx_nand_dma_setup()
746 "nand-slc"); in lpc32xx_nand_dma_setup()
747 if (!host->dma_chan) { in lpc32xx_nand_dma_setup()
748 dev_err(mtd->dev.parent, "Failed to request DMA channel\n"); in lpc32xx_nand_dma_setup()
749 return -EBUSY; in lpc32xx_nand_dma_setup()
758 struct device_node *np = dev->of_node; in lpc32xx_parse_dt()
764 of_property_read_u32(np, "nxp,wdr-clks", &ncfg->wdr_clks); in lpc32xx_parse_dt()
765 of_property_read_u32(np, "nxp,wwidth", &ncfg->wwidth); in lpc32xx_parse_dt()
766 of_property_read_u32(np, "nxp,whold", &ncfg->whold); in lpc32xx_parse_dt()
767 of_property_read_u32(np, "nxp,wsetup", &ncfg->wsetup); in lpc32xx_parse_dt()
768 of_property_read_u32(np, "nxp,rdr-clks", &ncfg->rdr_clks); in lpc32xx_parse_dt()
769 of_property_read_u32(np, "nxp,rwidth", &ncfg->rwidth); in lpc32xx_parse_dt()
770 of_property_read_u32(np, "nxp,rhold", &ncfg->rhold); in lpc32xx_parse_dt()
771 of_property_read_u32(np, "nxp,rsetup", &ncfg->rsetup); in lpc32xx_parse_dt()
773 if (!ncfg->wdr_clks || !ncfg->wwidth || !ncfg->whold || in lpc32xx_parse_dt()
774 !ncfg->wsetup || !ncfg->rdr_clks || !ncfg->rwidth || in lpc32xx_parse_dt()
775 !ncfg->rhold || !ncfg->rsetup) { in lpc32xx_parse_dt()
780 ncfg->wp_gpio = of_get_named_gpio(np, "gpios", 0); in lpc32xx_parse_dt()
790 if (chip->ecc.engine_type != NAND_ECC_ENGINE_TYPE_ON_HOST) in lpc32xx_nand_attach_chip()
793 /* OOB and ECC CPU and DMA work areas */ in lpc32xx_nand_attach_chip()
794 host->ecc_buf = (uint32_t *)(host->data_buf + LPC32XX_DMA_DATA_SIZE); in lpc32xx_nand_attach_chip()
801 if (mtd->writesize <= 512) in lpc32xx_nand_attach_chip()
804 chip->ecc.placement = NAND_ECC_PLACEMENT_INTERLEAVED; in lpc32xx_nand_attach_chip()
806 chip->ecc.size = 256; in lpc32xx_nand_attach_chip()
807 chip->ecc.strength = 1; in lpc32xx_nand_attach_chip()
808 chip->ecc.bytes = LPC32XX_SLC_DEV_ECC_BYTES; in lpc32xx_nand_attach_chip()
809 chip->ecc.prepad = 0; in lpc32xx_nand_attach_chip()
810 chip->ecc.postpad = 0; in lpc32xx_nand_attach_chip()
811 chip->ecc.read_page_raw = lpc32xx_nand_read_page_raw_syndrome; in lpc32xx_nand_attach_chip()
812 chip->ecc.read_page = lpc32xx_nand_read_page_syndrome; in lpc32xx_nand_attach_chip()
813 chip->ecc.write_page_raw = lpc32xx_nand_write_page_raw_syndrome; in lpc32xx_nand_attach_chip()
814 chip->ecc.write_page = lpc32xx_nand_write_page_syndrome; in lpc32xx_nand_attach_chip()
815 chip->ecc.write_oob = lpc32xx_nand_write_oob_syndrome; in lpc32xx_nand_attach_chip()
816 chip->ecc.read_oob = lpc32xx_nand_read_oob_syndrome; in lpc32xx_nand_attach_chip()
817 chip->ecc.calculate = lpc32xx_nand_ecc_calculate; in lpc32xx_nand_attach_chip()
818 chip->ecc.correct = lpc32xx_nand_ecc_correct; in lpc32xx_nand_attach_chip()
819 chip->ecc.hwctl = lpc32xx_nand_ecc_enable; in lpc32xx_nand_attach_chip()
823 * won't interfere with the ECC layout. Large and huge page in lpc32xx_nand_attach_chip()
826 if ((chip->bbt_options & NAND_BBT_USE_FLASH) && in lpc32xx_nand_attach_chip()
827 mtd->writesize <= 512) { in lpc32xx_nand_attach_chip()
828 chip->bbt_td = &bbt_smallpage_main_descr; in lpc32xx_nand_attach_chip()
829 chip->bbt_md = &bbt_smallpage_mirror_descr; in lpc32xx_nand_attach_chip()
840 * Probe for NAND controller
851 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); in lpc32xx_nand_probe()
853 return -ENOMEM; in lpc32xx_nand_probe()
856 host->io_base = devm_ioremap_resource(&pdev->dev, rc); in lpc32xx_nand_probe()
857 if (IS_ERR(host->io_base)) in lpc32xx_nand_probe()
858 return PTR_ERR(host->io_base); in lpc32xx_nand_probe()
860 host->io_base_dma = rc->start; in lpc32xx_nand_probe()
861 if (pdev->dev.of_node) in lpc32xx_nand_probe()
862 host->ncfg = lpc32xx_parse_dt(&pdev->dev); in lpc32xx_nand_probe()
863 if (!host->ncfg) { in lpc32xx_nand_probe()
864 dev_err(&pdev->dev, in lpc32xx_nand_probe()
865 "Missing or bad NAND config from device tree\n"); in lpc32xx_nand_probe()
866 return -ENOENT; in lpc32xx_nand_probe()
868 if (host->ncfg->wp_gpio == -EPROBE_DEFER) in lpc32xx_nand_probe()
869 return -EPROBE_DEFER; in lpc32xx_nand_probe()
870 if (gpio_is_valid(host->ncfg->wp_gpio) && devm_gpio_request(&pdev->dev, in lpc32xx_nand_probe()
871 host->ncfg->wp_gpio, "NAND WP")) { in lpc32xx_nand_probe()
872 dev_err(&pdev->dev, "GPIO not available\n"); in lpc32xx_nand_probe()
873 return -EBUSY; in lpc32xx_nand_probe()
877 host->pdata = dev_get_platdata(&pdev->dev); in lpc32xx_nand_probe()
879 chip = &host->nand_chip; in lpc32xx_nand_probe()
882 nand_set_flash_node(chip, pdev->dev.of_node); in lpc32xx_nand_probe()
883 mtd->owner = THIS_MODULE; in lpc32xx_nand_probe()
884 mtd->dev.parent = &pdev->dev; in lpc32xx_nand_probe()
886 /* Get NAND clock */ in lpc32xx_nand_probe()
887 host->clk = devm_clk_get(&pdev->dev, NULL); in lpc32xx_nand_probe()
888 if (IS_ERR(host->clk)) { in lpc32xx_nand_probe()
889 dev_err(&pdev->dev, "Clock failure\n"); in lpc32xx_nand_probe()
890 res = -ENOENT; in lpc32xx_nand_probe()
893 res = clk_prepare_enable(host->clk); in lpc32xx_nand_probe()
897 /* Set NAND IO addresses and command/ready functions */ in lpc32xx_nand_probe()
898 chip->legacy.IO_ADDR_R = SLC_DATA(host->io_base); in lpc32xx_nand_probe()
899 chip->legacy.IO_ADDR_W = SLC_DATA(host->io_base); in lpc32xx_nand_probe()
900 chip->legacy.cmd_ctrl = lpc32xx_nand_cmd_ctrl; in lpc32xx_nand_probe()
901 chip->legacy.dev_ready = lpc32xx_nand_device_ready; in lpc32xx_nand_probe()
902 chip->legacy.chip_delay = 20; /* 20us command delay time */ in lpc32xx_nand_probe()
904 /* Init NAND controller */ in lpc32xx_nand_probe()
909 /* NAND callbacks for LPC32xx SLC hardware */ in lpc32xx_nand_probe()
910 chip->legacy.read_byte = lpc32xx_nand_read_byte; in lpc32xx_nand_probe()
911 chip->legacy.read_buf = lpc32xx_nand_read_buf; in lpc32xx_nand_probe()
912 chip->legacy.write_buf = lpc32xx_nand_write_buf; in lpc32xx_nand_probe()
916 * extra space for the spare area and ECC storage area in lpc32xx_nand_probe()
918 host->dma_buf_len = LPC32XX_DMA_DATA_SIZE + LPC32XX_ECC_SAVE_SIZE; in lpc32xx_nand_probe()
919 host->data_buf = devm_kzalloc(&pdev->dev, host->dma_buf_len, in lpc32xx_nand_probe()
921 if (host->data_buf == NULL) { in lpc32xx_nand_probe()
922 res = -ENOMEM; in lpc32xx_nand_probe()
928 res = -EIO; in lpc32xx_nand_probe()
932 /* Find NAND device */ in lpc32xx_nand_probe()
933 chip->legacy.dummy_controller.ops = &lpc32xx_nand_controller_ops; in lpc32xx_nand_probe()
938 mtd->name = "nxp_lpc3220_slc"; in lpc32xx_nand_probe()
939 res = mtd_device_register(mtd, host->ncfg->parts, in lpc32xx_nand_probe()
940 host->ncfg->num_parts); in lpc32xx_nand_probe()
949 dma_release_channel(host->dma_chan); in lpc32xx_nand_probe()
951 clk_disable_unprepare(host->clk); in lpc32xx_nand_probe()
959 * Remove NAND device.
965 struct nand_chip *chip = &host->nand_chip; in lpc32xx_nand_remove()
971 dma_release_channel(host->dma_chan); in lpc32xx_nand_remove()
974 tmp = readl(SLC_CTRL(host->io_base)); in lpc32xx_nand_remove()
976 writel(tmp, SLC_CTRL(host->io_base)); in lpc32xx_nand_remove()
978 clk_disable_unprepare(host->clk); in lpc32xx_nand_remove()
990 /* Re-enable NAND clock */ in lpc32xx_nand_resume()
991 ret = clk_prepare_enable(host->clk); in lpc32xx_nand_resume()
995 /* Fresh init of NAND controller */ in lpc32xx_nand_resume()
1010 tmp = readl(SLC_CTRL(host->io_base)); in lpc32xx_nand_suspend()
1012 writel(tmp, SLC_CTRL(host->io_base)); in lpc32xx_nand_suspend()
1018 clk_disable_unprepare(host->clk); in lpc32xx_nand_suspend()
1029 { .compatible = "nxp,lpc3220-slc" },
1050 MODULE_DESCRIPTION("NAND driver for the NXP LPC32XX SLC controller");