Skip to contentSkip to conversation

davinci: spl: Create board_init_f for explicit initialization

PATCH New Adam Ford 2 participants 5 messages May 20, 2019 – May 31, 2019

Subsystems (3)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/1 davinci: spl: Create board_init_f for explicit initialization

The arch_cpu_init() and preloader_console_init() functions were not getting called until board_init_r() as part of the spl_board_init() functions. This patch explicitly moves these initialization sequences earlier in startup, and now clears BSS per the suggested workflow in the README. This also means that CONFIG_SPL_BOARD_INIT can be removed from the defconfig

arch/arm/mach-davinci/spl.c +27 -0
index 103639e347..05c78f1801 100644
@@ -37,6 +37,33 @@ void spl_board_init(void)
 	preloader_console_init();
 }
 
+void board_init_f(ulong boot_flags)
+{
+	gd->flags = boot_flags;
+	gd->have_console = 0;
+
+	if (!(gd->flags & GD_FLG_SPL_INIT)) {
+		if (spl_init())
+			hang();
+	}
+
+	arch_cpu_init();
+
+	board_early_init_f();
+
+	/* setup GP timer */
+	timer_init();
+
+	/* UART clocks enabled and gd valid - init serial console */
+	preloader_console_init();
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	/* load/boot image from boot device */
+	board_init_r(NULL, 0);
+}
+
 u32 spl_boot_device(void)
 {
 	switch (davinci_syscfg_regs->bootcfg) {
configs/da850evm_defconfig +0 -1
index 8c16d5c4f5..c095058282 100644
@@ -21,7 +21,6 @@ CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_TEXT_BASE=0x80000000
-CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_SPI_LOAD=y
configs/da850evm_nand_defconfig +0 -1
index b8eac0e659..7271016346 100644
@@ -19,7 +19,6 @@ CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_TEXT_BASE=0x80000000
-CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_NAND_SUPPORT=y
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 davinci: spl: Create board_init_f for explicit initialization

Quoted 34 lines · Adam Ford

The arch_cpu_init() and preloader_console_init() functions were not getting called until board_init_r() as part of the spl_board_init() functions. This patch explicitly moves these initialization sequences earlier in startup, and now clears BSS per the suggested workflow in the README. This also means that CONFIG_SPL_BOARD_INIT can be removed from the defconfig

arch/arm/mach-davinci/spl.c +16 -0
index 103639e347..05c78f1801 100644
@@ -37,6 +37,33 @@ void spl_board_init(void)
 	preloader_console_init();
 }
 
+void board_init_f(ulong boot_flags)
+{
+	gd->flags = boot_flags;
+	gd->have_console = 0;
+
+	if (!(gd->flags & GD_FLG_SPL_INIT)) {
+		if (spl_init())
+			hang();
+	}
+
+	arch_cpu_init();
+
+	board_early_init_f();
+
+	/* setup GP timer */
+	timer_init();

arch/arm/mach-davinci/spl.c void spl_board_init(void) · line 65

Quoted 10 lines
arch/arm/mach-davinci/spl.c +10 -0
+
+	/* UART clocks enabled and gd valid - init serial console */
+	preloader_console_init();
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	/* load/boot image from boot device */
+	board_init_r(NULL, 0);
+}

This seems incorrect. board_init_r() is already called by arch/arm/lib/crt0.S. A much simple fix should do. I was able to get back to working on this today. Will send a patch soon.

Thanks,
Sekhar

author
#2 lore raw

PATCH 1/1 davinci: spl: Create board_init_f for explicit initialization

Quoted 42 lines · Sekhar Nori
Quoted 40 lines · Adam Ford

The arch_cpu_init() and preloader_console_init() functions were not getting called until board_init_r() as part of the spl_board_init() functions. This patch explicitly moves these initialization sequences earlier in startup, and now clears BSS per the suggested workflow in the README. This also means that CONFIG_SPL_BOARD_INIT can be removed from the defconfig

arch/arm/mach-davinci/spl.c +22 -0
index 103639e347..05c78f1801 100644
@@ -37,6 +37,33 @@ void spl_board_init(void)
      preloader_console_init();
 }
 
+void board_init_f(ulong boot_flags)
+{
+     gd->flags = boot_flags;
+     gd->have_console = 0;
+
+     if (!(gd->flags & GD_FLG_SPL_INIT)) {
+             if (spl_init())
+                     hang();
+     }
+
+     arch_cpu_init();
+
+     board_early_init_f();
+
+     /* setup GP timer */
+     timer_init();
+
+     /* UART clocks enabled and gd valid - init serial console */
+     preloader_console_init();
+
+     /* Clear the BSS. */
+     memset(__bss_start, 0, __bss_end - __bss_start);
Quoted 8 lines

arch/arm/mach-davinci/spl.c void spl_board_init(void) · line 65

Quoted 4 lines
arch/arm/mach-davinci/spl.c +4 -0
+
+     /* load/boot image from boot device */
+     board_init_r(NULL, 0);
+}

This seems incorrect. board_init_r() is already called by arch/arm/lib/crt0.S. A much simple fix should do. I was able to get back to working on this today. Will send a patch soon.

I used the board_init_f functions I found for a bunch of various other boards as the basis and they do this, but I confirmed that removing the board_init_r() call from here appears to work correctly. However, I'll test your patch when it's available.

adam

Quoted 3 lines

Thanks,
Sekhar

author
#3 lore raw

PATCH 1/1 davinci: spl: Create board_init_f for explicit initialization

Quoted 44 lines · Adam Ford
Quoted 42 lines · Sekhar Nori
Quoted 40 lines · Adam Ford

The arch_cpu_init() and preloader_console_init() functions were not getting called until board_init_r() as part of the spl_board_init() functions. This patch explicitly moves these initialization sequences earlier in startup, and now clears BSS per the suggested workflow in the README. This also means that CONFIG_SPL_BOARD_INIT can be removed from the defconfig

arch/arm/mach-davinci/spl.c +22 -0
index 103639e347..05c78f1801 100644
@@ -37,6 +37,33 @@ void spl_board_init(void)
      preloader_console_init();
 }
 
+void board_init_f(ulong boot_flags)
+{
+     gd->flags = boot_flags;
+     gd->have_console = 0;
+
+     if (!(gd->flags & GD_FLG_SPL_INIT)) {
+             if (spl_init())
+                     hang();
+     }
+
+     arch_cpu_init();
+
+     board_early_init_f();
+
+     /* setup GP timer */
+     timer_init();
+
+     /* UART clocks enabled and gd valid - init serial console */
+     preloader_console_init();
+
+     /* Clear the BSS. */
+     memset(__bss_start, 0, __bss_end - __bss_start);
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-davinci/spl.c void spl_board_init(void) · line 65

Quoted 4 lines
arch/arm/mach-davinci/spl.c +4 -0
+
+     /* load/boot image from boot device */
+     board_init_r(NULL, 0);
+}

This seems incorrect. board_init_r() is already called by arch/arm/lib/crt0.S. A much simple fix should do. I was able to get back to working on this today. Will send a patch soon.

I reduced it further

void board_init_f(ulong dummy)
{
arch_cpu_init();
spl_early_init();
board_early_init_f();
preloader_console_init();
}

Quoted 10 lines

I used the board_init_f functions I found for a bunch of various other boards as the basis and they do this, but I confirmed that removing the board_init_r() call from here appears to work correctly. However, I'll test your patch when it's available.

adam

Quoted 3 lines

Thanks,
Sekhar

author
#4 lore raw

PATCH 1/1 davinci: spl: Create board_init_f for explicit initialization

In reply to Adam Ford
Quoted 8 lines · Adam Ford

The arch_cpu_init() and preloader_console_init() functions were not getting called until board_init_r() as part of the spl_board_init() functions. This patch explicitly moves these initialization sequences earlier in startup, and now clears BSS per the suggested workflow in the README. This also means that CONFIG_SPL_BOARD_INIT can be removed from the defconfig

Tom,

You can drop this. Use Sekhar's implementation [1] instead of mine.

[1] - https://patchwork.ozlabs.org/patch/1107760/

adam

Quoted 68 lines
arch/arm/mach-davinci/spl.c +27 -0
index 103639e347..05c78f1801 100644
@@ -37,6 +37,33 @@ void spl_board_init(void)
        preloader_console_init();
 }
 
+void board_init_f(ulong boot_flags)
+{
+       gd->flags = boot_flags;
+       gd->have_console = 0;
+
+       if (!(gd->flags & GD_FLG_SPL_INIT)) {
+               if (spl_init())
+                       hang();
+       }
+
+       arch_cpu_init();
+
+       board_early_init_f();
+
+       /* setup GP timer */
+       timer_init();
+
+       /* UART clocks enabled and gd valid - init serial console */
+       preloader_console_init();
+
+       /* Clear the BSS. */
+       memset(__bss_start, 0, __bss_end - __bss_start);
+
+       /* load/boot image from boot device */
+       board_init_r(NULL, 0);
+}
+
 u32 spl_boot_device(void)
 {
        switch (davinci_syscfg_regs->bootcfg) {
configs/da850evm_defconfig +0 -1
index 8c16d5c4f5..c095058282 100644
@@ -21,7 +21,6 @@ CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_TEXT_BASE=0x80000000
-CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_SPI_LOAD=y
configs/da850evm_nand_defconfig +0 -2
index b8eac0e659..7271016346 100644
@@ -19,7 +19,6 @@ CONFIG_VERSION_VARIABLE=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_BOARD_EARLY_INIT_F=y
 CONFIG_SPL_TEXT_BASE=0x80000000
-CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_NAND_SUPPORT=y
--

2.17.1