Lines Matching refs:espi
115 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_calc_divisors() local
116 unsigned long spi_clk_rate = clk_get_rate(espi->clk); in ep93xx_spi_calc_divisors()
150 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_chip_setup() local
173 writel(div_cpsr, espi->mmio + SSPCPSR); in ep93xx_spi_chip_setup()
174 writel(cr0, espi->mmio + SSPCR0); in ep93xx_spi_chip_setup()
181 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_do_write() local
187 val = ((u16 *)xfer->tx_buf)[espi->tx]; in ep93xx_do_write()
188 espi->tx += 2; in ep93xx_do_write()
191 val = ((u8 *)xfer->tx_buf)[espi->tx]; in ep93xx_do_write()
192 espi->tx += 1; in ep93xx_do_write()
194 writel(val, espi->mmio + SSPDR); in ep93xx_do_write()
199 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_do_read() local
203 val = readl(espi->mmio + SSPDR); in ep93xx_do_read()
206 ((u16 *)xfer->rx_buf)[espi->rx] = val; in ep93xx_do_read()
207 espi->rx += 2; in ep93xx_do_read()
210 ((u8 *)xfer->rx_buf)[espi->rx] = val; in ep93xx_do_read()
211 espi->rx += 1; in ep93xx_do_read()
228 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_read_write() local
232 while ((readl(espi->mmio + SSPSR) & SSPSR_RNE)) { in ep93xx_spi_read_write()
234 espi->fifo_level--; in ep93xx_spi_read_write()
238 while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < xfer->len) { in ep93xx_spi_read_write()
240 espi->fifo_level++; in ep93xx_spi_read_write()
243 if (espi->rx == xfer->len) in ep93xx_spi_read_write()
275 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_prepare() local
296 chan = espi->dma_rx; in ep93xx_spi_dma_prepare()
298 sgt = &espi->rx_sgt; in ep93xx_spi_dma_prepare()
300 conf.src_addr = espi->sspdr_phys; in ep93xx_spi_dma_prepare()
303 chan = espi->dma_tx; in ep93xx_spi_dma_prepare()
305 sgt = &espi->tx_sgt; in ep93xx_spi_dma_prepare()
307 conf.dst_addr = espi->sspdr_phys; in ep93xx_spi_dma_prepare()
342 sg_set_page(sg, virt_to_page(espi->zeropage), in ep93xx_spi_dma_prepare()
379 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_finish() local
384 chan = espi->dma_rx; in ep93xx_spi_dma_finish()
385 sgt = &espi->rx_sgt; in ep93xx_spi_dma_finish()
387 chan = espi->dma_tx; in ep93xx_spi_dma_finish()
388 sgt = &espi->tx_sgt; in ep93xx_spi_dma_finish()
406 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_transfer() local
430 dma_async_issue_pending(espi->dma_rx); in ep93xx_spi_dma_transfer()
431 dma_async_issue_pending(espi->dma_tx); in ep93xx_spi_dma_transfer()
440 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_interrupt() local
447 if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) { in ep93xx_spi_interrupt()
449 writel(0, espi->mmio + SSPICR); in ep93xx_spi_interrupt()
473 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_interrupt()
475 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_interrupt()
486 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_transfer_one() local
497 espi->rx = 0; in ep93xx_spi_transfer_one()
498 espi->tx = 0; in ep93xx_spi_transfer_one()
505 if (espi->dma_rx && xfer->len > SPI_FIFO_SIZE) in ep93xx_spi_transfer_one()
511 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_transfer_one()
513 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_transfer_one()
522 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_prepare_message() local
529 while (readl(espi->mmio + SSPSR) & SSPSR_RNE) { in ep93xx_spi_prepare_message()
535 readl(espi->mmio + SSPDR); in ep93xx_spi_prepare_message()
542 espi->fifo_level = 0; in ep93xx_spi_prepare_message()
549 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_prepare_hardware() local
553 ret = clk_prepare_enable(espi->clk); in ep93xx_spi_prepare_hardware()
557 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_prepare_hardware()
559 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_prepare_hardware()
566 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_unprepare_hardware() local
569 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_unprepare_hardware()
571 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_unprepare_hardware()
573 clk_disable_unprepare(espi->clk); in ep93xx_spi_unprepare_hardware()
587 static int ep93xx_spi_setup_dma(struct ep93xx_spi *espi) in ep93xx_spi_setup_dma() argument
592 espi->zeropage = (void *)get_zeroed_page(GFP_KERNEL); in ep93xx_spi_setup_dma()
593 if (!espi->zeropage) in ep93xx_spi_setup_dma()
599 espi->dma_rx_data.port = EP93XX_DMA_SSP; in ep93xx_spi_setup_dma()
600 espi->dma_rx_data.direction = DMA_DEV_TO_MEM; in ep93xx_spi_setup_dma()
601 espi->dma_rx_data.name = "ep93xx-spi-rx"; in ep93xx_spi_setup_dma()
603 espi->dma_rx = dma_request_channel(mask, ep93xx_spi_dma_filter, in ep93xx_spi_setup_dma()
604 &espi->dma_rx_data); in ep93xx_spi_setup_dma()
605 if (!espi->dma_rx) { in ep93xx_spi_setup_dma()
610 espi->dma_tx_data.port = EP93XX_DMA_SSP; in ep93xx_spi_setup_dma()
611 espi->dma_tx_data.direction = DMA_MEM_TO_DEV; in ep93xx_spi_setup_dma()
612 espi->dma_tx_data.name = "ep93xx-spi-tx"; in ep93xx_spi_setup_dma()
614 espi->dma_tx = dma_request_channel(mask, ep93xx_spi_dma_filter, in ep93xx_spi_setup_dma()
615 &espi->dma_tx_data); in ep93xx_spi_setup_dma()
616 if (!espi->dma_tx) { in ep93xx_spi_setup_dma()
624 dma_release_channel(espi->dma_rx); in ep93xx_spi_setup_dma()
625 espi->dma_rx = NULL; in ep93xx_spi_setup_dma()
627 free_page((unsigned long)espi->zeropage); in ep93xx_spi_setup_dma()
632 static void ep93xx_spi_release_dma(struct ep93xx_spi *espi) in ep93xx_spi_release_dma() argument
634 if (espi->dma_rx) { in ep93xx_spi_release_dma()
635 dma_release_channel(espi->dma_rx); in ep93xx_spi_release_dma()
636 sg_free_table(&espi->rx_sgt); in ep93xx_spi_release_dma()
638 if (espi->dma_tx) { in ep93xx_spi_release_dma()
639 dma_release_channel(espi->dma_tx); in ep93xx_spi_release_dma()
640 sg_free_table(&espi->tx_sgt); in ep93xx_spi_release_dma()
643 if (espi->zeropage) in ep93xx_spi_release_dma()
644 free_page((unsigned long)espi->zeropage); in ep93xx_spi_release_dma()
651 struct ep93xx_spi *espi; in ep93xx_spi_probe() local
672 master = spi_alloc_master(&pdev->dev, sizeof(*espi)); in ep93xx_spi_probe()
692 espi = spi_master_get_devdata(master); in ep93xx_spi_probe()
694 espi->clk = devm_clk_get(&pdev->dev, NULL); in ep93xx_spi_probe()
695 if (IS_ERR(espi->clk)) { in ep93xx_spi_probe()
697 error = PTR_ERR(espi->clk); in ep93xx_spi_probe()
705 master->max_speed_hz = clk_get_rate(espi->clk) / 2; in ep93xx_spi_probe()
706 master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); in ep93xx_spi_probe()
708 espi->sspdr_phys = res->start + SSPDR; in ep93xx_spi_probe()
710 espi->mmio = devm_ioremap_resource(&pdev->dev, res); in ep93xx_spi_probe()
711 if (IS_ERR(espi->mmio)) { in ep93xx_spi_probe()
712 error = PTR_ERR(espi->mmio); in ep93xx_spi_probe()
723 if (info->use_dma && ep93xx_spi_setup_dma(espi)) in ep93xx_spi_probe()
727 writel(0, espi->mmio + SSPCR1); in ep93xx_spi_probe()
741 ep93xx_spi_release_dma(espi); in ep93xx_spi_probe()
751 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_remove() local
753 ep93xx_spi_release_dma(espi); in ep93xx_spi_remove()