From: Jonathan Cameron <jic23@kernel.org>
To: Olivier Moysan <olivier.moysan@foss.st.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Fabrice Gasnier <fabrice.gasnier@foss.st.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>, <nuno.sa@analog.com>,
Paul Cercueil <paul@crapouillou.net>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Wan Jiabing <wanjiabing@vivo.com>,
Yannick Brosseau <yannick.brosseau@gmail.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 3/8] iio: adc: stm32-adc: add stm32mp13 support
Date: Sun, 2 Oct 2022 14:42:13 +0100 [thread overview]
Message-ID: <20221002144213.4d6d4363@jic23-huawei> (raw)
In-Reply-To: <20220928164114.48339-4-olivier.moysan@foss.st.com>
On Wed, 28 Sep 2022 18:41:09 +0200
Olivier Moysan <olivier.moysan@foss.st.com> wrote:
> Add STM32 ADC support for STM32MP13x SOCs family.
>
> On STM32MP13x, each ADC peripheral has a single ADC block.
Wrap this a bit nearer 80 chars. Personally I go with 75, but anywhere around
that is fine.
> These ADC peripherals, ADC1 and ADC2, are fully independent.
> This introduces changes in common registers handling.
>
> Some features such as boost mode, channel preselection and
> linear calibration are not supported by the STM32MP13x ADC.
> Add diversity management for these features.
>
> The STM32MP13x ADC introduces registers and bitfield variants
> on existing features such as calibration factors and internal
> channels. Add register diversity management.
>
> Add also support of new internal channels VDDCPU and VDDQ_DDR.
>
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Hi Oliver
A few really trivial things inline,
Jonathan
> ---
> drivers/iio/adc/stm32-adc-core.c | 21 +++
> drivers/iio/adc/stm32-adc-core.h | 32 +++++
> drivers/iio/adc/stm32-adc.c | 212 +++++++++++++++++++++++++++----
> 3 files changed, 237 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
> index 81d5db91c67b..6564aa61b595 100644
> --- a/drivers/iio/adc/stm32-adc-core.c
> +++ b/drivers/iio/adc/stm32-adc-core.c
> @@ -322,6 +322,16 @@ static const struct stm32_adc_common_regs stm32h7_adc_common_regs = {
> .eocie_msk = STM32H7_EOCIE,
> };
>
> +/* STM32MP13 common registers definitions */
> +static const struct stm32_adc_common_regs stm32mp13_adc_common_regs = {
> + .csr = STM32H7_ADC_CSR,
> + .ccr = STM32H7_ADC_CCR,
> + .eoc_msk = { STM32H7_EOC_MST},
space before },
ouch. I see this odd balance is common in this driver. Don't carry it on and
if you fancy adding the missing spaces to the rest of the driver that would be
great!
> + .ovr_msk = { STM32H7_OVR_MST},
> + .ier = STM32H7_ADC_IER,
> + .eocie_msk = STM32H7_EOCIE,
> +};
> +
> static const unsigned int stm32_adc_offset[STM32_ADC_MAX_ADCS] = {
> 0, STM32_ADC_OFFSET, STM32_ADC_OFFSET * 2,
> };
> @@ -868,6 +878,14 @@ static const struct stm32_adc_priv_cfg stm32mp1_adc_priv_cfg = {
> .num_irqs = 2,
> };
>
> +static const struct stm32_adc_priv_cfg stm32mp13_adc_priv_cfg = {
> + .regs = &stm32mp13_adc_common_regs,
> + .clk_sel = stm32h7_adc_clk_sel,
> + .max_clk_rate_hz = 75000000,
> + .ipid = STM32MP13_IPIDR_NUMBER,
> + .num_irqs = 1,
> +};
> +
> static const struct of_device_id stm32_adc_of_match[] = {
> {
> .compatible = "st,stm32f4-adc-core",
> @@ -878,6 +896,9 @@ static const struct of_device_id stm32_adc_of_match[] = {
> }, {
> .compatible = "st,stm32mp1-adc-core",
> .data = (void *)&stm32mp1_adc_priv_cfg
> + }, {
> + .compatible = "st,stm32mp13-adc-core",
> + .data = (void *)&stm32mp13_adc_priv_cfg
> }, {
> },
> };
> diff --git a/drivers/iio/adc/stm32-adc-core.h b/drivers/iio/adc/stm32-adc-core.h
> index 2118ef63843d..658fef4308ac 100644
> --- a/drivers/iio/adc/stm32-adc-core.h
> +++ b/drivers/iio/adc/stm32-adc-core.h
> @@ -112,6 +112,11 @@
> #define STM32MP1_ADC_IPDR 0x3F8
> #define STM32MP1_ADC_SIDR 0x3FC
>
> +/* STM32MP13 - Registers for each ADC instance */
> +#define STM32MP13_ADC_DIFSEL 0xB0
> +#define STM32MP13_ADC_CALFACT 0xB4
> +#define STM32MP13_ADC2_OR 0xC8
> +
> /* STM32H7 - common registers for all ADC instances */
> #define STM32H7_ADC_CSR (STM32_ADCX_COMN_OFFSET + 0x00)
> #define STM32H7_ADC_CCR (STM32_ADCX_COMN_OFFSET + 0x08)
> @@ -161,6 +166,10 @@ enum stm32h7_adc_dmngt {
> STM32H7_DMNGT_DMA_CIRC, /* DMA circular mode */
> };
>
> +/* STM32H7_ADC_DIFSEL - bit fields */
> +#define STM32H7_DIFSEL_SHIFT 0
This shift is both unnecessary, as encoded in the mask, and unused
so you can definitely get rid of it.
Might be nice to clean the rest of these out as well in favour of
just using the masks and FIELD_PREP() etc for any places where the mask
is a compile time constant.
Please check the others are actually useful.
> +#define STM32H7_DIFSEL_MASK GENMASK(19, 0)
> +
> /* STM32H7_ADC_CALFACT - bit fields */
> #define STM32H7_CALFACT_D_SHIFT 16
> #define STM32H7_CALFACT_D_MASK GENMASK(26, 16)
> @@ -210,7 +219,30 @@ enum stm32h7_adc_dmngt {
> /* STM32MP1_ADC_SIDR - bit fields */
> #define STM32MP1_SIDR_MASK GENMASK(31, 0)
...
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-10-02 13:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 16:41 [PATCH 0/8] iio: stm32-adc: add support of adc for stm32mp13 Olivier Moysan
2022-09-28 16:41 ` [PATCH 1/8] iio: adc: stm32-adc: fix channel sampling time init Olivier Moysan
2022-09-28 16:51 ` Andy Shevchenko
2022-10-02 13:33 ` Jonathan Cameron
2022-09-28 16:41 ` [PATCH 2/8] dt-bindings: iio: adc: stm32-adc: add stm32mp13 compatibles Olivier Moysan
2022-09-28 16:41 ` [PATCH 3/8] iio: adc: stm32-adc: add stm32mp13 support Olivier Moysan
2022-09-28 17:07 ` Andy Shevchenko
2022-10-02 13:42 ` Jonathan Cameron [this message]
2022-09-28 16:41 ` [PATCH 4/8] iio: adc: stm32: manage min sampling time on all internal channels Olivier Moysan
2022-09-28 16:41 ` [PATCH 5/8] ARM: dts: stm32: add adc support to stm32mp13 Olivier Moysan
2022-09-28 16:41 ` [PATCH 6/8] ARM: dts: stm32: add adc pins muxing on stm32mp135f-dk Olivier Moysan
2022-09-28 16:41 ` [PATCH 7/8] ARM: dts: stm32: add dummy vdd_adc regulator " Olivier Moysan
2022-09-28 16:41 ` [PATCH 8/8] ARM: dts: stm32: add adc support " Olivier Moysan
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=20221002144213.4d6d4363@jic23-huawei \
--to=jic23@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andy.shevchenko@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=fabrice.gasnier@foss.st.com \
--cc=lars@metafoo.de \
--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=mcoquelin.stm32@gmail.com \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.com \
--cc=paul@crapouillou.net \
--cc=wanjiabing@vivo.com \
--cc=yannick.brosseau@gmail.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