[U-Boot] [PATCH 1/3] ARM: lib: Remove CONFIG_ARCH_CPU_INIT dependency

Create a weak-aliased arch_cpu_init, so that we can get rid of CONFIG_ARCH_CPU_INIT and always call arch_cpu_init.
This way we do not need to define CONFIG_ARCH_CPU_INIT in every board file, since arch_cpu_init() is supposed to handle common CPU level code.
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com --- arch/arm/lib/board.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 500e216..6463db5 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -224,10 +224,16 @@ void __dram_init_banksize(void) void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize")));
+int __arch_cpu_init(void) +{ + return 0; +} +int arch_cpu_init(void) + __attribute__((weak, alias("__arch_cpu_init"))); + init_fnc_t *init_sequence[] = { -#if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ -#endif + #if defined(CONFIG_BOARD_EARLY_INIT_F) board_early_init_f, #endif

No need to define CONFIG_ARCH_CPU_INIT.
All mx6 based boards should use arch_cpu_init().
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com --- arch/arm/cpu/armv7/mx6/soc.c | 2 -- include/configs/mx6qarm2.h | 1 - include/configs/mx6qsabrelite.h | 1 - 3 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index 2ac74b5..2d07099 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -37,7 +37,6 @@ u32 get_cpu_rev(void) return system_rev; }
-#ifdef CONFIG_ARCH_CPU_INIT void init_aips(void) { struct aipstz_regs *aips1, *aips2; @@ -77,7 +76,6 @@ int arch_cpu_init(void)
return 0; } -#endif
#if defined(CONFIG_FEC_MXC) void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) diff --git a/include/configs/mx6qarm2.h b/include/configs/mx6qarm2.h index 0962d3c..87ff0a3 100644 --- a/include/configs/mx6qarm2.h +++ b/include/configs/mx6qarm2.h @@ -37,7 +37,6 @@ /* Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2 * 1024 * 1024)
-#define CONFIG_ARCH_CPU_INIT #define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_MXC_GPIO
diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index 93000f0..85e6570 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -37,7 +37,6 @@ /* Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2 * 1024 * 1024)
-#define CONFIG_ARCH_CPU_INIT #define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_MXC_GPIO

No need to define CONFIG_ARCH_CPU_INIT.
All mx6 based boards should use arch_cpu_init().
Acked-by: Marek Vasut marex@denx.de
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
arch/arm/cpu/armv7/mx6/soc.c | 2 -- include/configs/mx6qarm2.h | 1 - include/configs/mx6qsabrelite.h | 1 - 3 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index 2ac74b5..2d07099 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -37,7 +37,6 @@ u32 get_cpu_rev(void) return system_rev; }
-#ifdef CONFIG_ARCH_CPU_INIT void init_aips(void) { struct aipstz_regs *aips1, *aips2; @@ -77,7 +76,6 @@ int arch_cpu_init(void)
return 0; } -#endif
#if defined(CONFIG_FEC_MXC) void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) diff --git a/include/configs/mx6qarm2.h b/include/configs/mx6qarm2.h index 0962d3c..87ff0a3 100644 --- a/include/configs/mx6qarm2.h +++ b/include/configs/mx6qarm2.h @@ -37,7 +37,6 @@ /* Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2 * 1024 *
1024)
-#define CONFIG_ARCH_CPU_INIT #define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_MXC_GPIO
diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index 93000f0..85e6570 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -37,7 +37,6 @@ /* Size of malloc() pool */ #define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 2 * 1024 * 1024)
-#define CONFIG_ARCH_CPU_INIT #define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_MXC_GPIO

Hi Fabio,
Le Thu, 1 Mar 2012 19:31:45 +0100, Marek Vasut marex@denx.de a écrit :
No need to define CONFIG_ARCH_CPU_INIT.
All mx6 based boards should use arch_cpu_init().
Acked-by: Marek Vasut marex@denx.de
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
Applied (rebased) to u-boot-arm/master, thanks.
Amicalement,

No need to define CONFIG_ARCH_CPU_INIT.
All mx28 based boards should use arch_cpu_init().
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com --- arch/arm/cpu/arm926ejs/mx28/mx28.c | 2 -- include/configs/m28evk.h | 1 - include/configs/mx28evk.h | 1 - 3 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c index b235091..f98e6a3 100644 --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c @@ -135,7 +135,6 @@ int arch_misc_init(void) } #endif
-#ifdef CONFIG_ARCH_CPU_INIT int arch_cpu_init(void) { struct mx28_clkctrl_regs *clkctrl_regs = @@ -164,7 +163,6 @@ int arch_cpu_init(void)
return 0; } -#endif
#if defined(CONFIG_DISPLAY_CPUINFO) int print_cpuinfo(void) diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h index 4d59153..31aaf47 100644 --- a/include/configs/m28evk.h +++ b/include/configs/m28evk.h @@ -40,7 +40,6 @@ #define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF #define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_ARCH_CPU_INIT #define CONFIG_ARCH_MISC_INIT
/* diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h index 04967d7..92903da 100644 --- a/include/configs/mx28evk.h +++ b/include/configs/mx28evk.h @@ -34,7 +34,6 @@ #define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF #define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_ARCH_CPU_INIT #define CONFIG_ARCH_MISC_INIT
/*

No need to define CONFIG_ARCH_CPU_INIT.
All mx28 based boards should use arch_cpu_init().
Acked-by: Marek Vasut marex@denx.de
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
arch/arm/cpu/arm926ejs/mx28/mx28.c | 2 -- include/configs/m28evk.h | 1 - include/configs/mx28evk.h | 1 - 3 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c index b235091..f98e6a3 100644 --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c @@ -135,7 +135,6 @@ int arch_misc_init(void) } #endif
-#ifdef CONFIG_ARCH_CPU_INIT int arch_cpu_init(void) { struct mx28_clkctrl_regs *clkctrl_regs = @@ -164,7 +163,6 @@ int arch_cpu_init(void)
return 0; } -#endif
#if defined(CONFIG_DISPLAY_CPUINFO) int print_cpuinfo(void) diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h index 4d59153..31aaf47 100644 --- a/include/configs/m28evk.h +++ b/include/configs/m28evk.h @@ -40,7 +40,6 @@ #define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF #define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_ARCH_CPU_INIT #define CONFIG_ARCH_MISC_INIT
/* diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h index 04967d7..92903da 100644 --- a/include/configs/mx28evk.h +++ b/include/configs/mx28evk.h @@ -34,7 +34,6 @@ #define CONFIG_SYS_ICACHE_OFF #define CONFIG_SYS_DCACHE_OFF #define CONFIG_BOARD_EARLY_INIT_F -#define CONFIG_ARCH_CPU_INIT #define CONFIG_ARCH_MISC_INIT
/*

Hi Fabio,
On Thu, 1 Mar 2012 19:31:54 +0100, Marek Vasut marex@denx.de wrote:
No need to define CONFIG_ARCH_CPU_INIT.
All mx28 based boards should use arch_cpu_init().
Acked-by: Marek Vasut marex@denx.de
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
Applied to ub-boot-arm/master, thanks.
Amicalement,

Dear Albert ARIBAUD,
Hi Fabio,
On Thu, 1 Mar 2012 19:31:54 +0100, Marek Vasut marex@denx.de wrote:
No need to define CONFIG_ARCH_CPU_INIT.
All mx28 based boards should use arch_cpu_init().
Acked-by: Marek Vasut marex@denx.de
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
Applied to ub-boot-arm/master, thanks.
Did you also apply 1/3 ? If not, everything will be broken now (at least mx28 doesn't boot without 1/3 applied as well).
Amicalement,
Best regards, Marek Vasut

Create a weak-aliased arch_cpu_init, so that we can get rid of CONFIG_ARCH_CPU_INIT and always call arch_cpu_init.
This way we do not need to define CONFIG_ARCH_CPU_INIT in every board file, since arch_cpu_init() is supposed to handle common CPU level code.
Acked-by: Marek Vasut marex@denx.de
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
arch/arm/lib/board.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 500e216..6463db5 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -224,10 +224,16 @@ void __dram_init_banksize(void) void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize")));
+int __arch_cpu_init(void) +{
- return 0;
+} +int arch_cpu_init(void)
- __attribute__((weak, alias("__arch_cpu_init")));
init_fnc_t *init_sequence[] = { -#if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ -#endif
#if defined(CONFIG_BOARD_EARLY_INIT_F) board_early_init_f, #endif

Le 01/03/2012 15:02, Fabio Estevam a écrit :
Create a weak-aliased arch_cpu_init, so that we can get rid of CONFIG_ARCH_CPU_INIT and always call arch_cpu_init.
This way we do not need to define CONFIG_ARCH_CPU_INIT in every board file, since arch_cpu_init() is supposed to handle common CPU level code.
This adds (some) (functionally dead) code to all boards that did not require arch_cpu_init().
Amicalement,

On Thu, Mar 1, 2012 at 5:51 PM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
This adds (some) (functionally dead) code to all boards that did not require arch_cpu_init().
Yes, it adds a "return 0" only. Is this terribly bad?
Isn't it better than having to select CONFIG_ARCH_CPU_INIT for every board to select arch_cpu_init(), which is supposed to be CPU dependent?

Le 01/03/2012 21:57, Fabio Estevam a écrit :
On Thu, Mar 1, 2012 at 5:51 PM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
This adds (some) (functionally dead) code to all boards that did not require arch_cpu_init().
Yes, it adds a "return 0" only. Is this terribly bad?
Well...
Isn't it better than having to select CONFIG_ARCH_CPU_INIT for every board to select arch_cpu_init(), which is supposed to be CPU dependent?
It adds a "#define CONFIG_ARCH_CPU_INTI" only. Is this terribly bad ?
If what bothers you is that some board all repeat something that should be done only once, then it should bother you just as much that many boards repeat something that should not be done at all most of the time.
I understand that you see a repetition of CONFIG_ARCH_CPU_INIT that you suspect is highly redundant. But then, you should cure the repetition, not the existence of CONFIG_ARCH_CPU_INIT.
How about this approach: since the problem is the presence of CPU- (or Soc-)level elements in board-level config files, and since there are probably many other such items in board config files (CPU type in a SoC and HW IP configurations, for instance) then why not introduce some cpu-config and soc-config file which would group all those cpu- (resp soc-)level items, including any "#define CONFIG_ARCH_CPU_INIT", and replace these items in board config files with a single "#include "<cpu>-config.h" (or "<soc>-config.h")? This would significantly reduce board config file size.
One could even choose either of two courses depending on how many or how few boards require CONFIG_ARCH_CPU_INIT: if many boards require it, let the cpu- or soc-common config contain the define, and the few boards which don't will have to explicitly undefine it; if only a few boards need the define, then it won't be done in the cpu- or soc-common config but in each board that requires it.
And CPUs, SoCs and boards that don't need ARCH_CPU_INIT at all won't grow a single useless byte.
Amicalement,

On Thu, Mar 01, 2012 at 10:44:09PM +0100, Albert ARIBAUD wrote:
How about this approach: since the problem is the presence of CPU- (or Soc-)level elements in board-level config files, and since there are probably many other such items in board config files (CPU type in a SoC and HW IP configurations, for instance) then why not introduce some cpu-config and soc-config file which would group all those cpu- (resp soc-)level items, including any "#define CONFIG_ARCH_CPU_INIT", and replace these items in board config files with a single "#include "<cpu>-config.h" (or "<soc>-config.h")? This would significantly reduce board config file size.
Note that omap4/5 do something like this already and my hope is to do this for omap3/similar and make some other common files as well. It's not the top priority for me atm however...

Hi Tom,
Le 05/03/2012 18:56, Tom Rini a écrit :
On Thu, Mar 01, 2012 at 10:44:09PM +0100, Albert ARIBAUD wrote:
How about this approach: since the problem is the presence of CPU- (or Soc-)level elements in board-level config files, and since there are probably many other such items in board config files (CPU type in a SoC and HW IP configurations, for instance) then why not introduce some cpu-config and soc-config file which would group all those cpu- (resp soc-)level items, including any "#define CONFIG_ARCH_CPU_INIT", and replace these items in board config files with a single "#include "<cpu>-config.h" (or "<soc>-config.h")? This would significantly reduce board config file size.
Note that omap4/5 do something like this already and my hope is to do this for omap3/similar and make some other common files as well. It's not the top priority for me atm however...
Ok, so that's one more reason not to go the "everybody call (a possibly weak and empty) arch_cpu_init()" route.
Amicalement,

On 01/03/2012 15:02, Fabio Estevam wrote:
Create a weak-aliased arch_cpu_init, so that we can get rid of CONFIG_ARCH_CPU_INIT and always call arch_cpu_init.
This way we do not need to define CONFIG_ARCH_CPU_INIT in every board file, since arch_cpu_init() is supposed to handle common CPU level code.
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
arch/arm/lib/board.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 500e216..6463db5 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -224,10 +224,16 @@ void __dram_init_banksize(void) void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize")));
+int __arch_cpu_init(void) +{
- return 0;
+} +int arch_cpu_init(void)
- __attribute__((weak, alias("__arch_cpu_init")));
init_fnc_t *init_sequence[] = { -#if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ -#endif
#if defined(CONFIG_BOARD_EARLY_INIT_F) board_early_init_f, #endif
Acked-by: Stefano Babic sbabic@denx.de
Best regards, Stefano Babic

On Thu, Mar 01, 2012 at 11:02:38AM -0300, Fabio Estevam wrote:
Create a weak-aliased arch_cpu_init, so that we can get rid of CONFIG_ARCH_CPU_INIT and always call arch_cpu_init.
This way we do not need to define CONFIG_ARCH_CPU_INIT in every board file, since arch_cpu_init() is supposed to handle common CPU level code.
Signed-off-by: Fabio Estevam fabio.estevam@freescale.com
arch/arm/lib/board.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 500e216..6463db5 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -224,10 +224,16 @@ void __dram_init_banksize(void) void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize")));
+int __arch_cpu_init(void) +{
- return 0;
+} +int arch_cpu_init(void)
- __attribute__((weak, alias("__arch_cpu_init")));
Please add <linux/compiler.h> and use __weak instead.

On Mon, Mar 5, 2012 at 2:52 PM, Tom Rini trini@ti.com wrote:
+int __arch_cpu_init(void) +{
- return 0;
+} +int arch_cpu_init(void)
- __attribute__((weak, alias("__arch_cpu_init")));
Please add <linux/compiler.h> and use __weak instead.
Ok, before I rework this patch I would like to confirm with Albert if I should proceed with this patch series, or if he NACKs this idea.
Regards,
Fabio Estevam

On Mon, Mar 5, 2012 at 2:58 PM, Fabio Estevam festevam@gmail.com wrote:
On Mon, Mar 5, 2012 at 2:52 PM, Tom Rini trini@ti.com wrote:
+int __arch_cpu_init(void) +{
- return 0;
+} +int arch_cpu_init(void)
- __attribute__((weak, alias("__arch_cpu_init")));
Please add <linux/compiler.h> and use __weak instead.
Ok, before I rework this patch I would like to confirm with Albert if I should proceed with this patch series, or if he NACKs this idea.
By "this idea" I mean the removal of CONFIG_ARCH_CPU_INIT.
participants (7)
-
Albert ARIBAUD
-
Fabio Estevam
-
Fabio Estevam
-
Marek Vasut
-
Marek Vasut
-
Stefano Babic
-
Tom Rini