]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/cpu/armv7/arch_timer.c
psci: arm: remove armv7 function psci_save_target_pc
[u-boot] / arch / arm / cpu / armv7 / arch_timer.c
index 30915d28aa9cc09b86f23d4f4b6679996a458b40..3db31c020952389b3fe9952bcba45802746e1453 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2012-2014
  *     Texas Instruments Incorporated, <www.ti.com>
- *
- * SPDX-License-Identifier:     GPL-2.0+
  */
 
 #include <common.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_SYS_HZ_CLOCK
+static inline u32 read_cntfrq(void)
+{
+       u32 frq;
+
+       asm volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (frq));
+       return frq;
+}
+#endif
+
 int timer_init(void)
 {
        gd->arch.tbl = 0;
        gd->arch.tbu = 0;
 
-       gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK / CONFIG_SYS_HZ;
+#ifdef CONFIG_SYS_HZ_CLOCK
+       gd->arch.timer_rate_hz = CONFIG_SYS_HZ_CLOCK;
+#else
+       gd->arch.timer_rate_hz = read_cntfrq();
+#endif
        return 0;
 }
 
@@ -34,27 +47,9 @@ unsigned long long get_ticks(void)
 }
 
 
-ulong get_timer(ulong base)
-{
-       return lldiv(get_ticks(), gd->arch.timer_rate_hz) - base;
-}
-
 ulong timer_get_boot_us(void)
 {
-       return lldiv(get_ticks(), CONFIG_SYS_HZ_CLOCK / (CONFIG_SYS_HZ * 1000));
-}
-
-void __udelay(unsigned long usec)
-{
-       unsigned long long endtime;
-
-       endtime = lldiv((unsigned long long)usec * gd->arch.timer_rate_hz,
-                       1000UL);
-
-       endtime += get_ticks();
-
-       while (get_ticks() < endtime)
-               ;
+       return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000);
 }
 
 ulong get_tbclk(void)