From nobody Sun Feb 8 06:55:47 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B39CE27A469 for ; Tue, 23 Dec 2025 15:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766505353; cv=none; b=hxyX4tiMO4V1bg15Y6KQz7m9e+yByMLndYreHiGTS882rcGtsc6fb/YJ737BFtpkzh7ls1S8EjjCWWhjk9lj1bmca/Wvj15hyy1+BHjdDu2Kw0KGaMfMVaGYUr8elfrIq+r1NUT7Q/viRSz0nqd7eSWLqTEF3KlmgC8Gx58BF1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766505353; c=relaxed/simple; bh=Q3ctYQU1rVgXAMam9Ncnna7UIHqfS/2j8YnOh/bGPCA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EaZGaL2rprvidE1EOtmNrtykmOg0SDV72ZrLlX2CnmbMnUBIGerGwSumXZ1Sw0qxt1dw43JDe4WmVB7N+AKLlmNOR4etsa7eR/HLqZ36Pk7aOzjTJYIkp5LXlcz2wO2hu4z52NDIPqwfWL4U0Cs2IvImXPyUmxPAqoW+0HC6VHg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=yGQI0UkA; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="yGQI0UkA" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 4642E4E41D68; Tue, 23 Dec 2025 15:55:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1BAAD60716; Tue, 23 Dec 2025 15:55:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id C98F810AB0BB0; Tue, 23 Dec 2025 16:55:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1766505349; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=0AGvUoXA3WqR7xPRGLiv4z6PT4pGE6W54hFH1dJ1ESU=; b=yGQI0UkAmOqIxZCocLparNaW7Ptk96r0LKQQXarkb/k5tkw5BQ2kxcrJ5KX0dCsaWGYyCQ EeuglPeN3AZ+XvgeW3BmOFojaPgHhN8znm0JVDBVxdPbgLRSPGbYanYT3E0ymANt5Z1MHw p/OQHdpEEIzNoNoEalMX/ZyOvYLU6fWZlUzNicSrjfQBVYmFk2wGYxFPGTRsMuYyWVXulj dflDBZC0yGewkDdO2yAwpIhIXPRu+w6R2sYw5DhB7xUj1ECaD3eJFURYV3LFYsTqtNAZqA Jp1hSYejAgQ/LE+VbXZ+Zzo7OX7DflEXDuEpu0xJgh9zNo2ZI6t3LSDqlmz4gQ== From: Maxime Chevallier To: Jonathan Cameron , David Lechner , nuno.sa@analog.com, Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marcelo Schmitt , Matti Vaittinen , Antoniu Miclaus , Angelo Dureghello , Tobias Sperling , Eason Yang , Marilene Andrade Garcia , Cosmin Tanislav , duje@dujemihanovic.xyz, herve.codina@bootlin.com, Rodolfo Giometti Cc: Maxime Chevallier , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH 1/2] dt-bindings: iio: adc: add Texas Instruments TLA 2528 Date: Tue, 23 Dec 2025 16:55:32 +0100 Message-ID: <20251223155534.220504-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20251223155534.220504-1-maxime.chevallier@bootlin.com> References: <20251223155534.220504-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The TI TLA 2528 is a simple 8 channel, 12-bit ADC? Add a binding documentation for it. Signed-off-by: Maxime Chevallier --- .../bindings/iio/adc/ti,tla2528.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,tla2528.ya= ml diff --git a/Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml b/Do= cumentation/devicetree/bindings/iio/adc/ti,tla2528.yaml new file mode 100644 index 000000000000..0ee326d77014 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ti,tla2528.yaml @@ -0,0 +1,48 @@ +# 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 12bit I2C ADC + +maintainers: + - Maxime Chevallier + +description: | + 12bit 8-channel I2C ADC. + +properties: + compatible: + const: ti,tla2528 + + reg: + maxItems: 1 + + vref-supply: + description: Supply for 2.35V to 5.5V reference voltage + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + - vref-supply + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + adc@17 { + compatible =3D "ti,tla2528"; + reg =3D <0x17>; + vref-supply =3D <®_adc_supply>; + #io-channel-cells =3D <1>; + }; + }; +... --=20 2.49.0 From nobody Sun Feb 8 06:55:47 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3CC01DA62E; Tue, 23 Dec 2025 15:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766505358; cv=none; b=asW0Tkh5FdrZYSmcxYVnRZKaFgtgXb094G1XqOsP5hASL1i8AJeeidyiJjpZGYkhdtBnK2D2a6xh92sw3EJ5AXKl0aTkC3G/iNKsgRFvfUzKQsC0zhKJsar7pOyVAGa59z1Nz94ZFHTUSzyszH98txH07LQ0XjKYKVVyJNpjsT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766505358; c=relaxed/simple; bh=poZQn7Agu5ywNgg3uB33d1fbiLBYSy8hBxt1Mw++Hog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iFiCrbZ5GaNKjJBGhb/CzmILqXp8XdaKcChhsyQUInKKwToZCu4EE3VGzXOWXVSqWa7se29xUlH6FzywRijg0jg8G7Xq06g6f7odVobZC2LqLrQzyuPrxqVjIOYuLW9jxbSko8JK7CCiiZZO+5X6fOpgC1vOr6YNTll3eW7q4XM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=yKB8MM9e; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="yKB8MM9e" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 1AFC74E41D52; Tue, 23 Dec 2025 15:55:53 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E2E4660716; Tue, 23 Dec 2025 15:55:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 870B010AB0BB1; Tue, 23 Dec 2025 16:55:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1766505351; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=JqvpCgakLbqyOqF8D9gvhpB419I7/mBwXxM7M8O++/8=; b=yKB8MM9e/QwZH9JtiYpwGinoysi+6IbSZGsP5YkJm/eePtwpLIh5/XqVPKnHkRXBBd2+e3 lM2wdoQxZQKrqZ/I8BAVDRLFniuGNg4IoQ6/ISo7zFGeIMJ7e0zHXkPS1PFYzhLalylmS3 TSGeHmJMGONvk3Gef33DIZL4Ket6MsDbyY0+gJz5oCSSGrO3/uDuJVRLy+M0nOJWATYIQ9 4eUJjxj7GwBDoNeheeD/8n6/NJCaruul/Qs+N4qm8yuyJRa7AVB9mY6dqI060XUZTUdvMw Ek6C10o+sDnTIQPkYw6PdpxwjsWUglMx/7F9IbLcgpc7arQW3zFHrunZtywEOg== From: Maxime Chevallier To: Jonathan Cameron , David Lechner , nuno.sa@analog.com, Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Marcelo Schmitt , Matti Vaittinen , Antoniu Miclaus , Angelo Dureghello , Tobias Sperling , Eason Yang , Marilene Andrade Garcia , Cosmin Tanislav , duje@dujemihanovic.xyz, herve.codina@bootlin.com, Rodolfo Giometti Cc: Maxime Chevallier , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc Date: Tue, 23 Dec 2025 16:55:33 +0100 Message-ID: <20251223155534.220504-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20251223155534.220504-1-maxime.chevallier@bootlin.com> References: <20251223155534.220504-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" This adds a new driver for the TI TLA2528 ADC chip. It ha 8 12-bit channels, that can also be configured as 16-bit averaging channels. Add a very simple driver for it, allowing reading raw values for each channel. Signed-off-by: Rodolfo Giometti Signed-off-by: Maxime Chevallier --- MAINTAINERS | 7 ++ drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ti-tla2528.c | 209 +++++++++++++++++++++++++++++++++++ 4 files changed, 227 insertions(+) create mode 100644 drivers/iio/adc/ti-tla2528.c diff --git a/MAINTAINERS b/MAINTAINERS index dc731d37c8fe..5c382ae216c7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -25866,6 +25866,13 @@ 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 =20 +TEXAS INSTRUMENTS' TLA2528 ADC DRIVER +M: Maxime Chevallier +L: linux-iio@vger.kernel.org +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 L: linux-iio@vger.kernel.org diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 58da8255525e..67376de410bf 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1803,6 +1803,16 @@ config TI_LMP92064 This driver can also be built as a module. If so, the module will be ca= lled ti-lmp92064. =20 +config TI_TLA2528 + tristate "Texas Instruments TLA2528 ADC driver" + depends on I2C + 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 diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 7cc8f9a12f76..941606defbf7 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -157,6 +157,7 @@ obj-$(CONFIG_TI_ADS8344) +=3D ti-ads8344.o obj-$(CONFIG_TI_ADS8688) +=3D ti-ads8688.o obj-$(CONFIG_TI_AM335X_ADC) +=3D ti_am335x_adc.o obj-$(CONFIG_TI_LMP92064) +=3D ti-lmp92064.o +obj-$(CONFIG_TI_TLA2528) +=3D ti-tla2528.o obj-$(CONFIG_TI_TLC4541) +=3D ti-tlc4541.o obj-$(CONFIG_TI_TSC2046) +=3D ti-tsc2046.o obj-$(CONFIG_TWL4030_MADC) +=3D twl4030-madc.o diff --git a/drivers/iio/adc/ti-tla2528.c b/drivers/iio/adc/ti-tla2528.c new file mode 100644 index 000000000000..9c572e730ffb --- /dev/null +++ b/drivers/iio/adc/ti-tla2528.c @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Driver for Texas Instruments TLA2528 ADC + * + * Copyright (C) 2020-2021 Rodolfo Giometti + * Copyright (C) 2025 Maxime Chevallier + */ + +#include +#include +#include +#include +#include + +#include + +#define TLA2528_OP_WRITE_REG 0x08 + +#define TLA2528_DATA_CFG_ADR 0x02 + +/* Datasheet says [5:4] sets the append status, but only bit 4 is used */ +#define TLA2528_DATA_CFG_APPEND_STATUS BIT(4) +#define TLA2528_PIN_CFG_ADR 0x05 +#define TLA2528_SEQUENCE_CFG_ADR 0x10 +#define TLA2528_CHANNEL_SEL_ADR 0x11 + +struct tla2528 { + struct i2c_client *client; + int vref_uv; + + /* Protects manual channel selection, i.e. last_read_channel */ + struct mutex lock; + u8 last_read_channel; +}; + +static s32 tla2528_write_reg(const struct i2c_client *client, u8 reg, u8 v= al) +{ + u8 data[3] =3D {TLA2528_OP_WRITE_REG, reg, val}; + int ret; + + ret =3D i2c_master_send(client, data, 3); + + return ret < 0 ? ret : 0; +} + +static int tla2528_read_sample(const struct i2c_client *client) +{ + __be16 data; + int ret; + + ret =3D i2c_master_recv(client, (char *)&data, 2); + if (ret < 0) + return ret; + + return be16_to_cpu(data) >> 4; +} + +static int tla2528_read(struct tla2528 *tla2528, u8 channel, int *val) +{ + struct i2c_client *client =3D tla2528->client; + int ret; + + if (channel !=3D tla2528->last_read_channel) { + ret =3D tla2528_write_reg(client, TLA2528_CHANNEL_SEL_ADR, channel); + if (ret < 0) + return ret; + + tla2528->last_read_channel =3D channel; + } + + ret =3D tla2528_read_sample(client); + if (ret < 0) + return ret; + + *val =3D ret; + + return 0; +} + +static int tla2528_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct tla2528 *tla2528 =3D iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&tla2528->lock); + ret =3D tla2528_read(tla2528, chan->channel, val); + mutex_unlock(&tla2528->lock); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + *val =3D tla2528->vref_uv / 1000; + *val2 =3D 12; + + return IIO_VAL_FRACTIONAL_LOG2; + + default: + return -EINVAL; + } +} + +#define TLA2528_CHAN(_chan, _name) { \ + .type =3D IIO_VOLTAGE, \ + .channel =3D (_chan), \ + .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_SCALE), \ + .datasheet_name =3D _name, \ + .indexed =3D 1, \ +} + +static const struct iio_chan_spec tla2528_channel[] =3D { + TLA2528_CHAN(0, "AIN0"), + TLA2528_CHAN(1, "AIN1"), + TLA2528_CHAN(2, "AIN2"), + TLA2528_CHAN(3, "AIN3"), + TLA2528_CHAN(4, "AIN4"), + TLA2528_CHAN(5, "AIN5"), + TLA2528_CHAN(6, "AIN6"), + TLA2528_CHAN(7, "AIN7"), +}; + +static const struct iio_info tla2528_info =3D { + .read_raw =3D tla2528_read_raw, +}; + +static int tla2528_probe(struct i2c_client *client) +{ + struct iio_dev *indio_dev; + struct tla2528 *tla2528; + int ret; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | + I2C_FUNC_SMBUS_WRITE_WORD_DATA)) + return -EOPNOTSUPP; + + indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*tla2528)); + if (!indio_dev) + return -ENOMEM; + + tla2528 =3D iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + tla2528->client =3D client; + + indio_dev->name =3D client->name; + indio_dev->info =3D &tla2528_info; + indio_dev->modes =3D INDIO_DIRECT_MODE; + indio_dev->channels =3D tla2528_channel; + indio_dev->num_channels =3D ARRAY_SIZE(tla2528_channel); + + mutex_init(&tla2528->lock); + + tla2528->vref_uv =3D devm_regulator_get_enable_read_voltage(&client->dev, + "vref"); + if (tla2528->vref_uv < 0) + return tla2528->vref_uv; + + /* Set all inputs as analog */ + ret =3D tla2528_write_reg(tla2528->client, TLA2528_PIN_CFG_ADR, 0x00); + if (ret < 0) + return ret; + + ret =3D tla2528_write_reg(tla2528->client, TLA2528_DATA_CFG_ADR, + TLA2528_DATA_CFG_APPEND_STATUS); + if (ret < 0) + return ret; + + /* Set manual mode */ + ret =3D tla2528_write_reg(tla2528->client, TLA2528_SEQUENCE_CFG_ADR, 0x00= ); + if (ret < 0) + return ret; + + /* Init private data */ + tla2528->last_read_channel =3D ~0; + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id tla2528_id[] =3D { + { "tla2528", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, tla2528_id); + +static const struct of_device_id tla2528_of_match[] =3D { + { .compatible =3D "ti,tla2528", }, + { }, +}; +MODULE_DEVICE_TABLE(of, tla2528_of_match); + +static struct i2c_driver tla2528_driver =3D { + .driver =3D { + .name =3D "tla2528", + .of_match_table =3D tla2528_of_match, + }, + .probe =3D tla2528_probe, + .id_table =3D tla2528_id, +}; +module_i2c_driver(tla2528_driver); + +MODULE_AUTHOR("Maxime Chevallier "); +MODULE_AUTHOR("Rodolfo Giometti "); +MODULE_DESCRIPTION("Texas Instruments TLA2528 ADC driver"); +MODULE_LICENSE("GPL"); --=20 2.49.0