Skip to content

Commit 4917e49

Browse files
Fabrice GasnierLee Jones
authored andcommitted
mfd: stm32-timers: Avoid clearing auto reload register
The ARR register is cleared unconditionally upon probing, after the maximum value has been read. This initial condition is rather not intuitive, when considering the counter child driver. It rather expects the maximum value by default: - The counter interface shows a zero value by default for 'ceiling' attribute. - Enabling the counter without any prior configuration makes it doesn't count. The reset value of ARR register is the maximum. So Choice here is to backup it, and restore it then, instead of clearing its value. It also fixes the initial condition seen by the counter driver. Fixes: d0f949e ("mfd: Add STM32 Timers driver") Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com> Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent 10d82ad commit 4917e49

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎drivers/mfd/stm32-timers.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,18 @@ static const struct regmap_config stm32_timers_regmap_cfg = {
158158

159159
static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
160160
{
161+
u32 arr;
162+
163+
/* Backup ARR to restore it after getting the maximum value */
164+
regmap_read(ddata->regmap, TIM_ARR, &arr);
165+
161166
/*
162167
* Only the available bits will be written so when readback
163168
* we get the maximum value of auto reload register
164169
*/
165170
regmap_write(ddata->regmap, TIM_ARR, ~0L);
166171
regmap_read(ddata->regmap, TIM_ARR, &ddata->max_arr);
167-
regmap_write(ddata->regmap, TIM_ARR, 0x0);
172+
regmap_write(ddata->regmap, TIM_ARR, arr);
168173
}
169174

170175
static int stm32_timers_dma_probe(struct device *dev,

0 commit comments

Comments
 (0)