zynq: timer: Fix wrong timer calculation

Fix wrong timer calculation in get_timer_masked incase of
overflow.
This fixes the issue of getting wrong time from get_timer()
calls.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
master
Siva Durga Prasad Paladugu 10 years ago committed by Michal Simek
parent eddabd1662
commit a7858f62d7
  1. 4
      arch/arm/cpu/armv7/zynq/timer.c

@ -93,7 +93,9 @@ ulong get_timer_masked(void)
gd->arch.tbl += gd->arch.lastinc - now;
} else {
/* We have an overflow ... */
gd->arch.tbl += gd->arch.lastinc + TIMER_LOAD_VAL - now + 1;
gd->arch.tbl += gd->arch.lastinc + (TIMER_LOAD_VAL /
(gd->arch.timer_rate_hz / CONFIG_SYS_HZ)) -
now + 1;
}
gd->arch.lastinc = now;

Loading…
Cancel
Save