summaryrefslogtreecommitdiff
path: root/arch/arm/cpu/armv7/socfpga/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/cpu/armv7/socfpga/timer.c')
-rw-r--r--arch/arm/cpu/armv7/socfpga/timer.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/arm/cpu/armv7/socfpga/timer.c b/arch/arm/cpu/armv7/socfpga/timer.c
index bbead45672..cb16a66460 100644
--- a/arch/arm/cpu/armv7/socfpga/timer.c
+++ b/arch/arm/cpu/armv7/socfpga/timer.c
@@ -80,14 +80,15 @@ ulong get_timer_masked(void)
{
/* current tick value */
ulong now = read_timer() /
- (CONFIG_TIMER_CLOCK_KHZ*1000 / CONFIG_SYS_HZ);
+ (CONFIG_TIMER_CLOCK_KHZ * 1000 / CONFIG_SYS_HZ);
if (gd->lastinc >= now) {
/* normal mode (non roll) */
/* move stamp forward with absolute diff ticks */
gd->tbl += gd->lastinc - now;
} else {
/* we have overflow of the count down timer */
- gd->tbl += TIMER_LOAD_VAL - gd->lastinc + now;
+ gd->tbl += (TIMER_LOAD_VAL / (CONFIG_TIMER_CLOCK_KHZ * 1000
+ / CONFIG_SYS_HZ)) - gd->lastinc + now;
}
gd->lastinc = now;
return gd->tbl;
@@ -100,7 +101,7 @@ void reset_timer(void)
{
/* capture current decrementer value time */
gd->lastinc = read_timer() /
- (CONFIG_TIMER_CLOCK_KHZ*1000 / CONFIG_SYS_HZ);
+ (CONFIG_TIMER_CLOCK_KHZ * 1000 / CONFIG_SYS_HZ);
/* start "advancing" time stamp from 0 */
gd->tbl = 0;
}
@@ -129,7 +130,7 @@ ulong get_timer_count_masked(void)
ulong get_timer_count(ulong base)
{
- return get_timer_masked() - base;
+ return get_timer_count_masked() - base;
}
/*