]> git.hungrycats.org Git - linux/commit
hwmon: (ina238) Add support for samples and update_interval
authorFerdinand Schwenk <ferdinand.schwenk@advastore.com>
Tue, 9 Jun 2026 19:43:10 +0000 (21:43 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 9 Jun 2026 20:48:13 +0000 (13:48 -0700)
commit1f7a5cfe44bf96bf54ce879339c896598db8e12e
tree5ea8f0491e5be644246101116cf81b3c06dd93ec
parent55c01d37949d215281106a3e532dd56fe678493d
hwmon: (ina238) Add support for samples and update_interval

Expose INA238 ADC averaging count (AVG) and conversion timing
(VBUSCT/VSHCT/VTCT) through chip-level hwmon attributes:

  chip/samples
  chip/update_interval

Use per-chip conversion-time lookup tables so the same helpers work
for INA228/INA237/INA238/INA700/INA780 and SQ52206. Cache ADC_CONFIG
in driver data and update it on writes to avoid extra register reads
during read-modify-write updates.

Report update_interval in milliseconds as required by the hwmon ABI.
Compute it from raw ADC cycle time multiplied by the active averaging
count, and apply the inverse mapping on writes so programmed conversion
time tracks the selected sample count.

Clamp user-provided update_interval before unit scaling to prevent
overflow in arithmetic conversions.

Also combine chip attributes in HWMON_CHANNEL_INFO using a bitwise OR
for a single logical chip channel.

Signed-off-by: Ferdinand Schwenk <ferdinand.schwenk@advastore.com>
Link: https://lore.kernel.org/r/20260609-hwmon-ina238-update-interval-us-v2-v3-1-016b55567950@advastore.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina238.c