Skip to contentSkip to conversation

iio: adc: add driver for Texas Instruments TLA2528 adc

PATCH Applied Maxime Chevallier 5 participants 9 messages Nov 13 – Nov 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover iio: adc: add driver for Texas Instruments TLA2528 adc

Hi everyone,

This is V4 for the TI TLA2528 driver, for the ADC part. This new revision contains a small amount of changes, after the reviews from Joshua, Andy, Jonathan, and sashiko.

Thanks everyone for the quick feedback,

Maxime

V4:
- Return -EIO on a short read in tla2528_read(), from Joshua
- Drop mod_devicetable.h, include asm/byteorder.h
- Rename vref_mv to vref_mV
- Drop the L: entry in MAINTAINERS

V3: https://lore.kernel.org/r/[email protected]
- Require channels to be described
- Use guard()
- Add Datasheet link
- Drop the unused registers
- Use named initializers in the id table
- Collect Conor's Ack

V2: https://lore.kernel.org/r/[email protected]
- Describe AVDD and DVDD in the bindings instead of vref.
- Add gpio-controller
- Allow describing individual ADC channels
- Switch to regmap with caching
- Reset the chip at probe time
- Small cleanups following all the reviews
- Moved MAINTAINERS to patch 1

V1: https://lore.kernel.org/linux-iio/[email protected]/

Maxime Chevallier (2):
dt-bindings: iio: adc: add Texas Instruments TLA2528
iio: adc: add driver for Texas Instruments TLA2528 adc

 .../bindings/iio/adc/ti,tla2528.yaml          |  91 ++++++++
 MAINTAINERS                                   |   6 +
 drivers/iio/adc/Kconfig                       |  12 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/ti-tla2528.c                  | 218 ++++++++++++++++++
 5 files changed, 328 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml
 create mode 100644 drivers/iio/adc/ti-tla2528.c
Signature · 1 line
2.56.0
#1 lore raw

PATCH v4 1/2 dt-bindings: iio: adc: add Texas Instruments TLA2528

The TI TLA2528 is a simple 8-channel, 12-bit ADC and GPIO chip accessible over i2c. The ADC part has an AVDD supply that doubles as a reference.

---
 .../bindings/iio/adc/ti,tla2528.yaml          | 91 +++++++++++++++++++
 MAINTAINERS                                   |  5 +
 2 files changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml
Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml new file +91 -0
new file mode 100644
index 000000000000..7a50a5026c1e
@@ -0,0 +1,91 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/ti,tla2528.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments TLA2528 8-channel 12-bit I2C ADC
+
+maintainers:
+  - Maxime Chevallier <[email protected]>
+
+description:
+  Each of the 8 input pins can be configured as an analog input, a digital
+  input or a digital output.
+
+properties:
+  compatible:
+    const: ti,tla2528
+
+  reg:
+    maxItems: 1
+
+  avdd-supply:
+    description: Analog supply, also used as the ADC reference voltage.
+
+  dvdd-supply: true
+
+  gpio-controller: true
+
+  "#gpio-cells":
+    const: 2
+
+  "#io-channel-cells":
+    const: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+patternProperties:
+  "^channel@[0-7]$":
+    type: object
+    $ref: adc.yaml
+    description: Represents an analog input.
+
+    properties:
+      reg:
+        description: AIN pin number
+        minimum: 0
+        maximum: 7
+
+    required:
+      - reg
+
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - avdd-supply
+  - dvdd-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@17 {
+            compatible = "ti,tla2528";
+            reg = <0x17>;
+            avdd-supply = <&reg_adc_supply>;
+            dvdd-supply = <&reg_adc_supply>;
+            #io-channel-cells = <1>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            channel@0 {
+                reg = <0>;
+            };
+
+            channel@3 {
+                reg = <3>;
+            };
+        };
+    };
+...
MAINTAINERS +5 -0
index 93abbb315065..2cf3fc9bb74d 100644
@@ -27758,6 +27758,11 @@ F:	include/dt-bindings/soc/ti,sci_pm_domain.h
 F:	include/linux/soc/ti/ti_sci_inta_msi.h
 F:	include/linux/soc/ti/ti_sci_protocol.h
 
+TEXAS INSTRUMENTS' TLA2528 ADC DRIVER
+M:	Maxime Chevallier <[email protected]>
+S:	Supported
+F:	Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml
+
 TEXAS INSTRUMENTS' TMP117 TEMPERATURE SENSOR DRIVER
 M:	Puranjay Mohan <[email protected]>
 L:	[email protected]
Signature · 1 line
2.56.0
#2 lore raw

PATCH v4 2/2 iio: adc: add driver for Texas Instruments TLA2528 adc

In reply to Maxime Chevallier

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

---
 MAINTAINERS                  |   1 +
 drivers/iio/adc/Kconfig      |  12 ++
 drivers/iio/adc/Makefile     |   1 +
 drivers/iio/adc/ti-tla2528.c | 218 +++++++++++++++++++++++++++++++++++
 4 files changed, 232 insertions(+)
 create mode 100644 drivers/iio/adc/ti-tla2528.c
MAINTAINERS +1 -0
index 2cf3fc9bb74d..59e960d7e547 100644
@@ -27762,6 +27762,7 @@ TEXAS INSTRUMENTS' TLA2528 ADC DRIVER
 M:	Maxime Chevallier <[email protected]>
 S:	Supported
 F:	Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml
+F:	drivers/iio/adc/ti-tla2528.c
 
 TEXAS INSTRUMENTS' TMP117 TEMPERATURE SENSOR DRIVER
 M:	Puranjay Mohan <[email protected]>
drivers/iio/adc/Kconfig +12 -0
index a802d8ee4dd9..8633267d6056 100644
@@ -2016,6 +2016,18 @@ config TI_LMP92064
 	  This driver can also be built as a module. If so, the module will be called
 	  ti-lmp92064.
 
+config TI_TLA2528
+	tristate "Texas Instruments TLA2528 ADC driver"
+	depends on I2C
+	select REGMAP_I2C
+	select IIO_ADC_HELPER
+	help
+	  Say yes here to build support for Texas Instruments TLA2528
+	  12-Bit 8-Channel ADC.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called ti-tla2528.
+
 config TI_TLC4541
 	tristate "Texas Instruments TLC4541 ADC driver"
 	depends on SPI
drivers/iio/adc/Makefile +1 -0
index 9e82c21dbd37..b98cded4d0c7 100644
@@ -171,6 +171,7 @@ obj-$(CONFIG_TI_ADS8344) += ti-ads8344.o
 obj-$(CONFIG_TI_ADS8688) += ti-ads8688.o
 obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o
 obj-$(CONFIG_TI_LMP92064) += ti-lmp92064.o
+obj-$(CONFIG_TI_TLA2528) += ti-tla2528.o
 obj-$(CONFIG_TI_TLC4541) += ti-tlc4541.o
 obj-$(CONFIG_TI_TSC2046) += ti-tsc2046.o
 obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o
drivers/iio/adc/ti-tla2528.c new file +218 -0

218 lines not on this page · raw message

Signature · 1 line
2.56.0
Reviewed-by on v4 2/2
#3 lore raw
Quoted 11 lines · On Fri, 13 Nov 2026 16:15:42 +0100 Maxime Chevallier…

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

---

This looks ready to be applied.

Signature · 2 lines
Kind regards,
Joshua Crofts
#4 lore raw
In reply to Maxime Chevallier
Quoted 10 lines · Maxime Chevallier

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

This looks very familiar to me. I am pretty sure I've reviewed this. Is there a reason the RB-tag wasn't carried over? (Sorry if I've missed some change(s))!

Yours,
-- Matti

Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
#5 lore raw

Hi Matti,

Quoted 8 lines · Matti Vaittinen
Quoted 7 lines · Maxime Chevallier

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

Quoted 7 lines
Quoted 3 lines

This looks very familiar to me. I am pretty sure I've reviewed this. Is there a reason the RB-tag wasn't carried over? (Sorry if I've missed some change(s))!

Yours,
  -- Matti

You did add a Rb tag on V2, but I dropped it for V3 as the delta between V2 and V3 was quite substantial and included changes requested by other people than you :)

I mentionned your tag being dropped on the V3 cover, but I didn't carry that info for V4, sorry about that...

Anyways thanks a lot for the help,

Maxime

#6 lore raw
Quoted 14 lines · Maxime Chevallier

Hi Matti,

Quoted 11 lines · Matti Vaittinen
Quoted 10 lines · Maxime Chevallier

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

Quoted 8 lines
Quoted 4 lines

This looks very familiar to me. I am pretty sure I've reviewed this. Is there a reason the RB-tag wasn't carried over? (Sorry if I've missed some change(s))!

Yours,
  -- Matti

You did add a Rb tag on V2, but I dropped it for V3 as the delta between V2 and V3 was quite substantial and included changes requested by other people than you :)

Ok. Thanks for the explanation.

Quoted 2 lines

I mentionned your tag being dropped on the V3 cover, but I didn't carry that info for V4, sorry about that...

Keeping the note in the cover version history can indeed help reviewers.

Quoted 1 line

Anyways thanks a lot for the help,

No problem. It looks like a clean and nice driver to me. Good job.

Yours,
-- Matti

Signature · 5 lines
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~
Reviewed-by on v4 2/2
#7 lore raw
In reply to Maxime Chevallier
Quoted 2 lines · Maxime Chevallier

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

I forgot to check if there is a justification of the brand new driver, I assume there is.

Quoted 3 lines

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

Some nit-picks below, but they do not prevent from this patch being accepted, so

...

drivers/iio/adc/ti-tla2528.c line 72

Quoted 11 lines
drivers/iio/adc/ti-tla2528.c new file +11 -0
+static int tla2528_read(struct tla2528 *tla2528, u8 channel, int *val)
+{
+	__be16 data;
+	int ret;
+
+	guard(mutex)(&tla2528->lock);
+
+	ret = regmap_update_bits(tla2528->regmap, TLA2528_CHANNEL_SEL_ADR,
+				 TLA2528_CHANNEL_SEL_MANUAL_CHID, channel);
+	if (ret)
+		return ret;

Ideally this needs a comment explaining in short why regmap IO accessors may not be used.

Quoted 10 lines
drivers/iio/adc/ti-tla2528.c new file +10 -0
+	ret = i2c_master_recv(tla2528->client, (char *)&data, sizeof(data));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(data))
+		return -EIO;
+
+	*val = be16_to_cpu(data) >> 4;
+
+	return 0;
+}

...

drivers/iio/adc/ti-tla2528.c line 183

Quoted 2 lines
drivers/iio/adc/ti-tla2528.c new file +2 -0
+	ret = regmap_write(tla2528->regmap, TLA2528_GENERAL_CFG_ADR,
+			   TLA2528_GENERAL_CFG_RST);

With locally defined

	struct regmap *map;
	...
	map = devm_regmap_*init*(...);
	...
	tla2528->regmap = map;
	...
	ret = regmap_write(map, TLA2528_GENERAL_CFG_ADR, TLA2528_GENERAL_CFG_RST);

this can kill two birds with one stone:
- make this one line (yes, 82 characters is okay)
- keeping data structure free from error pointers

Quoted 2 lines
(quoted diff) +2 -0
+	if (ret)
+		return ret;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#8 lore raw
Quoted 7 lines · On Fri, 13 Nov 2026 17:40:45 +0200 Andy Shevchenko…
Quoted 2 lines · Maxime Chevallier

Add a new driver for the TI TLA2528 ADC chip. It has 8 12-bit channels, that can also be configured as 16-bit averaging channels.

I forgot to check if there is a justification of the brand new driver, I assume there is.

Quoted 9 lines
Quoted 3 lines

This is a very simple driver, allowing reading raw values for each channel. GPIO mode isn't supported for now, as well as buffered mode and the 16-bit averaging mode.

Some nit-picks below, but they do not prevent from this patch being accepted, so

Applied, I did the second of these suggestions as a tweak.

Thanks,

Jonathan

Quoted 16 lines

...

Review

Quoted 11 lines
(quoted diff) +11 -0
+static int tla2528_read(struct tla2528 *tla2528, u8 channel, int *val)
+{
+	__be16 data;
+	int ret;
+
+	guard(mutex)(&tla2528->lock);
+
+	ret = regmap_update_bits(tla2528->regmap, TLA2528_CHANNEL_SEL_ADR,
+				 TLA2528_CHANNEL_SEL_MANUAL_CHID, channel);
+	if (ret)
+		return ret;  

Ideally this needs a comment explaining in short why regmap IO accessors may not be used.

I left this alone because there is a comment in probe. I'm not sure repeating a comment that basically says 'because weird' is worth it.

Quoted 27 lines
Quoted 11 lines
(quoted diff) +10 -0
+	ret = i2c_master_recv(tla2528->client, (char *)&data, sizeof(data));
+	if (ret < 0)
+		return ret;
+	if (ret != sizeof(data))
+		return -EIO;
+
+	*val = be16_to_cpu(data) >> 4;
+
+	return 0;
+}  

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+	ret = regmap_write(tla2528->regmap, TLA2528_GENERAL_CFG_ADR,
+			   TLA2528_GENERAL_CFG_RST);  

With locally defined

	struct regmap *map;
	...
	map = devm_regmap_*init*(...);
	...
	tla2528->regmap = map;
	...
	ret = regmap_write(map, TLA2528_GENERAL_CFG_ADR, TLA2528_GENERAL_CFG_RST);
Quoted 4 lines

this can kill two birds with one stone:
- make this one line (yes, 82 characters is okay)
- keeping data structure free from error pointers

drivers/iio/adc/ti-tla2528.c +7 -5
index c02b04e19785..754b31d6725f 100644
@@ -128,6 +128,7 @@ static int tla2528_probe(struct i2c_client *client)
 	struct iio_chan_spec *channels;
 	struct iio_dev *indio_dev;
 	struct tla2528 *tla2528;
+	struct regmap *map;
 	int ret;
 
 	/*
@@ -148,9 +149,11 @@ static int tla2528_probe(struct i2c_client *client)
 	tla2528 = iio_priv(indio_dev);
 	tla2528->client = client;
 
-	tla2528->regmap = devm_regmap_init_i2c(client, &tla2528_regmap_config);
-	if (IS_ERR(tla2528->regmap))
-		return PTR_ERR(tla2528->regmap);
+	map = devm_regmap_init_i2c(client, &tla2528_regmap_config);
+	if (IS_ERR(map))
+		return PTR_ERR(map);
+
+	tla2528->regmap = map;
 
 	ret = devm_mutex_init(dev, &tla2528->lock);
 	if (ret)
@@ -179,8 +182,7 @@ static int tla2528_probe(struct i2c_client *client)
 	indio_dev->info = &tla2528_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = regmap_write(tla2528->regmap, TLA2528_GENERAL_CFG_ADR,
-			   TLA2528_GENERAL_CFG_RST);
+	ret = regmap_write(map, TLA2528_GENERAL_CFG_ADR, TLA2528_GENERAL_CFG_RST);
 	if (ret)
 		return ret;
 
Quoted 3 lines
Quoted 2 lines
(quoted diff) +2 -0
+	if (ret)
+		return ret;