I want to access an SPI device (an optical mouse device from Avago Tech) on an embedded Linux system using the SPIDEV driver. The device is connected to SPI0.
I enabled SPI and "User mode SPI device driver support" in menuconfig > "Device Drivers" > "SPI".
I added the code to the board.c file
static struct spi_board_info spidev_board_info[] {
{
.modalias = "spidev",
.max_speed_hz = 1000000,
.bus_num = 1,
.chips_select = 0,
.mode = SPI_MODE_3,
},
{
.modalias = "spidev",
.max_speed_hz = 1000000,
.bus_num = 1,
.chips_select = 1,
.mode = SPI_MODE_3,
},
};
spi_register_board_info(spidev_board_info, ARRAY_SIZE(spidev_board_info));
I tried both 500000 and 1000000 as max_speed_hz (1Mhz being the highest allowed by the sensor). SPI_MODE_3 is correct, checked on the datasheet. bus_num = 1 should correct as it refers to SPI0 (I also tried = 0 out of curiosity).
I checked the electrical connections and are all working.
The kernel compiles and the image starts correctly, but I cannot find any device in /sys/class/spidev/ (neither in /sys/bus/spi/...). No reference to SPI appears during system boot either.
Any idea on where the problem can be?