SPI mode not clocking as configured

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

SPI mode not clocking as configured

跳至解决方案
1,683 次查看
mukelarvin
Contributor IV

Hi I'm having some trouble with the SPI on my IMX6S based Riotboard. I am running Android v4.3 with kernel v3.0.35.

I'm trying to get SPI_MODE3 to work but it appears to always clock out in SPI_MODE0. Has anyone seen this before?

Spidev test program:

root@RIoTboard_6solo:/ # /system/lcdtest/spidev_test -H -O

spi mode: 3

bits per word: 8

max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF

FF FF FF FF FF FF

FF FF FF FF FF FF

FF FF FF FF FF FF

FF FF FF FF FF FF

FF FF FF FF FF FF

FF FF

Output on logic analyser:

spidev_test_mode_3.png

标签 (3)
标记 (2)
0 项奖励
1 解答
1,014 次查看
mukelarvin
Contributor IV

I found a guy who had the same problem and got SPI_MODE_3 working.

SPI_MODE_3 On I.mx6q, ECSPI2

在原帖中查看解决方案

0 项奖励
4 回复数
1,015 次查看
mukelarvin
Contributor IV

I found a guy who had the same problem and got SPI_MODE_3 working.

SPI_MODE_3 On I.mx6q, ECSPI2

0 项奖励
1,014 次查看
mxpencil
Contributor I

Hi, Luke

I had the same problem. Could you share the method you solve it. Thanks!

raohechang@hust.edu.cn

0 项奖励
1,014 次查看
mukelarvin
Contributor IV

Well it looks like they deleted the post that I used as a reference. That's not very helpful.

I think I was able to find the change that I made.

diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c

index be58e17..4bc1b70 100644

--- a/drivers/spi/spi_imx.c

+++ b/drivers/spi/spi_imx.c

@@ -185,6 +185,7 @@ static unsigned int spi_imx_clkdiv_2(unsigned int fin,

#define SPI_IMX2_3_CONFIG_SCLKPOL(cs)  (1 << ((cs) +  4))

#define SPI_IMX2_3_CONFIG_SBBCTRL(cs)  (1 << ((cs) +  8))

#define SPI_IMX2_3_CONFIG_SSBPOL(cs)  (1 << ((cs) + 12))

+#define SPI_IMX2_3_CONFIG_SCLKCTL(cs)    (1 << ((cs) + 20))

#define SPI_IMX2_3_INT        0x10

#define SPI_IMX2_3_INT_TEEN            (1 <<  0)

@@ -276,7 +277,10 @@ static int __maybe_unused spi_imx2_3_config(struct spi_imx_data *spi_imx,

                cfg |= SPI_IMX2_3_CONFIG_SCLKPHA(config->cs);

        if (config->mode & SPI_CPOL)

-              cfg |= SPI_IMX2_3_CONFIG_SCLKPOL(config->cs);

+      {

+              //cfg |= SPI_IMX2_3_CONFIG_SCLKPOL(config->cs);

+              cfg |= SPI_IMX2_3_CONFIG_SCLKCTL(config->cs);

+      }

        if (config->mode & SPI_CS_HIGH)

                cfg |= SPI_IMX2_3_CONFIG_SSBPOL(config->cs);

That may help. Although in the end I ended up bit banging the SPI.

0 项奖励
1,014 次查看
kaisun1
Contributor III

Hi Luke,

               i have the same problem of the spi_mode changge, but i used your method, i found the spi_imx2_3_config have not used ,Pls,give me suggest.

Br

ken

0 项奖励