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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,037 Views
864535720
Contributor II

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。

Labels (2)
4 Replies

826 Views
art
NXP Employee
NXP Employee

Do you mean that when you try to output the following dataset:

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,

through SPI using DMA, the actual dataset that appears on the physical SPI output is as follows?

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

Please confirm.

0 Kudos

826 Views
864535720
Contributor II

Can you tell me what caused this situation?

0 Kudos

826 Views
864535720
Contributor II

Yes.
This situation has been encountered in the process of debugging.

0 Kudos

826 Views
radhikasomaiya
Senior Contributor II

Hi 其东 刘,

Kindly find my comment in the below mentioned thread :

How does the IMX6 SPI use DMA to transfer data?