Skip to content

Commit

Permalink
mach-sunxi: Move timer code to mach folder
Browse files Browse the repository at this point in the history
Both armv7 and arm926ejs use this timer code so move it to mach-sunxi.

Signed-off-by: Jesse Taube <[email protected]>
Reviewed-by: Andre Przywara <[email protected]>
Signed-off-by: Andre Przywara <[email protected]>
  • Loading branch information
Mr-Bossman authored and Andre-ARM committed Feb 4, 2022
1 parent 508f75a commit 0d4377f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion arch/arm/cpu/armv7/sunxi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Based on some other Makefile
# (C) Copyright 2000-2003
# Wolfgang Denk, DENX Software Engineering, [email protected].
obj-y += timer.o

obj-$(CONFIG_MACH_SUN6I) += tzpc.o
obj-$(CONFIG_MACH_SUN8I_H3) += tzpc.o
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-sunxi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ 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);

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;
Expand All @@ -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;
Expand Down

0 comments on commit 0d4377f

Please sign in to comment.