aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Taube <mr.bossman075@gmail.com>2022-01-29 10:23:01 -0500
committerAndre Przywara <andre.przywara@arm.com>2022-02-04 00:09:57 +0000
commit0d4377fc921710cde36270a6a9a56803bfe545c4 (patch)
tree567b3e805ce2910c332faea766736796772761e7
parent508f75afb57d044a71e7ffd58e4e3e32aaa5ed30 (diff)
downloadu-boot-0d4377fc921710cde36270a6a9a56803bfe545c4.zip
u-boot-0d4377fc921710cde36270a6a9a56803bfe545c4.tar.gz
u-boot-0d4377fc921710cde36270a6a9a56803bfe545c4.tar.bz2
mach-sunxi: Move timer code to mach folder
Both armv7 and arm926ejs use this timer code so move it to mach-sunxi. Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r--arch/arm/cpu/armv7/sunxi/Makefile1
-rw-r--r--arch/arm/mach-sunxi/Makefile3
-rw-r--r--arch/arm/mach-sunxi/timer.c (renamed from arch/arm/cpu/armv7/sunxi/timer.c)7
3 files changed, 7 insertions, 4 deletions
diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile
index ad11be7..3e975b3 100644
--- a/arch/arm/cpu/armv7/sunxi/Makefile
+++ b/arch/arm/cpu/armv7/sunxi/Makefile
@@ -5,7 +5,6 @@
# Based on some other Makefile
# (C) Copyright 2000-2003
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-obj-y += timer.o
obj-$(CONFIG_MACH_SUN6I) += tzpc.o
obj-$(CONFIG_MACH_SUN8I_H3) += tzpc.o
diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
index 5d3fd70..b1adb75 100644
--- a/arch/arm/mach-sunxi/Makefile
+++ b/arch/arm/mach-sunxi/Makefile
@@ -25,6 +25,9 @@ obj-$(CONFIG_MACH_SUN8I) += clock_sun6i.o
endif
obj-$(CONFIG_MACH_SUN9I) += clock_sun9i.o gtbus_sun9i.o
obj-$(CONFIG_SUN50I_GEN_H6) += clock_sun50i_h6.o
+ifndef CONFIG_ARM64
+obj-y += timer.o
+endif
ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_DRAM_SUN4I) += dram_sun4i.o
diff --git a/arch/arm/cpu/armv7/sunxi/timer.c b/arch/arm/mach-sunxi/timer.c
index b758599..fc9d419 100644
--- a/arch/arm/cpu/armv7/sunxi/timer.c
+++ b/arch/arm/mach-sunxi/timer.c
@@ -51,6 +51,7 @@ int timer_init(void)
struct sunxi_timer_reg *timers =
(struct sunxi_timer_reg *)SUNXI_TIMER_BASE;
struct sunxi_timer *timer = &timers->timer[TIMER_NUM];
+
writel(TIMER_LOAD_VAL, &timer->inter);
writel(TIMER_MODE | TIMER_DIV | TIMER_SRC | TIMER_RELOAD | TIMER_EN,
&timer->ctl);
@@ -58,15 +59,14 @@ int timer_init(void)
return 0;
}
-/* timer without interrupts */
static ulong get_timer_masked(void)
{
/* current tick value */
ulong now = TICKS_TO_HZ(read_timer());
- if (now >= gd->arch.lastinc) /* normal (non rollover) */
+ if (now >= gd->arch.lastinc) { /* normal (non rollover) */
gd->arch.tbl += (now - gd->arch.lastinc);
- else {
+ } else {
/* rollover */
gd->arch.tbl += (TICKS_TO_HZ(TIMER_LOAD_VAL)
- gd->arch.lastinc) + now;
@@ -76,6 +76,7 @@ static ulong get_timer_masked(void)
return gd->arch.tbl;
}
+/* timer without interrupts */
ulong get_timer(ulong base)
{
return get_timer_masked() - base;