]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
zynq: timer: Fix wrong timer calculation
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Mon, 13 Apr 2015 05:27:04 +0000 (10:57 +0530)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:31:34 +0000 (22:31 +0200)
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>
arch/arm/cpu/armv7/zynq/timer.c

index 303dbcfceafb3fe6d515a6a091c7ece6061561db..5ed9642df9b331d2723864edd7a0d12cadc1737c 100644 (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;