Skip to content

Commit d0a4564

Browse files
Olivier Moysanthierryreding
authored andcommitted
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>
1 parent de614ac commit d0a4564

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/pwm/pwm-stm32.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
207207
regmap_write(priv->regmap, TIM_ARR, priv->max_arr);
208208
regmap_write(priv->regmap, TIM_PSC, psc);
209209

210+
/* Reset input selector to its default input and disable slave mode */
211+
regmap_write(priv->regmap, TIM_TISEL, 0x0);
212+
regmap_write(priv->regmap, TIM_SMCR, 0x0);
213+
210214
/* Map TI1 or TI2 PWM input to IC1 & IC2 (or TI3/4 to IC3 & IC4) */
211215
regmap_update_bits(priv->regmap,
212216
pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2,

include/linux/mfd/stm32-timers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define TIM_BDTR 0x44 /* Break and Dead-Time Reg */
3232
#define TIM_DCR 0x48 /* DMA control register */
3333
#define TIM_DMAR 0x4C /* DMA register for transfer */
34+
#define TIM_TISEL 0x68 /* Input Selection */
3435

3536
#define TIM_CR1_CEN BIT(0) /* Counter Enable */
3637
#define TIM_CR1_DIR BIT(4) /* Counter Direction */

0 commit comments

Comments
 (0)