Recently, I have been writing a camera driver use I2C interface read/write registers, and use spi interface to write firmware data to it. So my question is how to obtain a spi_device pointer in the I2C driver?
Thanks.
Recently, I have been writing a camera driver use I2C interface read/write registers, and use spi interface to write firmware data to it. So my question is how to obtain a spi_device pointer in the I2C driver?
Thanks.
Got the same question as you. After a while of digging in the kernel. I found this: https://elixir.bootlin.com/linux/v4.9.80/source/drivers/media/i2c/s5c73m3/s5c73m3-spi.c#L123. You will need to define an spi_driver in your driver's private data, and then use that to register an SPI driver. In the probe function of SPI, you will be able to retrieve the private data from the pointer of the SPI driver.
Note: I don't know if the same trick works on other versions of Linux kernel. But I think it worth a try.
Why you need SPI handle in I2C driver.Currently I am assuming u mean application i.e. the place where you are writing/reading registers and writing firmware.U need to open both I2C ans SPI instances using the function that is returning the respective handle.