From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Julien Stephan" <jstephan@baylibre.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Conor Dooley <conor.dooley@microchip.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 3/5] iio: adc: ad7380: add missing supplies
Date: Mon, 21 Oct 2024 13:15:19 +0200 [thread overview]
Message-ID: <717d15c36fbd1a5c23526ac87bc9d66cd39c54d3.camel@gmail.com> (raw)
In-Reply-To: <20241021-ad7380-fix-supplies-v2-3-2ca551b3352a@baylibre.com>
On Mon, 2024-10-21 at 12:00 +0200, Julien Stephan wrote:
> vcc and vlogic are required but are not retrieved and enabled in the
> probe. Add them.
>
> In order to prepare support for additional parts requiring different
> supplies, add vcc and vlogic to the platform specific structures
>
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> ---
One small not below... With that,
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> drivers/iio/adc/ad7380.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7380.c b/drivers/iio/adc/ad7380.c
> index
> e033c734191143a25a490b09c730dbf95f796737..e257f78d63edd7910fcb936ec5344922f8e7
> 0b99 100644
> --- a/drivers/iio/adc/ad7380.c
> +++ b/drivers/iio/adc/ad7380.c
> @@ -75,6 +75,7 @@
> #define T_CONVERT_NS 190 /* conversion time */
> #define T_CONVERT_0_NS 10 /* 1st conversion start time
> (oversampling) */
> #define T_CONVERT_X_NS 500 /* xth conversion start time
> (oversampling) */
> +#define T_POWERUP_MS 5 /* Power up */
>
> struct ad7380_timing_specs {
> const unsigned int t_csh_ns; /* CS minimum high time */
> @@ -86,6 +87,8 @@ struct ad7380_chip_info {
> unsigned int num_channels;
> unsigned int num_simult_channels;
> bool has_mux;
> + const char * const *supplies;
> + unsigned int num_supplies;
> const char * const *vcm_supplies;
> unsigned int num_vcm_supplies;
> const unsigned long *available_scan_masks;
> @@ -243,6 +246,10 @@ DEFINE_AD7380_8_CHANNEL(ad7386_4_channels, 16, 0, u);
> DEFINE_AD7380_8_CHANNEL(ad7387_4_channels, 14, 0, u);
> DEFINE_AD7380_8_CHANNEL(ad7388_4_channels, 12, 0, u);
>
> +static const char * const ad7380_supplies[] = {
> + "vcc", "vlogic",
> +};
> +
> static const char * const ad7380_2_channel_vcm_supplies[] = {
> "aina", "ainb",
> };
> @@ -338,6 +345,8 @@ static const struct ad7380_chip_info ad7380_chip_info = {
> .channels = ad7380_channels,
> .num_channels = ARRAY_SIZE(ad7380_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .available_scan_masks = ad7380_2_channel_scan_masks,
> .timing_specs = &ad7380_timing,
> };
> @@ -347,6 +356,8 @@ static const struct ad7380_chip_info ad7381_chip_info = {
> .channels = ad7381_channels,
> .num_channels = ARRAY_SIZE(ad7381_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .available_scan_masks = ad7380_2_channel_scan_masks,
> .timing_specs = &ad7380_timing,
> };
> @@ -356,6 +367,8 @@ static const struct ad7380_chip_info ad7383_chip_info = {
> .channels = ad7383_channels,
> .num_channels = ARRAY_SIZE(ad7383_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .vcm_supplies = ad7380_2_channel_vcm_supplies,
> .num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
> .available_scan_masks = ad7380_2_channel_scan_masks,
> @@ -367,6 +380,8 @@ static const struct ad7380_chip_info ad7384_chip_info = {
> .channels = ad7384_channels,
> .num_channels = ARRAY_SIZE(ad7384_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .vcm_supplies = ad7380_2_channel_vcm_supplies,
> .num_vcm_supplies = ARRAY_SIZE(ad7380_2_channel_vcm_supplies),
> .available_scan_masks = ad7380_2_channel_scan_masks,
> @@ -378,6 +393,8 @@ static const struct ad7380_chip_info ad7386_chip_info = {
> .channels = ad7386_channels,
> .num_channels = ARRAY_SIZE(ad7386_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .has_mux = true,
> .available_scan_masks = ad7380_2x2_channel_scan_masks,
> .timing_specs = &ad7380_timing,
> @@ -388,6 +405,8 @@ static const struct ad7380_chip_info ad7387_chip_info = {
> .channels = ad7387_channels,
> .num_channels = ARRAY_SIZE(ad7387_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .has_mux = true,
> .available_scan_masks = ad7380_2x2_channel_scan_masks,
> .timing_specs = &ad7380_timing,
> @@ -398,6 +417,8 @@ static const struct ad7380_chip_info ad7388_chip_info = {
> .channels = ad7388_channels,
> .num_channels = ARRAY_SIZE(ad7388_channels),
> .num_simult_channels = 2,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .has_mux = true,
> .available_scan_masks = ad7380_2x2_channel_scan_masks,
> .timing_specs = &ad7380_timing,
> @@ -408,6 +429,8 @@ static const struct ad7380_chip_info ad7380_4_chip_info =
> {
> .channels = ad7380_4_channels,
> .num_channels = ARRAY_SIZE(ad7380_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .available_scan_masks = ad7380_4_channel_scan_masks,
> .timing_specs = &ad7380_4_timing,
> };
> @@ -417,6 +440,8 @@ static const struct ad7380_chip_info ad7381_4_chip_info =
> {
> .channels = ad7381_4_channels,
> .num_channels = ARRAY_SIZE(ad7381_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .available_scan_masks = ad7380_4_channel_scan_masks,
> .timing_specs = &ad7380_4_timing,
> };
> @@ -426,6 +451,8 @@ static const struct ad7380_chip_info ad7383_4_chip_info =
> {
> .channels = ad7383_4_channels,
> .num_channels = ARRAY_SIZE(ad7383_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .vcm_supplies = ad7380_4_channel_vcm_supplies,
> .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
> .available_scan_masks = ad7380_4_channel_scan_masks,
> @@ -437,6 +464,8 @@ static const struct ad7380_chip_info ad7384_4_chip_info =
> {
> .channels = ad7384_4_channels,
> .num_channels = ARRAY_SIZE(ad7384_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .vcm_supplies = ad7380_4_channel_vcm_supplies,
> .num_vcm_supplies = ARRAY_SIZE(ad7380_4_channel_vcm_supplies),
> .available_scan_masks = ad7380_4_channel_scan_masks,
> @@ -448,6 +477,8 @@ static const struct ad7380_chip_info ad7386_4_chip_info =
> {
> .channels = ad7386_4_channels,
> .num_channels = ARRAY_SIZE(ad7386_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .has_mux = true,
> .available_scan_masks = ad7380_2x4_channel_scan_masks,
> .timing_specs = &ad7380_4_timing,
> @@ -458,6 +489,8 @@ static const struct ad7380_chip_info ad7387_4_chip_info =
> {
> .channels = ad7387_4_channels,
> .num_channels = ARRAY_SIZE(ad7387_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .has_mux = true,
> .available_scan_masks = ad7380_2x4_channel_scan_masks,
> .timing_specs = &ad7380_4_timing,
> @@ -468,6 +501,8 @@ static const struct ad7380_chip_info ad7388_4_chip_info =
> {
> .channels = ad7388_4_channels,
> .num_channels = ARRAY_SIZE(ad7388_4_channels),
> .num_simult_channels = 4,
> + .supplies = ad7380_supplies,
> + .num_supplies = ARRAY_SIZE(ad7380_supplies),
> .has_mux = true,
> .available_scan_masks = ad7380_2x4_channel_scan_masks,
> .timing_specs = &ad7380_4_timing,
> @@ -1004,6 +1039,14 @@ static int ad7380_probe(struct spi_device *spi)
> if (!st->chip_info)
> return dev_err_probe(&spi->dev, -EINVAL, "missing match
> data\n");
>
> + ret = devm_regulator_bulk_get_enable(&spi->dev, st->chip_info-
> >num_supplies,
> + st->chip_info->supplies);
> +
> + if (ret)
> + return dev_err_probe(&spi->dev, ret,
> + "Failed to enable power supplies\n");
> + msleep(T_POWERUP_MS);
T_POWERUP_MS is 5ms so msleep() is not the advised API to use. In order to have
not to think about it, use fsleep(). This came up recently and this is one of
the reasons why I think (in most common cases at least) using fsleep() is a good
practise even if we already know which function we need to call. Also makes
reviewers lives easier as we don't have to double check the time being slept.
- Nuno Sá
next prev parent reply other threads:[~2024-10-21 11:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 10:00 [PATCH v2 0/5] iio: adc: ad7380: fix several supplies issues Julien Stephan
2024-10-21 10:00 ` [PATCH v2 1/5] dt-bindings: iio: adc: ad7380: fix ad7380-4 reference supply Julien Stephan
2024-10-21 12:07 ` Conor Dooley
2024-10-21 10:00 ` [PATCH v2 2/5] iio: adc: ad7380: use devm_regulator_get_enable_read_voltage() Julien Stephan
2024-10-21 11:09 ` Nuno Sá
2024-10-21 10:00 ` [PATCH v2 3/5] iio: adc: ad7380: add missing supplies Julien Stephan
2024-10-21 11:15 ` Nuno Sá [this message]
2024-10-21 10:00 ` [PATCH v2 4/5] iio: adc: ad7380: fix supplies for ad7380-4 Julien Stephan
2024-10-21 11:22 ` Nuno Sá
2024-10-21 12:50 ` Julien Stephan
2024-10-21 10:00 ` [PATCH v2 5/5] docs: iio: ad7380: fix supply " Julien Stephan
2024-10-21 20:49 ` [PATCH v2 0/5] iio: adc: ad7380: fix several supplies issues David Lechner
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=717d15c36fbd1a5c23526ac87bc9d66cd39c54d3.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=jstephan@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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