From a5b629a33e717e794db8db5b0fedbd3aa254e711 Mon Sep 17 00:00:00 2001 From: Francois Retief Date: Sat, 21 Nov 2015 17:07:48 +0200 Subject: sparc: Fix whitespace in cpu/leon2/cpu_init.c Signed-off-by: Francois Retief --- arch/sparc/cpu/leon2/cpu_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'arch/sparc/cpu/leon2/cpu_init.c') diff --git a/arch/sparc/cpu/leon2/cpu_init.c b/arch/sparc/cpu/leon2/cpu_init.c index 6e07fe6bb40..695ee028b36 100644 --- a/arch/sparc/cpu/leon2/cpu_init.c +++ b/arch/sparc/cpu/leon2/cpu_init.c @@ -50,17 +50,17 @@ void cpu_init_f(void) /* cache */ - /* I/O port setup */ + /* I/O port setup */ #ifdef LEON2_IO_PORT_DIR - leon2->PIO_Direction = LEON2_IO_PORT_DIR; + leon2->PIO_Direction = LEON2_IO_PORT_DIR; #endif #ifdef LEON2_IO_PORT_DATA - leon2->PIO_Data = LEON2_IO_PORT_DATA; + leon2->PIO_Data = LEON2_IO_PORT_DATA; #endif #ifdef LEON2_IO_PORT_INT - leon2->PIO_Interrupt = LEON2_IO_PORT_INT; + leon2->PIO_Interrupt = LEON2_IO_PORT_INT; #else - leon2->PIO_Interrupt = 0; + leon2->PIO_Interrupt = 0; #endif } -- cgit v1.2.3 From e17c5200c7e9a802783a53d4f4457fa68f7fa074 Mon Sep 17 00:00:00 2001 From: Francois Retief Date: Wed, 28 Oct 2015 14:29:32 +0200 Subject: sparc: Initial ground work for generic board initialization Initial ground work in preperation for generic board initialization code for the SPARC architecture. Signed-off-by: Francois Retief --- arch/sparc/cpu/leon2/cpu_init.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'arch/sparc/cpu/leon2/cpu_init.c') diff --git a/arch/sparc/cpu/leon2/cpu_init.c b/arch/sparc/cpu/leon2/cpu_init.c index 695ee028b36..581f0572699 100644 --- a/arch/sparc/cpu/leon2/cpu_init.c +++ b/arch/sparc/cpu/leon2/cpu_init.c @@ -1,8 +1,8 @@ /* Initializes CPU and basic hardware such as memory * controllers, IRQ controller and system timer 0. * - * (C) Copyright 2007 - * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com + * (C) Copyright 2007, 2015 + * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com * * SPDX-License-Identifier: GPL-2.0+ */ @@ -18,14 +18,6 @@ DECLARE_GLOBAL_DATA_PTR; -/* reset CPU (jump to 0, without reset) */ -void start(void); - -struct { - gd_t gd_area; - bd_t bd; -} global_data; - /* * Breath some life into the CPU... * @@ -69,6 +61,15 @@ void cpu_init_f2(void) } +int arch_cpu_init(void) +{ + gd->cpu_clk = CONFIG_SYS_CLK_FREQ; + gd->bus_clk = CONFIG_SYS_CLK_FREQ; + gd->ram_size = CONFIG_SYS_SDRAM_SIZE; + + return 0; +} + /* * initialize higher level parts of CPU like time base and timers */ -- cgit v1.2.3 From c837901bf15616dd08997c30461e0f62bcd55245 Mon Sep 17 00:00:00 2001 From: Francois Retief Date: Sat, 21 Nov 2015 13:25:41 +0200 Subject: sparc: leon2: Updates for generic board initialization Reworked the LEON2 start.S code to call board_init_f function at startup. Also implemented the relocate_code function in assembly to relocate the monitor and setup the stack pointer before calling relocated board_init_r. Add the CONFIG_SYS_GENERIC_BOARD variable to all the LEON2 boards. Signed-off-by: Francois Retief --- arch/sparc/cpu/leon2/cpu_init.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'arch/sparc/cpu/leon2/cpu_init.c') diff --git a/arch/sparc/cpu/leon2/cpu_init.c b/arch/sparc/cpu/leon2/cpu_init.c index 581f0572699..5630b095d49 100644 --- a/arch/sparc/cpu/leon2/cpu_init.c +++ b/arch/sparc/cpu/leon2/cpu_init.c @@ -56,11 +56,6 @@ void cpu_init_f(void) #endif } -void cpu_init_f2(void) -{ - -} - int arch_cpu_init(void) { gd->cpu_clk = CONFIG_SYS_CLK_FREQ; -- cgit v1.2.3 From c97088c3cfa84e7e53fddd26896f145cc8c431a2 Mon Sep 17 00:00:00 2001 From: Francois Retief Date: Wed, 28 Oct 2015 15:18:22 +0200 Subject: 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 --- arch/sparc/cpu/leon2/cpu_init.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'arch/sparc/cpu/leon2/cpu_init.c') diff --git a/arch/sparc/cpu/leon2/cpu_init.c b/arch/sparc/cpu/leon2/cpu_init.c index 5630b095d49..b4d91e50398 100644 --- a/arch/sparc/cpu/leon2/cpu_init.c +++ b/arch/sparc/cpu/leon2/cpu_init.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -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; +} -- cgit v1.2.3 From 7a4fb11b85939b47738283c3a7ae7f461468e274 Mon Sep 17 00:00:00 2001 From: Francois Retief Date: Sat, 21 Nov 2015 23:15:07 +0200 Subject: sparc: Remove non-generic board init files: board.c, time.c Remove the board.c and time.c files and all associated non-generic board initialization code. Signed-off-by: Francois Retief --- arch/sparc/cpu/leon2/cpu_init.c | 45 +---------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'arch/sparc/cpu/leon2/cpu_init.c') diff --git a/arch/sparc/cpu/leon2/cpu_init.c b/arch/sparc/cpu/leon2/cpu_init.c index b4d91e50398..9dfb99cb0f7 100644 --- a/arch/sparc/cpu/leon2/cpu_init.c +++ b/arch/sparc/cpu/leon2/cpu_init.c @@ -14,9 +14,6 @@ #include -#define TIMER_BASE_CLK 1000000 -#define US_PER_TICK (1000000 / CONFIG_SYS_HZ) - DECLARE_GLOBAL_DATA_PTR; /* @@ -77,48 +74,8 @@ int cpu_init_r(void) return 0; } -/* Uses Timer 0 to get accurate - * pauses. Max 2 raised to 32 ticks - * - */ -void cpu_wait_ticks(unsigned long ticks) -{ - unsigned long start = get_timer(0); - while (get_timer(start) < ticks) ; -} - -/* initiate and setup timer0 interrupt to configured HZ. Base clock is 1MHz. - * Return irq number for timer int or a negative number for - * dealing with self - */ -int timer_interrupt_init_cpu(void) -{ - LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS; - - /* SYS_HZ ticks per second */ - leon2->Timer_Counter_1 = 0; - leon2->Timer_Reload_1 = (TIMER_BASE_CLK / CONFIG_SYS_HZ) - 1; - leon2->Timer_Control_1 = - (LEON2_TIMER_CTRL_EN | LEON2_TIMER_CTRL_RS | LEON2_TIMER_CTRL_LD); - - return LEON2_TIMER1_IRQNO; -} - -/* - * This function is intended for SHORT delays only. +/* initiate and setup timer0 to configured HZ. Base clock is 1MHz. */ -unsigned long cpu_usec2ticks(unsigned long usec) -{ - if (usec < US_PER_TICK) - return 1; - return usec / US_PER_TICK; -} - -unsigned long cpu_ticks2usec(unsigned long ticks) -{ - return ticks * US_PER_TICK; -} - int timer_init(void) { LEON2_regs *leon2 = (LEON2_regs *)LEON2_PREGS; -- cgit v1.2.3