[PATCH 3/3] iio: adc: ltc2309: add support for LTC2305

Carlos Jones Jr posted 3 patches 2 weeks ago
There is a newer version of this series
[PATCH 3/3] iio: adc: ltc2309: add support for LTC2305
Posted by Carlos Jones Jr 2 weeks ago
The LTC2305 is a 2-channel, 12-bit, fast ADC with an I2C interface,
compatible with the LTC2309 (which has 8 channels).

This patch adds support for the LTC2305 by using the chip_info
structure to handle the different channel configurations between the
two variants. The LTC2305 exposes 2 single-ended channels and 2
differential combinations.

The LTC2305 requires a 1.6μs delay between I2C write and read
operations, which is implemented using chip-specific timing to avoid
affecting existing LTC2309 functionality.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
---
 drivers/iio/adc/Kconfig   |  6 +++---
 drivers/iio/adc/ltc2309.c | 23 +++++++++++++++++++----
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index a9dedbb8eb46..791a1ac594c2 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -915,11 +915,11 @@ config LPC32XX_ADC
 	  via sysfs.
 
 config LTC2309
-	tristate "Linear Technology LTC2309 ADC driver"
+	tristate "Linear Technology LTC2309 and similar ADC driver"
 	depends on I2C
 	help
-	  Say yes here to build support for Linear Technology LTC2309, a low
-	  noise, low power, 8-channel, 12-bit SAR ADC
+	  Say yes here to build support for Linear Technology LTC2309 and
+	  similar low noise, low power SAR ADCs.
 
 	  This driver can also be built as a module. If so, the module will
 	  be called ltc2309.
diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 4ea25873398c..179ccc780219 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -108,6 +108,13 @@ static const struct iio_chan_spec ltc2309_channels[] = {
 	LTC2309_DIFF_CHAN(7, 6, LTC2309_CH7_CH6),
 };
 
+static const struct iio_chan_spec ltc2305_channels[] = {
+	LTC2309_CHAN(0, LTC2309_CH0),
+	LTC2309_CHAN(1, LTC2309_CH1),
+	LTC2309_DIFF_CHAN(0, 1, LTC2309_CH0_CH1),
+	LTC2309_DIFF_CHAN(1, 0, LTC2309_CH1_CH0),
+};
+
 static int ltc2309_read_raw_channel(struct ltc2309 *ltc2309,
 				    unsigned long address, int *val)
 {
@@ -175,6 +182,12 @@ static const struct ltc2309_chip_info ltc2309_chip_info = {
 	.read_delay_us = 0,
 };
 
+static const struct ltc2309_chip_info ltc2305_chip_info = {
+	.channels = ltc2305_channels,
+	.num_channels = ARRAY_SIZE(ltc2305_channels),
+	.read_delay_us = 2,
+};
+
 static int ltc2309_probe(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev;
@@ -188,7 +201,7 @@ static int ltc2309_probe(struct i2c_client *client)
 	ltc2309 = iio_priv(indio_dev);
 	ltc2309->dev = &indio_dev->dev;
 	ltc2309->client = client;
-	ltc2309->chip_info = &ltc2309_chip_info;
+	ltc2309->chip_info = i2c_get_match_data(client);
 
 	indio_dev->name = "ltc2309";
 	indio_dev->modes = INDIO_DIRECT_MODE;
@@ -209,13 +222,15 @@ static int ltc2309_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id ltc2309_of_match[] = {
-	{ .compatible = "lltc,ltc2309" },
+	{ .compatible = "lltc,ltc2309", .data = &ltc2309_chip_info },
+	{ .compatible = "lltc,ltc2305", .data = &ltc2305_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ltc2309_of_match);
 
 static const struct i2c_device_id ltc2309_id[] = {
-	{ "ltc2309" },
+	{ "ltc2309", (kernel_ulong_t)&ltc2309_chip_info },
+	{ "ltc2305", (kernel_ulong_t)&ltc2305_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, ltc2309_id);
@@ -231,5 +246,5 @@ static struct i2c_driver ltc2309_driver = {
 module_i2c_driver(ltc2309_driver);
 
 MODULE_AUTHOR("Liam Beguin <liambeguin@gmail.com>");
-MODULE_DESCRIPTION("Linear Technology LTC2309 ADC");
+MODULE_DESCRIPTION("Linear Technology LTC2309 and similar ADC driver");
 MODULE_LICENSE("GPL v2");
-- 
2.43.0

Re: [PATCH 3/3] iio: adc: ltc2309: add support for LTC2305
Posted by Andy Shevchenko 2 weeks ago
On Fri, Mar 20, 2026 at 10:08:19PM +0800, Carlos Jones Jr wrote:
> The LTC2305 is a 2-channel, 12-bit, fast ADC with an I2C interface,
> compatible with the LTC2309 (which has 8 channels).
> 
> This patch adds support for the LTC2305 by using the chip_info
> structure to handle the different channel configurations between the
> two variants. The LTC2305 exposes 2 single-ended channels and 2
> differential combinations.
> 
> The LTC2305 requires a 1.6μs delay between I2C write and read
> operations, which is implemented using chip-specific timing to avoid
> affecting existing LTC2309 functionality.

...

>  config LTC2309
> -	tristate "Linear Technology LTC2309 ADC driver"
> +	tristate "Linear Technology LTC2309 and similar ADC driver"
>  	depends on I2C
>  	help
> -	  Say yes here to build support for Linear Technology LTC2309, a low
> -	  noise, low power, 8-channel, 12-bit SAR ADC
> +	  Say yes here to build support for Linear Technology LTC2309 and
> +	  similar low noise, low power SAR ADCs.

No, in Kconfig help text (and possibly title above) we have to be crystal
clear for user what IPs (chips, SoCs, et cetera) are being supported by
the driver. There is no go for 'and similar'.

...

> -	ltc2309->chip_info = &ltc2309_chip_info;
> +	ltc2309->chip_info = i2c_get_match_data(client);

Strictly speaking this change with the associated ID table changes should go
in a separate patch.

...

>  static const struct of_device_id ltc2309_of_match[] = {
> -	{ .compatible = "lltc,ltc2309" },
> +	{ .compatible = "lltc,ltc2309", .data = &ltc2309_chip_info },


> +	{ .compatible = "lltc,ltc2305", .data = &ltc2305_chip_info },

Keep it ordered by the value of compatible string.

>  	{ }
>  };

...

>  static const struct i2c_device_id ltc2309_id[] = {
> -	{ "ltc2309" },
> +	{ "ltc2309", (kernel_ulong_t)&ltc2309_chip_info },
> +	{ "ltc2305", (kernel_ulong_t)&ltc2305_chip_info },
>  	{ }

In the similar way as above.

>  };

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH 3/3] iio: adc: ltc2309: add support for LTC2305
Posted by Jonathan Cameron 1 week, 6 days ago
On Fri, 20 Mar 2026 16:48:35 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, Mar 20, 2026 at 10:08:19PM +0800, Carlos Jones Jr wrote:
> > The LTC2305 is a 2-channel, 12-bit, fast ADC with an I2C interface,
> > compatible with the LTC2309 (which has 8 channels).
> > 
> > This patch adds support for the LTC2305 by using the chip_info
> > structure to handle the different channel configurations between the
> > two variants. The LTC2305 exposes 2 single-ended channels and 2
> > differential combinations.
> > 
> > The LTC2305 requires a 1.6μs delay between I2C write and read
> > operations, which is implemented using chip-specific timing to avoid
> > affecting existing LTC2309 functionality.  
> 
> ...
> 
> >  config LTC2309
> > -	tristate "Linear Technology LTC2309 ADC driver"
> > +	tristate "Linear Technology LTC2309 and similar ADC driver"
> >  	depends on I2C
> >  	help
> > -	  Say yes here to build support for Linear Technology LTC2309, a low
> > -	  noise, low power, 8-channel, 12-bit SAR ADC
> > +	  Say yes here to build support for Linear Technology LTC2309 and
> > +	  similar low noise, low power SAR ADCs.  
> 
> No, in Kconfig help text (and possibly title above) we have to be crystal
> clear for user what IPs (chips, SoCs, et cetera) are being supported by
> the driver. There is no go for 'and similar'.

One follow up comment is format the resulting description as a list
as it reduces churn in the long run.  e.g. how AD7173 does it.