Devicetree
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Add support for LTC2305
@ 2026-03-24  7:13 Carlos Jones Jr
  2026-03-24  7:13 ` [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure Carlos Jones Jr
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Carlos Jones Jr @ 2026-03-24  7:13 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques
  Cc: linux-iio, devicetree, linux-kernel

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 introducing a chip_info
structure to handle the different channel configurations between the two
variants. The LTC2305 exposes 2 single-ended channels and 2 differential
combinations.

Also updates the device tree bindings to include the lltc,ltc2305
compatible string and documents it in the Kconfig.
---
Changes in v2:
- Changed usleep_range() to fsleep()
- Added missing #include <linux/array_size.h> header
- Removed explicit .read_delay_us = 0 initialization (implicit zero)
- Added __counted_by_ptr() annotation to channels pointer
- Modified ltc2309 struct to store only read_delay_us value instead
  of full chip_info pointer, reducing memory overhead
- Alphabetically ordered device entries in ID tables (ltc2305
  before ltc2309)
- Reformatted Kconfig help text with explicit bulleted list of
  supported devices instead of vague "and similar" language
- Added device names to chip_info structure for proper sysfs
  identification
- Split changes into proper preparatory patches before adding
  new device support
- Link to v1: https://lore.kernel.org/all/20260320140819.191700-1-carlosjr.jones@analog.com/

Note:
The ltc2309_chip_info structure has a 4-byte hole due to alignment
requirements for the __counted_by_ptr() annotation. The count field
must precede the pointer field for the bounds checking to work correctly.
The total structure size remains 32 bytes either way due to required
padding, so the memory overhead is minimal (8 bytes total for both chip
variants).
---
Carlos Jones Jr (4):
  iio: adc: ltc2309: Introduce chip_info structure
  iio: adc: ltc2309: Use i2c_get_match_data() helper
  dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible
  iio: adc: ltc2309: Add LTC2305 support

 .../bindings/iio/adc/lltc,ltc2497.yaml        |  9 ++-
 drivers/iio/adc/Kconfig                       |  8 ++-
 drivers/iio/adc/ltc2309.c                     | 59 ++++++++++++++++---
 3 files changed, 65 insertions(+), 11 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure
  2026-03-24  7:13 [PATCH v2 0/4] Add support for LTC2305 Carlos Jones Jr
@ 2026-03-24  7:13 ` Carlos Jones Jr
  2026-03-24 12:24   ` Andy Shevchenko
  2026-03-24  7:13 ` [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper Carlos Jones Jr
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Carlos Jones Jr @ 2026-03-24  7:13 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques
  Cc: linux-iio, devicetree, linux-kernel

Introduce a chip_info structure to facilitate adding support for
chip variants with different channel configurations and timing
requirements.

The chip_info structure contains:
- Device name for proper sysfs identification
- Channel specifications and count
- Read delay timing for variants requiring settling time

The ltc2309 struct is modified to store only the read_delay_us value
rather than a pointer to the full chip_info, as this is the only
runtime-accessed field after probe.

This preparatory refactoring does not modify existing LTC2309
functionality.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
---
 drivers/iio/adc/ltc2309.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 5f0d947d0615..0644b1f02568 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -8,12 +8,14 @@
  * Copyright (c) 2023, Liam Beguin <liambeguin@gmail.com>
  */
 #include <linux/bitfield.h>
+#include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/regulator/consumer.h>
+#include <linux/array_size.h>
 
 #define LTC2309_ADC_RESOLUTION	12
 #define LTC2309_INTERNAL_REF_MV 4096
@@ -26,18 +28,27 @@
 #define LTC2309_DIN_UNI		BIT(3)
 #define LTC2309_DIN_SLEEP	BIT(2)
 
+struct ltc2309_chip_info {
+	const char *name;
+	unsigned int num_channels;
+	const struct iio_chan_spec *channels __counted_by_ptr(num_channels);
+	unsigned int read_delay_us;
+};
+
 /**
  * struct ltc2309 - internal device data structure
  * @dev:	Device reference
  * @client:	I2C reference
  * @lock:	Lock to serialize data access
  * @vref_mv:	Internal voltage reference
+ * @read_delay_us:	Chip-specific read delay in microseconds
  */
 struct ltc2309 {
 	struct device		*dev;
 	struct i2c_client	*client;
 	struct mutex		lock; /* serialize data access */
 	int			vref_mv;
+	unsigned int		read_delay_us;
 };
 
 /* Order matches expected channel address, See datasheet Table 1. */
@@ -117,6 +128,9 @@ static int ltc2309_read_raw_channel(struct ltc2309 *ltc2309,
 		return ret;
 	}
 
+	if (ltc2309->read_delay_us)
+		fsleep(ltc2309->read_delay_us);
+
 	ret = i2c_master_recv(ltc2309->client, (char *)&buf, 2);
 	if (ret < 0) {
 		dev_err(ltc2309->dev, "i2c read failed: %pe\n", ERR_PTR(ret));
@@ -156,10 +170,18 @@ static const struct iio_info ltc2309_info = {
 	.read_raw = ltc2309_read_raw,
 };
 
+static const struct ltc2309_chip_info ltc2309_chip_info = {
+	.name = "ltc2309",
+	.num_channels = ARRAY_SIZE(ltc2309_channels),
+	.channels = ltc2309_channels,
+};
+
+
 static int ltc2309_probe(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev;
 	struct ltc2309 *ltc2309;
+	const struct ltc2309_chip_info *chip_info;
 	int ret;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*ltc2309));
@@ -169,11 +191,13 @@ static int ltc2309_probe(struct i2c_client *client)
 	ltc2309 = iio_priv(indio_dev);
 	ltc2309->dev = &indio_dev->dev;
 	ltc2309->client = client;
+	chip_info = &ltc2309_chip_info;
+	ltc2309->read_delay_us = chip_info->read_delay_us;
 
-	indio_dev->name = "ltc2309";
+	indio_dev->name = chip_info->name;
 	indio_dev->modes = INDIO_DIRECT_MODE;
-	indio_dev->channels = ltc2309_channels;
-	indio_dev->num_channels = ARRAY_SIZE(ltc2309_channels);
+	indio_dev->channels = chip_info->channels;
+	indio_dev->num_channels = chip_info->num_channels;
 	indio_dev->info = &ltc2309_info;
 
 	ret = devm_regulator_get_enable_read_voltage(&client->dev, "vref");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper
  2026-03-24  7:13 [PATCH v2 0/4] Add support for LTC2305 Carlos Jones Jr
  2026-03-24  7:13 ` [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure Carlos Jones Jr
@ 2026-03-24  7:13 ` Carlos Jones Jr
  2026-03-24 12:35   ` Andy Shevchenko
  2026-03-24  7:13 ` [PATCH v2 3/4] dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible Carlos Jones Jr
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Carlos Jones Jr @ 2026-03-24  7:13 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques
  Cc: linux-iio, devicetree, linux-kernel

Convert the driver to use the i2c_get_match_data() helper function
for retrieving chip-specific information. This simplifies device
identification and aligns with modern kernel practices.

Update both of_device_id and i2c_device_id tables to include
chip_info data pointers. The device name is now sourced from
chip_info to ensure proper identification in sysfs.

No functional changes to existing LTC2309 behavior.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
---
 drivers/iio/adc/ltc2309.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 0644b1f02568..475ecc21ebe9 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -191,7 +191,7 @@ static int ltc2309_probe(struct i2c_client *client)
 	ltc2309 = iio_priv(indio_dev);
 	ltc2309->dev = &indio_dev->dev;
 	ltc2309->client = client;
-	chip_info = &ltc2309_chip_info;
+	chip_info = i2c_get_match_data(client);
 	ltc2309->read_delay_us = chip_info->read_delay_us;
 
 	indio_dev->name = chip_info->name;
@@ -213,13 +213,13 @@ 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 },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ltc2309_of_match);
 
 static const struct i2c_device_id ltc2309_id[] = {
-	{ "ltc2309" },
+	{ "ltc2309", (kernel_ulong_t)&ltc2309_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, ltc2309_id);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 3/4] dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible
  2026-03-24  7:13 [PATCH v2 0/4] Add support for LTC2305 Carlos Jones Jr
  2026-03-24  7:13 ` [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure Carlos Jones Jr
  2026-03-24  7:13 ` [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper Carlos Jones Jr
@ 2026-03-24  7:13 ` Carlos Jones Jr
  2026-03-24 12:36   ` Krzysztof Kozlowski
  2026-03-24  7:13 ` [PATCH v2 4/4] iio: adc: ltc2309: Add LTC2305 support Carlos Jones Jr
  2026-03-25 20:19 ` [PATCH v2 0/4] Add support for LTC2305 Jonathan Cameron
  4 siblings, 1 reply; 13+ messages in thread
From: Carlos Jones Jr @ 2026-03-24  7:13 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques
  Cc: linux-iio, devicetree, linux-kernel

Add device tree binding for the LTC2305, a 2-channel, 12-bit SAR ADC
from Linear Technology (now part of Analog Devices).

The LTC2305 uses the same I2C register interface as the LTC2309 but
differs in:
- Channel count: 2 channels vs 8 channels (LTC2309)
- Conversion timing: Requires 1.6μs settling time vs negligible for
  LTC2309

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
---
 .../devicetree/bindings/iio/adc/lltc,ltc2497.yaml        | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml b/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml
index 5cc6a9684077..b246d492950e 100644
--- a/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml
@@ -4,13 +4,19 @@
 $id: http://devicetree.org/schemas/iio/adc/lltc,ltc2497.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Linear Technology / Analog Devices LTC2497 and LTC2309 ADC
+title: Linear Technology / Analog Devices LTC2497 and similar ADCs
 
 maintainers:
   - Michael Hennerich <michael.hennerich@analog.com>
   - Liam Beguin <liambeguin@gmail.com>
 
 description: |
+  LTC2305:
+    low noise, low power, 2-channel, 12-bit successive approximation ADC with an
+    I2C compatible serial interface.
+
+    https://www.analog.com/media/en/technical-documentation/data-sheets/2305fa.pdf
+
   LTC2309:
     low noise, low power, 8-channel, 12-bit successive approximation ADC with an
     I2C compatible serial interface.
@@ -28,6 +34,7 @@ description: |
 properties:
   compatible:
     enum:
+      - lltc,ltc2305
       - lltc,ltc2309
       - lltc,ltc2497
       - lltc,ltc2499
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 4/4] iio: adc: ltc2309: Add LTC2305 support
  2026-03-24  7:13 [PATCH v2 0/4] Add support for LTC2305 Carlos Jones Jr
                   ` (2 preceding siblings ...)
  2026-03-24  7:13 ` [PATCH v2 3/4] dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible Carlos Jones Jr
@ 2026-03-24  7:13 ` Carlos Jones Jr
  2026-03-24 12:39   ` Andy Shevchenko
  2026-03-25 20:19 ` [PATCH v2 0/4] Add support for LTC2305 Jonathan Cameron
  4 siblings, 1 reply; 13+ messages in thread
From: Carlos Jones Jr @ 2026-03-24  7:13 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques
  Cc: linux-iio, devicetree, linux-kernel

Add support for the LTC2305, a 2-channel, 12-bit SAR ADC that shares
the same I2C interface as the LTC2309.

The LTC2305 differs from the LTC2309 in:
- Channel configuration: 2 single-ended + 2 differential vs 8
  single-ended + 8 differential
- Read timing: Requires 2μs delay (1.6μs rounded up)
  between I2C write and read operations

Device tree binding added in previous commit.

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

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index a9dedbb8eb46..860c0909dbbb 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -915,11 +915,13 @@ 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 low noise,
+	  low power 12-bit SAR ADCs:
+	  - LTC2305 - 2-channel
+	  - LTC2309 - 8-channel
 
 	  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 475ecc21ebe9..d7ec4d92a96c 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -1,9 +1,14 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * The LTC2309 is an 8-Channel, 12-Bit SAR ADC with an I2C Interface.
+ * Low noise, low power 12-Bit SAR ADC with an I2C Interface.
+ *
+ * Supported devices:
+ * LTC2305 - 2-channel
+ * LTC2309 - 8-channel
  *
  * Datasheet:
  * https://www.analog.com/media/en/technical-documentation/data-sheets/2309fd.pdf
+ * https://www.analog.com/media/en/technical-documentation/data-sheets/23015fb.pdf
  *
  * Copyright (c) 2023, Liam Beguin <liambeguin@gmail.com>
  */
@@ -110,6 +115,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)
 {
@@ -170,6 +182,13 @@ static const struct iio_info ltc2309_info = {
 	.read_raw = ltc2309_read_raw,
 };
 
+static const struct ltc2309_chip_info ltc2305_chip_info = {
+	.name = "ltc2305",
+	.num_channels = ARRAY_SIZE(ltc2305_channels),
+	.channels = ltc2305_channels,
+	.read_delay_us = 2,
+};
+
 static const struct ltc2309_chip_info ltc2309_chip_info = {
 	.name = "ltc2309",
 	.num_channels = ARRAY_SIZE(ltc2309_channels),
@@ -213,12 +232,14 @@ static int ltc2309_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id ltc2309_of_match[] = {
+	{ .compatible = "lltc,ltc2305", .data = &ltc2305_chip_info },
 	{ .compatible = "lltc,ltc2309", .data = &ltc2309_chip_info },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ltc2309_of_match);
 
 static const struct i2c_device_id ltc2309_id[] = {
+	{ "ltc2305", (kernel_ulong_t)&ltc2305_chip_info },
 	{ "ltc2309", (kernel_ulong_t)&ltc2309_chip_info },
 	{ }
 };
@@ -235,5 +256,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 LTC2305/LTC2309 ADC driver");
 MODULE_LICENSE("GPL v2");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure
  2026-03-24  7:13 ` [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure Carlos Jones Jr
@ 2026-03-24 12:24   ` Andy Shevchenko
  2026-03-25  0:01     ` Jones, Carlos jr
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2026-03-24 12:24 UTC (permalink / raw)
  To: Carlos Jones Jr
  Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques, linux-iio, devicetree,
	linux-kernel

On Tue, Mar 24, 2026 at 03:13:28PM +0800, Carlos Jones Jr wrote:
> Introduce a chip_info structure to facilitate adding support for
> chip variants with different channel configurations and timing
> requirements.
> 
> The chip_info structure contains:
> - Device name for proper sysfs identification
> - Channel specifications and count
> - Read delay timing for variants requiring settling time
> 
> The ltc2309 struct is modified to store only the read_delay_us value
> rather than a pointer to the full chip_info, as this is the only
> runtime-accessed field after probe.
> 
> This preparatory refactoring does not modify existing LTC2309
> functionality.

...

>  #include <linux/bitfield.h>
> +#include <linux/delay.h>
>  #include <linux/i2c.h>
>  #include <linux/iio/iio.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/regulator/consumer.h>

> +#include <linux/array_size.h>

It starts with 'a'...

...

> +struct ltc2309_chip_info {
> +	const char *name;
> +	unsigned int num_channels;
> +	const struct iio_chan_spec *channels __counted_by_ptr(num_channels);
> +	unsigned int read_delay_us;

Now on some architectures this might have gaps. Have you run `pahole`?
Even if it's fine, I would rather see

	const char *name;
	const struct iio_chan_spec *channels __counted_by_ptr(num_channels);
	unsigned int num_channels;
	unsigned int read_delay_us;

OR (if there are limitations of __counted_by_ptr() attribute)

	const char *name;
	unsigned int read_delay_us;
	unsigned int num_channels;
	const struct iio_chan_spec *channels __counted_by_ptr(num_channels);

> +};

...

> +static const struct ltc2309_chip_info ltc2309_chip_info = {
> +	.name = "ltc2309",
> +	.num_channels = ARRAY_SIZE(ltc2309_channels),
> +	.channels = ltc2309_channels,
> +};
> +
> +

One blank line too many.

...

>  static int ltc2309_probe(struct i2c_client *client)
>  {
>  	struct iio_dev *indio_dev;
>  	struct ltc2309 *ltc2309;
> +	const struct ltc2309_chip_info *chip_info;

Try to preserve reversed xmas tree order.

>  	int ret;

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper
  2026-03-24  7:13 ` [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper Carlos Jones Jr
@ 2026-03-24 12:35   ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2026-03-24 12:35 UTC (permalink / raw)
  To: Carlos Jones Jr
  Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques, linux-iio, devicetree,
	linux-kernel

On Tue, Mar 24, 2026 at 03:13:29PM +0800, Carlos Jones Jr wrote:
> Convert the driver to use the i2c_get_match_data() helper function
> for retrieving chip-specific information. This simplifies device
> identification and aligns with modern kernel practices.
> 
> Update both of_device_id and i2c_device_id tables to include
> chip_info data pointers. The device name is now sourced from
> chip_info to ensure proper identification in sysfs.
> 
> No functional changes to existing LTC2309 behavior.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 3/4] dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible
  2026-03-24  7:13 ` [PATCH v2 3/4] dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible Carlos Jones Jr
@ 2026-03-24 12:36   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 13+ messages in thread
From: Krzysztof Kozlowski @ 2026-03-24 12:36 UTC (permalink / raw)
  To: Carlos Jones Jr, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques
  Cc: linux-iio, devicetree, linux-kernel

On 24/03/2026 08:13, Carlos Jones Jr wrote:
> Add device tree binding for the LTC2305, a 2-channel, 12-bit SAR ADC
> from Linear Technology (now part of Analog Devices).
> 
> The LTC2305 uses the same I2C register interface as the LTC2309 but
> differs in:
> - Channel count: 2 channels vs 8 channels (LTC2309)
> - Conversion timing: Requires 1.6μs settling time vs negligible for
>   LTC2309
> 
> Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
> ---


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 4/4] iio: adc: ltc2309: Add LTC2305 support
  2026-03-24  7:13 ` [PATCH v2 4/4] iio: adc: ltc2309: Add LTC2305 support Carlos Jones Jr
@ 2026-03-24 12:39   ` Andy Shevchenko
  0 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2026-03-24 12:39 UTC (permalink / raw)
  To: Carlos Jones Jr
  Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Michael Hennerich, Liam Beguin, Nuno Sá, Andy Shevchenko,
	Tobias Sperling, Jorge Marques, linux-iio, devicetree,
	linux-kernel

On Tue, Mar 24, 2026 at 03:13:31PM +0800, Carlos Jones Jr wrote:
> Add support for the LTC2305, a 2-channel, 12-bit SAR ADC that shares
> the same I2C interface as the LTC2309.
> 
> The LTC2305 differs from the LTC2309 in:
> - Channel configuration: 2 single-ended + 2 differential vs 8
>   single-ended + 8 differential
> - Read timing: Requires 2μs delay (1.6μs rounded up)
>   between I2C write and read operations
> 
> Device tree binding added in previous commit.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure
  2026-03-24 12:24   ` Andy Shevchenko
@ 2026-03-25  0:01     ` Jones, Carlos jr
  0 siblings, 0 replies; 13+ messages in thread
From: Jones, Carlos jr @ 2026-03-25  0:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, David Lechner,
	Hennerich, Michael, Liam Beguin, Sa, Nuno, Andy Shevchenko,
	Tobias Sperling, Marques, Jorge, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org

> On Tue, Mar 24, 2026 at 03:13:28PM +0800, Carlos Jones Jr wrote:
> > Introduce a chip_info structure to facilitate adding support for chip
> > variants with different channel configurations and timing
> > requirements.
> >
> > The chip_info structure contains:
> > - Device name for proper sysfs identification
> > - Channel specifications and count
> > - Read delay timing for variants requiring settling time
> >
> > The ltc2309 struct is modified to store only the read_delay_us value
> > rather than a pointer to the full chip_info, as this is the only
> > runtime-accessed field after probe.
> >
> > This preparatory refactoring does not modify existing LTC2309
> > functionality.
> 
> ...
> > +struct ltc2309_chip_info {
> > +	const char *name;
> > +	unsigned int num_channels;
> > +	const struct iio_chan_spec *channels
> __counted_by_ptr(num_channels);
> > +	unsigned int read_delay_us;
> 
> Now on some architectures this might have gaps. Have you run `pahole`?
> Even if it's fine, I would rather see
> 
> 	const char *name;
> 	const struct iio_chan_spec *channels
> __counted_by_ptr(num_channels);
> 	unsigned int num_channels;
> 	unsigned int read_delay_us;
> 
> OR (if there are limitations of __counted_by_ptr() attribute)
> 
> 	const char *name;
> 	unsigned int read_delay_us;
> 	unsigned int num_channels;
> 	const struct iio_chan_spec *channels
> __counted_by_ptr(num_channels);
> 
> > +};
> ...

Thanks, Andy. The previous arrangement has hole but the latter of the
two recommendations above have none (pahole output shown below).
I will update accordingly.

struct ltc2309_chip_info {
        const char  *              name;                 /*     0     8 */
        unsigned int               read_delay_us;        /*     8     4 */
        unsigned int               num_channels;         /*    12     4 */
        const struct iio_chan_spec  * channels;          /*    16     8 */

        /* size: 24, cachelines: 1, members: 4 */
        /* last cacheline: 24 bytes */
};

Will also revise the static declaration to align with the change.

static const struct ltc2309_chip_info ltc2305_chip_info = {
	.name = "ltc2305",
	.read_delay_us = 2,
	.num_channels = ARRAY_SIZE(ltc2305_channels),
	.channels = ltc2305_channels,
};

And noted on the comments about the alphabetical arrangement
of headers, extra space, and xmas tree order of local variables,
revised as shown below.

static int ltc2309_probe(struct i2c_client *client)
{
	const struct ltc2309_chip_info *chip_info;
	struct iio_dev *indio_dev;
	struct ltc2309 *ltc2309;
	int ret;

Kind regards.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/4] Add support for LTC2305
  2026-03-24  7:13 [PATCH v2 0/4] Add support for LTC2305 Carlos Jones Jr
                   ` (3 preceding siblings ...)
  2026-03-24  7:13 ` [PATCH v2 4/4] iio: adc: ltc2309: Add LTC2305 support Carlos Jones Jr
@ 2026-03-25 20:19 ` Jonathan Cameron
  2026-03-26  2:21   ` Jones, Carlos jr
  4 siblings, 1 reply; 13+ messages in thread
From: Jonathan Cameron @ 2026-03-25 20:19 UTC (permalink / raw)
  To: Carlos Jones Jr
  Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, David Lechner, Michael Hennerich, Liam Beguin,
	Nuno Sá, Andy Shevchenko, Tobias Sperling, Jorge Marques,
	linux-iio, devicetree, linux-kernel, Kyle Hsieh

On Tue, 24 Mar 2026 15:13:27 +0800
Carlos Jones Jr <carlosjr.jones@analog.com> 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 introducing a chip_info
> structure to handle the different channel configurations between the two
> variants. The LTC2305 exposes 2 single-ended channels and 2 differential
> combinations.
> 
> Also updates the device tree bindings to include the lltc,ltc2305
> compatible string and documents it in the Kconfig.
> ---

Whilst checking for what comments were in v1, I realized we have
two different people looking at the same thing within a few
weeks of each other. +cc Kyle. 

https://lore.kernel.org/all/20260325-add_ltc2305_driver-v5-0-e0d29daa54f9@gmail.com/#r

I guess this is just a case of neither noticing on the list?
Too many similar part names, so I missed it until now.

Currently I have Kyle's patches queued up.  All else being equal
that seems fair as Kyle started on this last year whereas 
Carlos' work on this is much more recent. 

I'm seeing some small differences. Please could you work together on this.
Ideally send any additional changes on top of Kyle's series.

Thanks,

Jonathan

> Changes in v2:
> - Changed usleep_range() to fsleep()
> - Added missing #include <linux/array_size.h> header
> - Removed explicit .read_delay_us = 0 initialization (implicit zero)
> - Added __counted_by_ptr() annotation to channels pointer
> - Modified ltc2309 struct to store only read_delay_us value instead
>   of full chip_info pointer, reducing memory overhead
> - Alphabetically ordered device entries in ID tables (ltc2305
>   before ltc2309)
> - Reformatted Kconfig help text with explicit bulleted list of
>   supported devices instead of vague "and similar" language
> - Added device names to chip_info structure for proper sysfs
>   identification
> - Split changes into proper preparatory patches before adding
>   new device support
> - Link to v1: https://lore.kernel.org/all/20260320140819.191700-1-carlosjr.jones@analog.com/
> 
> Note:
> The ltc2309_chip_info structure has a 4-byte hole due to alignment
> requirements for the __counted_by_ptr() annotation. The count field
> must precede the pointer field for the bounds checking to work correctly.
> The total structure size remains 32 bytes either way due to required
> padding, so the memory overhead is minimal (8 bytes total for both chip
> variants).
> ---
> Carlos Jones Jr (4):
>   iio: adc: ltc2309: Introduce chip_info structure
>   iio: adc: ltc2309: Use i2c_get_match_data() helper
>   dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible
>   iio: adc: ltc2309: Add LTC2305 support
> 
>  .../bindings/iio/adc/lltc,ltc2497.yaml        |  9 ++-
>  drivers/iio/adc/Kconfig                       |  8 ++-
>  drivers/iio/adc/ltc2309.c                     | 59 ++++++++++++++++---
>  3 files changed, 65 insertions(+), 11 deletions(-)
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: [PATCH v2 0/4] Add support for LTC2305
  2026-03-25 20:19 ` [PATCH v2 0/4] Add support for LTC2305 Jonathan Cameron
@ 2026-03-26  2:21   ` Jones, Carlos jr
  2026-03-26  8:17     ` Jonathan Cameron
  0 siblings, 1 reply; 13+ messages in thread
From: Jones, Carlos jr @ 2026-03-26  2:21 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, David Lechner, Hennerich, Michael, Liam Beguin,
	Sa, Nuno, Andy Shevchenko, Tobias Sperling, Marques, Jorge,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Kyle Hsieh

> On Tue, 24 Mar 2026 15:13:27 +0800
> Carlos Jones Jr <carlosjr.jones@analog.com> 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 introducing a chip_info
> > structure to handle the different channel configurations between the
> > two variants. The LTC2305 exposes 2 single-ended channels and 2
> > differential combinations.
> >
> > Also updates the device tree bindings to include the lltc,ltc2305
> > compatible string and documents it in the Kconfig.
> > ---
> 
> Whilst checking for what comments were in v1, I realized we have two
> different people looking at the same thing within a few weeks of each other.
> +cc Kyle.
> 
> https://urldefense.com/v3/__https://lore.kernel.org/all/20260325-
> add_ltc2305_driver-v5-0-
> e0d29daa54f9@gmail.com/*r__;Iw!!A3Ni8CS0y2Y!6jxk_dJQLHUO4PVi3Oca_
> VzVHN-qeFu-y2tE5xXMwuy-
> x2UFG5Fn3KO4Cw15QcDsqTCgFXQQLLRQrdgokg$
> 
> I guess this is just a case of neither noticing on the list?
> Too many similar part names, so I missed it until now.
> 
> Currently I have Kyle's patches queued up.  All else being equal that seems fair
> as Kyle started on this last year whereas Carlos' work on this is much more
> recent.
> 
> I'm seeing some small differences. Please could you work together on this.
> Ideally send any additional changes on top of Kyle's series.
> 
> Thanks,
> 
> Jonathan
> 

First off, my apologies to everyone for not knowing how to check for
existing upstream request for the LTC2305 device before working on it
and wasting everyone's review time. It's a learning experience for me.

But it's still awesome to see how both ended up with almost the same
code after review.

I'll reply to Kyle's series to ask if the delay for LTC2305 could be included.

Kind regards,
Carlos

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 0/4] Add support for LTC2305
  2026-03-26  2:21   ` Jones, Carlos jr
@ 2026-03-26  8:17     ` Jonathan Cameron
  0 siblings, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2026-03-26  8:17 UTC (permalink / raw)
  To: Jones, Carlos jr
  Cc: Lars-Peter Clausen, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, David Lechner, Hennerich, Michael, Liam Beguin,
	Sa, Nuno, Andy Shevchenko, Tobias Sperling, Marques, Jorge,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Kyle Hsieh

On Thu, 26 Mar 2026 02:21:28 +0000
"Jones, Carlos jr" <Carlosjr.Jones@analog.com> wrote:

> > On Tue, 24 Mar 2026 15:13:27 +0800
> > Carlos Jones Jr <carlosjr.jones@analog.com> 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 introducing a chip_info
> > > structure to handle the different channel configurations between the
> > > two variants. The LTC2305 exposes 2 single-ended channels and 2
> > > differential combinations.
> > >
> > > Also updates the device tree bindings to include the lltc,ltc2305
> > > compatible string and documents it in the Kconfig.
> > > ---  
> > 
> > Whilst checking for what comments were in v1, I realized we have two
> > different people looking at the same thing within a few weeks of each other.
> > +cc Kyle.
> > 
> > https://urldefense.com/v3/__https://lore.kernel.org/all/20260325-
> > add_ltc2305_driver-v5-0-
> > e0d29daa54f9@gmail.com/*r__;Iw!!A3Ni8CS0y2Y!6jxk_dJQLHUO4PVi3Oca_
> > VzVHN-qeFu-y2tE5xXMwuy-
> > x2UFG5Fn3KO4Cw15QcDsqTCgFXQQLLRQrdgokg$
> > 
> > I guess this is just a case of neither noticing on the list?
> > Too many similar part names, so I missed it until now.
> > 
> > Currently I have Kyle's patches queued up.  All else being equal that seems fair
> > as Kyle started on this last year whereas Carlos' work on this is much more
> > recent.
> > 
> > I'm seeing some small differences. Please could you work together on this.
> > Ideally send any additional changes on top of Kyle's series.
> > 
> > Thanks,
> > 
> > Jonathan
> >   
> 
> First off, my apologies to everyone for not knowing how to check for
> existing upstream request for the LTC2305 device before working on it
> and wasting everyone's review time. It's a learning experience for me.
It is pretty rare!  Only tend to see this sort of collision once every
few years.

> 
> But it's still awesome to see how both ended up with almost the same
> code after review.
> 
> I'll reply to Kyle's series to ask if the delay for LTC2305 could be included.
Excellent!  Note I've merged Kyle's code, so patches on top please.
Potentially the delay might be a fix if I understand it correctly.

Thanks,

Jonathan

> 
> Kind regards,
> Carlos
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-03-26  8:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24  7:13 [PATCH v2 0/4] Add support for LTC2305 Carlos Jones Jr
2026-03-24  7:13 ` [PATCH v2 1/4] iio: adc: ltc2309: Introduce chip_info structure Carlos Jones Jr
2026-03-24 12:24   ` Andy Shevchenko
2026-03-25  0:01     ` Jones, Carlos jr
2026-03-24  7:13 ` [PATCH v2 2/4] iio: adc: ltc2309: Use i2c_get_match_data() helper Carlos Jones Jr
2026-03-24 12:35   ` Andy Shevchenko
2026-03-24  7:13 ` [PATCH v2 3/4] dt-bindings: iio: adc: ltc2497: Add LTC2305 compatible Carlos Jones Jr
2026-03-24 12:36   ` Krzysztof Kozlowski
2026-03-24  7:13 ` [PATCH v2 4/4] iio: adc: ltc2309: Add LTC2305 support Carlos Jones Jr
2026-03-24 12:39   ` Andy Shevchenko
2026-03-25 20:19 ` [PATCH v2 0/4] Add support for LTC2305 Jonathan Cameron
2026-03-26  2:21   ` Jones, Carlos jr
2026-03-26  8:17     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox