i2c4 pins

  • rhoki wrote: 2024-04-16 0:10 Hello, I wanted to use i2c4 pins on Pico Pro Max board. I connected the device and ran i2cdetect. It finished fast and only shown some reserved address at 0x30. Detect on i2c3 ran normally. After checking board configuration I discovered, that only i2c3 is enabled in rv1106g-luckfox-pico-pro-max.dts file.

    Code: Select all

    /**********I2C**********/
    // &i2c1 {
    // 	status = "okay";
    // 	pinctrl-0 = <&i2c1m1_xfer>;
    // 	clock-frequency = <100000>;
    // };
    &i2c3 {
    	status = "okay";
    	pinctrl-0 = <&i2c3m1_xfer>;
    	clock-frequency = <100000>;
    };
    After some more checking, I have found that in file rv1106-luckfox-pico-pro-max-ipc.dtsi in lines 120-188 i2c4 is configured to work with camera sensor.

    Code: Select all

    &i2c4 {
    	status = "okay";
    	clock-frequency = <400000>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c4m2_xfer>;
    
    	sc3336: sc3336@30 {
    		compatible = "smartsens,sc3336";
    		status = "okay";
    		reg = <0x30>;
    		clocks = <&cru MCLK_REF_MIPI0>;
    		clock-names = "xvclk";
    		pwdn-gpios = <&gpio3 RK_PC5 GPIO_ACTIVE_HIGH>;
    		pinctrl-names = "default";
    		pinctrl-0 = <&mipi_refclk_out0>;
    		...
    		};
    	};
    	...
    };
    Can I configure i2c4 pins for my use without worry? Can I just copy the configuration from i2c3, or should I do some additional configuration?
    Hello, if you need to configure the i2c4 pin, you'll have to add the relevant i2c4 configuration in the corresponding dts file.
    i2c4_m0.jpg

    Code: Select all

    &i2c4 {
    	status = "okay";
    	pinctrl-0 = <&i2c4m0_xfer>;
    	clock-frequency = <100000>;
    };
    

    The specific settings for the i2c4 peripheral are located in rv1106.dtsi under the dts path. The content added in the dts file is equivalent to overriding the settings in the dtsi file. Based on your requirements, you can refer to rv1106.dtsi for more configurations.

    Please note that only one i2c interface (i2c4_m0, i2c4_m1, i2c4_m2) can be enabled for a given set of configurations. Therefore, you'll need to comment out the relevant i2c4 configurations. By default, i2c4_m2 is used for the CSI camera. Since the CSI configuration includes protocol layer, physical layer, and ISP, many nodes are interconnected. If you only comment out the i2c4 node, it will cause the CSI configuration to lose nodes and fail to compile successfully. So, please note that the content you need to comment out includes (csi2_dphy_hw csi2_dphy0 i2c4 mipi0_csi2 rkcif rkcif_mipi_lvds rkcif_mipi_lvds_sditf rkisp rkisp_vir0).

    I hope this helps you.
  • Thank you for the reply.
    So in order to have two sets of i2c pins exposed I will have to use I2c1m1 and one of the i2c3, m0 or m1. Both i2c3m0 and i2c3m1 will not work, is that correct?
  • rhoki wrote: 2024-04-16 10:45 Thank you for the reply.
    So in order to have two sets of i2c pins exposed I will have to use I2c1m1 and one of the i2c3, m0 or m1. Both i2c3m0 and i2c3m1 will not work, is that correct?
    Yes, when using i2c3, you can only select one set of pins (m0/m1) for multiplexing. However, typically, utilizing chip select pins allows you to connect multiple devices to the same i2c interface simultaneously, which may be a preferable option. Of course, if you have high real-time requirements but don't need to achieve the maximum frequency of I2C, you can also use GPIO to simulate I2C, as mentioned in the Rockchip documentation.

    [/attachment]
    gpio_i2c.jpg
    Attachments
    Downloaded 299 times