imx6 spidev cannot set spi_mode (CPOL = 1)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

imx6 spidev cannot set spi_mode (CPOL = 1)

1,985件の閲覧回数
jongjyhhsieh
Contributor I

I am trying to use mx6q spidev to control a dac chip.

The chip requires CPOL to be enabled so that SCLK is high at idle and starts out with a falling edge.

I have set the SPI_MODE_2(CPOL =1 , CPHA = 0) from user space via ioctrl to the /dev/spidevX.X and was able to read back the same mode from SPI_IOC_RD_MODE. Though when I send spi data, the oscilloscope wave shows that CPOL remains zero at the idle and starts with a rising edge. 

Is there any other setting required to change SPI_MODE?

any help would be appreciated. 

envrioment:

. imx6q

. linux kernel 3.0.101 

. imx_spi, spi_dev

John 

ラベル(4)
0 件の賞賛
返信
3 返答(返信)

1,823件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Hi John,

how are you setting CPOL? If you set CPOL using memtool does it work?

Regards,

Carlos

0 件の賞賛
返信

1,823件の閲覧回数
jongjyhhsieh
Contributor I

In the userspace, I open the /dev/spidevX.X and set the mode to be "SPI_MODE_2", which is for CPOL = 1. 

After setting, I read the mode back to verified if it is correctly set. 

ioctl(fd, SPI_IOC_WR_MODE, &mode)

ioctl(fd, SPI_IOC_RD_MODE, &mode)

I also added some debug code in imx_spi.c and check if the ECSPI register value change and verified that ECSCPI_CONFIGREG 's SCLK_POL bits are correctly set to be idle high. 

pastedImage_1.png

0 件の賞賛
返信

1,823件の閲覧回数
Carlos_Musich
NXP Employee
NXP Employee

Can you please try setting it with the memtool and let me know if it changes?

0 件の賞賛
返信