Colibri T30 SPI on linux with Iris carrier board

alt text

I compiled the test program listed in Documentation/spi/spidev and I am running it on Colibri T30 with iris Carrier board running linux. I get an error message as shown in the attachment.
“can’t set spi mode: Inappropriate ioctl for device”

I can run the same program on my Raspberry Pi without issues. See attached. I need some pointers on what I am missing on my Colibri setup.

alt text

It is the spidev_test.c program. The T30 supports various modes (see attached).

The same executable file generated by cross compiling in Eclipse runs on Raspberry Pi without errors. Why?

alt text

The same executable file generated by cross compiling in Eclipse runs on Raspberry Pi without errors. Why?
Because Raspberry Pi does not use Tegra. You can’t really compare apples and oranges…

I am not sure what do you mean by “test program”, but I assume that it is spidev_test.c. If so, try to run it with different combinations of clock phase (–cpha) and polarity (–cpol). I have no experience with SPI on T30, but controller and/or driver might be picky about clock settings.

Could you tell us which kernel version are you using? And are you sure that you are compiling spidev_test.c against right kernel headers? It might me important.

This is quite long shot, but I believe that kernel v3.15 had changed format of spi_ioc_transfer structure, so you might need to modify spidev_test.c to work properly. Try zeroing whole structure tr using memset before setting values into individual fields.

I believe the problem is related to the SPI_IOC_WR_MODE32 argument. I am guessing it is only supported for newer kernels. Colibri T30 is perhaps using an older kernel. The version shown for T30 (uname -r) is 3.1.10-2.7.2+ge8678dd

In the spidev_test.c I changed the initialization to the following. It was initially set to SPI_IOC_WR_MODE32 and SPI_IOC_RD_MODE32

After the change I don’t see the message “inappropriate ioctl for device”. And the new program runs on Ras Pi as well.

/* spi mode*/
ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
if (ret == -1)
pabort(“can’t set spi mode”);
ret = ioctl(fd, SPI_IOC_RD_MODE, &mode);
if (ret == -1)
pabort(“can’t get spi mode”);