From: Vikas MANOCHA Date: Tue, 3 Oct 2017 16:16:42 +0000 Subject: [U-Boot] [PATCH] ARM: stm32f7: fix prescaler calculation of timer In-Reply-To: <1507009679-16565-1-git-send-email-voice.shen@gmail.com> References: <1507009679-16565-1-git-send-email-voice.shen@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > -----Original Message----- > From: Bo Shen [mailto:voice.shen at gmail.com] > Sent: Monday, October 02, 2017 10:48 PM > To: albert.u.boot at aribaud.net; Vikas MANOCHA > Cc: u-boot at lists.denx.de; Bo Shen > Subject: [PATCH] ARM: stm32f7: fix prescaler calculation of timer > > 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 Reviewed-by: Vikas Manocha Cheers, Vikas > --- > arch/arm/mach-stm32/stm32f7/timer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm/mach-stm32/stm32f7/timer.c b/arch/arm/mach-stm32/stm32f7/timer.c > index c15f8bb..b04c101 100644 > --- a/arch/arm/mach-stm32/stm32f7/timer.c > +++ b/arch/arm/mach-stm32/stm32f7/timer.c > @@ -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 */ > -- > 2.7.4