ARM: stm32f7: fix prescaler calculation of timer
authorBo Shen <voice.shen@gmail.com>
Tue, 3 Oct 2017 05:47:59 +0000 (22:47 -0700)
committerTom Rini <trini@konsulko.com>
Sun, 8 Oct 2017 20:19:56 +0000 (16:19 -0400)
As the timer 2 is on APB1 bus, the maximum of clock frequency of APB1 timer
clock is half of SYSCLK. Then to calculate the timer prescaler for timer 2
which need to be divided by 2.

Signed-off-by: Bo Shen <voice.shen@gmail.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
arch/arm/mach-stm32/stm32f7/timer.c

index c15f8bbe32da69cd2f004d185ebe45c40a50a5b8..b04c1013e9ce4cf23d4ed0cfe3faf924d3c15661 100644 (file)
@@ -26,7 +26,7 @@ int timer_init(void)
        /* Stop the timer */
        writel(readl(&gpt1_regs_ptr->cr1) & ~GPT_CR1_CEN, &gpt1_regs_ptr->cr1);
 
-       writel((CONFIG_SYS_CLK_FREQ/CONFIG_SYS_HZ_CLOCK) - 1,
+       writel((CONFIG_SYS_CLK_FREQ / 2 / CONFIG_SYS_HZ_CLOCK) - 1,
                                                &gpt1_regs_ptr->psc);
 
        /* Configure timer for auto-reload */