diff options
author | Thomas Chou <thomas@wytron.com.tw> | 2014-08-22 11:36:47 +0800 |
---|---|---|
committer | Thomas Chou <thomas@wytron.com.tw> | 2014-08-24 11:28:10 +0800 |
commit | 5ff10aa7e76fc7dbd205ec13381757bfa2c99911 (patch) | |
tree | b61f3a949766cb6cda4f537874bebe7790356c8e /arch/nios2/cpu | |
parent | 70fbc46192dfd52896560f4b31e40daa3d16b99f (diff) | |
download | u-boot-imx-5ff10aa7e76fc7dbd205ec13381757bfa2c99911.zip u-boot-imx-5ff10aa7e76fc7dbd205ec13381757bfa2c99911.tar.gz u-boot-imx-5ff10aa7e76fc7dbd205ec13381757bfa2c99911.tar.bz2 |
nios2: add generic board support
This patch implements the generic board init as described in
doc/README.generic-board.
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Signed-off-by: Scott McNutt <smcnutt@psyent.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'arch/nios2/cpu')
-rw-r--r-- | arch/nios2/cpu/cpu.c | 14 | ||||
-rw-r--r-- | arch/nios2/cpu/start.S | 34 |
2 files changed, 43 insertions, 5 deletions
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index e0dcbc2..86f94b7 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -10,11 +10,14 @@ #include <nios2-io.h> #include <asm/cache.h> +DECLARE_GLOBAL_DATA_PTR; + #if defined (CONFIG_SYS_NIOS_SYSID_BASE) extern void display_sysid (void); #endif /* CONFIG_SYS_NIOS_SYSID_BASE */ -int checkcpu (void) +#ifdef CONFIG_DISPLAY_CPUINFO +int print_cpuinfo(void) { printf ("CPU : Nios-II\n"); #if !defined(CONFIG_SYS_NIOS_SYSID_BASE) @@ -24,6 +27,7 @@ int checkcpu (void) #endif return (0); } +#endif /* CONFIG_DISPLAY_CPUINFO */ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -47,3 +51,11 @@ void dcache_disable(void) { flush_dcache(CONFIG_SYS_DCACHE_SIZE, CONFIG_SYS_DCACHELINE_SIZE); } + +int arch_cpu_init(void) +{ + gd->cpu_clk = CONFIG_SYS_CLK_FREQ; + gd->ram_size = CONFIG_SYS_SDRAM_SIZE; + + return 0; +} diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S index 7ce0d34..6af9b4e 100644 --- a/arch/nios2/cpu/start.S +++ b/arch/nios2/cpu/start.S @@ -134,11 +134,12 @@ _reloc: mov fp, sp /* - * Call board_init -- never returns + * Call board_init_f -- never returns */ - movhi r4, %hi(board_init@h) - ori r4, r4, %lo(board_init@h) - callr r4 + mov r4, r0 + movhi r2, %hi(board_init_f@h) + ori r2, r2, %lo(board_init_f@h) + callr r2 /* NEVER RETURNS -- but branch to the _start just * in case ;-) @@ -146,6 +147,31 @@ _reloc: br _start + +/* + * relocate_code -- Nios2 handles the relocation above. But + * the generic board code monkeys with the heap, stack, etc. + * (it makes some assumptions that may not be appropriate + * for Nios). Nevertheless, we capitulate here. + * + * We'll call the board_init_r from here since this isn't + * supposed to return. + * + * void relocate_code (ulong sp, gd_t *global_data, + * ulong reloc_addr) + * __attribute__ ((noreturn)); + */ + .text + .global relocate_code + +relocate_code: + mov sp, r4 /* Set the new sp */ + mov r4, r5 + movhi r8, %hi(board_init_r@h) + ori r8, r8, %lo(board_init_r@h) + callr r8 + ret + /* * dly_clks -- Nios2 (like Nios1) doesn't have a timebase in * the core. For simple delay loops, we do our best by counting |