imx6 spidev cannot set spi_mode (CPOL = 1)

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

imx6 spidev cannot set spi_mode (CPOL = 1)

1,035 Views
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 

Labels (4)
0 Kudos
3 Replies

873 Views
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 Kudos

873 Views
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 Kudos

873 Views
Carlos_Musich
NXP Employee
NXP Employee

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

0 Kudos