Lines Matching refs:host

225 static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)  in lpc32xx_nand_setup()  argument
230 writel(SLCCTRL_SW_RESET, SLC_CTRL(host->io_base)); in lpc32xx_nand_setup()
234 writel(0, SLC_CFG(host->io_base)); in lpc32xx_nand_setup()
235 writel(0, SLC_IEN(host->io_base)); in lpc32xx_nand_setup()
237 SLC_ICR(host->io_base)); in lpc32xx_nand_setup()
240 clkrate = clk_get_rate(host->clk); in lpc32xx_nand_setup()
245 tmp = SLCTAC_WDR(host->ncfg->wdr_clks) | in lpc32xx_nand_setup()
246 SLCTAC_WWIDTH(clkrate, host->ncfg->wwidth) | in lpc32xx_nand_setup()
247 SLCTAC_WHOLD(clkrate, host->ncfg->whold) | in lpc32xx_nand_setup()
248 SLCTAC_WSETUP(clkrate, host->ncfg->wsetup) | in lpc32xx_nand_setup()
249 SLCTAC_RDR(host->ncfg->rdr_clks) | in lpc32xx_nand_setup()
250 SLCTAC_RWIDTH(clkrate, host->ncfg->rwidth) | in lpc32xx_nand_setup()
251 SLCTAC_RHOLD(clkrate, host->ncfg->rhold) | in lpc32xx_nand_setup()
252 SLCTAC_RSETUP(clkrate, host->ncfg->rsetup); in lpc32xx_nand_setup()
253 writel(tmp, SLC_TAC(host->io_base)); in lpc32xx_nand_setup()
264 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_cmd_ctrl() local
267 tmp = readl(SLC_CFG(host->io_base)); in lpc32xx_nand_cmd_ctrl()
272 writel(tmp, SLC_CFG(host->io_base)); in lpc32xx_nand_cmd_ctrl()
276 writel(cmd, SLC_CMD(host->io_base)); in lpc32xx_nand_cmd_ctrl()
278 writel(cmd, SLC_ADDR(host->io_base)); in lpc32xx_nand_cmd_ctrl()
288 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_device_ready() local
291 if ((readl(SLC_STAT(host->io_base)) & SLCSTAT_NAND_READY) != 0) in lpc32xx_nand_device_ready()
300 static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host) in lpc32xx_wp_enable() argument
302 if (gpio_is_valid(host->ncfg->wp_gpio)) in lpc32xx_wp_enable()
303 gpio_set_value(host->ncfg->wp_gpio, 0); in lpc32xx_wp_enable()
309 static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host) in lpc32xx_wp_disable() argument
311 if (gpio_is_valid(host->ncfg->wp_gpio)) in lpc32xx_wp_disable()
312 gpio_set_value(host->ncfg->wp_gpio, 1); in lpc32xx_wp_disable()
343 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_read_byte() local
345 return (uint8_t)readl(SLC_DATA(host->io_base)); in lpc32xx_nand_read_byte()
354 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_read_buf() local
358 *buf++ = (uint8_t)readl(SLC_DATA(host->io_base)); in lpc32xx_nand_read_buf()
367 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_write_buf() local
371 writel((uint32_t)*buf++, SLC_DATA(host->io_base)); in lpc32xx_nand_write_buf()
432 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_xmit_dma() local
437 host->dma_slave_config.direction = dir; in lpc32xx_xmit_dma()
438 host->dma_slave_config.src_addr = dma; in lpc32xx_xmit_dma()
439 host->dma_slave_config.dst_addr = dma; in lpc32xx_xmit_dma()
440 host->dma_slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in lpc32xx_xmit_dma()
441 host->dma_slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in lpc32xx_xmit_dma()
442 host->dma_slave_config.src_maxburst = 4; in lpc32xx_xmit_dma()
443 host->dma_slave_config.dst_maxburst = 4; in lpc32xx_xmit_dma()
445 host->dma_slave_config.device_fc = false; in lpc32xx_xmit_dma()
446 if (dmaengine_slave_config(host->dma_chan, &host->dma_slave_config)) { in lpc32xx_xmit_dma()
451 sg_init_one(&host->sgl, mem, len); in lpc32xx_xmit_dma()
453 res = dma_map_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
459 desc = dmaengine_prep_slave_sg(host->dma_chan, &host->sgl, 1, dir, in lpc32xx_xmit_dma()
466 init_completion(&host->comp); in lpc32xx_xmit_dma()
468 desc->callback_param = &host->comp; in lpc32xx_xmit_dma()
471 dma_async_issue_pending(host->dma_chan); in lpc32xx_xmit_dma()
473 wait_for_completion_timeout(&host->comp, msecs_to_jiffies(1000)); in lpc32xx_xmit_dma()
475 dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
480 dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
492 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_xfer() local
505 dma_buf = host->data_buf; in lpc32xx_xfer()
508 memcpy(host->data_buf, buf, mtd->writesize); in lpc32xx_xfer()
512 writel(readl(SLC_CFG(host->io_base)) | in lpc32xx_xfer()
514 SLCCFG_DMA_BURST, SLC_CFG(host->io_base)); in lpc32xx_xfer()
516 writel((readl(SLC_CFG(host->io_base)) | in lpc32xx_xfer()
519 SLC_CFG(host->io_base)); in lpc32xx_xfer()
523 writel(SLCCTRL_ECC_CLEAR, SLC_CTRL(host->io_base)); in lpc32xx_xfer()
526 writel(mtd->writesize, SLC_TC(host->io_base)); in lpc32xx_xfer()
529 writel(readl(SLC_CTRL(host->io_base)) | SLCCTRL_DMA_START, in lpc32xx_xfer()
530 SLC_CTRL(host->io_base)); in lpc32xx_xfer()
534 res = lpc32xx_xmit_dma(mtd, SLC_DMA_DATA(host->io_base_dma), in lpc32xx_xfer()
545 res = lpc32xx_xmit_dma(mtd, SLC_ECC(host->io_base_dma), in lpc32xx_xfer()
546 &host->ecc_buf[i], 4, DMA_DEV_TO_MEM); in lpc32xx_xfer()
558 if (readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO) { in lpc32xx_xfer()
561 while ((readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO) && in lpc32xx_xfer()
573 host->ecc_buf[chip->ecc.steps - 1] = in lpc32xx_xfer()
574 readl(SLC_ECC(host->io_base)); in lpc32xx_xfer()
577 dmaengine_terminate_all(host->dma_chan); in lpc32xx_xfer()
579 if (readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO || in lpc32xx_xfer()
580 readl(SLC_TC(host->io_base))) { in lpc32xx_xfer()
587 writel(readl(SLC_CTRL(host->io_base)) & ~SLCCTRL_DMA_START, in lpc32xx_xfer()
588 SLC_CTRL(host->io_base)); in lpc32xx_xfer()
589 writel(readl(SLC_CFG(host->io_base)) & in lpc32xx_xfer()
591 SLCCFG_DMA_BURST), SLC_CFG(host->io_base)); in lpc32xx_xfer()
594 memcpy(buf, host->data_buf, mtd->writesize); in lpc32xx_xfer()
607 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_read_page_syndrome() local
621 lpc32xx_slc_ecc_copy(tmpecc, (uint32_t *) host->ecc_buf, chip->ecc.steps); in lpc32xx_nand_read_page_syndrome()
669 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_write_page_syndrome() local
682 lpc32xx_slc_ecc_copy(pb, (uint32_t *)host->ecc_buf, chip->ecc.steps); in lpc32xx_nand_write_page_syndrome()
704 static int lpc32xx_nand_dma_setup(struct lpc32xx_nand_host *host) in lpc32xx_nand_dma_setup() argument
706 struct mtd_info *mtd = &host->mtd; in lpc32xx_nand_dma_setup()
709 if (!host->pdata || !host->pdata->dma_filter) { in lpc32xx_nand_dma_setup()
716 host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter, in lpc32xx_nand_dma_setup()
718 if (!host->dma_chan) { in lpc32xx_nand_dma_setup()
762 struct lpc32xx_nand_host *host; in lpc32xx_nand_probe() local
776 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); in lpc32xx_nand_probe()
777 if (!host) in lpc32xx_nand_probe()
779 host->io_base_dma = rc->start; in lpc32xx_nand_probe()
781 host->io_base = devm_ioremap_resource(&pdev->dev, rc); in lpc32xx_nand_probe()
782 if (IS_ERR(host->io_base)) in lpc32xx_nand_probe()
783 return PTR_ERR(host->io_base); in lpc32xx_nand_probe()
786 host->ncfg = lpc32xx_parse_dt(&pdev->dev); in lpc32xx_nand_probe()
787 if (!host->ncfg) { in lpc32xx_nand_probe()
792 if (host->ncfg->wp_gpio == -EPROBE_DEFER) in lpc32xx_nand_probe()
794 if (gpio_is_valid(host->ncfg->wp_gpio) && devm_gpio_request(&pdev->dev, in lpc32xx_nand_probe()
795 host->ncfg->wp_gpio, "NAND WP")) { in lpc32xx_nand_probe()
799 lpc32xx_wp_disable(host); in lpc32xx_nand_probe()
801 host->pdata = dev_get_platdata(&pdev->dev); in lpc32xx_nand_probe()
803 mtd = &host->mtd; in lpc32xx_nand_probe()
804 chip = &host->nand_chip; in lpc32xx_nand_probe()
805 chip->priv = host; in lpc32xx_nand_probe()
811 host->clk = devm_clk_get(&pdev->dev, NULL); in lpc32xx_nand_probe()
812 if (IS_ERR(host->clk)) { in lpc32xx_nand_probe()
817 clk_prepare_enable(host->clk); in lpc32xx_nand_probe()
820 chip->IO_ADDR_R = SLC_DATA(host->io_base); in lpc32xx_nand_probe()
821 chip->IO_ADDR_W = SLC_DATA(host->io_base); in lpc32xx_nand_probe()
827 lpc32xx_nand_setup(host); in lpc32xx_nand_probe()
829 platform_set_drvdata(pdev, host); in lpc32xx_nand_probe()
851 host->dma_buf_len = LPC32XX_DMA_DATA_SIZE + LPC32XX_ECC_SAVE_SIZE; in lpc32xx_nand_probe()
852 host->data_buf = devm_kzalloc(&pdev->dev, host->dma_buf_len, in lpc32xx_nand_probe()
854 if (host->data_buf == NULL) { in lpc32xx_nand_probe()
859 res = lpc32xx_nand_dma_setup(host); in lpc32xx_nand_probe()
872 host->ecc_buf = (uint32_t *)(host->data_buf + LPC32XX_DMA_DATA_SIZE); in lpc32xx_nand_probe()
888 if (host->ncfg->use_bbt) { in lpc32xx_nand_probe()
912 res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts, in lpc32xx_nand_probe()
913 host->ncfg->num_parts); in lpc32xx_nand_probe()
920 dma_release_channel(host->dma_chan); in lpc32xx_nand_probe()
922 clk_disable_unprepare(host->clk); in lpc32xx_nand_probe()
924 lpc32xx_wp_enable(host); in lpc32xx_nand_probe()
935 struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); in lpc32xx_nand_remove() local
936 struct mtd_info *mtd = &host->mtd; in lpc32xx_nand_remove()
939 dma_release_channel(host->dma_chan); in lpc32xx_nand_remove()
942 tmp = readl(SLC_CTRL(host->io_base)); in lpc32xx_nand_remove()
944 writel(tmp, SLC_CTRL(host->io_base)); in lpc32xx_nand_remove()
946 clk_disable_unprepare(host->clk); in lpc32xx_nand_remove()
947 lpc32xx_wp_enable(host); in lpc32xx_nand_remove()
955 struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); in lpc32xx_nand_resume() local
958 clk_prepare_enable(host->clk); in lpc32xx_nand_resume()
961 lpc32xx_nand_setup(host); in lpc32xx_nand_resume()
964 lpc32xx_wp_disable(host); in lpc32xx_nand_resume()
972 struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); in lpc32xx_nand_suspend() local
975 tmp = readl(SLC_CTRL(host->io_base)); in lpc32xx_nand_suspend()
977 writel(tmp, SLC_CTRL(host->io_base)); in lpc32xx_nand_suspend()
980 lpc32xx_wp_enable(host); in lpc32xx_nand_suspend()
983 clk_disable_unprepare(host->clk); in lpc32xx_nand_suspend()