X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=arch%2Farm%2Fcpu%2Farmv7%2Farch_timer.c;h=3db31c020952389b3fe9952bcba45802746e1453;hb=9ce751a6f5d6683b0fabd3cfc62da7e9f30bc57f;hp=545c5185066bd4b90033be7097a311cf7db0badc;hpb=77aace579a9a84c74e99d2e86ecc08b1d9ca402b;p=u-boot diff --git a/arch/arm/cpu/armv7/arch_timer.c b/arch/arm/cpu/armv7/arch_timer.c index 545c518506..3db31c0209 100644 --- a/arch/arm/cpu/armv7/arch_timer.c +++ b/arch/arm/cpu/armv7/arch_timer.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2012-2014 * Texas Instruments Incorporated, - * - * SPDX-License-Identifier: GPL-2.0+ */ #include @@ -12,12 +11,26 @@ 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; +#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; } @@ -36,7 +49,7 @@ unsigned long long get_ticks(void) ulong timer_get_boot_us(void) { - return lldiv(get_ticks(), CONFIG_SYS_HZ_CLOCK / 1000000); + return lldiv(get_ticks(), gd->arch.timer_rate_hz / 1000000); } ulong get_tbclk(void)