mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Cc: "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>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Marek Vasut" <marex@nabladev.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 02/14] iio: adc: stm32-adc: core: manage clock prescaler diversity
Date: Sun, 27 Sep 2026 19:57:53 +0100	[thread overview]
Message-ID: <20260927195753.307af72f@jic23-hlaptop> (raw)
In-Reply-To: <20260923-adc-stm32mp25-v1-v2-2-46bc019537c6@foss.st.com>

On Wed, 23 Sep 2026 17:39:05 +0200
Fabrice Gasnier <fabrice.gasnier@foss.st.com> wrote:

> Make the clock prescaler selection configurable, to prepare stm32mp2
> support.
> Reuse existing stm32f4_adc_clk_sel(). Rename it so it's no longer
> specific to stm32f4. Add configuration data to handle upcoming
> differences on:
> - registers and bits
> - division ratio
> No functional change intended.
> 
> Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Hi Fabrice,

One small suggestion to use field_prep() rather than having
to carry the shift around.
>  
> -	priv->common.rate = rate / stm32f4_pclk_div[i];
> -	val = readl_relaxed(priv->common.base + STM32F4_ADC_CCR);
> -	val &= ~STM32F4_ADC_ADCPRE_MASK;
> -	val |= i << STM32F4_ADC_ADCPRE_SHIFT;
> -	writel_relaxed(val, priv->common.base + STM32F4_ADC_CCR);
> +	priv->common.rate = rate / priv->cfg->presc[i];
> +	val = readl_relaxed(priv->common.base + priv->cfg->regs->ccr);
> +	val &= ~priv->cfg->regs->presc_msk;
> +	val |= i << priv->cfg->regs->presc_shift;

I think this isn't a particularly hot path, so we can use
field_prep()  (the lower case one doesn't mind non const masks)

The we don't need to store the shift as well as the mask.

Maybe it is worth thinking about adding a field_modify() similar
to FIELD_MODIFY(). Perhaps that's not a thing to do in this patch set
though.

> +	writel_relaxed(val, priv->common.base + priv->cfg->regs->ccr);
>  
>  	dev_dbg(&pdev->dev, "Using analog clock source at %ld kHz\n",
>  		priv->common.rate / 1000);

> 


  reply	other threads:[~2026-09-27 18:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 15:39 [PATCH v2 00/14] iio: adc: stm32: add support for stm32mp23 and stm32mp25 Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 01/14] dt-bindings: iio: adc: stm32-adc: " Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 02/14] iio: adc: stm32-adc: core: manage clock prescaler diversity Fabrice Gasnier
2026-09-27 18:57   ` Jonathan Cameron [this message]
2026-09-23 15:39 ` [PATCH v2 03/14] iio: adc: stm32-adc: core: configurable number of interrupts Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 04/14] iio: adc: stm32-adc: manage characterization voltage diversity Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 05/14] iio: adc: stm32-adc: rework internal channels data Fabrice Gasnier
2026-09-24 10:02   ` Fabrice Gasnier
2026-09-24 20:53   ` Andy Shevchenko
2026-09-23 15:39 ` [PATCH v2 06/14] iio: adc: stm32-adc: add vreg enable option to manage diversity Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 07/14] iio: adc: stm32-adc: add support for stm32mp25 Fabrice Gasnier
2026-09-24 21:01   ` Andy Shevchenko
2026-09-29 16:48     ` Fabrice Gasnier
2026-09-30  8:33       ` Andy Shevchenko
2026-09-30  8:44         ` Fabrice Gasnier
2026-09-30  8:55           ` Andy Shevchenko
2026-09-23 15:39 ` [PATCH v2 08/14] iio: adc: stm32-adc: add support for stm32mp23 Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 09/14] iio: adc: stm32: add support for vddgpu on stm32mp23 and stm32mp25 Fabrice Gasnier
2026-09-27 19:03   ` Jonathan Cameron
2026-09-23 15:39 ` [PATCH v2 10/14] arm64: dts: st: add vrefint calibration on stm32mp23 Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 11/14] arm64: dts: st: add vrefint calibration on stm32mp25 Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 12/14] arm64: dts: st: add ADC nodes on stm32mp231 Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 13/14] arm64: dts: st: add ADC nodes on stm32mp251 Fabrice Gasnier
2026-09-23 15:39 ` [PATCH v2 14/14] arm64: dts: st: add ADC support on stm32mp257f-ev1 board Fabrice Gasnier

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=20260927195753.307af72f@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=marex@nabladev.com \
    --cc=mcoquelin.stm32@gmail.com \
    --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

all inboxes | Powered by JetHome®