[U-Boot] [PATCH 2/3] arm: add initcalls_init

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- lib_arm/board.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib_arm/board.c b/lib_arm/board.c index e081fbc..f40e227 100644 --- a/lib_arm/board.c +++ b/lib_arm/board.c @@ -42,6 +42,7 @@ #include <command.h> #include <malloc.h> #include <devices.h> +#include <init.h> #include <timestamp.h> #include <version.h> #include <net.h> @@ -284,6 +285,7 @@ init_fnc_t *init_sequence[] = { #if defined(CONFIG_DISPLAY_BOARDINFO) checkboard, /* display board info */ #endif + initcalls_init, #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) init_func_i2c, #endif

apply to at91sam9263ek
this will result to reduce the size of 2212 bytes
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- board/atmel/at91sam9263ek/at91sam9263ek.c | 12 ++++++------ include/netdev.h | 12 ------------ net/eth.c | 16 ---------------- 3 files changed, 6 insertions(+), 34 deletions(-)
diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c index 57d5c95..54b0f59 100644 --- a/board/atmel/at91sam9263ek/at91sam9263ek.c +++ b/board/atmel/at91sam9263ek/at91sam9263ek.c @@ -23,6 +23,7 @@ */
#include <common.h> +#include <init.h> #include <asm/sizes.h> #include <asm/arch/at91sam9263.h> #include <asm/arch/at91sam9263_matrix.h> @@ -272,11 +273,10 @@ void reset_phy(void) } #endif
-int board_eth_init(bd_t *bis) -{ - int rc = 0; #ifdef CONFIG_MACB - rc = macb_eth_initialize(0, (void *)AT91SAM9263_BASE_EMAC, 0x00); -#endif - return rc; +static int at91sam9263ek_eth_init(bd_t *bis) +{ + return macb_eth_initialize(0, (void *)AT91SAM9263_BASE_EMAC, 0x00); } +__initcall(at91sam9263ek_eth_init); +#endif diff --git a/include/netdev.h b/include/netdev.h index 63cf730..9860c99 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -28,18 +28,6 @@ #ifndef _NETDEV_H_ #define _NETDEV_H_
-/* - * Board and CPU-specific initialization functions - * board_eth_init() has highest priority. cpu_eth_init() only - * gets called if board_eth_init() isn't instantiated or fails. - * Return values: - * 0: success - * -1: failure - */ - -int board_eth_init(bd_t *bis); -int cpu_eth_init(bd_t *bis); - /* Driver initialization prototypes */ int au1x00_enet_initialize(bd_t*); int bfin_EMAC_initialize(bd_t *bis); diff --git a/net/eth.c b/net/eth.c index 8940ebf..2904180 100644 --- a/net/eth.c +++ b/net/eth.c @@ -56,18 +56,6 @@ int eth_setenv_enetaddr(char *name, const uchar *enetaddr) #endif
#if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI) - -/* - * CPU and board-specific Ethernet initializations. Aliased function - * signals caller to move on - */ -static int __def_eth_init(bd_t *bis) -{ - return -1; -} -int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init"))); -int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init"))); - extern int mv6436x_eth_initialize(bd_t *); extern int mv6446x_eth_initialize(bd_t *);
@@ -191,10 +179,6 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) miiphy_init(); #endif - /* Try board-specific initialization first. If it fails or isn't - * present, try the cpu-specific initialization */ - if (board_eth_init(bis) < 0) - cpu_eth_init(bis);
#if defined(CONFIG_DB64360) || defined(CONFIG_CPCI750) mv6436x_eth_initialize(bis);

Jean-Christophe,
On Sat, May 23, 2009 at 8:08 AM, Jean-Christophe PLAGNIOL-VILLARD < plagnioj@jcrosoft.com> wrote:
apply to at91sam9263ek
this will result to reduce the size of 2212 bytes
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
board/atmel/at91sam9263ek/at91sam9263ek.c | 12 ++++++------ include/netdev.h | 12 ------------ net/eth.c | 16 ---------------- 3 files changed, 6 insertions(+), 34 deletions(-)
<snip>
/* Try board-specific initialization first. If it fails or isn't
* present, try the cpu-specific initialization */
if (board_eth_init(bis) < 0)
cpu_eth_init(bis);
Good idea, but your implementation is flawed. It's critically important that the prioritization of board ethernet initialization over CPU ethernet initialization be preserved. Your idea doesn't handle that (at least that I can see).
regards, Ben

On 08:41 Sat 23 May , Ben Warren wrote:
Jean-Christophe,
On Sat, May 23, 2009 at 8:08 AM, Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com wrote:
apply to at91sam9263ek this will result to reduce the size of 2212 bytes Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> --- board/atmel/at91sam9263ek/at91sam9263ek.c | 12 ++++++------ include/netdev.h | 12 ------------ net/eth.c | 16 ---------------- 3 files changed, 6 insertions(+), 34 deletions(-)
<snip>
- /* Try board-specific initialization first. If it fails or isn't - * present, try the cpu-specific initialization */ - if (board_eth_init(bis) < 0) - cpu_eth_init(bis);
Good idea, but your implementation is flawed. It's critically important that the prioritization of board ethernet initialization over CPU ethernet initialization be preserved. Your idea doesn't handle that (at least that I can see).
with this only patch yes, but I'm preparing a full implementation that will If I understand correctly the board_eth_init is unsed to overwrite the default cpu_eth_init by passing different parameter
with a device/driver model this will be handle correctly
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090523163600.GD26561@game.jcrosoft.org you wrote:
Good idea, but your implementation is flawed. It's critically important that the prioritization of board ethernet initialization over CPU ethernet initialization be preserved. Your idea doesn't handle that (at least that I can see).
with this only patch yes, but I'm preparing a full implementation that will If I understand correctly the board_eth_init is unsed to overwrite the default cpu_eth_init by passing different parameter
I would appreciate if you would - before spending time and effort on actual implementation - try and discuss your ideas for such a far-reaching change. So far, I cannot even see which sort of benefit you expect - keep in mind that U-Boot does not use virtual memory, so initcall memory freed will remain dead and unusable. Would you please explain where you expect advantages from such an implementation?
Best regards,
Wolfgang Denk

On Sat, May 23, 2009 at 9:36 AM, Jean-Christophe PLAGNIOL-VILLARD < plagnioj@jcrosoft.com> wrote:
On 08:41 Sat 23 May , Ben Warren wrote:
Jean-Christophe,
On Sat, May 23, 2009 at 8:08 AM, Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com wrote:
apply to at91sam9263ek this will result to reduce the size of 2212 bytes Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <
plagnioj@jcrosoft.com>
--- board/atmel/at91sam9263ek/at91sam9263ek.c | 12 ++++++------ include/netdev.h | 12 ------------ net/eth.c | 16 ---------------- 3 files changed, 6 insertions(+), 34 deletions(-)
<snip>
- /* Try board-specific initialization first. If it fails or isn't - * present, try the cpu-specific initialization */ - if (board_eth_init(bis) < 0) - cpu_eth_init(bis);
Good idea, but your implementation is flawed. It's critically
important
that the prioritization of board ethernet initialization over CPU
ethernet
initialization be preserved. Your idea doesn't handle that (at least
that
I can see).
with this only patch yes, but I'm preparing a full implementation that will If I understand correctly the board_eth_init is unsed to overwrite the default cpu_eth_init by passing different parameter
with a device/driver model this will be handle correctly
I'm not really sure why you used this one as an example, then, since it doesn't provide any obvious benefit. As far as I can tell, the only benefit of using the Linux-style grouping of initialization calls is to control flow during boot-up, and U-boot already handles this pretty well IMHO. I think in U-boot it will only make the code harder to read and understand. I'd be interested in seeing a different example, though.
regards, Ben
participants (3)
-
Ben Warren
-
Jean-Christophe PLAGNIOL-VILLARD
-
Wolfgang Denk