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>
This commit is contained in:
Siva Durga Prasad Paladugu 2015-04-13 10:57:04 +05:30 committed by Michal Simek
parent eddabd1662
commit a7858f62d7

View file

@ -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;