From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: David Lechner <dlechner@baylibre.com>,
nuno.sa@analog.com, Andy Shevchenko <andy@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Marcelo Schmitt <marcelo.schmitt@analog.com>,
Matti Vaittinen <mazziesaccount@gmail.com>,
Antoniu Miclaus <antoniu.miclaus@analog.com>,
Angelo Dureghello <adureghello@baylibre.com>,
Tobias Sperling <tobias.sperling@softing.com>,
Eason Yang <j2anfernee@gmail.com>,
Marilene Andrade Garcia <marilene.agarcia@gmail.com>,
Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>,
duje@dujemihanovic.xyz, herve.codina@bootlin.com,
Rodolfo Giometti <giometti@enneenne.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com
Subject: Re: [PATCH 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc
Date: Mon, 5 Jan 2026 11:16:39 +0100 [thread overview]
Message-ID: <6b7bf02e-d016-4d2b-a409-6cd378d409fb@bootlin.com> (raw)
In-Reply-To: <20251227184204.6815a3b4@jic23-huawei>
Hi Jonathan,
On 27/12/2025 19:42, Jonathan Cameron wrote:
> On Tue, 23 Dec 2025 16:55:33 +0100
> Maxime Chevallier <maxime.chevallier@bootlin.com> wrote:
>
>> 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 <giometti@enneenne.com>
>> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
>
> Hi Maxime,
>
> A few extra bits from me
>
> Thanks,
>
> Jonathan
>
>
>> 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 @@
>
>> +
>> +static s32 tla2528_write_reg(const struct i2c_client *client, u8 reg, u8 val)
>> +{
>> + u8 data[3] = {TLA2528_OP_WRITE_REG, reg, val};
>
> Style wise. Prefer { TLA25... val };
Sure thing, I'll address that.
>
> - couple of spaces next to the brackets.
>
>> + int ret;
>> +
>> + ret = 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 = i2c_master_recv(client, (char *)&data, 2);
>
> sizeof(data)
>
>> + if (ret < 0)
>> + return ret;
>> +
>> + return be16_to_cpu(data) >> 4;
>> +}
>
>> +
>> +#define TLA2528_CHAN(_chan, _name) { \
>
> The _ aren't adding anything here, so I'd drop them.
>
>> + .type = IIO_VOLTAGE, \
>> + .channel = (_chan), \
>> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
>> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
>> + .datasheet_name = _name, \
>> + .indexed = 1, \
>> +}
Absolutely :)
>> +
>> +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 = devm_iio_device_alloc(&client->dev, sizeof(*tla2528));
>> + if (!indio_dev)
>> + return -ENOMEM;
>> +
>> + tla2528 = iio_priv(indio_dev);
>> + i2c_set_clientdata(client, indio_dev);
>
> Ever used? If not don't set it.
David mentionned that as well, I'll drop this as this is no longer
required. It used to be required before switching to devm_ helpers.
>
>> + tla2528->client = client;
>> +
>> + indio_dev->name = client->name;
>
> Prefer to see it hard coded as a string. If we added extra firmware
> types in future the content of client->name can become something other
> than the part number.
True, I'll change that
>
>
>> + indio_dev->info = &tla2528_info;
>> + indio_dev->modes = INDIO_DIRECT_MODE;
>> + indio_dev->channels = tla2528_channel;
>> + indio_dev->num_channels = ARRAY_SIZE(tla2528_channel);
>> +
>> + mutex_init(&tla2528->lock);
>> +
>> + tla2528->vref_uv = devm_regulator_get_enable_read_voltage(&client->dev,
>> + "vref");
>> + if (tla2528->vref_uv < 0)
>> + return tla2528->vref_uv;
>> +
>> + /* Set all inputs as analog */
>> + ret = tla2528_write_reg(tla2528->client, TLA2528_PIN_CFG_ADR, 0x00);
>> + if (ret < 0)
>> + return ret;
>> +
>> + ret = tla2528_write_reg(tla2528->client, TLA2528_DATA_CFG_ADR,
>> + TLA2528_DATA_CFG_APPEND_STATUS);
>> + if (ret < 0)
>> + return ret;
>> +
>> + /* Set manual mode */
>> + ret = tla2528_write_reg(tla2528->client, TLA2528_SEQUENCE_CFG_ADR, 0x00);
>> + if (ret < 0)
>> + return ret;
>> +
>> + /* Init private data */
>> + tla2528->last_read_channel = ~0;
>> +
>> + return devm_iio_device_register(&client->dev, indio_dev);
>> +}
Thanks for the reviews :)
Maxime
next prev parent reply other threads:[~2026-01-05 10:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 15:55 [PATCH 0/2] Add driver for the TI TLA2528 i2c ADC Maxime Chevallier
2025-12-23 15:55 ` [PATCH 1/2] dt-bindings: iio: adc: add Texas Instruments TLA 2528 Maxime Chevallier
2025-12-23 18:26 ` David Lechner
2025-12-29 8:04 ` Matti Vaittinen
2025-12-29 9:31 ` Andy Shevchenko
2025-12-29 13:23 ` Matti Vaittinen
2026-01-05 9:17 ` Maxime Chevallier
2026-01-05 9:18 ` Maxime Chevallier
2025-12-23 15:55 ` [PATCH 2/2] iio: adc: add driver for Texas Instruments TLA2528 adc Maxime Chevallier
2025-12-23 17:12 ` Maxime Chevallier
2025-12-23 17:33 ` David Lechner
2025-12-27 14:43 ` Andy Shevchenko
2025-12-23 18:26 ` David Lechner
2026-01-05 10:11 ` Maxime Chevallier
2025-12-27 18:42 ` Jonathan Cameron
2026-01-05 10:16 ` Maxime Chevallier [this message]
2026-01-11 12:04 ` Jonathan Cameron
2025-12-29 8:20 ` Matti Vaittinen
2025-12-31 17:12 ` Jonathan Cameron
2026-01-02 7:13 ` Matti Vaittinen
2026-01-11 12:06 ` Jonathan Cameron
2026-01-05 10:25 ` Maxime Chevallier
2025-12-29 9:39 ` Andy Shevchenko
2026-01-05 10:27 ` Maxime Chevallier
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=6b7bf02e-d016-4d2b-a409-6cd378d409fb@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=adureghello@baylibre.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=conor+dt@kernel.org \
--cc=cosmin-gabriel.tanislav.xa@renesas.com \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=duje@dujemihanovic.xyz \
--cc=giometti@enneenne.com \
--cc=herve.codina@bootlin.com \
--cc=j2anfernee@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--cc=marilene.agarcia@gmail.com \
--cc=mazziesaccount@gmail.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=tobias.sperling@softing.com \
/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