diff options
author | Olivier Moysan <olivier.moysan@foss.st.com> | 2022-12-13 11:27:07 +0100 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2023-04-06 16:35:01 +0200 |
commit | d0a4564bd024eaa81cab8c7255e7c44230bdd8a2 (patch) | |
tree | b40d147bb43e000c7fd0d5f401e8a9283d60f177 /drivers/pwm/pwm-stm32.c | |
parent | de614ac31955fe20f71021fd5f4a9a811e90028f (diff) | |
download | lwn-d0a4564bd024eaa81cab8c7255e7c44230bdd8a2.tar.gz lwn-d0a4564bd024eaa81cab8c7255e7c44230bdd8a2.zip |
pwm: stm32: Enforce settings for PWM capture
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.
Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Acked-by: Lee Jones <lee@kernel.org>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-stm32.c')
-rw-r--r-- | drivers/pwm/pwm-stm32.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index a482f7e0e4ab..62e397aeb9aa 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, |