Lines Matching refs:espi

118 	struct ep93xx_spi *espi = spi_master_get_devdata(master);  in ep93xx_spi_calc_divisors()  local
119 unsigned long spi_clk_rate = clk_get_rate(espi->clk); in ep93xx_spi_calc_divisors()
153 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()
262 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_prepare() local
283 chan = espi->dma_rx; in ep93xx_spi_dma_prepare()
285 sgt = &espi->rx_sgt; in ep93xx_spi_dma_prepare()
287 conf.src_addr = espi->sspdr_phys; in ep93xx_spi_dma_prepare()
290 chan = espi->dma_tx; in ep93xx_spi_dma_prepare()
292 sgt = &espi->tx_sgt; in ep93xx_spi_dma_prepare()
294 conf.dst_addr = espi->sspdr_phys; in ep93xx_spi_dma_prepare()
329 sg_set_page(sg, virt_to_page(espi->zeropage), in ep93xx_spi_dma_prepare()
365 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_finish() local
370 chan = espi->dma_rx; in ep93xx_spi_dma_finish()
371 sgt = &espi->rx_sgt; in ep93xx_spi_dma_finish()
373 chan = espi->dma_tx; in ep93xx_spi_dma_finish()
374 sgt = &espi->tx_sgt; in ep93xx_spi_dma_finish()
392 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_dma_transfer() local
416 dma_async_issue_pending(espi->dma_rx); in ep93xx_spi_dma_transfer()
417 dma_async_issue_pending(espi->dma_tx); in ep93xx_spi_dma_transfer()
426 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_interrupt() local
433 if (readl(espi->mmio + SSPIIR) & SSPIIR_RORIS) { in ep93xx_spi_interrupt()
435 writel(0, espi->mmio + SSPICR); in ep93xx_spi_interrupt()
459 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_interrupt()
461 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_interrupt()
472 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_transfer_one() local
483 espi->rx = 0; in ep93xx_spi_transfer_one()
484 espi->tx = 0; in ep93xx_spi_transfer_one()
491 if (espi->dma_rx && xfer->len > SPI_FIFO_SIZE) in ep93xx_spi_transfer_one()
497 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_transfer_one()
499 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_transfer_one()
508 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_prepare_message() local
515 while (readl(espi->mmio + SSPSR) & SSPSR_RNE) { in ep93xx_spi_prepare_message()
521 readl(espi->mmio + SSPDR); in ep93xx_spi_prepare_message()
528 espi->fifo_level = 0; in ep93xx_spi_prepare_message()
535 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_prepare_hardware() local
539 ret = clk_enable(espi->clk); in ep93xx_spi_prepare_hardware()
543 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_prepare_hardware()
545 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_prepare_hardware()
552 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_unprepare_hardware() local
555 val = readl(espi->mmio + SSPCR1); in ep93xx_spi_unprepare_hardware()
557 writel(val, espi->mmio + SSPCR1); in ep93xx_spi_unprepare_hardware()
559 clk_disable(espi->clk); in ep93xx_spi_unprepare_hardware()
573 static int ep93xx_spi_setup_dma(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()
585 espi->dma_rx_data.port = EP93XX_DMA_SSP; in ep93xx_spi_setup_dma()
586 espi->dma_rx_data.direction = DMA_DEV_TO_MEM; in ep93xx_spi_setup_dma()
587 espi->dma_rx_data.name = "ep93xx-spi-rx"; in ep93xx_spi_setup_dma()
589 espi->dma_rx = dma_request_channel(mask, ep93xx_spi_dma_filter, in ep93xx_spi_setup_dma()
590 &espi->dma_rx_data); in ep93xx_spi_setup_dma()
591 if (!espi->dma_rx) { in ep93xx_spi_setup_dma()
596 espi->dma_tx_data.port = EP93XX_DMA_SSP; in ep93xx_spi_setup_dma()
597 espi->dma_tx_data.direction = DMA_MEM_TO_DEV; in ep93xx_spi_setup_dma()
598 espi->dma_tx_data.name = "ep93xx-spi-tx"; in ep93xx_spi_setup_dma()
600 espi->dma_tx = dma_request_channel(mask, ep93xx_spi_dma_filter, in ep93xx_spi_setup_dma()
601 &espi->dma_tx_data); in ep93xx_spi_setup_dma()
602 if (!espi->dma_tx) { in ep93xx_spi_setup_dma()
610 dma_release_channel(espi->dma_rx); in ep93xx_spi_setup_dma()
611 espi->dma_rx = NULL; in ep93xx_spi_setup_dma()
613 free_page((unsigned long)espi->zeropage); in ep93xx_spi_setup_dma()
618 static void ep93xx_spi_release_dma(struct ep93xx_spi *espi) in ep93xx_spi_release_dma() argument
620 if (espi->dma_rx) { in ep93xx_spi_release_dma()
621 dma_release_channel(espi->dma_rx); in ep93xx_spi_release_dma()
622 sg_free_table(&espi->rx_sgt); in ep93xx_spi_release_dma()
624 if (espi->dma_tx) { in ep93xx_spi_release_dma()
625 dma_release_channel(espi->dma_tx); in ep93xx_spi_release_dma()
626 sg_free_table(&espi->tx_sgt); in ep93xx_spi_release_dma()
629 if (espi->zeropage) in ep93xx_spi_release_dma()
630 free_page((unsigned long)espi->zeropage); in ep93xx_spi_release_dma()
637 struct ep93xx_spi *espi; in ep93xx_spi_probe() local
661 master = spi_alloc_master(&pdev->dev, sizeof(*espi)); in ep93xx_spi_probe()
700 espi = spi_master_get_devdata(master); in ep93xx_spi_probe()
702 espi->clk = devm_clk_get(&pdev->dev, NULL); in ep93xx_spi_probe()
703 if (IS_ERR(espi->clk)) { in ep93xx_spi_probe()
705 error = PTR_ERR(espi->clk); in ep93xx_spi_probe()
713 master->max_speed_hz = clk_get_rate(espi->clk) / 2; in ep93xx_spi_probe()
714 master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256); in ep93xx_spi_probe()
716 espi->sspdr_phys = res->start + SSPDR; in ep93xx_spi_probe()
718 espi->mmio = devm_ioremap_resource(&pdev->dev, res); in ep93xx_spi_probe()
719 if (IS_ERR(espi->mmio)) { in ep93xx_spi_probe()
720 error = PTR_ERR(espi->mmio); in ep93xx_spi_probe()
731 if (info->use_dma && ep93xx_spi_setup_dma(espi)) in ep93xx_spi_probe()
735 writel(0, espi->mmio + SSPCR1); in ep93xx_spi_probe()
749 ep93xx_spi_release_dma(espi); in ep93xx_spi_probe()
759 struct ep93xx_spi *espi = spi_master_get_devdata(master); in ep93xx_spi_remove() local
761 ep93xx_spi_release_dma(espi); in ep93xx_spi_remove()