From cd5689e020865627a184562da91ad03dc7b325aa 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 | 44 ++++++++++++++----- 2 files changed, 46 insertions(+), 11 deletions(-) --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -2514,6 +2514,10 @@ 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 @@ -2525,6 +2529,11 @@ Params: addr Set the 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 (as73211, as7331, hdc3020, hts221, max30102, mpu6050 and mpu9250 only) @@ -2584,6 +2593,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 @@ -534,6 +534,26 @@ #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>; + }; + }; + }; + + fragment@36 { + target = <&i2cbus>; + __dormant__ { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + hts221: hts221@5f { compatible = "st,hts221-humid", "st,hts221"; reg = <0x5f>; @@ -545,7 +565,7 @@ }; }; - fragment@36 { + fragment@37 { target = <&i2cbus>; __dormant__ { #address-cells = <1>; @@ -555,12 +575,11 @@ veml6075: veml6075@10 { compatible = "vishay,veml6075"; reg = <0x10>; - status = "okay"; }; }; }; - fragment@37 { + fragment@38 { target = <&i2cbus>; __dormant__ { #address-cells = <1>; @@ -578,7 +597,7 @@ }; }; - fragment@38 { + fragment@39 { target = <&i2cbus>; __dormant__ { #address-cells = <1>; @@ -596,7 +615,7 @@ }; }; - fragment@39 { + fragment@40 { target = <&i2cbus>; __dormant__ { #address-cells = <1>; @@ -661,11 +680,12 @@ bno055 = <0>,"+31"; sht4x = <0>,"+32"; adt7410 = <0>,"+34"; - hts221 = <0>,"+35+99"; - veml6075 = <0>,"+36"; - hdc3020 = <0>,"+37+99"; - as73211 = <0>,"+38+99"; - as7331 = <0>,"+39+99"; + ina238 = <0>,"+35"; + hts221 = <0>,"+36+99"; + veml6075 = <0>,"+37"; + hdc3020 = <0>,"+38+99"; + as73211 = <0>,"+39+99"; + as7331 = <0>,"+40+99"; addr = <&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0", <&lm75>,"reg:0", <&hdc100x>,"reg:0", <&sht3x>,"reg:0", @@ -675,7 +695,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", <&hdc3020>,"reg:0", <&as73211>,"reg:0", <&as7331>,"reg:0"; int_pin = <&int_pins>, "brcm,pins:0", @@ -689,5 +709,7 @@ <&as7331>, "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"; }; };