blackfin: convert blackfin board_f and board_r to use generic board init functions
PATCH v4 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
---
v4-changes:
- move macros for generic board to arch specific config.h
- disable flash driver in board files to shrink default image size
--- arch/blackfin/config.mk | 3 + arch/blackfin/cpu/cpu.c | 334 +++++++++++++++++++++++++--- arch/blackfin/cpu/start.S | 14 +- arch/blackfin/cpu/u-boot.lds | 4 +- arch/blackfin/include/asm/config.h | 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/bf506f-ezkit.h | 5 +- include/configs/bf533-stamp.h | 3 +- include/configs/bf538f-ezkit.h | 3 +- 12 files changed, 341 insertions(+), 493 deletions(-) delete mode 100644 arch/blackfin/lib/board.c create mode 100644 arch/blackfin/lib/sections.c
arch/blackfin/config.mk +3 -0
@@ -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 LDFLAGS_FINAL += --gc-sections
arch/blackfin/cpu/cpu.c +298 -36
372 lines not on this page · raw message
arch/blackfin/cpu/start.S +12 -2
@@ -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
@@ -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/config.h +4 -0
@@ -174,4 +174,8 @@ }#endif +#define CONFIG_SYS_GENERIC_BOARD +#define CONFIG_DISPLAY_CPUINFO +#define CONFIG_ARCH_MISC_INIT +#endif
arch/blackfin/include/asm/u-boot.h +3 -0
@@ -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
@@ -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
@@ -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/bf506f-ezkit.h +2 -3
@@ -56,7 +56,7 @@/* * Flash Settings */ - +/* #define CONFIG_FLASH_CFI_DRIVER #define CONFIG_SYS_FLASH_BASE 0x20000000 #define CONFIG_SYS_FLASH_CFI
@@ -64,9 +64,8 @@#define CONFIG_SYS_MAX_FLASH_SECT 71 #define CONFIG_CMD_FLASH #define CONFIG_MONITOR_IS_IN_RAM -/* -#define CONFIG_SYS_NO_FLASH */ +#define CONFIG_SYS_NO_FLASH /* * SPI Settings
include/configs/bf533-stamp.h +2 -1
@@ -98,10 +98,11 @@*/ #define CONFIG_BFIN_SPI #define CONFIG_ENV_SPI_MAX_HZ 30000000 +/* #define CONFIG_SF_DEFAULT_SPEED 30000000 #define CONFIG_SPI_FLASH #define CONFIG_SPI_FLASH_ALL - +*/ /* * Env Storage Settings
include/configs/bf538f-ezkit.h +2 -1
@@ -83,10 +83,11 @@*/ #define CONFIG_BFIN_SPI #define CONFIG_ENV_SPI_MAX_HZ 30000000 +/* #define CONFIG_SF_DEFAULT_SPEED 30000000 #define CONFIG_SPI_FLASH #define CONFIG_SPI_FLASH_ALL - +*/ /* * Env Storage Settings
Signature · 1 line
1.8.2.3
PATCH v4 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
v4-changes:
- Init hw watchdog only when generic board macro is defined, because m68k havsn't switched over to generic board yet.
- avoid reserving video for Blackfin boards
--- common/board_f.c | 45 ++++++++++++++++++++++++++++++++++----------- include/watchdog.h | 3 ++- 2 files changed, 36 insertions(+), 12 deletions(-)
common/board_f.c +34 -11
@@ -106,9 +106,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 ();
@@ -146,7 +151,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
@@ -261,6 +270,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 ;
@@ -470,8 +481,9 @@ static int reserve_trace(void)return 0 ; } -#if defined(CONFIG_VIDEO ) && (!defined(CONFIG_PPC ) || defined(CONFIG_8xx)) \ - && !defined(CONFIG_ARM ) && !defined(CONFIG_X86 ) +#if defined(CONFIG_VIDEO ) && (!defined(CONFIG_PPC ) || defined(CONFIG_8xx)) && \ + !defined(CONFIG_ARM ) && !defined(CONFIG_X86 ) && \ + !defined(CONFIG_BLACKFIN )static int reserve_video (void ) {/* reserve memory for video display (always full pages) */
@@ -516,11 +528,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
@@ -721,7 +735,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);
@@ -828,7 +844,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
@@ -929,6 +945,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
@@ -945,11 +965,14 @@ static init_fnc_t init_sequence_f[] = {#endif reserve_trace,/* TODO: Why the dependency on CONFIG_8xx? */ -#if defined(CONFIG_VIDEO ) && (!defined(CONFIG_PPC ) || defined(CONFIG_8xx)) \ - && !defined(CONFIG_ARM ) && !defined(CONFIG_X86 ) +#if defined(CONFIG_VIDEO ) && (!defined(CONFIG_PPC ) || defined(CONFIG_8xx)) && \ + !defined(CONFIG_ARM ) && !defined(CONFIG_X86 ) && \ + !defined(CONFIG_BLACKFIN ) reserve_video,#endif +#if !defined(CONFIG_BLACKFIN ) reserve_uboot, +#endif #ifndef CONFIG_SPL_BUILD reserve_malloc, reserve_board,
include/watchdog.h +2 -1
@@ -21,7 +21,8 @@int init_func_watchdog_reset (void );#endif -#ifdef CONFIG_WATCHDOG +#if defined(CONFIG_SYS_GENERIC_BOARD ) && \ + (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
PATCH v4 2/2 support blackfin board initialization in generic board_f
Quoted 8 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
- init hardware watchdog if applicable
- useCONFIG_SYS_MONITOR_LENas the gd monitor len for Blackfin
- reserve u-boot memory at the top field of the RAM for Blackfin
- avoid refer toCONFIG_SYS_MONITOR_LEN, which is not defined by BlackfinSigned-off-by Sonic Zhang <[email protected]>
Build tested this and 1/2 for blackfin and m68k here and everything is good now, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140808/1698b975/attachment.pgp>
PATCH v4 1/2 blackfin: convert blackfin board_f and board_r to use generic board init functions
In reply to Sonic ZhangHi Sonic
Quoted 6 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
- move blackfin specific cpu init code from blackfin
board.ctocpu.c
- remove blackfin specific board init code and invoke genericboard_ffron cpu init entry
- rename section namebss_vmatobss_startin order to match the generic board init code
- add a fakerelocate_codefunction to set up the new stack only
I would like get more information about this change.
I have spent some time on Microblaze to move to generic board and I need to use sort of the same approach.
I will play with full reloc but as I see there will be a lot of additional code generated which increase u-boot footprint and brings nothing.
That's why I would like to know why you have decided to use fake relocate_code function and what setup you are using before and "after" relocation (location of stack, gd, malloc areas, etc).
Thanks,
Michal
Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140829/b7644819/attachment.pgp>
PATCH v4 1/2 blackfin: convert blackfin board_f and board_r to use generic board init functions
Hi Michael,
Quoted 16 lines · Michal Simek
Hi Sonic
Quoted 6 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
- move blackfin specific cpu init code from blackfin
board.ctocpu.c
- remove blackfin specific board init code and invoke genericboard_ffron cpu init entry
- rename section namebss_vmatobss_startin order to match the generic board init code
- add a fakerelocate_codefunction to set up the new stack onlyI would like get more information about this change.
I have spent some time on Microblaze to move to generic board and I need to use sort of the same approach.
I will play with full reloc but as I see there will be a lot of additional code generated which increase u-boot footprint and brings nothing.
Quoted 3 lines
That's why I would like to know why you have decided to use fake
relocate_codefunction and what setup you are using before and "after" relocation (location of stack, gd, malloc areas, etc).
The Blackfin u-boot start code has already done the relocation before the generic board_init_f() is invoked. But, the new stack pointer can not be set until all functions in init_sequence_f[] are done. So, the last function in init_sequence_f[] relocate_code() is used to update the stack point and jump to the generic board_init_f(). Blackfin architecture defines global static gd and bd data and set the init stack point to (CONFIG_SYS_MALLOC_BASE - 4).
Regards,
Sonic
PATCH v4 1/2 blackfin: convert blackfin board_f and board_r to use generic board init functions
Quoted 23 lines · Sonic Zhang
Hi Michael,
Quoted 16 lines · Michal Simek
Hi Sonic
Quoted 6 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
- move blackfin specific cpu init code from blackfin
board.ctocpu.c
- remove blackfin specific board init code and invoke genericboard_ffron cpu init entry
- rename section namebss_vmatobss_startin order to match the generic board init code
- add a fakerelocate_codefunction to set up the new stack onlyI would like get more information about this change.
I have spent some time on Microblaze to move to generic board and I need to use sort of the same approach.
I will play with full reloc but as I see there will be a lot of additional code generated which increase u-boot footprint and brings nothing.Quoted 3 lines
That's why I would like to know why you have decided to use fake
relocate_codefunction and what setup you are using before and "after" relocation (location of stack, gd, malloc areas, etc).
Quoted 7 lines
The Blackfin u-boot start code has already done the relocation before the generic
board_init_f()is invoked. But, the new stack pointer can not be set until all functions in init_sequence_f[] are done. So, the last function in init_sequence_f[]relocate_code()is used to update the stack point and jump to the genericboard_init_f(). Blackfin architecture defines global static gd and bd data and set the init stack point to (CONFIG_SYS_MALLOC_BASE- 4).
Ah ok.
Thanks,
Michal
Signature · 15 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140901/f4366f3d/attachment.pgp>