AnsweredAssumed Answered

Imx6 How to make all data transfer through dma when using spi communication

Question asked by 其东 刘 on Feb 18, 2019
Latest reply on Feb 24, 2019 by 其东 刘

My kernel version is 3.14.52
My development board is imx6qsabresd
When I use spi to communicate, I find that when the data transmitted is greater than 64 bytes, spi uses dma transmission. When it is less than 64 bytes, it uses pio to transmit.
Check out the code inside spi-imx.c. In the spi_imx_transfer() function, whether to use dma transfer or pio transfer is selected according to the (transfer->len > spi_imx_get_fifosize(spi_imx)) condition.
Now, I want all the data to be transmitted via dma.
I tried to change the ECSPIx_DMAREG register. Remove the conditional restriction (transfer->len > spi_imx_get_fifosize(spi_imx)), forcing spi to use dma transmission. In this way, all data can be transmitted through dma, but the received data is wrong and confusing.

For example, the data I sent is:

         0x0 , 0x1 , 0x2 , 0x3 , 0x4 , 0x5 ,
        0x6 , 0x7 , 0x8 , 0x9 , 0xa , 0xb ,
        0xc , 0xd , 0xe , 0xf , 0x10, 0x11,
        0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
        0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
        0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
        0x24, 0x25, 0x26, 0x27, 0x28, 0x29,

 

The data I receive is:

14 15 16 17 18 19
1A 1B 1C 1D 1E 1F
20 21 22 23 24 25
26 27 28 29 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00

 

I hope everyone can help me.

thank。

Outcomes