mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Stephan Costa Barros <stephanbrrs8@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <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>,
	"Mike Looijmans" <mike.looijmans@topic.nl>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/6] iio: adc: ti-ads1298: fix power-up and clock handling
Date: Sun, 25 Oct 2026 22:18:20 +0200	[thread overview]
Message-ID: <at5kDPzBIfwAGCNT@ashevche-desk.local> (raw)
In-Reply-To: <20261024231335.280955-3-stephanbrrs8@gmail.com>

On Sat, Oct 24, 2026 at 08:13:31PM -0300, Stephan Costa Barros wrote:
> Fix three issues with the power-up sequence and the device clock:
> 
> - The datasheet powers up the supplies first, then the clock, then
>   waits t_POR = 2^18 clock cycles (128 ms at 2.048 MHz) before the
>   reset. The driver enabled an external clock and the vref supply
>   before AVDD, reset right away, and did not wait for the 150 ms
>   start-up of the internal reference. Follow the datasheet. Probe takes
>   about 280 ms longer.
> 
> - The binding describes one optional clock and no clock-names, but the
>   driver asked for the clock named "clk". With a device tree that
>   follows the binding, the lookup fails, the optional getter returns
>   NULL, and a clock given in the device tree is never enabled, while the
>   sampling frequency is computed from the nominal 2.048 MHz. Ask for the
>   first clock of the node; a device tree with clock-names = "clk" still
>   gets the same clock.
> 
> - A command takes 4 cycles of the device clock to decode, the minimum
>   reset pulse is 2 cycles, and the reset takes 18 more. These were
>   converted with the nominal 2.048 MHz, so a command ends after a fixed
>   2 us, short of 4 cycles with an external clock below 2 MHz, which the
>   ADS129x allows down to 1.94 MHz. Convert them with the rate of the
>   clock in use. At 2.048 MHz the delays do not change.
> 
> The clock lookup was seen to fail on a Raspberry Pi 4, with a
> fixed-clock in the device tree. The power-up order was found by review
> and reproduced on an emulated device only. The decode time was found
> with an emulated device; it is not seen on hardware running at
> 2.048 MHz.

...

> +	clk_rate = priv->clk ? clk_get_rate(priv->clk) : 0;

Why this conditional?

> +	if (!clk_rate)
> +		clk_rate = ADS1298_CLK_RATE_HZ;
> +	priv->clk_rate = clk_rate;

...

> +	/* Power-on reset time, counted from when the clock is valid */
> +	msleep(DIV_ROUND_UP(ADS1298_TPOR_CLOCKS * MILLI, clk_rate));

Do you mean MSEC_PER_SEC?

...

> +	priv->rdata_xfer.delay.value = ads1298_clocks_to_usecs(priv,
> +							       ADS1298_DECODE_CLOCKS);

Indent it as

	priv->rdata_xfer.delay.value =
		ads1298_clocks_to_usecs(priv, ADS1298_DECODE_CLOCKS);

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-10-25 20:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24 23:13 [PATCH v2 0/6] iio: adc: ti-ads1298: fixes, and ADS1299 support Stephan Costa Barros
2026-10-24 23:13 ` [PATCH v2 1/6] iio: adc: ti-ads1298: fix the data read path Stephan Costa Barros
2026-10-25 20:14   ` Andy Shevchenko
2026-10-25 23:06   ` Jonathan Cameron
2026-10-24 23:13 ` [PATCH v2 2/6] iio: adc: ti-ads1298: fix power-up and clock handling Stephan Costa Barros
2026-10-25 20:18   ` Andy Shevchenko [this message]
2026-10-25 23:07   ` Jonathan Cameron
2026-10-26  6:27   ` Mike Looijmans
2026-10-24 23:13 ` [PATCH v2 3/6] iio: adc: ti-ads1298: fix scale, ID check, regmap and Kconfig Stephan Costa Barros
2026-10-25 23:12   ` Jonathan Cameron
2026-10-24 23:13 ` [PATCH v2 4/6] iio: adc: ti-ads1298: prepare for more chip families Stephan Costa Barros
2026-10-25 20:27   ` Andy Shevchenko
2026-10-25 23:26   ` Jonathan Cameron
2026-10-24 23:13 ` [PATCH v2 5/6] dt-bindings: iio: adc: ti,ads1298: add ADS1299 Stephan Costa Barros
2026-10-24 23:13 ` [PATCH v2 6/6] iio: adc: ti-ads1298: add ADS1299 support Stephan Costa Barros
2026-10-25 20:34   ` Andy Shevchenko
2026-10-25 23:34   ` Jonathan Cameron

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=at5kDPzBIfwAGCNT@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.looijmans@topic.nl \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=stephanbrrs8@gmail.com \
    --cc=u.kleine-koenig@baylibre.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

all inboxes | Powered by JetHome®