aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/nios2/config.mk2
-rw-r--r--arch/nios2/cpu/cpu.c14
-rw-r--r--arch/nios2/cpu/start.S34
-rw-r--r--arch/nios2/include/asm/config.h3
-rw-r--r--arch/nios2/include/asm/u-boot.h10
-rw-r--r--arch/nios2/lib/Makefile1
-rw-r--r--arch/nios2/lib/board.c147
7 files changed, 49 insertions, 162 deletions
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index 82bd887961b..9b7c56dc856 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -17,3 +17,5 @@ PLATFORM_CPPFLAGS += -G0
LDFLAGS_FINAL += --gc-sections
PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
+__HAVE_ARCH_GENERIC_BOARD := y
diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c
index e0dcbc201f3..86f94b76fad 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 7ce0d34d7fa..6af9b4e9433 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
diff --git a/arch/nios2/include/asm/config.h b/arch/nios2/include/asm/config.h
index cd297347894..476a32bdc65 100644
--- a/arch/nios2/include/asm/config.h
+++ b/arch/nios2/include/asm/config.h
@@ -7,4 +7,7 @@
#ifndef _ASM_CONFIG_H_
#define _ASM_CONFIG_H_
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
+
#endif
diff --git a/arch/nios2/include/asm/u-boot.h b/arch/nios2/include/asm/u-boot.h
index 51f6c30ef76..cb02e98a827 100644
--- a/arch/nios2/include/asm/u-boot.h
+++ b/arch/nios2/include/asm/u-boot.h
@@ -15,15 +15,7 @@
#ifndef __ASM_NIOS2_U_BOOT_H_
#define __ASM_NIOS2_U_BOOT_H_
-typedef struct bd_info {
- unsigned long bi_memstart; /* start of DRAM memory */
- phys_size_t bi_memsize; /* size of DRAM memory in bytes */
- unsigned long bi_flashstart; /* start of FLASH memory */
- unsigned long bi_flashsize; /* size of FLASH memory */
- unsigned long bi_flashoffset; /* reserved area for startup monitor */
- unsigned long bi_sramstart; /* start of SRAM memory */
- unsigned long bi_sramsize; /* size of SRAM memory */
-} bd_t;
+#include <asm-generic/u-boot.h>
/* For image.h:image_check_target_arch() */
#define IH_ARCH_DEFAULT IH_ARCH_NIOS2
diff --git a/arch/nios2/lib/Makefile b/arch/nios2/lib/Makefile
index 7cb25c0ee13..079378a9056 100644
--- a/arch/nios2/lib/Makefile
+++ b/arch/nios2/lib/Makefile
@@ -6,7 +6,6 @@
#
obj-y += cache.o
-obj-y += board.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-y += libgcc.o
obj-y += time.o
diff --git a/arch/nios2/lib/board.c b/arch/nios2/lib/board.c
deleted file mode 100644
index f24218ff1c1..00000000000
--- a/arch/nios2/lib/board.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
- * Scott McNutt <smcnutt@psyent.com>
- *
- * (C) Copyright 2000-2002
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <common.h>
-#include <stdio_dev.h>
-#include <watchdog.h>
-#include <malloc.h>
-#include <mmc.h>
-#include <net.h>
-#ifdef CONFIG_STATUS_LED
-#include <status_led.h>
-#endif
-#if defined(CONFIG_SYS_NIOS_EPCSBASE)
-#include <nios2-epcs.h>
-#endif
-#ifdef CONFIG_CMD_NAND
-#include <nand.h> /* cannot even include nand.h if it isnt configured */
-#endif
-
-DECLARE_GLOBAL_DATA_PTR;
-
-/*
- * All attempts to come up with a "common" initialization sequence
- * that works for all boards and architectures failed: some of the
- * requirements are just _too_ different. To get rid of the resulting
- * mess of board dependend #ifdef'ed code we now make the whole
- * initialization sequence configurable to the user.
- *
- * The requirements for any new initalization function is simple: it
- * receives a pointer to the "global data" structure as it's only
- * argument, and returns an integer return code, where 0 means
- * "continue" and != 0 means "fatal error, hang the system".
- */
-
-
-typedef int (init_fnc_t) (void);
-
-
-/************************************************************************
- * Initialization sequence *
- ***********************************************************************/
-
-init_fnc_t *init_sequence[] = {
-#if defined(CONFIG_BOARD_EARLY_INIT_F)
- board_early_init_f, /* Call board-specific init code early.*/
-#endif
-#if defined(CONFIG_SYS_NIOS_EPCSBASE)
- epcs_reset,
-#endif
-
- env_init,
- serial_init,
- console_init_f,
- display_options,
- checkcpu,
- checkboard,
- NULL, /* Terminate this list */
-};
-
-
-/***********************************************************************/
-void board_init(void)
-{
- bd_t *bd;
- init_fnc_t **init_fnc_ptr;
- static gd_t gd_data;
- static bd_t bd_data;
-
- /* Pointer is writable since we allocated a register for it. */
- gd = &gd_data;
- /* compiler optimization barrier needed for GCC >= 3.4 */
- __asm__ __volatile__("" : : : "memory");
-
- gd->bd = &bd_data;
- gd->baudrate = CONFIG_BAUDRATE;
- gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
-
- bd = gd->bd;
- bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
- bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
-#ifndef CONFIG_SYS_NO_FLASH
- bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
-#endif
-#if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
- bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
- bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;
-#endif
-
- for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
- WATCHDOG_RESET();
- if ((*init_fnc_ptr) () != 0)
- hang();
- }
-
- WATCHDOG_RESET();
-
- /* The Malloc area is immediately below the monitor copy in RAM */
- mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
-
-#ifndef CONFIG_SYS_NO_FLASH
- WATCHDOG_RESET();
- bd->bi_flashsize = flash_init();
-#endif
-
-#ifdef CONFIG_CMD_NAND
- puts("NAND: ");
- nand_init();
-#endif
-
-#ifdef CONFIG_GENERIC_MMC
- puts("MMC: ");
- mmc_initialize(bd);
-#endif
-
- WATCHDOG_RESET();
- env_relocate();
-
- WATCHDOG_RESET();
- stdio_init();
- jumptable_init();
- console_init_r();
-
- WATCHDOG_RESET();
- interrupt_init();
-
-#if defined(CONFIG_BOARD_LATE_INIT)
- board_late_init();
-#endif
-
-#if defined(CONFIG_CMD_NET)
- puts("Net: ");
- eth_initialize(bd);
-#endif
-
- /* main_loop */
- for (;;) {
- WATCHDOG_RESET();
- main_loop();
- }
-}