October 2017
Intermediate to advanced
586 pages
14h 8m
English
Its prototype is as follows:
static int probe(struct spi_device *spi)
You may refer to Chapter 7, I2C Client Drivers, in order to see what is to be done in a probe function. The same steps apply here. Therefore, unlike an I2C driver, which has no capability to change the controller bus parameters (CS state, bit per word, clock) at runtime, an SPI driver can. You can set up the bus according to your device properties.
A typical SPI probe function would look like the following:
static int my_probe(struct spi_device *spi) { [...] /* declare your variable/structures */ /* bits_per_word cannot be configured in platform data */ spi->mode = SPI_MODE_0; /* SPI mode */ spi->max_speed_hz = 20000000; /* Max clock for the device ...