Patchwork [U-Boot,1/2] ARM: introduce arch_early_init_r()

login
register
mail settings
Submitter Fabio Estevam
Date April 2, 2012, 9:19 p.m.
Message ID <1333401586-24032-1-git-send-email-fabio.estevam@freescale.com>
Download mbox | patch
Permalink /patch/150253/
State Accepted
Commit d519b4bc0a1216eb273c76c129b779fa1ba2beb5
Delegated to: Albert ARIBAUD
Headers show

Comments

Fabio Estevam - April 2, 2012, 9:19 p.m.
Introduce arch_early_init_r() function, which can be useful for doing
early initialization after relocation has happened.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/include/asm/u-boot-arm.h |    1 +
 arch/arm/lib/board.c              |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)
Tom Rini - April 2, 2012, 9:42 p.m.
On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:

> Introduce arch_early_init_r() function, which can be useful for doing
> early initialization after relocation has happened.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Perhaps I just overlooked earlier conversations, but why not just do
this in board_init() ?
Marek Vasut - April 2, 2012, 10 p.m.
Dear Tom Rini,

> On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:
> > Introduce arch_early_init_r() function, which can be useful for doing
> > early initialization after relocation has happened.
> > 
> > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Perhaps I just overlooked earlier conversations, but why not just do
> this in board_init() ?

Because we have multiple boards and they all need it.

Best regards,
Marek Vasut
Tom Rini - April 2, 2012, 10:01 p.m.
On Tue, Apr 03, 2012 at 12:00:31AM +0200, Marek Vasut wrote:
> Dear Tom Rini,
> 
> > On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:
> > > Introduce arch_early_init_r() function, which can be useful for doing
> > > early initialization after relocation has happened.
> > > 
> > > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> > 
> > Perhaps I just overlooked earlier conversations, but why not just do
> > this in board_init() ?
> 
> Because we have multiple boards and they all need it.

And you aren't architectured with a common board_init() over the family
(would there be little to no duplication)?  This is what we do in
various TI families.
Marek Vasut - April 2, 2012, 10:08 p.m.
Dear Tom Rini,

> On Tue, Apr 03, 2012 at 12:00:31AM +0200, Marek Vasut wrote:
> > Dear Tom Rini,
> > 
> > > On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:
> > > > Introduce arch_early_init_r() function, which can be useful for doing
> > > > early initialization after relocation has happened.
> > > > 
> > > > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> > > 
> > > Perhaps I just overlooked earlier conversations, but why not just do
> > > this in board_init() ?
> > 
> > Because we have multiple boards and they all need it.
> 
> And you aren't architectured with a common board_init() over the family
> (would there be little to no duplication)?  This is what we do in
> various TI families.

Common board_init() ? How would you then do the actual distinct per-board init?

Best regards,
Marek Vasut
Tom Rini - April 2, 2012, 10:13 p.m.
On Tue, Apr 03, 2012 at 12:08:33AM +0200, Marek Vasut wrote:
> Dear Tom Rini,
> 
> > On Tue, Apr 03, 2012 at 12:00:31AM +0200, Marek Vasut wrote:
> > > Dear Tom Rini,
> > > 
> > > > On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:
> > > > > Introduce arch_early_init_r() function, which can be useful for doing
> > > > > early initialization after relocation has happened.
> > > > > 
> > > > > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> > > > 
> > > > Perhaps I just overlooked earlier conversations, but why not just do
> > > > this in board_init() ?
> > > 
> > > Because we have multiple boards and they all need it.
> > 
> > And you aren't architectured with a common board_init() over the family
> > (would there be little to no duplication)?  This is what we do in
> > various TI families.
> 
> Common board_init() ? How would you then do the actual distinct per-board init?

Pah, mis-recalled things, sorry.  We have a pre-relocation hook that's
common per-family (lowlevel_init (generic) -> s_init (TI generic)).
Tom Rini - April 2, 2012, 10:15 p.m.
On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:

> Introduce arch_early_init_r() function, which can be useful for doing
> early initialization after relocation has happened.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
[snip]
> +#ifdef CONFIG_ARCH_EARLY_INIT_R
> +	arch_early_init_r();
> +#endif

We never check return status, make this a void?  As Wolfgang has said
before, just because the other examples do things wrong doesn't mean we
should keep doing it :)
Graeme Russ - April 2, 2012, 11:05 p.m.
Hi Tom,

On Tue, Apr 3, 2012 at 8:15 AM, Tom Rini <trini@ti.com> wrote:
> On Mon, Apr 02, 2012 at 06:19:45PM -0300, Fabio Estevam wrote:
>
>> Introduce arch_early_init_r() function, which can be useful for doing
>> early initialization after relocation has happened.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> [snip]
>> +#ifdef CONFIG_ARCH_EARLY_INIT_R
>> +     arch_early_init_r();
>> +#endif
>
> We never check return status, make this a void?  As Wolfgang has said
> before, just because the other examples do things wrong doesn't mean we
> should keep doing it :)

The INIT_FUNC patch series will require that the board_init...() functions
get flattened to simply processing loops and all of these extra functions
that have crept in outside those loops be moved into the init arrays.

Have a look at arch/x86/lib/board.c for reference

Defining these functions as returning int with no parameters will make
that work a lot easier

Regards,

Graeme
Marek Vasut - April 6, 2012, 12:30 a.m.
Dear Fabio Estevam,

> Introduce arch_early_init_r() function, which can be useful for doing
> early initialization after relocation has happened.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Are we getting anywhere with this patchset please?

CCing Albert Aribaud.

Best regards,
Marek Vasut
Fabio Estevam - April 6, 2012, 12:33 a.m.
On Thu, Apr 5, 2012 at 9:30 PM, Marek Vasut <marex@denx.de> wrote:
> Dear Fabio Estevam,
>
>> Introduce arch_early_init_r() function, which can be useful for doing
>> early initialization after relocation has happened.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>
> Are we getting anywhere with this patchset please?

Looking forward for it to be applied :-)

>
> CCing Albert Aribaud.

I added Albert on Cc on my initial patch submission.

Regards,

Fabio Estevam
Marek Vasut - April 6, 2012, 1:04 a.m.
Dear Fabio Estevam,

> On Thu, Apr 5, 2012 at 9:30 PM, Marek Vasut <marex@denx.de> wrote:
> > Dear Fabio Estevam,
> > 
> >> Introduce arch_early_init_r() function, which can be useful for doing
> >> early initialization after relocation has happened.
> >> 
> >> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> > 
> > Are we getting anywhere with this patchset please?
> 
> Looking forward for it to be applied :-)
> 
> > CCing Albert Aribaud.
> 
> I added Albert on Cc on my initial patch submission.

Well ... let's prod him a bit more ;)

> Regards,
> 
> Fabio Estevam

Best regards,
Marek Vasut
Albert ARIBAUD - July 7, 2012, 11:53 a.m.
Hi Fabio,

On Mon, 2 Apr 2012 18:19:45 -0300, Fabio Estevam
<fabio.estevam@freescale.com> wrote:

> Introduce arch_early_init_r() function, which can be useful for doing
> early initialization after relocation has happened.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  arch/arm/include/asm/u-boot-arm.h |    1 +
>  arch/arm/lib/board.c              |    4 ++++
>  2 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/include/asm/u-boot-arm.h
> b/arch/arm/include/asm/u-boot-arm.h index 4ca75f9..9f3cae5 100644
> --- a/arch/arm/include/asm/u-boot-arm.h
> +++ b/arch/arm/include/asm/u-boot-arm.h
> @@ -52,6 +52,7 @@ void	cpu_init_cp15(void);
>  /* cpu/.../arch/cpu.c */
>  int	arch_cpu_init(void);
>  int	arch_misc_init(void);
> +int	arch_early_init_r(void);
>  
>  /* board/.../... */
>  int	board_init(void);
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 5270c11..025d6ca 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -500,6 +500,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  	malloc_start = dest_addr - TOTAL_MALLOC_LEN;
>  	mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
>  
> +#ifdef CONFIG_ARCH_EARLY_INIT_R
> +	arch_early_init_r();
> +#endif
> +
>  #if !defined(CONFIG_SYS_NO_FLASH)
>  	puts("Flash: ");
>  

Applied to u-boot-arm (with an addmittedly very slow sensitivity to
prodding), thanks.

Amicalement,

Patch

diff --git a/arch/arm/include/asm/u-boot-arm.h b/arch/arm/include/asm/u-boot-arm.h
index 4ca75f9..9f3cae5 100644
--- a/arch/arm/include/asm/u-boot-arm.h
+++ b/arch/arm/include/asm/u-boot-arm.h
@@ -52,6 +52,7 @@  void	cpu_init_cp15(void);
 /* cpu/.../arch/cpu.c */
 int	arch_cpu_init(void);
 int	arch_misc_init(void);
+int	arch_early_init_r(void);
 
 /* board/.../... */
 int	board_init(void);
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 5270c11..025d6ca 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -500,6 +500,10 @@  void board_init_r(gd_t *id, ulong dest_addr)
 	malloc_start = dest_addr - TOTAL_MALLOC_LEN;
 	mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
 
+#ifdef CONFIG_ARCH_EARLY_INIT_R
+	arch_early_init_r();
+#endif
+
 #if !defined(CONFIG_SYS_NO_FLASH)
 	puts("Flash: ");