Lines Matching refs:espi
111 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_calc_divisors() local
112 unsigned long spi_clk_rate = clk_get_rate(espi->clk); in ep93xx_spi_calc_divisors()
146 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_chip_setup() local
169 writel(div_cpsr, espi->mmio + SSPCPSR); in ep93xx_spi_chip_setup()
170 writel(cr0, espi->mmio + SSPCR0); in ep93xx_spi_chip_setup()
177 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_do_write() local
183 val = ((u16 *)xfer->tx_buf)[espi->tx]; in ep93xx_do_write()
184 espi->tx += 2; in ep93xx_do_write()
187 val = ((u8 *)xfer->tx_buf)[espi->tx]; in ep93xx_do_write()
188 espi->tx += 1; in ep93xx_do_write()
190 writel(val, espi->mmio + SSPDR); in ep93xx_do_write()
195 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_do_read() local
199 val = readl(espi->mmio + SSPDR); in ep93xx_do_read()
202 ((u16 *)xfer->rx_buf)[espi->rx] = val; in ep93xx_do_read()
203 espi->rx += 2; in ep93xx_do_read()
206 ((u8 *)xfer->rx_buf)[espi->rx] = val; in ep93xx_do_read()
207 espi->rx += 1; in ep93xx_do_read()
224 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_read_write() local
228 while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) { in ep93xx_spi_read_write()
230 espi->fifo_level--; in ep93xx_spi_read_write()
234 while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < xfer->len) { in ep93xx_spi_read_write()
236 espi->fifo_level++; in ep93xx_spi_read_write()
239 if (espi->rx == xfer->len) in ep93xx_spi_read_write()
271 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_dma_prepare() local
292 chan = espi->dma_rx; in ep93xx_spi_dma_prepare()
294 sgt = &espi->rx_sgt; in ep93xx_spi_dma_prepare()
296 conf.src_addr = espi->sspdr_phys; in ep93xx_spi_dma_prepare()
299 chan = espi->dma_tx; in ep93xx_spi_dma_prepare()
301 sgt = &espi->tx_sgt; in ep93xx_spi_dma_prepare()
303 conf.dst_addr = espi->sspdr_phys; in ep93xx_spi_dma_prepare()
338 sg_set_page(sg, virt_to_page(espi->zeropage), in ep93xx_spi_dma_prepare()
375 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_dma_finish() local
380 chan = espi->dma_rx; in ep93xx_spi_dma_finish()
381 sgt = &espi->rx_sgt; in ep93xx_spi_dma_finish()
383 chan = espi->dma_tx; in ep93xx_spi_dma_finish()
384 sgt = &espi->tx_sgt; in ep93xx_spi_dma_finish()
402 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_dma_transfer() local
426 dma_async_issue_pending(espi->dma_rx); in ep93xx_spi_dma_transfer()
427 dma_async_issue_pending(espi->dma_tx); in ep93xx_spi_dma_transfer()
436 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_interrupt() local
443 if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) { in ep93xx_spi_interrupt()
445 writel(0, espi->mmio + SSPICR); in ep93xx_spi_interrupt()
469 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_interrupt()
471 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_interrupt()
482 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_transfer_one() local
493 espi->rx = 0; in ep93xx_spi_transfer_one()
494 espi->tx = 0; in ep93xx_spi_transfer_one()
501 if (espi->dma_rx && xfer->len > SPI_FIFO_SIZE) in ep93xx_spi_transfer_one()
507 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_transfer_one()
509 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_transfer_one()
518 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_prepare_message() local
525 while (readl(espi->mmio + SSPSR) & SSPSR_RNE) { in ep93xx_spi_prepare_message()
531 readl(espi->mmio + SSPDR); in ep93xx_spi_prepare_message()
538 espi->fifo_level = 0; in ep93xx_spi_prepare_message()
545 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_prepare_hardware() local
549 ret = clk_prepare_enable(espi->clk); in ep93xx_spi_prepare_hardware()
553 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_prepare_hardware()
555 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_prepare_hardware()
562 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_unprepare_hardware() local
565 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_unprepare_hardware()
567 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_unprepare_hardware()
569 clk_disable_unprepare(espi->clk); in ep93xx_spi_unprepare_hardware()
574 static int ep93xx_spi_setup_dma(struct device *dev, struct ep93xx_spi *espi) in ep93xx_spi_setup_dma() argument
578 espi->zeropage = (void *)get_zeroed_page(GFP_KERNEL); in ep93xx_spi_setup_dma()
579 if (!espi->zeropage) in ep93xx_spi_setup_dma()
582 espi->dma_rx = dma_request_chan(dev, "rx"); in ep93xx_spi_setup_dma()
583 if (IS_ERR(espi->dma_rx)) { in ep93xx_spi_setup_dma()
584 ret = dev_err_probe(dev, PTR_ERR(espi->dma_rx), "rx DMA setup failed"); in ep93xx_spi_setup_dma()
588 espi->dma_tx = dma_request_chan(dev, "tx"); in ep93xx_spi_setup_dma()
589 if (IS_ERR(espi->dma_tx)) { in ep93xx_spi_setup_dma()
590 ret = dev_err_probe(dev, PTR_ERR(espi->dma_tx), "tx DMA setup failed"); in ep93xx_spi_setup_dma()
597 dma_release_channel(espi->dma_rx); in ep93xx_spi_setup_dma()
598 espi->dma_rx = NULL; in ep93xx_spi_setup_dma()
600 free_page((unsigned long)espi->zeropage); in ep93xx_spi_setup_dma()
605 static void ep93xx_spi_release_dma(struct ep93xx_spi *espi) in ep93xx_spi_release_dma() argument
607 if (espi->dma_rx) { in ep93xx_spi_release_dma()
608 dma_release_channel(espi->dma_rx); in ep93xx_spi_release_dma()
609 sg_free_table(&espi->rx_sgt); in ep93xx_spi_release_dma()
611 if (espi->dma_tx) { in ep93xx_spi_release_dma()
612 dma_release_channel(espi->dma_tx); in ep93xx_spi_release_dma()
613 sg_free_table(&espi->tx_sgt); in ep93xx_spi_release_dma()
616 if (espi->zeropage) in ep93xx_spi_release_dma()
617 free_page((unsigned long)espi->zeropage); in ep93xx_spi_release_dma()
623 struct ep93xx_spi *espi; in ep93xx_spi_probe() local
632 host = spi_alloc_host(&pdev->dev, sizeof(*espi)); in ep93xx_spi_probe()
652 espi = spi_controller_get_devdata(host); in ep93xx_spi_probe()
654 espi->clk = devm_clk_get(&pdev->dev, NULL); in ep93xx_spi_probe()
655 if (IS_ERR(espi->clk)) { in ep93xx_spi_probe()
657 error = PTR_ERR(espi->clk); in ep93xx_spi_probe()
665 host->max_speed_hz = clk_get_rate(espi->clk) / 2; in ep93xx_spi_probe()
666 host->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); in ep93xx_spi_probe()
668 espi->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in ep93xx_spi_probe()
669 if (IS_ERR(espi->mmio)) { in ep93xx_spi_probe()
670 error = PTR_ERR(espi->mmio); in ep93xx_spi_probe()
673 espi->sspdr_phys = res->start + SSPDR; in ep93xx_spi_probe()
682 error = ep93xx_spi_setup_dma(&pdev->dev, espi); in ep93xx_spi_probe()
690 writel(0, espi->mmio + SSPCR1); in ep93xx_spi_probe()
705 ep93xx_spi_release_dma(espi); in ep93xx_spi_probe()
715 struct ep93xx_spi *espi = spi_controller_get_devdata(host); in ep93xx_spi_remove() local
717 ep93xx_spi_release_dma(espi); in ep93xx_spi_remove()