Skip to contentSkip to conversation

blackfin: convert blackfin board_f and board_r to use generic board init functions

PATCH Superseded Sonic Zhang 1 participant 2 messages Aug 1, 2014

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 blackfin: convert blackfin board_f and board_r to use generic board init functions

From: Sonic Zhang <[email protected]>

- move blackfin specific cpu init code from blackfin board.c to cpu.c
- remove blackfin specific board init code and invoke generic board_f fron cpu init entry
- rename section name bss_vma to bss_start in order to match the generic board init code
- add a fake relocate_code function to set up the new stack only

---

 arch/blackfin/config.mk            |   3 +
 arch/blackfin/cpu/cpu.c            | 333 +++++++++++++++++++++++++---
 arch/blackfin/cpu/start.S          |  14 +-
 arch/blackfin/cpu/u-boot.lds       |   4 +-
 arch/blackfin/include/asm/u-boot.h |   3 +
 arch/blackfin/lib/Makefile         |   7 +-
 arch/blackfin/lib/board.c          | 443 -------------------------------------
 arch/blackfin/lib/sections.c       |  11 +
 include/configs/bfin_adi_common.h  |   4 +
 9 files changed, 334 insertions(+), 488 deletions(-)
 delete mode 100644 arch/blackfin/lib/board.c
 create mode 100644 arch/blackfin/lib/sections.c
arch/blackfin/config.mk +3 -0
index fcaa44f..96730dd 100644
@@ -20,6 +20,9 @@ CONFIG_BFIN_CPU := $(strip $(CONFIG_BFIN_CPU:"%"=%))
 endif
 CONFIG_BFIN_BOOT_MODE := $(strip $(CONFIG_BFIN_BOOT_MODE:"%"=%))
 
+# Support generic board on Blackfin
+__HAVE_ARCH_GENERIC_BOARD := y
+
 PLATFORM_RELFLAGS += -ffixed-P3 -fomit-frame-pointer -mno-fdpic
 PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN
 
arch/blackfin/cpu/cpu.c +297 -36

371 lines not on this page · raw message

arch/blackfin/cpu/start.S +12 -2
index 29a7c23..f31abfa 100644
@@ -196,8 +196,8 @@ ENTRY(_start)
 	 * takes care of clearing things for us.
 	 */
 	serial_early_puts("Zero BSS");
-	r0.l = __bss_vma;
-	r0.h = __bss_vma;
+	r0.l = __bss_start;
+	r0.h = __bss_start;
 	r1 = 0 (x);
 	r2.l = __bss_len;
 	r2.h = __bss_len;
@@ -251,3 +251,13 @@ LENTRY(_get_pc)
 #endif
 	rts;
 ENDPROC(_get_pc)
+
+ENTRY(_relocate_code)
+	/* Fake relocate code. Setup the new stack only */
+	sp = r0;
+	fp = sp;
+	r0 = p3;
+	r1.h = 0x2000;
+	r1.l = 0x10;
+	jump.l _board_init_r
+ENDPROC(_relocate_code)
arch/blackfin/cpu/u-boot.lds +3 -1
index 7f0411f..ae1b813 100644
@@ -135,6 +135,8 @@ SECTIONS
 		*(COMMON)
 		. = ALIGN(4);
 	} >ram_data
-	__bss_vma = ADDR(.bss);
+	__bss_end = .;
+	__bss_start = ADDR(.bss);
 	__bss_len = SIZEOF(.bss);
+	__init_end = .;
 }
arch/blackfin/include/asm/u-boot.h +3 -0
index acaeee9..7b5cf6a 100644
@@ -25,9 +25,12 @@ typedef struct bd_info {
 	unsigned long bi_vco;
 	unsigned long bi_cclk;
 	unsigned long bi_sclk;
+	unsigned char bi_enetaddr[6];
 } bd_t;
 
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_BLACKFIN
 
+int	arch_misc_init(void);
+
 #endif	/* _U_BOOT_H_ */
arch/blackfin/lib/Makefile +1 -6
index 4ba7bf6..b534a98 100644
@@ -9,11 +9,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# Unnecessary.
-# Use CONFIG_SYS_BOARD instead of BFIN_BOARD_NAME
-# and delete this.
-ccflags-y += -DBFIN_BOARD_NAME='"$(BOARD)"'
-
 obj-y	+= ins.o
 obj-y	+= memcmp.o
 obj-y	+= memcpy.o
@@ -21,7 +16,6 @@ obj-y	+= memmove.o
 obj-y	+= memset.o
 obj-y	+= outs.o
 obj-$(CONFIG_CMD_KGDB) += __kgdb.o
-obj-y	+= board.o
 obj-y	+= boot.o
 obj-y	+= cache.o
 obj-y	+= clocks.o
@@ -30,3 +24,4 @@ obj-$(CONFIG_CMD_KGDB) += kgdb.o
 obj-y	+= muldi3.o
 obj-$(CONFIG_HAS_POST) += post.o
 obj-y	+= string.o
+obj-y	+= sections.o
arch/blackfin/lib/board.c deleted +0 -443

443 lines not on this page · raw message

arch/blackfin/lib/sections.c new file +11 -0
new file mode 100644
index 0000000..b50f30a
@@ -0,0 +1,11 @@
+/*
+ * U-boot - section.c
+ *
+ * Copyright (c) 2014 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+char __bss_start[0] __attribute__((section(".__bss_start")));
+char __bss_end[0] __attribute__((section(".__bss_end")));
+char __init_end[0] __attribute__((section(".__init_end")));
include/configs/bfin_adi_common.h +4 -0
index ea9acf6..19160ce 100644
@@ -327,4 +327,8 @@
 #ifndef CONFIG_ADI_GPIO2
 # define CONFIG_ADI_GPIO1
 #endif
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_DISPLAY_CPUINFO
+#define CONFIG_ARCH_MISC_INIT
+
 #endif
Signature · 1 line
1.8.2.3
#1 lore raw

PATCH v3 2/2 support blackfin board initialization in generic board_f

From: Sonic Zhang <[email protected]>

- init hardware watchdog if applicable
- use CONFIG_SYS_MONITOR_LEN as the gd monitor len for Blackfin
- reserve u-boot memory at the top field of the RAM for Blackfin
- avoid refer to CONFIG_SYS_MONITOR_LEN, which is not defined by Blackfin

---

v2-changes:
- make hardware watchdog init depend on BLACKFIN || M68K || MICROBLAZE || SH
- define watchdog init and reset macros for both software and hardware watchdog

v3-changes:
- allocate board info struct only when it is not already allocated in arch init

---
 common/board_f.c   | 35 ++++++++++++++++++++++++++++-------
 include/watchdog.h |  2 +-
 2 files changed, 29 insertions(+), 8 deletions(-)
common/board_f.c +28 -7
index bdab38e..c934365 100644
@@ -104,9 +104,14 @@ __weak void blue_led_off(void) {}
  * Could the CONFIG_SPL_BUILD infection become a flag in gd?
  */
 
-#if defined(CONFIG_WATCHDOG)
+#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
 static int init_func_watchdog_init(void)
 {
+# if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \
+	defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
+	defined(CONFIG_SH))
+	hw_watchdog_init();
+# endif
 	puts("       Watchdog enabled\n");
 	WATCHDOG_RESET();
 
@@ -144,7 +149,11 @@ static int display_text_info(void)
 	bss_end = (ulong)&__bss_end;
 
 	debug("U-Boot code: %08X -> %08lX  BSS: -> %08lX\n",
+#ifdef CONFIG_SYS_TEXT_BASE
 	      CONFIG_SYS_TEXT_BASE, bss_start, bss_end);
+#else
+	      CONFIG_SYS_MONITOR_BASE, bss_start, bss_end);
+#endif
 #endif
 
 #ifdef CONFIG_MODEM_SUPPORT
@@ -259,6 +268,8 @@ static int setup_mon_len(void)
 	gd->mon_len = (ulong)&__bss_end - (ulong)_start;
 #elif defined(CONFIG_SANDBOX)
 	gd->mon_len = (ulong)&_end - (ulong)_init;
+#elif defined(CONFIG_BLACKFIN)
+	gd->mon_len = CONFIG_SYS_MONITOR_LEN;
 #else
 	/* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
 	gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
@@ -514,11 +525,13 @@ static int reserve_malloc(void)
 /* (permanently) allocate a Board Info struct */
 static int reserve_board(void)
 {
-	gd->start_addr_sp -= sizeof(bd_t);
-	gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
-	memset(gd->bd, '\0', sizeof(bd_t));
-	debug("Reserving %zu Bytes for Board Info at: %08lx\n",
-			sizeof(bd_t), gd->start_addr_sp);
+	if (!gd->bd) {
+		gd->start_addr_sp -= sizeof(bd_t);
+		gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
+		memset(gd->bd, '\0', sizeof(bd_t));
+		debug("Reserving %zu Bytes for Board Info at: %08lx\n",
+				sizeof(bd_t), gd->start_addr_sp);
+	}
 	return 0;
 }
 #endif
@@ -719,7 +732,9 @@ static int reloc_fdt(void)
 
 static int setup_reloc(void)
 {
+#ifdef CONFIG_SYS_TEXT_BASE
 	gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
+#endif
 	memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
 
 	debug("Relocation Offset is: %08lx\n", gd->reloc_off);
@@ -802,7 +817,7 @@ static init_fnc_t init_sequence_f[] = {
 	/* TODO: can we rename this to timer_init()? */
 	init_timebase,
 #endif
-#if defined(CONFIG_ARM) || defined(CONFIG_MIPS)
+#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_BLACKFIN)
 	timer_init,		/* initialize timer */
 #endif
 #ifdef CONFIG_SYS_ALLOC_DPRAM
@@ -901,6 +916,10 @@ static init_fnc_t init_sequence_f[] = {
 	 *  - board info struct
 	 */
 	setup_dest_addr,
+#if defined(CONFIG_BLACKFIN)
+	/* Blackfin u-boot monitor should be on top of the ram */
+	reserve_uboot,
+#endif
 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
 	reserve_logbuffer,
 #endif
@@ -921,7 +940,9 @@ static init_fnc_t init_sequence_f[] = {
 		&& !defined(CONFIG_ARM) && !defined(CONFIG_X86)
 	reserve_video,
 #endif
+#if !defined(CONFIG_BLACKFIN)
 	reserve_uboot,
+#endif
 #ifndef CONFIG_SPL_BUILD
 	reserve_malloc,
 	reserve_board,
include/watchdog.h +1 -1
index aacacb9..437df4b 100644
@@ -21,7 +21,7 @@
 int init_func_watchdog_reset(void);
 #endif
 
-#ifdef CONFIG_WATCHDOG
+#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
 #define INIT_FUNC_WATCHDOG_INIT	init_func_watchdog_init,
 #define INIT_FUNC_WATCHDOG_RESET	init_func_watchdog_reset,
 #else
Signature · 1 line
1.8.2.3