summaryrefslogtreecommitdiff
path: root/arch/sparc/cpu/leon2
diff options
context:
space:
mode:
authorFrancois Retief <fgretief@spaceteq.co.za>2015-10-28 15:18:22 +0200
committerFrancois Retief <fgretief@spaceteq.co.za>2015-12-03 13:15:49 +0200
commitc97088c3cfa84e7e53fddd26896f145cc8c431a2 (patch)
tree6aed60fefa95f3b01e05a5ecf7e56bdb4e8eb409 /arch/sparc/cpu/leon2
parentc837901bf15616dd08997c30461e0f62bcd55245 (diff)
downloadu-boot-imx-c97088c3cfa84e7e53fddd26896f145cc8c431a2.zip
u-boot-imx-c97088c3cfa84e7e53fddd26896f145cc8c431a2.tar.gz
u-boot-imx-c97088c3cfa84e7e53fddd26896f145cc8c431a2.tar.bz2
sparc: Update cpu_init.c to use generic timer infrastructure
Introduce the CONFIG_SYS_TIMER_* macros in include/asm/config.h to make use of the generic timer infrastructure in lib/time.c. Created a timer_init() function to initialize the timer hardware and update the #ifdef in board_init_f to allow this function to be called during the start-up sequence. Signed-off-by: Francois Retief <fgretief@spaceteq.co.za>
Diffstat (limited to 'arch/sparc/cpu/leon2')
-rw-r--r--arch/sparc/cpu/leon2/cpu_init.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/arch/sparc/cpu/leon2/cpu_init.c b/arch/sparc/cpu/leon2/cpu_init.c
index 5630b09..b4d91e5 100644
--- a/arch/sparc/cpu/leon2/cpu_init.c
+++ b/arch/sparc/cpu/leon2/cpu_init.c
@@ -10,6 +10,7 @@
#include <common.h>
#include <asm/asi.h>
#include <asm/leon.h>
+#include <asm/io.h>
#include <config.h>
@@ -54,6 +55,9 @@ void cpu_init_f(void)
#else
leon2->PIO_Interrupt = 0;
#endif
+
+ /* disable timers */
+ leon2->Timer_Control_1 = leon2->Timer_Control_2 = 0;
}
int arch_cpu_init(void)
@@ -66,17 +70,11 @@ int arch_cpu_init(void)
}
/*
- * initialize higher level parts of CPU like time base and timers
+ * initialize higher level parts of CPU
*/
int cpu_init_r(void)
{
- LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
-
- /* initialize prescaler common to all timers to 1MHz */
- leon2->Scaler_Counter = leon2->Scaler_Reload =
- (((CONFIG_SYS_CLK_FREQ / 1000) + 500) / 1000) - 1;
-
- return (0);
+ return 0;
}
/* Uses Timer 0 to get accurate
@@ -106,11 +104,6 @@ int timer_interrupt_init_cpu(void)
return LEON2_TIMER1_IRQNO;
}
-ulong get_tbclk(void)
-{
- return TIMER_BASE_CLK;
-}
-
/*
* This function is intended for SHORT delays only.
*/
@@ -125,3 +118,21 @@ unsigned long cpu_ticks2usec(unsigned long ticks)
{
return ticks * US_PER_TICK;
}
+
+int timer_init(void)
+{
+ LEON2_regs *leon2 = (LEON2_regs *)LEON2_PREGS;
+
+ /* initialize prescaler common to all timers to 1MHz */
+ leon2->Scaler_Counter = leon2->Scaler_Reload =
+ (((CONFIG_SYS_CLK_FREQ / 1000) + 500) / 1000) - 1;
+
+ /* SYS_HZ ticks per second */
+ leon2->Timer_Counter_1 = 0;
+ leon2->Timer_Reload_1 = (CONFIG_SYS_TIMER_RATE / CONFIG_SYS_HZ) - 1;
+ leon2->Timer_Control_1 = LEON2_TIMER_CTRL_EN | LEON2_TIMER_CTRL_RS |
+ LEON2_TIMER_CTRL_LD;
+
+ CONFIG_SYS_TIMER_COUNTER = (void *)&leon2->Timer_Counter_1;
+ return 0;
+}