Hi, I’m unable to communicate with an SPI display connected to the iMX6 with the spidev driver.
I’ve already changed the DTS as stated in your SPI (linux) documentation and the spidev3.0 is correctly shown in /dev/. I’m testing with a C program which works perfectly with an VF61 and T30 (with its respective spidevX.Y changes).
Descriptor is correctly opened, and nor the write nor the read returns any error with the ioctl operation, but nothing is read. This is my init operation:
if (Driver->Board == COLIBRI){
fd = open("/dev/spidev1.0", O_RDWR);
}
else if (Driver->Board == TEGRA){
fd = open("/dev/spidev0.0", O_RDWR);
}
else if (Driver->Board == IMX6){
fd = open("/dev/spidev3.0", O_RDWR);
}
if (fd <= 0){
fprintf(stderr,"can't open spi device: %s\n", strerror(errno));
return -1;
}
mode = SPI_MODE_0 | SPI_LSB_FIRST;
if (ioctl(fd, SPI_IOC_RD_MODE, &mode) < 0){
fprintf(stderr,"SPI rd_mode");
return -1;
}
if (ioctl(fd, SPI_IOC_WR_MODE, &mode) < 0){
fprintf(stderr,"SPI wr_mode");
return -1;
}
if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &mode) < 0){
fprintf(stderr,"SPI rd_lsb_fist");
return -1;
}
if (ioctl(fd, SPI_IOC_WR_LSB_FIRST, &mode) < 0){
fprintf(stderr,"SPI rw_lsb_fist");
return -1;
}
Driver->Transfer[channel][0].delay_usecs = 0, //delay in us
Driver->Transfer[channel][0].speed_hz = 20000000, //speed
Driver->Transfer[channel][0].bits_per_word = 8, // bites per word 8
Driver->Transfer[channel][1].delay_usecs = 0;
Driver->Transfer[channel][1].speed_hz = 20000000;
Driver->Transfer[channel][1].bits_per_word = 8;
Driver->Descriptor[channel] = fd;
Driver struct is as follow:
#define MAX_SPI_BUF 4096UL
#define MAX_SPI_CONNECTIONS 2
typedef unsigned char UCHAR;
typedef unsigned char BOOL;
typedef signed char SCHAR;
typedef char CHAR;
typedef unsigned short int UWORD;
typedef signed short int SWORD;
typedef short int WORD;
typedef unsigned int UDWORD;
typedef signed int SDWORD;
typedef int DWORD;
struct SPIDriver {
UWORD Board;
DWORD Descriptor [MAX_SPI_CONNECTIONS];
BOOL Opened [MAX_SPI_CONNECTIONS];
CHAR Tx [MAX_SPI_BUF];
CHAR Rx [MAX_SPI_BUF];
SWORD ChannelsUsed;
struct spi_ioc_transfer Transfer [MAX_SPI_CONNECTIONS][2]; //0 = Tx, 1 = Rx
UWORD Debug;
} ISpiDriver;
Attached I leave the logic analyzer output for both VF61 and iMX6 respectively. I’m noticing that the CS is not really working the same in both SoC so that could be the issue but it’s beyond what I currently know.
[upload|Whl5pMeJ1LCsNOJDD/EBqdE8ZK4=]
[upload|nZK6imBAoXVhPxg5rjrWV2nv0Ug=]
As additional info, I haven’t made any other changes to the iMX6 DTS but just activating UART4 and 5, in case some GPIO changes are required…
Thanks, Álvaro.