From: Jonathan Cameron <jic23@kernel.org>
To: Jakub Szczudlo <jakubszczudlo40@gmail.com>
Cc: linux-iio@vger.kernel.org, andy@kernel.org,
antoniu.miclaus@analog.com, conor+dt@kernel.org,
devicetree@vger.kernel.org, dlechner@baylibre.com,
duje@dujemihanovic.xyz, jishnu.prakash@oss.qualcomm.com,
jorge.marques@analog.com, joshua.crofts1@gmail.com,
krzk+dt@kernel.org, linusw@kernel.org,
marcelo.schmitt@analog.com, mazziesaccount@gmail.com,
mike.looijmans@topic.nl, nuno.sa@analog.com, robh@kernel.org,
sakari.ailus@linux.intel.com, wens@kernel.org
Subject: Re: [PATCH v6 3/3] iio: adc: Add ti-ads1110 support to ti-ads1100 driver
Date: Mon, 13 Jul 2026 02:26:24 +0100 [thread overview]
Message-ID: <20260713022624.08e7b897@jic23-huawei> (raw)
In-Reply-To: <20260711184414.1013686-4-jakubszczudlo40@gmail.com>
On Sat, 11 Jul 2026 20:44:14 +0200
Jakub Szczudlo <jakubszczudlo40@gmail.com> wrote:
> Add ADS1110 support that have faster datarate than ADS1100, it also uses
> internal voltage reference of 2.048V for measurement.
>
> Signed-off-by: Jakub Szczudlo <jakubszczudlo40@gmail.com>
> ---
> drivers/iio/adc/Kconfig | 9 ++--
> drivers/iio/adc/ti-ads1100.c | 84 +++++++++++++++++++++++++++---------
> 2 files changed, 69 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 1c663c98c6c9..2459ff2af105 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -1765,11 +1765,14 @@ config TI_ADS1018
> called ti-ads1018.
>
> config TI_ADS1100
> - tristate "Texas Instruments ADS1100 and ADS1000 ADC"
> + tristate "Texas Instruments ADS1100 and similar single channel I2C ADC"
> depends on I2C
> help
> - If you say yes here you get support for Texas Instruments ADS1100 and
> - ADS1000 ADC chips.
> + If you say yes here you get support for TI single channel I2C Analog
> + Devices.
> + * ADS1000 12-Bit, 128 MSPS Analog-to-Digital Converter
> + * ADS1100 16-Bit, 128 MSPS Analog-to-Digital Converter
> + * ADS1110 16-Bit, 240 MSPS Analog-to-Digital Converter
Sashiko makes the point that these are not mega sample per second ADCs.
Those are never interfaced by I2C given typically 400kHZ bus clock rate!
>
> This driver can also be built as a module. If so, the module will be
> called ti-ads1100.
> diff --git a/drivers/iio/adc/ti-ads1100.c b/drivers/iio/adc/ti-ads1100.c
> index 6ad80d42d390..06892ebc593d 100644
> --- a/drivers/iio/adc/ti-ads1100.c
> +++ b/drivers/iio/adc/ti-ads1100.c
> @@ -5,7 +5,7 @@
> * Copyright (c) 2023, Topic Embedded Products
> *
> * Datasheet: https://www.ti.com/lit/gpn/ads1100
> - * IIO driver for ADS1100 and ADS1000 ADC 16-bit I2C
> + * IIO driver for ADS1100 and similar single channel ADC 16-bit I2C
> */
>
> #include <linux/bitfield.h>
> @@ -41,20 +41,44 @@
> #define ADS1100_SINGLESHOT ADS1100_CFG_SC
>
> #define ADS1100_SLEEP_DELAY_MS 2000
> +#define ADS1110_INTERNAL_REF_mV 2048
>
> static const int ads1100_data_rate[] = { 128, 32, 16, 8 };
> +static const int ads1110_data_rate[] = { 240, 60, 30, 15 };
> static const int ads1100_data_rate_bits[] = { 12, 14, 15, 16 };
>
> /* Timeout based on the minimum sample rate of 8 SPS (7500ms) */
> #define ADS1100_MAX_DRDY_TIMEOUT_US (7500 * USEC_PER_MSEC)
>
> +struct ads1100_config {
> + const char *name;
Doesn't seem like name is used. (Another one Sashiko noticed!)
iio_dev->name should be set to this.
> + const int *available_data_rate_hz;
> + const int data_rate_count;
> + bool has_internal_vref_only;
> +};
> @@ -90,6 +114,20 @@ static int ads1100_set_config_bits(struct ads1100_data *data, u8 mask, u8 value)
> return 0;
> };
>
> +static int ads1100_get_vref_milivolts(struct ads1100_data *data)
Another Sashiko one. milli (two ls)
> +{
> + int voltage_uV;
> +
> + if (data->ads_config->has_internal_vref_only)
> + return ADS1110_INTERNAL_REF_mV;
> +
> + voltage_uV = regulator_get_voltage(data->reg_vdd);
> + if (voltage_uV < 0)
> + return voltage_uV;
> +
> + return voltage_uV / (MICRO / MILLI);
> +}
> +
> static int ads1100_data_bits(struct ads1100_data *data)
> {
> return ads1100_data_rate_bits[FIELD_GET(ADS1100_DR_MASK, data->config)];
> @@ -144,7 +182,8 @@ static bool ads1100_new_data_not_ready(struct ads1100_data *data)
>
> static int ads1100_poll_data_ready(struct ads1100_data *data)
> {
> - int data_rate_Hz = ads1100_data_rate[FIELD_GET(ADS1100_DR_MASK, data->config)];
> + int data_rate_index = FIELD_GET(ADS1100_DR_MASK, data->config);
> + int data_rate_Hz = data->ads_config->available_data_rate_hz[data_rate_index];
> /* To be sure we wait 5 times more than data rate */
> unsigned long wait_time_us = DIV_ROUND_CLOSEST(USEC_PER_SEC, 5 * data_rate_Hz);
> bool data_ready;
> @@ -181,7 +220,7 @@ static int ads1100_set_scale(struct ads1100_data *data, int val, int val2)
> if (ret)
> return ret;
>
> - microvolts = regulator_get_voltage(data->reg_vdd);
> + microvolts = ads1100_get_vref_milivolts(data) * (MICRO / MILLI);
Sashiko commented on error returns here - I think David raised this as well.
> /*
> * val2 is in 'micro' units, n = val2 / 1000000
> * result must be millivolts, d = microvolts / 1000
prev parent reply other threads:[~2026-07-13 1:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 18:44 [PATCH v6 0/3 ] iio: adc: Add support for TI ADS1110 to ti-ads1100 driver Jakub Szczudlo
2026-07-11 18:44 ` [PATCH v6 1/3] iio: adc: Fix incorrect reading when datarate changed in single mode Jakub Szczudlo
2026-07-11 18:54 ` sashiko-bot
2026-07-11 19:51 ` David Lechner
2026-07-13 1:20 ` Jonathan Cameron
2026-07-13 10:53 ` Jakub Szczudło
2026-07-13 14:12 ` David Lechner
2026-07-11 18:44 ` [PATCH v6 2/3] dt-bindings: iio: adc: ti,ads1100: add support for ADS1110 Jakub Szczudlo
2026-07-11 18:44 ` [PATCH v6 3/3] iio: adc: Add ti-ads1110 support to ti-ads1100 driver Jakub Szczudlo
2026-07-11 18:57 ` sashiko-bot
2026-07-11 20:01 ` David Lechner
2026-07-12 10:16 ` Jakub Szczudło
2026-07-12 16:32 ` David Lechner
2026-07-13 1:26 ` Jonathan Cameron [this message]
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=20260713022624.08e7b897@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=duje@dujemihanovic.xyz \
--cc=jakubszczudlo40@gmail.com \
--cc=jishnu.prakash@oss.qualcomm.com \
--cc=jorge.marques@analog.com \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--cc=mazziesaccount@gmail.com \
--cc=mike.looijmans@topic.nl \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=wens@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox