I have a CM4 Compute Module and am trying to set the clock phase on the second SPI channel. But the ioctl() to set mode returns an error whenever I attempt to set this phase bit:
int fd = open("/dev/spidev1.0", O_RDWR); unsigned int mode; mode = 0; // normal clock phase ioctl(fd, SPI_IOC_WR_MODE, &mode); // this works mode = 1; // inverted clock phase ioctl(fd, SPI_IOC_WR_MODE, &mode); // this fails!
I have tried the test program spidev_test.c and it has the same problem. The program errors when adding the flag to set the clock phase:
./spidev_test -D /dev/spidev1.0 --cpha can't set spi mode: Invalid argument Aborted ./spidev_test -D /dev/spidev1.0 spi mode: 4 bits per word: 8 max speed: 500000 Hz (500 KHz) (data follows, i.e. this works)
Is there some reason that clock phase can't be set on spidev1.0? Setting the phase does work on spidev0.0.
Here is my kernel version:
Linux raspberrypi 5.19.0-rc1-v8 #1 SMP PREEMPT Tue Jun 7 21:32:27 UTC 2022 aarch64 GNU/Linux
Can anyone else with a CM4 verify this behavior? The instructions for downloading and building the spidev-test program can be found here: https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/raspberry-pi/spi-bus-on-raspberry-pi.adoc