Lines Matching refs:host

222 static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)  in lpc32xx_nand_setup()  argument
227 writel(SLCCTRL_SW_RESET, SLC_CTRL(host->io_base)); in lpc32xx_nand_setup()
231 writel(0, SLC_CFG(host->io_base)); in lpc32xx_nand_setup()
232 writel(0, SLC_IEN(host->io_base)); in lpc32xx_nand_setup()
234 SLC_ICR(host->io_base)); in lpc32xx_nand_setup()
237 clkrate = clk_get_rate(host->clk); in lpc32xx_nand_setup()
242 tmp = SLCTAC_WDR(host->ncfg->wdr_clks) | in lpc32xx_nand_setup()
243 SLCTAC_WWIDTH(1 + (clkrate / host->ncfg->wwidth)) | in lpc32xx_nand_setup()
244 SLCTAC_WHOLD(1 + (clkrate / host->ncfg->whold)) | in lpc32xx_nand_setup()
245 SLCTAC_WSETUP(1 + (clkrate / host->ncfg->wsetup)) | in lpc32xx_nand_setup()
246 SLCTAC_RDR(host->ncfg->rdr_clks) | in lpc32xx_nand_setup()
247 SLCTAC_RWIDTH(1 + (clkrate / host->ncfg->rwidth)) | in lpc32xx_nand_setup()
248 SLCTAC_RHOLD(1 + (clkrate / host->ncfg->rhold)) | in lpc32xx_nand_setup()
249 SLCTAC_RSETUP(1 + (clkrate / host->ncfg->rsetup)); in lpc32xx_nand_setup()
250 writel(tmp, SLC_TAC(host->io_base)); in lpc32xx_nand_setup()
261 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_cmd_ctrl() local
264 tmp = readl(SLC_CFG(host->io_base)); in lpc32xx_nand_cmd_ctrl()
269 writel(tmp, SLC_CFG(host->io_base)); in lpc32xx_nand_cmd_ctrl()
273 writel(cmd, SLC_CMD(host->io_base)); in lpc32xx_nand_cmd_ctrl()
275 writel(cmd, SLC_ADDR(host->io_base)); in lpc32xx_nand_cmd_ctrl()
285 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_device_ready() local
288 if ((readl(SLC_STAT(host->io_base)) & SLCSTAT_NAND_READY) != 0) in lpc32xx_nand_device_ready()
297 static void lpc32xx_wp_enable(struct lpc32xx_nand_host *host) in lpc32xx_wp_enable() argument
299 if (gpio_is_valid(host->ncfg->wp_gpio)) in lpc32xx_wp_enable()
300 gpio_set_value(host->ncfg->wp_gpio, 0); in lpc32xx_wp_enable()
306 static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host) in lpc32xx_wp_disable() argument
308 if (gpio_is_valid(host->ncfg->wp_gpio)) in lpc32xx_wp_disable()
309 gpio_set_value(host->ncfg->wp_gpio, 1); in lpc32xx_wp_disable()
340 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_read_byte() local
342 return (uint8_t)readl(SLC_DATA(host->io_base)); in lpc32xx_nand_read_byte()
351 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_read_buf() local
355 *buf++ = (uint8_t)readl(SLC_DATA(host->io_base)); in lpc32xx_nand_read_buf()
364 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_write_buf() local
368 writel((uint32_t)*buf++, SLC_DATA(host->io_base)); in lpc32xx_nand_write_buf()
429 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_xmit_dma() local
434 host->dma_slave_config.direction = dir; in lpc32xx_xmit_dma()
435 host->dma_slave_config.src_addr = dma; in lpc32xx_xmit_dma()
436 host->dma_slave_config.dst_addr = dma; in lpc32xx_xmit_dma()
437 host->dma_slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in lpc32xx_xmit_dma()
438 host->dma_slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in lpc32xx_xmit_dma()
439 host->dma_slave_config.src_maxburst = 4; in lpc32xx_xmit_dma()
440 host->dma_slave_config.dst_maxburst = 4; in lpc32xx_xmit_dma()
442 host->dma_slave_config.device_fc = false; in lpc32xx_xmit_dma()
443 if (dmaengine_slave_config(host->dma_chan, &host->dma_slave_config)) { in lpc32xx_xmit_dma()
448 sg_init_one(&host->sgl, mem, len); in lpc32xx_xmit_dma()
450 res = dma_map_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
456 desc = dmaengine_prep_slave_sg(host->dma_chan, &host->sgl, 1, dir, in lpc32xx_xmit_dma()
463 init_completion(&host->comp); in lpc32xx_xmit_dma()
465 desc->callback_param = &host->comp; in lpc32xx_xmit_dma()
468 dma_async_issue_pending(host->dma_chan); in lpc32xx_xmit_dma()
470 wait_for_completion_timeout(&host->comp, msecs_to_jiffies(1000)); in lpc32xx_xmit_dma()
472 dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
477 dma_unmap_sg(host->dma_chan->device->dev, &host->sgl, 1, in lpc32xx_xmit_dma()
489 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_xfer() local
502 dma_buf = host->data_buf; in lpc32xx_xfer()
505 memcpy(host->data_buf, buf, mtd->writesize); in lpc32xx_xfer()
509 writel(readl(SLC_CFG(host->io_base)) | in lpc32xx_xfer()
511 SLCCFG_DMA_BURST, SLC_CFG(host->io_base)); in lpc32xx_xfer()
513 writel((readl(SLC_CFG(host->io_base)) | in lpc32xx_xfer()
516 SLC_CFG(host->io_base)); in lpc32xx_xfer()
520 writel(SLCCTRL_ECC_CLEAR, SLC_CTRL(host->io_base)); in lpc32xx_xfer()
523 writel(mtd->writesize, SLC_TC(host->io_base)); in lpc32xx_xfer()
526 writel(readl(SLC_CTRL(host->io_base)) | SLCCTRL_DMA_START, in lpc32xx_xfer()
527 SLC_CTRL(host->io_base)); in lpc32xx_xfer()
531 res = lpc32xx_xmit_dma(mtd, SLC_DMA_DATA(host->io_base_dma), in lpc32xx_xfer()
542 res = lpc32xx_xmit_dma(mtd, SLC_ECC(host->io_base_dma), in lpc32xx_xfer()
543 &host->ecc_buf[i], 4, DMA_DEV_TO_MEM); in lpc32xx_xfer()
555 if (readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO) { in lpc32xx_xfer()
558 while ((readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO) && in lpc32xx_xfer()
570 host->ecc_buf[chip->ecc.steps - 1] = in lpc32xx_xfer()
571 readl(SLC_ECC(host->io_base)); in lpc32xx_xfer()
574 dmaengine_terminate_all(host->dma_chan); in lpc32xx_xfer()
576 if (readl(SLC_STAT(host->io_base)) & SLCSTAT_DMA_FIFO || in lpc32xx_xfer()
577 readl(SLC_TC(host->io_base))) { in lpc32xx_xfer()
584 writel(readl(SLC_CTRL(host->io_base)) & ~SLCCTRL_DMA_START, in lpc32xx_xfer()
585 SLC_CTRL(host->io_base)); in lpc32xx_xfer()
586 writel(readl(SLC_CFG(host->io_base)) & in lpc32xx_xfer()
588 SLCCFG_DMA_BURST), SLC_CFG(host->io_base)); in lpc32xx_xfer()
591 memcpy(buf, host->data_buf, mtd->writesize); in lpc32xx_xfer()
604 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_read_page_syndrome() local
618 lpc32xx_slc_ecc_copy(tmpecc, (uint32_t *) host->ecc_buf, chip->ecc.steps); in lpc32xx_nand_read_page_syndrome()
665 struct lpc32xx_nand_host *host = chip->priv; in lpc32xx_nand_write_page_syndrome() local
678 lpc32xx_slc_ecc_copy(pb, (uint32_t *)host->ecc_buf, chip->ecc.steps); in lpc32xx_nand_write_page_syndrome()
700 static int lpc32xx_nand_dma_setup(struct lpc32xx_nand_host *host) in lpc32xx_nand_dma_setup() argument
702 struct mtd_info *mtd = &host->mtd; in lpc32xx_nand_dma_setup()
705 if (!host->pdata || !host->pdata->dma_filter) { in lpc32xx_nand_dma_setup()
712 host->dma_chan = dma_request_channel(mask, host->pdata->dma_filter, in lpc32xx_nand_dma_setup()
714 if (!host->dma_chan) { in lpc32xx_nand_dma_setup()
758 struct lpc32xx_nand_host *host; in lpc32xx_nand_probe() local
772 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); in lpc32xx_nand_probe()
773 if (!host) in lpc32xx_nand_probe()
775 host->io_base_dma = rc->start; in lpc32xx_nand_probe()
777 host->io_base = devm_ioremap_resource(&pdev->dev, rc); in lpc32xx_nand_probe()
778 if (IS_ERR(host->io_base)) in lpc32xx_nand_probe()
779 return PTR_ERR(host->io_base); in lpc32xx_nand_probe()
782 host->ncfg = lpc32xx_parse_dt(&pdev->dev); in lpc32xx_nand_probe()
783 if (!host->ncfg) { in lpc32xx_nand_probe()
788 if (host->ncfg->wp_gpio == -EPROBE_DEFER) in lpc32xx_nand_probe()
790 if (gpio_is_valid(host->ncfg->wp_gpio) && devm_gpio_request(&pdev->dev, in lpc32xx_nand_probe()
791 host->ncfg->wp_gpio, "NAND WP")) { in lpc32xx_nand_probe()
795 lpc32xx_wp_disable(host); in lpc32xx_nand_probe()
797 host->pdata = dev_get_platdata(&pdev->dev); in lpc32xx_nand_probe()
799 mtd = &host->mtd; in lpc32xx_nand_probe()
800 chip = &host->nand_chip; in lpc32xx_nand_probe()
801 chip->priv = host; in lpc32xx_nand_probe()
807 host->clk = devm_clk_get(&pdev->dev, NULL); in lpc32xx_nand_probe()
808 if (IS_ERR(host->clk)) { in lpc32xx_nand_probe()
813 clk_enable(host->clk); in lpc32xx_nand_probe()
816 chip->IO_ADDR_R = SLC_DATA(host->io_base); in lpc32xx_nand_probe()
817 chip->IO_ADDR_W = SLC_DATA(host->io_base); in lpc32xx_nand_probe()
823 lpc32xx_nand_setup(host); in lpc32xx_nand_probe()
825 platform_set_drvdata(pdev, host); in lpc32xx_nand_probe()
847 host->dma_buf_len = LPC32XX_DMA_DATA_SIZE + LPC32XX_ECC_SAVE_SIZE; in lpc32xx_nand_probe()
848 host->data_buf = devm_kzalloc(&pdev->dev, host->dma_buf_len, in lpc32xx_nand_probe()
850 if (host->data_buf == NULL) { in lpc32xx_nand_probe()
855 res = lpc32xx_nand_dma_setup(host); in lpc32xx_nand_probe()
868 host->ecc_buf = (uint32_t *)(host->data_buf + LPC32XX_DMA_DATA_SIZE); in lpc32xx_nand_probe()
884 if (host->ncfg->use_bbt) { in lpc32xx_nand_probe()
908 res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts, in lpc32xx_nand_probe()
909 host->ncfg->num_parts); in lpc32xx_nand_probe()
916 dma_release_channel(host->dma_chan); in lpc32xx_nand_probe()
918 clk_disable(host->clk); in lpc32xx_nand_probe()
920 lpc32xx_wp_enable(host); in lpc32xx_nand_probe()
931 struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); in lpc32xx_nand_remove() local
932 struct mtd_info *mtd = &host->mtd; in lpc32xx_nand_remove()
935 dma_release_channel(host->dma_chan); in lpc32xx_nand_remove()
938 tmp = readl(SLC_CTRL(host->io_base)); in lpc32xx_nand_remove()
940 writel(tmp, SLC_CTRL(host->io_base)); in lpc32xx_nand_remove()
942 clk_disable(host->clk); in lpc32xx_nand_remove()
943 lpc32xx_wp_enable(host); in lpc32xx_nand_remove()
951 struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); in lpc32xx_nand_resume() local
954 clk_enable(host->clk); in lpc32xx_nand_resume()
957 lpc32xx_nand_setup(host); in lpc32xx_nand_resume()
960 lpc32xx_wp_disable(host); in lpc32xx_nand_resume()
968 struct lpc32xx_nand_host *host = platform_get_drvdata(pdev); in lpc32xx_nand_suspend() local
971 tmp = readl(SLC_CTRL(host->io_base)); in lpc32xx_nand_suspend()
973 writel(tmp, SLC_CTRL(host->io_base)); in lpc32xx_nand_suspend()
976 lpc32xx_wp_enable(host); in lpc32xx_nand_suspend()
979 clk_disable(host->clk); in lpc32xx_nand_suspend()