From: Lee Jones <lee@kernel.org>
To: Olivier Moysan <olivier.moysan@foss.st.com>
Cc: "Fabrice Gasnier" <fabrice.gasnier@foss.st.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
"Benjamin Gaignard" <benjamin.gaignard@linaro.org>,
linux-pwm@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] pwm: stm32: enforce settings for pwm capture
Date: Tue, 3 Jan 2023 12:34:03 +0000 [thread overview]
Message-ID: <Y7Qgu8ugq/l7JzwU@google.com> (raw)
In-Reply-To: <20221213102707.1096345-1-olivier.moysan@foss.st.com>
On Tue, 13 Dec 2022, Olivier Moysan wrote:
> The PWM capture assumes that the input selector is set to default
> input and that the slave mode is disabled. Force reset state for
> TISEL and SMCR registers to match this requirement.
>
> Note that slave mode disabling is not a pre-requisite by itself
> for capture mode, as hardware supports it for PWM capture.
> However, the current implementation of the driver does not
> allow slave mode for PWM capture. Setting slave mode for PWM
> capture results in wrong capture values.
>
> Fixes: 53e38fe73f94 ("pwm: stm32: Add capture support")
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
> ---
> drivers/pwm/pwm-stm32.c | 4 ++++
> include/linux/mfd/stm32-timers.h | 1 +
Acked-by: Lee Jones <lee@kernel.org>
> 2 files changed, 5 insertions(+)
>
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index 794ca5b02968..24aab0450c78 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -207,6 +207,10 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
> regmap_write(priv->regmap, TIM_ARR, priv->max_arr);
> regmap_write(priv->regmap, TIM_PSC, psc);
>
> + /* Reset input selector to its default input and disable slave mode */
> + regmap_write(priv->regmap, TIM_TISEL, 0x0);
> + regmap_write(priv->regmap, TIM_SMCR, 0x0);
> +
> /* Map TI1 or TI2 PWM input to IC1 & IC2 (or TI3/4 to IC3 & IC4) */
> regmap_update_bits(priv->regmap,
> pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2,
> diff --git a/include/linux/mfd/stm32-timers.h b/include/linux/mfd/stm32-timers.h
> index 5f5c43fd69dd..1b94325febb3 100644
> --- a/include/linux/mfd/stm32-timers.h
> +++ b/include/linux/mfd/stm32-timers.h
> @@ -31,6 +31,7 @@
> #define TIM_BDTR 0x44 /* Break and Dead-Time Reg */
> #define TIM_DCR 0x48 /* DMA control register */
> #define TIM_DMAR 0x4C /* DMA register for transfer */
> +#define TIM_TISEL 0x68 /* Input Selection */
>
> #define TIM_CR1_CEN BIT(0) /* Counter Enable */
> #define TIM_CR1_DIR BIT(4) /* Counter Direction */
> --
> 2.25.1
>
--
Lee Jones [李琼斯]
prev parent reply other threads:[~2023-01-03 12:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 10:27 [PATCH] pwm: stm32: enforce settings for pwm capture Olivier Moysan
2022-12-13 10:51 ` Uwe Kleine-König
2022-12-14 15:09 ` Olivier MOYSAN
2023-01-17 21:43 ` Uwe Kleine-König
2023-04-12 15:41 ` Uwe Kleine-König
2023-01-03 12:34 ` Lee Jones [this message]
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=Y7Qgu8ugq/l7JzwU@google.com \
--to=lee@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=benjamin.gaignard@linaro.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=olivier.moysan@foss.st.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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