summaryrefslogtreecommitdiff
path: root/arch/arm/cpu
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2013-03-28 04:32:17 +0000
committerMinkyu Kang <mk7.kang@samsung.com>2013-04-01 14:02:08 +0900
commitf24869d3a8f6646c2d207057719e6fa0a8f31eb0 (patch)
treed14942201488f330c95e3bc141dc12bcefe43c33 /arch/arm/cpu
parent3d00c0cb96ff93a929700b80d89cb905e5ab5315 (diff)
downloadu-boot-imx-f24869d3a8f6646c2d207057719e6fa0a8f31eb0.zip
u-boot-imx-f24869d3a8f6646c2d207057719e6fa0a8f31eb0.tar.gz
u-boot-imx-f24869d3a8f6646c2d207057719e6fa0a8f31eb0.tar.bz2
Exynos: Add timer_get_us function
timer_get_us returns the time in microseconds since a certain reference point of history. However, it does not guarantee to return an accurate time after a long period; instead, it wraps around (that is, the reference point is reset to some other point of history) after some periods. The frequency of wrapping around is about an hour (or 2^32 microseconds). Test with command "sf probe 1:0; time sf read 40008000 0 1000". Try with different numbers of bytes and see that sane values are obtained Signed-off-by: Che-Liang Chiou <clchiou@chromium.org> Signed-off-by: Akshay Saraswat <akshay.s@samsung.com> Acked-by: Simon Glass <sjg@chromium.org> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/armv7/s5p-common/timer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv7/s5p-common/timer.c b/arch/arm/cpu/armv7/s5p-common/timer.c
index c48a297..de61405 100644
--- a/arch/arm/cpu/armv7/s5p-common/timer.c
+++ b/arch/arm/cpu/armv7/s5p-common/timer.c
@@ -90,6 +90,21 @@ unsigned long get_timer(unsigned long base)
return gd->arch.timer_reset_value / 1000 - base;
}
+unsigned long timer_get_us(void)
+{
+ static unsigned long base_time_us;
+
+ struct s5p_timer *const timer =
+ (struct s5p_timer *)samsung_get_base_timer();
+ unsigned long now_downward_us = readl(&timer->tcnto4);
+
+ if (!base_time_us)
+ base_time_us = now_downward_us;
+
+ /* Note that this timer counts downward. */
+ return base_time_us - now_downward_us;
+}
+
/* delay x useconds */
void __udelay(unsigned long usec)
{