From 94de19285cc9bd781394bf1aa4fb8d401aac5195 Mon Sep 17 00:00:00 2001 From: James Sarrett Date: Sun, 26 Jan 2025 11:29:31 -0800 Subject: [PATCH] add ina238 to i2c-sensors This patch adds the ina238 device tree parameters to the i2c-sensors overlay. The ina238 driver needs 2 configuration parameters, shut_resistor and ti,shunt-gain in addition to it's address, so they are added as well. --- arch/arm/boot/dts/overlays/README | 13 ++++++++++ .../boot/dts/overlays/i2c-sensor-common.dtsi | 26 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -2486,11 +2486,20 @@ Params: addr Set the ds1621 Select the Dallas Semiconductors DS1621 temp sensor. Valid addresses 0x48-0x4f, default 0x48 + gain Gain used for measuring shunt resistor current. + Valid values 1 or 4, default 1. (ina238 only, + disabled by default) + hdc100x Select the Texas Instruments HDC100x temp sensor Valid addresses 0x40-0x43, default 0x40 htu21 Select the HTU21 temperature and humidity sensor + ina238 Select the TI INA238 power monitor. Valid + addresses 0x40-0x4F, default 0x40. + Uses parameters shunt-resistor and + ti,shunt-gain for configuration + int_pin Set the GPIO to use for interrupts (max30102, mpu6050 and mpu9250 only) @@ -2549,6 +2558,10 @@ Params: addr Set the reset_pin GPIO to be used to reset the device (bno055 only, disabled by default) + shunt_resistor Value of shunt resistor used for current + measurement in uOhms. (ina238 only, disabled + by default) + sht3x Select the Sensirion SHT3x temperature and humidity sensors. Valid addresses 0x44-0x45, default 0x44 --- a/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi +++ b/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi @@ -526,6 +526,27 @@ }; }; + fragment@35 { + target = <&i2cbus>; + __dormant__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + ina238: ina238@48 { + compatible = "ti,ina238"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x40>; + /* uOhms, uint32_t */ + shunt-resistor = <1000>; + /* 1 or 4, (±40.96 mV or ±163.84 mV) */ + ti,shunt-gain = <1>; + status = "okay"; + }; + }; + }; + fragment@99 { target = <&gpio>; __dormant__ { @@ -573,6 +594,7 @@ bno055 = <0>,"+31"; sht4x = <0>,"+32"; adt7410 = <0>,"+34"; + ina238 = <0>,"+35"; addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0", <&lm75>,"reg:0", <&hdc100x>,"reg:0", <&sht3x>,"reg:0", @@ -582,7 +604,7 @@ <&ms5837>,"reg:0", <&ms8607>,"reg:0", <&mpu6050>,"reg:0", <&mpu9250>,"reg:0", <&bno055>,"reg:0", <&sht4x>,"reg:0", - <&bmp380>,"reg:0", <&adt7410>,"reg:0"; + <&bmp380>,"reg:0", <&adt7410>,"reg:0", <&ina238>,"reg:0"; int_pin = <&int_pins>, "brcm,pins:0", <&int_pins>, "reg:0", <&max30102>, "interrupts:0", @@ -590,5 +612,7 @@ <&mpu9250>, "interrupts:0"; no_timeout = <&jc42>, "smbus-timeout-disable?"; reset_pin = <&bno055>,"reset-gpios:4", <0>,"+30"; + shunt_resistor = <&ina238>,"shunt-resistor:0"; + gain = <&ina238>,"ti,shunt-gain:0"; }; };