DESK-RZ-L/Peripherals/I2C

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2025/12/16 DESK-RZ-L-1.x.x release


Peripheral I2C[edit | edit source]

Notice: On the I2C bus B, there is the PCIe clock generator and RTC, which is located in the SoM. If the EVK is used with ConfigID 2003 (I2C B pins used for motors), the PCIe blocks and RTC are not initialized; therefore, no side effects are observed when running motor demos.

Configuration[edit | edit source]

These peripheral(s) can only be used with the following ConfigID(s) (see the associated BOM):

ConfigID Note
2002 Available I2C buses are A and B; the attached devices are split across the two buses
2003 Only I2C bus A is available; all devices except the touch controller and RTC are moved from I2C B to I2C A (I2C B pins are used to drive motors)

Device tree configuration[edit | edit source]

Below is an example of a device tree configuration used on ZERO Evaluation Kit.

From rzt2h-dsab.dtsi (SOM device tree):

...
// I2C B
&i2c1 {
	clock-frequency = <100000>;

	pinctrl-0 = <&i2c1_pins>;
	pinctrl-names = "default";

	rtc@6f {
		compatible = "isil,isl1208";
		reg = <0x6f>;

		//external-oscillator;
	};
};
...
&pinctrl {
...
	i2c1_pins: i2c1 {
		pinmux =    <RZT2H_PORT_PINMUX(5, 0, 0x17)>,    /* P05_0 SDA    | B_AA21 AA10 */
			        <RZT2H_PORT_PINMUX(4, 7, 0x17)>;    /* P04_7 SCL    | B_AA20 AC11 */
	};
};

From rzt2h-eb23-cb2002.dts (I2C A & I2C B):

// I2C A
&i2c0 {
	clock-frequency = <100000>;

	pinctrl-0 = <&i2c0_pins>;
	pinctrl-names = "default";

	status = "okay";

	tlv320aic3100: tlv320aic3100@18 {
		#sound-dai-cells = <0>;
		compatible = "ti,tlv320aic3100";
		reg = <0x18>;
		status = "disable";
	};

	tpl0102_100:tpl0102_100@57 {
		compatible = "tpl0102-104";

		reg = <0x57>;
		status = "disable";
	};

	// PTN5110NHQZ
	ptn5110: tcpc@50 {
		compatible = "nxp,ptn5110";

		reg = <0x50>;
		status = "disable";
	};

	ilitek@41 {
		compatible = "ilitek,ili251x";
		reg = <0x41>;

		vin-supply = <&touch_vdd>;

		interrupt-parent = <&gic>;
		interrupts = <GIC_SPI 70 IRQ_TYPE_EDGE_FALLING>;

		ilitek,irq-gpio = <&pinctrl RZT2H_GPIO(7, 0) GPIO_ACTIVE_LOW>;
		ilitek,reset-gpio = <&exp_1 13 GPIO_ACTIVE_LOW>;
		ilitek,name = "ilitek_i2c";

		touchscreen-size-x = <16384>;
		touchscreen-size-y = <9600>;
	};
};

// I2C B
&i2c1 {
	status = "okay";

	rtc@6f {
		compatible = "isil,isl1208";
		reg = <0x6f>;

		//external-oscillator;
	};

	ina226_cb: ina226@44 {
		compatible = "ti,ina226";
		reg = <0x44>;

		#io-channel-cells = <1>;
		label = "5v_cb";
		
		shunt-resistor = <9000>;
	};

	ina226_som: ina226@45 {
		compatible = "ti,ina226";
		reg = <0x45>;

		#io-channel-cells = <1>;
		label = "5v_som";
		
		shunt-resistor = <9000>;
	};

	// U13
	exp_0: gpio_exp_0@74 {
		compatible = "ti,tca9539";
		reg = <0x74>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;
	};

	// U14
	exp_1: gpio_exp_1@75 {
		compatible = "ti,tca9539";
		reg = <0x75>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;
	};

	// U15
	exp_2: gpio_exp_2@76 {
		compatible = "ti,tca9539";
		reg = <0x76>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;

		pinctrl-names = "default";
		pinctrl-0 = <&tca6424_2_pins>;

		interrupt-controller;
		interrupt-parent = <&gic>;
		interrupts = <GIC_SPI 62 GPIO_ACTIVE_LOW>;
	};
};
...
&pinctrl {
...
	i2c0_pins: i2c0 {
		pinmux =    <RZT2H_PORT_PINMUX(2, 3, 0x17)>,    /* P02_3 SDA    | B_AA15 AF12 */
			        <RZT2H_PORT_PINMUX(2, 4, 0x17)>;    /* P02_4 SCL    | B_AA16 AE12 */
	};
...
};

From rzt2h-eb23-cb2003.dts (only I2C A):


// I2C A
&i2c0 {
	clock-frequency = <100000>;

	pinctrl-0 = <&i2c0_pins>;
	pinctrl-names = "default";

	status = "okay";

	tlv320aic3100: tlv320aic3100@18 {
		#sound-dai-cells = <0>;
		compatible = "ti,tlv320aic3100";
		reg = <0x18>;
		status = "disable";
	};

	tpl0102_100:tpl0102_100@57 {
		compatible = "tpl0102-104";

		reg = <0x57>;
		status = "disable";
	};

	// PTN5110NHQZ
	ptn5110: tcpc@50 {
		compatible = "nxp,ptn5110";

		reg = <0x50>;
		status = "disable";
	};

	ina226_cb: ina226@44 {
		compatible = "ti,ina226";
		reg = <0x44>;

		#io-channel-cells = <1>;
		label = "5v_cb";
		
		shunt-resistor = <9000>;
	};

	ina226_som: ina226@45 {
		compatible = "ti,ina226";
		reg = <0x45>;

		#io-channel-cells = <1>;
		label = "5v_som";
		
		shunt-resistor = <9000>;
	};

	// U13
	exp_0: gpio_exp_0@74 {
		compatible = "ti,tca9539";
		reg = <0x74>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;
	};

	// U14
	exp_1: gpio_exp_1@75 {
		compatible = "ti,tca9539";
		reg = <0x75>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;
	};

	// U15
	exp_2: gpio_exp_2@76 {
		compatible = "ti,tca9539";
		reg = <0x76>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;

		pinctrl-names = "default";
		pinctrl-0 = <&tca6424_2_pins>;

		interrupt-controller;
		interrupt-parent = <&gic>;
		interrupts = <GIC_SPI 62 GPIO_ACTIVE_LOW>;
	};
};

Accessing the peripheral[edit | edit source]

The examples shown are obtained using a board with ConfigID 2002 (both I2C buses A and B present).

Attention:

Touch devices are detected only if they are physically connected to the board. In the following example, the touch device is not present; therefore, the device at address 0x41 is not visible on the I2C bus.

The INA226 devices are expected to be visible by default and usable from Linux at addresses 0x44 and 0x45. Using connector J53, it is possible to disconnect these devices from the on-board I2C bus and instead use them on an external I2C bus, for example, to perform measurements during suspend or in other states where the embedded system cannot access or perform sensor readings.

Refer to the image below for the connector location and additional details.

External INA226 access
Pin Description
1 GND
2 SCL (normally on-board I2C bus); see pin 4 (EN). If EN = GND, use an external I2C bus
3 SDA (normally on-board I2C bus); see pin 4 (EN). If EN = GND, use an external I2C bus
4 EN (normally tied to the voltage level of pin 6); pull to GND to disconnect the INA226 devices
5 NC
6 V_INA

If pin 4 (EN) is left unchanged, the I2C bus can be routed externally.

Linux[edit | edit source]

  • I2C_A is mapped to i2c0
  • I2C_B is mapped to i2c1
...
[   62.385806] i2c-riic 80088000.i2c: registered with 100000Hz bus speed
[   62.439432] i2c-riic 80088400.i2c: registered with 100000Hz bus speed
...
root@desk-t2h-usd-devel:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
root@desk-t2h-usd-devel:~# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- UU UU -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- UU 
70: -- -- -- -- UU UU UU -- 


Example INA226 usage:

root@desk-t2h-usd-devel:~# echo $(cat /sys/class/hwmon/hwmon1/of_node/label)
5v_som
root@desk-t2h-usd-devel:~# cat /sys/class/hwmon/hwmon1/curr1_input 
327
root@desk-t2h-usd-devel:~# echo $(cat /sys/class/hwmon/hwmon0/of_node/label)
5v_cb
root@desk-t2h-usd-devel:~# cat /sys/class/hwmon/hwmon0/curr1_input 
690