Re: [PATCH v2 4/7] iio: adc: ti-ads1262: Add excitation current support
From: Kurt Borja
Date: Tue Jun 30 2026 - 13:22:18 EST
On Mon Jun 29, 2026 at 7:47 PM -05, Jonathan Cameron wrote:
> On Sun, 28 Jun 2026 00:36:05 -0500
> Kurt Borja <kuurtb@xxxxxxxxx> wrote:
>
>> Support the two IDAC excitation current sources. Each channel can route
>> its IDAC1/IDAC2 outputs to a pin via the "excitation-channels" property
>> and select a magnitude via "excitation-current-nanoamp".
>>
>> Signed-off-by: Kurt Borja <kuurtb@xxxxxxxxx>
>> ---
>> drivers/iio/adc/ti-ads1262.c | 78 ++++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 76 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ti-ads1262.c b/drivers/iio/adc/ti-ads1262.c
>> index ece97a0c2b1304ad..8921eaae537f6b0a 100644
>> --- a/drivers/iio/adc/ti-ads1262.c
>> +++ b/drivers/iio/adc/ti-ads1262.c
>> @@ -193,6 +193,22 @@ enum {
>> ADS1262_INPMUX_LAST
>> };
>>
>> +enum {
>> + ADS1262_IDACMUX_AIN0,
>> + ADS1262_IDACMUX_AIN1,
>> + ADS1262_IDACMUX_AIN2,
>> + ADS1262_IDACMUX_AIN3,
>> + ADS1262_IDACMUX_AIN4,
>> + ADS1262_IDACMUX_AIN5,
>> + ADS1262_IDACMUX_AIN6,
>> + ADS1262_IDACMUX_AIN7,
>> + ADS1262_IDACMUX_AIN8,
>> + ADS1262_IDACMUX_AIN9,
>> + ADS1262_IDACMUX_AINCOM,
>> + ADS1262_IDACMUX_NO_CONN,
>> + ADS1262_IDACMUX_LAST
>
> _LAST usually means inclusive. So probably call this NUM or something like that
> to show that it should be one more than last value.
>
>> +};
>
>> @@ -450,7 +468,7 @@ static int ads1262_dev_read_by_cmd(struct ads1262 *st, u8 cmd, __be32 *val)
>> static int ads1262_channel_enable(struct ads1262 *st,
>> struct ads1262_channel *chan)
>> {
>> - u8 mode0, mode1, mode2, inpmux, refmux;
>> + u8 mode0, mode1, mode2, inpmux, idacmux, idacmag, refmux;
>> int ret;
>>
>> /* Avoid using guard() here to mitigate AB/BA deadlock warning */
>> @@ -464,6 +482,10 @@ static int ads1262_channel_enable(struct ads1262 *st,
>> FIELD_PREP(ADS1262_MODE2_BYPASS_MASK, chan->pga_bypass);
>> inpmux = FIELD_PREP(ADS1262_INPMUX_MUXN_MASK, chan->input[1]) |
>> FIELD_PREP(ADS1262_INPMUX_MUXP_MASK, chan->input[0]);
>> + idacmux = FIELD_PREP(ADS1262_IDACMUX_MUX1_MASK, chan->idac_mux[0]) |
>> + FIELD_PREP(ADS1262_IDACMUX_MUX2_MASK, chan->idac_mux[1]);
>> + idacmag = FIELD_PREP(ADS1262_IDACMAG_MAG1_MASK, chan->idac_mag[0]) |
>> + FIELD_PREP(ADS1262_IDACMAG_MAG2_MASK, chan->idac_mag[1]);
>
> This presumably feeds into the discussion of locking that you were having
> with David, but I'd find this a lot easier to read if these were just
> above where the values are used. Then we can clearly see the match between
> masks and fields. If you have to do it like this, then add variables up
> here for the masks as well.
I'll move them above each regmap calls after reorganizing the locking
stuff.
>
>
>> refmux = FIELD_PREP(ADS1262_REFMUX_RMUXN_MASK, chan->reference[1]) |
>> FIELD_PREP(ADS1262_REFMUX_RMUXP_MASK, chan->reference[0]);
>> mutex_unlock(&st->chan_lock);
--
Thanks,
~ Kurt