Using I2C switch to connect two cameras

Document created by jimmychan Employee on Jul 17, 2015Last modified by jimmychan Employee on Aug 9, 2015
Version 3Show Document
  • View in full screen mode

This is an example to show how to connect two cameras (with same I2C address) on the i.MX6Q board.

 

In this example, the I2C switch is PCA9543A. Two cameras are OV5640 & OV5645. OV5640 is connected to CSI0, and other one OV5645 is connected to MIPI.

 

 

The Linux BSP is L3.0.35. In the your_board.c file, add the following for pca954x.

 

 

static struct pca954x_platform_mode pca954x_modes[] = {

     {

           .adap_id = 4,

           .deselect_on_exit = true,

     },

     {

           .adap_id = 5,

           .deselect_on_exit = true,

     },

};

 

static struct pca954x_platform_data pca954x_data = {

     .modes = pca954x_modes,

     .num_modes = ARRAY_SIZE(pca954x_modes)

};

 

 

 

In this example, the I2C switch is connected to i.MX6Q’s I2C0. The I2C address of the PCA9543A is 0x70.

 

static struct i2c_board_info mxc_i2c0_board_info[] __initdata = {

     {

           I2C_BOARD_INFO("pca9543", 0x70),

           .platform_data = (void *)&pca954x_data,

     },

};

 

The channel 0 of PCA9543A is connected to the I2C of OV5645 MIPI.

 

static struct i2c_board_info mux_i2c4_board_info[] __initdata = {

     {

           I2C_BOARD_INFO("ov5645_mipi", 0x3c),

           .platform_data = (void *)&mipi_csi2_data,

     },

};

 

The channel 1 of PCA9543A is connected to the I2C of OV5640 CSI0.

 

static struct i2c_board_info mux_i2c5_board_info[] __initdata = {

     {

           I2C_BOARD_INFO("ov5640", 0x3c),

           .platform_data = (void *)&csi0_camera_data,

     },

};

 

In the board_init function, register the I2C4 and I2C5.

 

i2c_register_board_info(4, mux_i2c4_board_info,

                ARRAY_SIZE(mux_i2c4_board_info));

 

i2c_register_board_info(5, mux_i2c5_board_info,

                ARRAY_SIZE(mux_i2c5_board_info));

 

Select the PCA954x driver In kernel configuration

  1. In Kernel Configuration, go to Device Drivers --> I2C support --> I2C bus multiplexing support --> Multiplexer I2C Chip support  -->
  2. Select <*> Philips PCA954x I2C Mux/switches

 

Attachments

    Outcomes