Skip to contentSkip to conversation

spl: add a new stub spl_early_board_init() for early SoC-specific setup

PATCH New Masahiro Yamada 3 participants 6 messages Mar 8, 2016 – Mar 13, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: add a new stub spl_early_board_init() for early SoC-specific setup

We are generally supposed to implement SoC/board-specific SPL init code in spl_board_init(), but it is called after spl_init() where the FDT is setup and devices are bound.

This new stub spl_early_board_init() would be useful to put something really SoC-specific, for example, debug_uart_init().

In fact, I was hit by some problems on FDT setup when I was tackling on a completely new platform. I wished I could use the debug UART earlier in situations like that.

---

 common/spl/spl.c | 6 ++++++
 include/spl.h    | 1 +
 2 files changed, 7 insertions(+)
common/spl/spl.c +6 -0
index e5167bf..df85b09 100644
@@ -150,6 +150,10 @@ static int spl_ram_load_image(void)
 }
 #endif
 
+void __weak spl_early_board_init(void)
+{
+}
+
 int spl_init(void)
 {
 	int ret;
@@ -344,6 +348,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 {
 	int i;
 
+	spl_early_board_init();
+
 	debug(">>spl:board_init_r()\n");
 
 #if defined(CONFIG_SYS_SPL_MALLOC_START)
include/spl.h +1 -0
index 92cdc04..e3c1873 100644
@@ -93,6 +93,7 @@ int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition);
  */
 int spl_init(void);
 
+void spl_early_board_init(void);
 #ifdef CONFIG_SPL_BOARD_INIT
 void spl_board_init(void);
 #endif
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 spl: add a new stub spl_early_board_init() for early SoC-specific setup

Quoted 4 lines · Masahiro Yamada

We are generally supposed to implement SoC/board-specific SPL init code in spl_board_init(), but it is called after spl_init() where the FDT is setup and devices are bound.

Quoted 8 lines

This new stub spl_early_board_init() would be useful to put something really SoC-specific, for example, debug_uart_init().

In fact, I was hit by some problems on FDT setup when I was tackling on a completely new platform. I wished I could use the debug UART earlier in situations like that.

This is usually done with s_init() and uniphier opts out of that. I would conceed however that things could use some further clean-up and organization here.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160308/3f70b5a7/attachment.sig>
#2 lore raw

PATCH 1/1 spl: add a new stub spl_early_board_init() for early SoC-specific setup

Hi Tom,

2016-03-09 8:23 GMT+09:00 Tom Rini <[email protected]>:

Quoted 9 lines · Masahiro Yamada
Quoted 8 lines

We are generally supposed to implement SoC/board-specific SPL init code in spl_board_init(), but it is called after spl_init() where the FDT is setup and devices are bound.

This new stub spl_early_board_init() would be useful to put something really SoC-specific, for example, debug_uart_init().

Quoted 7 lines
Quoted 5 lines

In fact, I was hit by some problems on FDT setup when I was tackling on a completely new platform. I wished I could use the debug UART earlier in situations like that.

This is usually done with s_init() and uniphier opts out of that.

Yes, ARM32 UniPhier needs to do some tricky initialization right after the start-up,
so it has its own lowlevel_init.

ARM64 UniPhier is more like the standard ARM architecture, so hopefully I will be able to reuse more common code.

Quoted 3 lines

I
would conceed however that things could use some further clean-up and organization here.

As Simon pointed out, an alternative would be to override board_init_f(). I can live with that, too.

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH 1/1 spl: add a new stub spl_early_board_init() for early SoC-specific setup

In reply to Masahiro Yamada

Hi Masahiro,

Quoted 34 lines · Masahiro Yamada

We are generally supposed to implement SoC/board-specific SPL init code in spl_board_init(), but it is called after spl_init() where the FDT is setup and devices are bound.

This new stub spl_early_board_init() would be useful to put something really SoC-specific, for example, debug_uart_init().

In fact, I was hit by some problems on FDT setup when I was tackling on a completely new platform. I wished I could use the debug UART earlier in situations like that.

---

 common/spl/spl.c | 6 ++++++
 include/spl.h    | 1 +
 2 files changed, 7 insertions(+)
common/spl/spl.c +4 -0
index e5167bf..df85b09 100644
@@ -150,6 +150,10 @@ static int spl_ram_load_image(void)
 }
 #endif
 
+void __weak spl_early_board_init(void)
+{
+}
+
 int spl_init(void)
 {
        int ret;

common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 351

Quoted 4 lines
common/spl/spl.c +1 -0
@@ -344,6 +348,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 {
        int i;
 
+       spl_early_board_init();

Why not put this in board_init_f()? That is a little earlier.

In fact you can replace that function with your own version.

(although it would be better if we had a single board_init_f() and called out to board-specific code from there.)

common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 354

Quoted 3 lines
common/spl/spl.c +1 -0
+
        debug(">>spl:board_init_r()\n");
 

[snip]

Regards,
Simon

#4 lore raw

PATCH 1/1 spl: add a new stub spl_early_board_init() for early SoC-specific setup

Hi Simon,

2016-03-09 8:33 GMT+09:00 Simon Glass <[email protected]>:

Quoted 40 lines

Hi Masahiro,

Quoted 37 lines · Masahiro Yamada

We are generally supposed to implement SoC/board-specific SPL init code in spl_board_init(), but it is called after spl_init() where the FDT is setup and devices are bound.

This new stub spl_early_board_init() would be useful to put something really SoC-specific, for example, debug_uart_init().

In fact, I was hit by some problems on FDT setup when I was tackling on a completely new platform. I wished I could use the debug UART earlier in situations like that.

---

 common/spl/spl.c | 6 ++++++
 include/spl.h    | 1 +
 2 files changed, 7 insertions(+)
common/spl/spl.c +4 -0
index e5167bf..df85b09 100644
@@ -150,6 +150,10 @@ static int spl_ram_load_image(void)
 }
 #endif
 
+void __weak spl_early_board_init(void)
+{
+}
+
 int spl_init(void)
 {
        int ret;
@@ -344,6 +348,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 {
        int i;
 
Quoted 3 lines

common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 351

Quoted 1 line
common/spl/spl.c +1 -0
+       spl_early_board_init();

Why not put this in board_init_f()? That is a little earlier.

The reason is board_init_f() for SPL is not placed in the common place.

We can move it there if it is OK to deal with it per arch.

Quoted 1 line

In fact you can replace that function with your own version.

Right. This is an alternative.

The definition of board_init_f() in arch/arm/lib/spl.c is short enough.

I can copy it into arch/arm/mach-uniphier/ and adjust it for my own use.

Quoted 6 lines

(although it would be better if we had a single board_init_f() and called out to board-specific code from there.)

Quoted 3 lines
common/spl/spl.c +1 -0
+
        debug(">>spl:board_init_r()\n");
 

So, what shall we do about this?

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw

PATCH 1/1 spl: add a new stub spl_early_board_init() for early SoC-specific setup

Hi Masahiro,

Quoted 62 lines · Masahiro Yamada

Hi Simon,

2016-03-09 8:33 GMT+09:00 Simon Glass <[email protected]>:

Quoted 40 lines

Hi Masahiro,

Quoted 37 lines · Masahiro Yamada

We are generally supposed to implement SoC/board-specific SPL init code in spl_board_init(), but it is called after spl_init() where the FDT is setup and devices are bound.

This new stub spl_early_board_init() would be useful to put something really SoC-specific, for example, debug_uart_init().

In fact, I was hit by some problems on FDT setup when I was tackling on a completely new platform. I wished I could use the debug UART earlier in situations like that.

---

 common/spl/spl.c | 6 ++++++
 include/spl.h    | 1 +
 2 files changed, 7 insertions(+)
common/spl/spl.c +4 -0
index e5167bf..df85b09 100644
@@ -150,6 +150,10 @@ static int spl_ram_load_image(void)
 }
 #endif
 
+void __weak spl_early_board_init(void)
+{
+}
+
 int spl_init(void)
 {
        int ret;
@@ -344,6 +348,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 {
        int i;
 
Quoted 3 lines

common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 351

Quoted 1 line
common/spl/spl.c +1 -0
+       spl_early_board_init();

Why not put this in board_init_f()? That is a little earlier.

The reason is board_init_f() for SPL is not placed in the common place.

We can move it there if it is OK to deal with it per arch.

Quoted 1 line

In fact you can replace that function with your own version.

Right. This is an alternative.

The definition of board_init_f() in arch/arm/lib/spl.c is short enough.

I can copy it into arch/arm/mach-uniphier/ and adjust it for my own use.

Quoted 8 lines
Quoted 6 lines

(although it would be better if we had a single board_init_f() and called out to board-specific code from there.)

Quoted 3 lines
common/spl/spl.c +1 -0
+
        debug(">>spl:board_init_r()\n");
 

So, what shall we do about this?

Well, a refactor, I think. I have not looked at how hard it is, but it's probably the next thing to do to make SPL more similar for all boards.

Regards,
Simon