Skip to contentSkip to conversation

spl_atmel.c: Switch s_init to board_init_f

PATCH New Tom Rini 5 participants 8 messages Feb 11, 2015 – Mar 31, 2015

Subsystems (3)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/2 spl_atmel.c: Switch s_init to board_init_f

To facilitate changing lowlevel_init to become s_init, move the current contents of s_init into board_init_f and add the rest of what board_init_f does here.

---
 arch/arm/cpu/at91-common/spl_atmel.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/cpu/at91-common/spl_atmel.c +6 -1
index 7297530..d815050 100644
@@ -58,7 +58,7 @@ static void switch_to_main_crystal_osc(void)
 	writel(tmp, &pmc->mor);
 }
 
-void s_init(void)
+void board_init_f(ulong dummy)
 {
 	switch_to_main_crystal_osc();
 
@@ -77,4 +77,9 @@ void s_init(void)
 	preloader_console_init();
 
 	mem_init();
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	board_init_r(NULL, 0);
 }
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 2/2 mx6: Rework s_init to be spl_board_init() and gate_ungate_all_mx6_pfds()

To facilitate changing lowlevel_init to become s_init, move the current contents of s_int() to gate_ungate_all_mx6_pfds() (and add extern to arch/arm/include/asm/arch-mx6/crm_regs.h) and add a default weak spl_board_init() that calls this function. The cm_fx6 platform already has a spl_board_init() so make that call the new function as well.

Cc Marek Vasut <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Igor Grinberg <[email protected]>
Cc Nikita Kiryanov <[email protected]>
---
 arch/arm/cpu/armv7/mx6/soc.c             |    7 ++++++-
 arch/arm/include/asm/arch-mx6/crm_regs.h |    2 ++
 board/compulab/cm_fx6/spl.c              |    2 ++
 include/configs/imx6_spl.h               |    1 +
 4 files changed, 11 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx6/soc.c +6 -1
index 5f5f497..ecc4272 100644
@@ -385,7 +385,7 @@ const struct boot_mode soc_boot_modes[] = {
 	{NULL,		0},
 };
 
-void s_init(void)
+void gate_ungate_all_mx6_pfds(void)
 {
 	struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR;
 	struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
@@ -429,6 +429,11 @@ void s_init(void)
 	writel(mask528, &anatop->pfd_528_clr);
 }
 
+void __weak spl_board_init(void)
+{
+	gate_ungate_all_mx6_pfds();
+}
+
 #ifdef CONFIG_IMX_HDMI
 void imx_enable_hdmi_phy(void)
 {
arch/arm/include/asm/arch-mx6/crm_regs.h +2 -0
index 39f3c07..700175e 100644
@@ -104,6 +104,8 @@ struct mxc_ccm_reg {
 	u32 analog_pfd_528_clr;
 	u32 analog_pfd_528_tog;
 };
+
+void gate_ungate_all_mx6_pfds(void);
 #endif
 
 /* Define the bits in register CCR */
board/compulab/cm_fx6/spl.c +2 -0
index 5b4b76f..83be867 100644
@@ -341,6 +341,8 @@ void spl_board_init(void)
 {
 	u32 boot_device = spl_boot_device();
 
+	gate_ungate_all_mx6_pfds();
+
 	if (boot_device == BOOT_DEVICE_SPI)
 		puts("Booting from SPI flash\n");
 	else if (boot_device == BOOT_DEVICE_MMC1)
include/configs/imx6_spl.h +1 -0
index 1b9c277..d49370d 100644
@@ -29,6 +29,7 @@
 #define CONFIG_SPL_TEXT_BASE		0x00908000
 #define CONFIG_SPL_MAX_SIZE		0x10000
 #define CONFIG_SPL_STACK		0x0091FFB8
+#define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 #define CONFIG_SPL_SERIAL_SUPPORT
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/2 mx6: Rework s_init to be spl_board_init() and gate_ungate_all_mx6_pfds()

Quoted 11 lines · Tom Rini

To facilitate changing lowlevel_init to become s_init, move the current contents of s_int() to gate_ungate_all_mx6_pfds() (and add extern to arch/arm/include/asm/arch-mx6/crm_regs.h) and add a default weak spl_board_init() that calls this function. The cm_fx6 platform already has a spl_board_init() so make that call the new function as well.

Cc Marek Vasut <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Igor Grinberg <[email protected]>
Cc Nikita Kiryanov <[email protected]>

Best regards,
Marek Vasut

#3 lore raw

PATCH 2/2 mx6: Rework s_init to be spl_board_init() and gate_ungate_all_mx6_pfds()

In reply to Tom Rini
Quoted 11 lines · Tom Rini

To facilitate changing lowlevel_init to become s_init, move the current contents of s_int() to gate_ungate_all_mx6_pfds() (and add extern to arch/arm/include/asm/arch-mx6/crm_regs.h) and add a default weak spl_board_init() that calls this function. The cm_fx6 platform already has a spl_board_init() so make that call the new function as well.

Cc Marek Vasut <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Igor Grinberg <[email protected]>
Cc Nikita Kiryanov <[email protected]>
Signature · 2 lines
Regards,
Igor.
#4 lore raw

PATCH 2/2 mx6: Rework s_init to be spl_board_init() and gate_ungate_all_mx6_pfds()

In reply to Tom Rini
Quoted 75 lines · Tom Rini

To facilitate changing lowlevel_init to become s_init, move the current contents of s_int() to gate_ungate_all_mx6_pfds() (and add extern to arch/arm/include/asm/arch-mx6/crm_regs.h) and add a default weak spl_board_init() that calls this function. The cm_fx6 platform already has a spl_board_init() so make that call the new function as well.

Cc Marek Vasut <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Igor Grinberg <[email protected]>
Cc Nikita Kiryanov <[email protected]>
---
 arch/arm/cpu/armv7/mx6/soc.c             |    7 ++++++-
 arch/arm/include/asm/arch-mx6/crm_regs.h |    2 ++
 board/compulab/cm_fx6/spl.c              |    2 ++
 include/configs/imx6_spl.h               |    1 +
 4 files changed, 11 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx6/soc.c +6 -1
index 5f5f497..ecc4272 100644
@@ -385,7 +385,7 @@ const struct boot_mode soc_boot_modes[] = {
 	{NULL,		0},
 };
 
-void s_init(void)
+void gate_ungate_all_mx6_pfds(void)
 {
 	struct anatop_regs *anatop = (struct anatop_regs *)ANATOP_BASE_ADDR;
 	struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
@@ -429,6 +429,11 @@ void s_init(void)
 	writel(mask528, &anatop->pfd_528_clr);
 }
 
+void __weak spl_board_init(void)
+{
+	gate_ungate_all_mx6_pfds();
+}
+
 #ifdef CONFIG_IMX_HDMI
 void imx_enable_hdmi_phy(void)
 {
arch/arm/include/asm/arch-mx6/crm_regs.h +2 -0
index 39f3c07..700175e 100644
@@ -104,6 +104,8 @@ struct mxc_ccm_reg {
 	u32 analog_pfd_528_clr;
 	u32 analog_pfd_528_tog;
 };
+
+void gate_ungate_all_mx6_pfds(void);
 #endif
 
 /* Define the bits in register CCR */
board/compulab/cm_fx6/spl.c +2 -0
index 5b4b76f..83be867 100644
@@ -341,6 +341,8 @@ void spl_board_init(void)
 {
 	u32 boot_device = spl_boot_device();
 
+	gate_ungate_all_mx6_pfds();
+
 	if (boot_device == BOOT_DEVICE_SPI)
 		puts("Booting from SPI flash\n");
 	else if (boot_device == BOOT_DEVICE_MMC1)
include/configs/imx6_spl.h +0 -0
index 1b9c277..d49370d 100644

include/configs/imx6_spl.h line 35

Quoted 7 lines
include/configs/imx6_spl.h +1 -0
@@ -29,6 +29,7 @@
 #define CONFIG_SPL_TEXT_BASE		0x00908000
 #define CONFIG_SPL_MAX_SIZE		0x10000
 #define CONFIG_SPL_STACK		0x0091FFB8
+#define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_LIBCOMMON_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 #define CONFIG_SPL_SERIAL_SUPPORT

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#5 lore raw

PATCH 1/2 spl_atmel.c: Switch s_init to board_init_f

In reply to Tom Rini

Hi Tom,

rebased and tried to apply, but unfortuantely this breaks SPL for at91 armv7 boards:

05: spl_atmel.c: Switch s_init to board_init_f
arm: + sama5d3xek_mmc sama5d3xek_nandflash sama5d3xek_spiflash
sama5d4_xplained_mmc sama5d4ek_nandflash +arch/arm/cpu/armv7/built-in.o: In function `lowlevel_init':
+build/../arch/arm/cpu/armv7/lowlevel_init.S:57: undefined reference to `s_init'
+make[2]: *** [spl/u-boot-spl] Error 1
+make[1]: *** [spl/u-boot-spl] Error 2
+make: *** [sub-make] Error 2

I have to provide an empty s_init() to compile cleanly. Are you fine with just adopting your patch or would you like to repost?

Andreas

Quoted 36 lines · Tom Rini

To facilitate changing lowlevel_init to become s_init, move the current contents of s_init into board_init_f and add the rest of what board_init_f does here.

---
 arch/arm/cpu/at91-common/spl_atmel.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/cpu/at91-common/spl_atmel.c +6 -1
index 7297530..d815050 100644
@@ -58,7 +58,7 @@ static void switch_to_main_crystal_osc(void)
 	writel(tmp, &pmc->mor);
 }
 
-void s_init(void)
+void board_init_f(ulong dummy)
 {
 	switch_to_main_crystal_osc();
 
@@ -77,4 +77,9 @@ void s_init(void)
 	preloader_console_init();
 
 	mem_init();
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	board_init_r(NULL, 0);
 }
#6 lore raw

PATCH 1/1 spl_atmel.c: Switch s_init to board_init_f

In reply to Tom Rini

Dear Tom Rini,

Quoted 12 lines · Tom Rini

To facilitate changing lowlevel_init to become s_init, move the current contents of s_init into board_init_f and add the rest of what board_init_f does here.
In order to compile clean without CONFIG_SKIP_LOWLEVEL_INIT set, leave an empty stub of s_init(). It can be removed when lowlevel_init becomes s_init.

Cc Bo Shen <[email protected]>
Cc Andreas Bie?mann <[email protected]>
[rebased on current master, leave s_init() as empty stub]
Quoted 3 lines

---
arch/arm/mach-at91/spl_atmel.c | 7 ++++++-

1 file changed, 6 insertions(+), 1 deletion(-)

applied a rebased and slightly modified version to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

#7 lore raw

PATCH 1/1 spl_atmel.c: Switch s_init to board_init_f

In reply to Tom Rini

Dear Tom Rini,

Quoted 12 lines · Tom Rini

To facilitate changing lowlevel_init to become s_init, move the current contents of s_init into board_init_f and add the rest of what board_init_f does here.
In order to compile clean without CONFIG_SKIP_LOWLEVEL_INIT set, leave an empty stub of s_init(). It can be removed when lowlevel_init becomes s_init.

Cc Bo Shen <[email protected]>
Cc Andreas Bie?mann <[email protected]>
[rebased on current master, leave s_init() as empty stub]
Quoted 3 lines

---
arch/arm/mach-at91/spl_atmel.c | 7 ++++++-

1 file changed, 6 insertions(+), 1 deletion(-)

applied a rebased and slightly modified version to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann