]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
zynq: timer: Fix hangs if network activity attempted after about one hour
authorMichal Simek <michal.simek@xilinx.com>
Fri, 22 Nov 2013 14:29:38 +0000 (15:29 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 2 Dec 2013 08:22:48 +0000 (09:22 +0100)
Cortex-A9 MPCore TRM' from ARM (ARM DDI 0407G ID072711) describes
in the section 4.1.1 how this value calculation should be done.

This patch fixes the problem if network activity such as ping or
tftp is attempted after u-boot has been idle for an hour,
it hangs, and cannot control-C out of it.

Signed-off-by: Uday Hegde <udayh@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
arch/arm/cpu/armv7/zynq/timer.c

index 544da17dcd803d4b8fd6dc410edbc10dfe735f28..aadc6586301360415521561546546a75984fe623 100644 (file)
@@ -56,7 +56,7 @@ int timer_init(void)
                        (TIMER_PRESCALE << SCUTIMER_CONTROL_PRESCALER_SHIFT) |
                        SCUTIMER_CONTROL_ENABLE_MASK;
 
-       gd->arch.timer_rate_hz = (gd->cpu_clk / 2) / TIMER_PRESCALE;
+       gd->arch.timer_rate_hz = (gd->cpu_clk / 2) / (TIMER_PRESCALE + 1);
 
        /* Load the timer counter register */
        writel(0xFFFFFFFF, &timer_base->load);
@@ -93,7 +93,7 @@ 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;
+               gd->arch.tbl += gd->arch.lastinc + TIMER_LOAD_VAL - now + 1;
        }
        gd->arch.lastinc = now;