AnsweredAssumed Answered

IMX7 SPI DMA request

Question asked by Cedric Jehasse on Aug 9, 2018
Latest reply on Jun 23, 2019 by caglar abidin



we have an SPI tft display connected to ECSPI3. We're using fbtft for the display driver.

To avoid a gap after every 8bit transfer on SPI, i've backported changes to spi-imx.c from a vanilla 4.14 kernel to the 4.9.88_2.0.0_ga.

When dma is enabled on ecspi3 i get "spi_imx 30840000.ecspi: I/O Error in DMA TX" errors when loading the fbtft driver.

fbtft first sends short transfers to spi which are sent in PIO mode by the SPI driver, then it sends bigger blocks of data sent in DMA mode.

To check what's wrong i mad a script that prints the DMA requests register (SDMAARM_EVT_MIRROR) in a loop when modprobing the driver. The register is either 0x00000000 or 0x00000020.

It seems it's only generating eCSPI3 Rx requests, no Tx requests.


I've found out if i modify the driver to only set ECSPIx_DMAREG for DMA transfer, and clear it for PIO transfers. I don't see have the problem. And polling the DMA request register sometimes shows 0x00000030, meaning eCSPI3 Tx request bit is set.


Is it possible the eCSPI3 Tx DMA request hasn't been set, on Tx empty? Or SDMA has cleared this DMA request before a SDMA transfer was programmed? 


Below is the change that solves the problem

from this:

writel((MX51_ECSPI_DMA_RX_WML(spi_imx->wml) |
          MX51_ECSPI_DMA_TX_WML(tx_wml) |
          MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) |
          MX51_ECSPI_DMA_RXTDEN, spi_imx->base + MX51_ECSPI_DMA);

to this:

writel((spi_imx->usedma ? MX51_ECSPI_DMA_RX_WML(spi_imx->wml) |
          MX51_ECSPI_DMA_TX_WML(tx_wml) |
          MX51_ECSPI_DMA_RXT_WML(spi_imx->wml) |
          MX51_ECSPI_DMA_RXTDEN : 0), spi_imx->base + MX51_ECSPI_DMA);


thanks for the help,