From: "Kurt Borja" <kuurtb@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>, "Kurt Borja" <kuurtb@gmail.com>
Cc: "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH 2/5] iio: adc: Add ti-ads1262 driver
Date: Sun, 14 Jun 2026 15:27:11 -0500 [thread overview]
Message-ID: <DJ91ZV8FQOMZ.YLIC552K4G5D@gmail.com> (raw)
In-Reply-To: <20260613144544.0594a7f0@jic23-huawei>
Hi Jonathan,
On Sat Jun 13, 2026 at 8:45 AM -05, Jonathan Cameron wrote:
> On Fri, 12 Jun 2026 17:46:20 -0500
> Kurt Borja <kuurtb@gmail.com> wrote:
>
>> Add ti-ads1262 driver for TI ADS1262 and ADS1263 ADCs with initial
>> support for the following features:
>>
>> - Power management
>> - IIO direct and buffer modes
>> - Channel hot-reloading
>> - Internal or external oscillator
>> - Internal or external voltage reference
>> - Filter configuration
>> - Sensor bias configuration
>> - IDAC configuration
>> - Level-shift voltage configuration
>> - Auxiliary ADC interoperability considerations
>>
>> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
>> ---
>> MAINTAINERS | 1 +
>> drivers/iio/adc/Kconfig | 13 +
>> drivers/iio/adc/Makefile | 1 +
>> drivers/iio/adc/ti-ads1262.c | 1816 ++++++++++++++++++++++++++++++++++++++++++
>
> That is rather too big. I think you'll have to work out how to split this
> up into more manageable chunks. Staying under a 1000 (preferably a lot less)
> per patch makes it much easier for people to review.
>
> Given the complexity of the device this might be one that has to go
> in as several series, building up functionality as we go.
I'll split it up as much as possible for next version.
I was thinking of taking out the hot-reloading stuff for a follow-up
series. In that case I would also add IIO_ACQUIRE_BUFFER_MODE().
What do you think?
>
> I'll ignore all the DT stuff as sounds like that may radically change and
> just take a fairly superficial first look at this.
Yes, I will just address Krzysztof comments and leave that patch until
we can discuss it with David.
>
> Jonathan
>
[...]
>> +#include <linux/lockdep.h>
>
> Fairly unusual to see that header in a driver.
> What's it here for?
I included it for lockdep_assert_held().
[...]
>> +/* IDACMAG constants */
>> +#define ADS1262_IDACMAG_OFF 0
>> +#define ADS1262_IDACMAG_COUNT 11
>> +
>> +/* REFMUX constants */
>
> Naming is good enough I'm not sure I'd bother with the comments
> to say what these are.
>
> On option is to just group them with the register they are about
> and using extra indenting to visually separate them from the register
>
> #define ADS1262_REFMUX_REG 0xxx
> #define ADS1262_REFMUX_RMUXP_MASK GENMASK(5, 3)
> #define ADS1262_RMUX_INTER 0
> #define ADS1262_RMUX_AIN0_AIN1 1
> #define ADS1262_RMUX_AIN2_AIN3 2
> #define ADS1262_RMUX_AIN4_AIN5 3
> #define ADS1262_RMUX_AVDD_AVSS 4
> #define ADS1262_RMUX_COUNT 5
I like this...
> However, if you are going to have a terminating entry, an anonymous enum might be better
> with that just as the last item.
...but this sounds good too. I'll go for what looks more organized.
>
> #define ADS1262_REFMUX_RMUXN_MASK GENMASK(2, 0)
>
>
>> +#define ADS1262_RMUX_INTER 0
>> +#define ADS1262_RMUX_AIN0_AIN1 1
>> +#define ADS1262_RMUX_AIN2_AIN3 2
>> +#define ADS1262_RMUX_AIN4_AIN5 3
>> +#define ADS1262_RMUX_AVDD_AVSS 4
>> +#define ADS1262_RMUX_COUNT 5
>> +
>> +struct ads1262_channel {
>
> As a general rule we tend to avoid bitfields because of all the problems
> with how loose the C spec is on how these actually get laid out.
> I'd just have this as a suitable 32 bit value and then have
> defines for masks within that.
Are you suggesting storing this whole struct data as a u32 and
reading/writing with FIELD_*() helpers? I think that may be less
readable but it would save memory. I don't know if I understood
correctly though.
I'm dropping the bitfield approach for next version anyway.
[...]
>> +struct ads1262 {
>> + struct spi_device *spi;
>> + struct regmap *regmap;
>> + struct iio_dev *indio_dev;
>> + struct iio_trigger *trig;
>> + struct gpio_desc *reset_gpiod;
>> + struct gpio_desc *start_gpiod;
>> +
>> + void *scan_buffer;
> I think this is always accessed as a __be32. If so just type it as that.
I was hesitant to do that because of the space reserved at the end for
the timestamp. Didn't feel right to assign __be32 when it would actually
be something like
struct {
__be32 buff;
aligned_s64 ts;
};
But I have no problem doing it.
[...]
>> +static int ads1262_fill_buffer_mult(struct ads1262 *st)
>> +{
>> + __be32 val, *scan_buffer = st->scan_buffer;
>
> Avoid mixing pointer and no point, or anything with assignments
> as it makes the code harder to read.
>
>> + unsigned int chan;
>> + int i = -1;
>> + int ret;
>> +
>> + /*
>> + * This routine enables and reads channels in a full-duplex fashion.
>> + *
>> + * When a channel is enabled, the previous conversion is clocked out of
>> + * the shift data register on the same transfer (Section 9.4.7.1). This
>> + * allows for low latency software sequencing but forbids any SPI
>> + * activity happen in between or data corruption may occur, hence the
>> + * need to take the xfer_lock for the whole operation.
>> + */
>
> Just to check: Is SPI traffic on the same bus to a different device fine?
> If not you'd need spi_bus_lock(). If it is fine then reword this to talk about
> communications with this device just to avoid confusion.
Yes, to a different device is fine. I'll reword it.
[...]
>> +static int ads1262_read_chip_name(struct ads1262 *st, char **name)
>> +{
>> + struct device *dev = &st->spi->dev;
>> + u8 dev_id;
>> + unsigned int val;
>> + int ret;
>> +
>> + ret = regmap_read(st->regmap, ADS1262_ID_REG, &val);
>> + if (ret)
>> + return ret;
>> +
>> + dev_id = FIELD_GET(ADS1262_DEV_ID_MASK, val);
>> +
>> + switch (dev_id) {
>> + case ADS1262_DEV_ID_ADS1262:
>> + *name = "ads1262";
>
> Given, at somepoint I would guess you'll want to support the auxiliary adc
> on the 1263, I'd start with a struct chip_info (with the name in there)
> and pick that rather than just the name here.
Makes sense. In that case I can add a dev_warn if the name doesn't match
the internal model. Would that be ok or would you prefer dev_dbg?
>
>> + break;
>> + case ADS1262_DEV_ID_ADS1263:
> Not particularly important but common practice to just change the prefix
> for anything device specific.
> case ADS1263_DEV_ID
Good to know!
>
>> + *name = "ads1263";
>> + break;
>> + default:
>> + *name = "ads1262";
> Given we'll ultimately want fallback compatibles to work and so allow
> for firmware to specify which device to fallback to, this should really be
> using the guidance from firmware to select rather than always guessing
> the 1262 variant. That is safe though given the 'subset' nature so this
> doesn't matter as much as it normally does.
Agreed.
[...]
>> +static const struct reg_default ads1262_reg_defaults[] = {
>> + { ADS1262_POWER_REG, 0x11 },
>
> Is it sensible to specify these in terms of the fields that make them up?
> Can make it easier to see what the default state actually means.
> Sometimes it is just too complex, so we don't bother.
I prefer not to do it because it would be too complex. I'll try though.
[...]
>> +MODULE_DESCRIPTION("Texas Instruments ADS1262 ADC driver");
>> +MODULE_LICENSE("GPL");
>> +MODULE_AUTHOR("Kurt Borja <kuurtb@gmail.com>");
>>
Ack to the rest of comments!
--
Thanks,
~ Kurt
next prev parent reply other threads:[~2026-06-14 20:27 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 22:46 [PATCH 0/5] iio: adc: Add TI ADS126X ADC family support Kurt Borja
2026-06-12 22:46 ` [PATCH 1/5] dt-bindings: iio: adc: Add TI ADS126x ADC family Kurt Borja
2026-06-12 22:53 ` sashiko-bot
2026-06-13 18:54 ` Krzysztof Kozlowski
2026-06-14 20:53 ` Kurt Borja
2026-06-14 21:37 ` David Lechner
2026-06-14 21:57 ` Kurt Borja
2026-06-15 0:06 ` David Lechner
2026-06-15 4:34 ` Krzysztof Kozlowski
2026-06-15 4:40 ` Kurt Borja
2026-06-12 22:46 ` [PATCH 2/5] iio: adc: Add ti-ads1262 driver Kurt Borja
2026-06-12 23:01 ` sashiko-bot
2026-06-13 19:00 ` Krzysztof Kozlowski
2026-06-14 20:58 ` Kurt Borja
2026-06-13 13:45 ` Jonathan Cameron
2026-06-13 14:06 ` Jonathan Cameron
2026-06-14 20:27 ` Kurt Borja [this message]
2026-06-13 18:59 ` Krzysztof Kozlowski
2026-06-14 13:39 ` Jonathan Cameron
2026-06-15 4:33 ` Krzysztof Kozlowski
2026-06-15 4:42 ` Kurt Borja
2026-06-14 20:56 ` Kurt Borja
2026-06-15 4:30 ` Krzysztof Kozlowski
2026-06-12 22:46 ` [PATCH 3/5] iio: adc: ti-ads1262: Add GPIO controller support Kurt Borja
2026-06-12 22:59 ` sashiko-bot
2026-06-13 6:23 ` Kurt Borja
2026-06-12 22:46 ` [PATCH 4/5] iio: adc: ti-ads1262: Add calibration support Kurt Borja
2026-06-12 23:02 ` sashiko-bot
2026-06-13 13:50 ` Jonathan Cameron
2026-06-14 20:31 ` Kurt Borja
2026-06-12 22:46 ` [PATCH 5/5] iio: adc: Add ti-ads1263-adc2 driver Kurt Borja
2026-06-12 23:11 ` sashiko-bot
2026-06-13 14:10 ` Jonathan Cameron
2026-06-14 20:43 ` Kurt Borja
2026-06-12 23:50 ` [PATCH 0/5] iio: adc: Add TI ADS126X ADC family support David Lechner
2026-06-13 0:06 ` Kurt Borja
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DJ91ZV8FQOMZ.YLIC552K4G5D@gmail.com \
--to=kuurtb@gmail.com \
--cc=andy@kernel.org \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.