Re: [PATCH v2 2/2] iio: adc: Add support for TI ADS1120

From: Ajith Anandhan

Date: Mon Dec 15 2025 - 12:50:48 EST




Thanks for the pointer.

I did look at reg_shift, but it doesn’t fit this device. With .reg_shift = 2, regmap would send only (reg << 2) (e.g. 0x0c for reg 3).

The ADS1120 requires the command byte to be CMD | (reg << 2) (e.g. 0x20 | 0x0c = 0x2c for an RREG of reg 3).

Similarly,

 .read_flag_mask would produce reg | mask (e.g. 0x03 | 0x20 = 0x23), which is also not the required format.

Unless I’m missing a regmap configuration that can generate (reg << 2) | CMD as a single byte,

a custom regmap bus seems necessary here. Please let me know if there is a way to express this with standard regmap-spi.



Sorry, I didn't read carefully enough. Wouldn't this work though?

.reg_bits = 2,
.reg_shift = 2,
.read_flag_mask = 0x20,
.write_flag_mask = 0x40,


Then a read should be 0x20 | ((reg & 0x3) << 2) and a write should be 0x40 | ((reg & 0x3) << 2).


Yes, that works thanks for spelling it out.
I missed the reg_bits interaction earlier.
I’ll drop the custom regmap bus and switch to standard regmap-spi.