Re: [PATCH v1 2/2] iio: adc: Add TI ADS131M0x ADC driver
From: Oleksij Rempel
Date: Fri Nov 07 2025 - 05:29:27 EST
Hi David,
On Thu, Nov 06, 2025 at 10:57:26AM -0600, David Lechner wrote:
> ...
>
> > +/**
> > + * ads131m_rmw_reg - Reads, modifies, and writes a single register.
>
> Any reason we couldn't turn the read/write into a regmap and avoid
> implementing extras like this?
I thought about regmap, but it is a poor fit for this chip.
The problem is the device protocol. It is not a simple register-based device;
it is a frame-based protocol that uses opcodes.
- Hot Path (Data Read): The main data read (in read_raw) does not access
registers. It sends a NULL opcode frame to read all channel data at once.
- Cold Path (Setup): Register access (RREG/WREG) is a complex, stateful
3-cycle operation. It is only used in probe for setup.
This leaves two (bad?) options for regmap:
- Mixed Access: Use regmap only for the cold path (probe) and use raw
for the hot path (read_raw). This is messy because we mix two access methods.
- Virtual Registers: Try to model all opcodes (NULL, RREG, WREG) as virtual
registers. This is a very unnatural abstraction for this chip.
Using the regmap dependency just to replace one rmw function that runs only
once at probe seemed like the overkill.
Best Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |