Same slave address in different mipi sensors

I’m building a driver for a new camera sensor (MIPI). This camera’s I2C slave address is 0x70, so in the device tree definition I’ll set reg = <0x70>. Anyway, there are multiple devices that has this same slave address. How will be the correct driver be called? I’be seen that, for example, IMX274 and IMX185 both have the same 0x70 slave address, but I assume that if one of those sensors is used, the correct driver will be called. Is it in the probe function where it decides which sensor is really connected?

Hi @euskadi,

The first device driver that is loaded will be the “owner” of that address, so other device drivers cannot use the same address because it is already busy (used by the first loaded driver). To avoid that issue, I suggest that when you build the kernel image, only select to build the camera driver that you want to use. This will avoid any issues when loading the drivers.

Another option that allows having several camera drivers (that use the same I2C address) built in your kernel image, is to add a “verify_chip_id()” method in the drivers and call it on the drivers´ probe function. The “verify_chip_id()” method has to read the camera chip id register and verify if it matches with the expected value accordingly to the camera datasheet. If the value doesn’t match with the expected value, the probe function of the drivers will fail and it won’t be loaded. So for example, imagine that you have the IMX274 and IMX185 driver built in your kernel image, and the loading order is first the IMX274 driver and second the IMX185 driver, but you only have the IMX185 camera connected to the board. When the kernel tries to load the IMX274 driver it will fail due to a mismatch in the expected chip_id expected value, so the IMX274 driver won’t be loaded, then the kernel will try to load the IMX185 driver, in this case, the chip_id will match with the expected value and the IMX185 driver will be successfully loaded.

I am not sure of your scenario, but if you want to load two different drivers that use the same slave address and have both cameras connected to the board, you have to do a little trick at driver level that depends on the camera sensor hardware. In this case, you have to check if the camera sensor has a slave address shift register, so you can overwrite the sensor slave address from the driver and avoid conflicts with other drivers using the same address. Or use an I2C expander IC could be an option too.

I hope this information helps you.

Best regards,