[U-Boot] [PATCH] net: Move initialization of Au1x00 SoC ethernet MAC to cpu_eth_init

From: Shinya Kuribayashi skuribay@ruby.dti.ne.jp
This patch will move au1x00_eth_initialize from net/eth.c to cpu_eth_init as a part of ongoing eth_initialize cleanup work. The function ret value is also fixed as it should be negative on fail.
Signed-off-by: Shinya Kuribayashi skuribay@ruby.dti.ne.jp Signed-off-by: Ben Warren biggerbadderben@gmail.com --- cpu/mips/au1x00_eth.c | 2 +- cpu/mips/cpu.c | 9 +++++++++ include/netdev.h | 1 + net/eth.c | 4 ---- 4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/cpu/mips/au1x00_eth.c b/cpu/mips/au1x00_eth.c index 8ddc06a..6272a3a 100644 --- a/cpu/mips/au1x00_eth.c +++ b/cpu/mips/au1x00_eth.c @@ -283,7 +283,7 @@ int au1x00_enet_initialize(bd_t *bis){
if ((dev = (struct eth_device*)malloc(sizeof *dev)) == NULL) { puts ("malloc failed\n"); - return 0; + return -1; }
memset(dev, 0, sizeof *dev); diff --git a/cpu/mips/cpu.c b/cpu/mips/cpu.c index 38d8697..b7180b0 100644 --- a/cpu/mips/cpu.c +++ b/cpu/mips/cpu.c @@ -23,6 +23,7 @@
#include <common.h> #include <command.h> +#include <netdev.h> #include <asm/mipsregs.h> #include <asm/cacheops.h> #include <asm/reboot.h> @@ -73,3 +74,11 @@ void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0, u32 low1) write_c0_index(index); tlb_write_indexed(); } + +int cpu_eth_init(bd_t *bis) +{ +#ifdef CONFIG_SOC_AU1X00 + au1x00_enet_initialize(bis); +#endif + return 0; +} diff --git a/include/netdev.h b/include/netdev.h index 3739980..31115e2 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -41,6 +41,7 @@ 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); int dc21x4x_initialize(bd_t *bis); int e1000_initialize(bd_t *bis); diff --git a/net/eth.c b/net/eth.c index cad8fe3..72fed69 100644 --- a/net/eth.c +++ b/net/eth.c @@ -39,7 +39,6 @@ static int __def_eth_init(bd_t *bis) 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 au1x00_enet_initialize(bd_t*); extern int fec_initialize(bd_t*); extern int mpc8220_fec_initialize(bd_t*); extern int mv6436x_eth_initialize(bd_t *); @@ -189,9 +188,6 @@ int eth_initialize(bd_t *bis) #if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC) fec_initialize(bis); #endif -#if defined(CONFIG_AU1X00) - au1x00_enet_initialize(bis); -#endif if (!eth_devices) { puts ("No ethernet found.\n"); show_boot_progress (-64);

This is no longer used by any boards, the last one was removed in commit 6de5bf24004c8d9c9b070bb8f7418d1c45e5eb27.
Signed-off-by: Ben Warren biggerbadderben@gmail.com --- cpu/mpc85xx/cpu.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cpu/mpc85xx/cpu.c b/cpu/mpc85xx/cpu.c index b8f9125..0918fc6 100644 --- a/cpu/mpc85xx/cpu.c +++ b/cpu/mpc85xx/cpu.c @@ -379,7 +379,7 @@ void upmconfig (uint upm, uint * table, uint size) */ int cpu_eth_init(bd_t *bis) { -#if defined(CONFIG_TSEC_ENET) || defined(CONFIG_MPC85xx_FEC) +#if defined(CONFIG_TSEC_ENET) tsec_standard_init(bis); #endif

Affected boards: Several MPC8xx boards Several MPC8260/MPC8272 boards Several MPC85xx boards
Removed initialization of the driver from net/eth.c
Signed-off-by: Ben Warren biggerbadderben@gmail.com --- cpu/mpc8260/cpu.c | 13 +++++++++++++ cpu/mpc85xx/cpu.c | 5 ++++- cpu/mpc8xx/cpu.c | 13 +++++++++++++ include/netdev.h | 1 + net/eth.c | 5 ----- 5 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c index 9f834d3..b9e748a 100644 --- a/cpu/mpc8260/cpu.c +++ b/cpu/mpc8260/cpu.c @@ -44,6 +44,7 @@ #include <watchdog.h> #include <command.h> #include <mpc8260.h> +#include <netdev.h> #include <asm/processor.h> #include <asm/cpm_8260.h>
@@ -315,3 +316,15 @@ void ft_cpu_setup (void *blob, bd_t *bd) do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1); } #endif /* CONFIG_OF_LIBFDT */ + +/* + * Initializes on-chip ethernet controllers. + * to override, implement board_eth_init() + */ +int cpu_eth_init(bd_t *bis) +{ +#if defined(CONFIG_ETHER_ON_FCC) + fec_initialize(bis); +#endif + return 0; +} diff --git a/cpu/mpc85xx/cpu.c b/cpu/mpc85xx/cpu.c index 0918fc6..d9e099c 100644 --- a/cpu/mpc85xx/cpu.c +++ b/cpu/mpc85xx/cpu.c @@ -30,6 +30,7 @@ #include <watchdog.h> #include <command.h> #include <tsec.h> +#include <netdev.h> #include <asm/cache.h> #include <asm/io.h>
@@ -379,9 +380,11 @@ void upmconfig (uint upm, uint * table, uint size) */ int cpu_eth_init(bd_t *bis) { +#if defined(CONFIG_ETHER_ON_FCC) + fec_initialize(bis); +#endif #if defined(CONFIG_TSEC_ENET) tsec_standard_init(bis); #endif - return 0; } diff --git a/cpu/mpc8xx/cpu.c b/cpu/mpc8xx/cpu.c index 420eaed..de3d679 100644 --- a/cpu/mpc8xx/cpu.c +++ b/cpu/mpc8xx/cpu.c @@ -37,6 +37,7 @@ #include <watchdog.h> #include <command.h> #include <mpc8xx.h> +#include <netdev.h> #include <asm/cache.h>
#if defined(CONFIG_OF_LIBFDT) @@ -635,3 +636,15 @@ void reset_8xx_watchdog (volatile immap_t * immr) # endif /* CONFIG_LWMON */ } #endif /* CONFIG_WATCHDOG */ + +/* + * Initializes on-chip ethernet controllers. + * to override, implement board_eth_init() + */ +int cpu_eth_init(bd_t *bis) +{ +#if defined(FEC_ENET) + fec_initialize(bis); +#endif + return 0; +} diff --git a/include/netdev.h b/include/netdev.h index 31115e2..0d1b0d5 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -47,6 +47,7 @@ int dc21x4x_initialize(bd_t *bis); int e1000_initialize(bd_t *bis); int eepro100_initialize(bd_t *bis); int eth_3com_initialize (bd_t * bis); +int fec_initialize (bd_t *bis); int greth_initialize(bd_t *bis); void gt6426x_eth_initialize(bd_t *bis); int inca_switch_initialize(bd_t *bis); diff --git a/net/eth.c b/net/eth.c index 72fed69..6cf53f4 100644 --- a/net/eth.c +++ b/net/eth.c @@ -39,7 +39,6 @@ static int __def_eth_init(bd_t *bis) 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 fec_initialize(bd_t*); extern int mpc8220_fec_initialize(bd_t*); extern int mv6436x_eth_initialize(bd_t *); extern int mv6446x_eth_initialize(bd_t *); @@ -184,10 +183,6 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_UEC_ETH6) uec_initialize(5); #endif - -#if defined(FEC_ENET) || defined(CONFIG_ETHER_ON_FCC) - fec_initialize(bis); -#endif if (!eth_devices) { puts ("No ethernet found.\n"); show_boot_progress (-64);

Removed initialization of the driver from net/eth.c
Signed-off-by: Ben Warren biggerbadderben@gmail.com --- cpu/mpc83xx/cpu.c | 20 +++++++++++++++++++- cpu/mpc85xx/cpu.c | 18 ++++++++++++++++++ include/netdev.h | 1 + net/eth.c | 19 ------------------- 4 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/cpu/mpc83xx/cpu.c b/cpu/mpc83xx/cpu.c index aa9b18d..ebcc790 100644 --- a/cpu/mpc83xx/cpu.c +++ b/cpu/mpc83xx/cpu.c @@ -33,6 +33,7 @@ #include <asm/processor.h> #include <libfdt.h> #include <tsec.h> +#include <netdev.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -361,9 +362,26 @@ int dma_xfer(void *dest, u32 count, void *src) */ int cpu_eth_init(bd_t *bis) { +#if defined(CONFIG_UEC_ETH1) + uec_initialize(0); +#endif +#if defined(CONFIG_UEC_ETH2) + uec_initialize(1); +#endif +#if defined(CONFIG_UEC_ETH3) + uec_initialize(2); +#endif +#if defined(CONFIG_UEC_ETH4) + uec_initialize(3); +#endif +#if defined(CONFIG_UEC_ETH5) + uec_initialize(4); +#endif +#if defined(CONFIG_UEC_ETH6) + uec_initialize(5); +#endif #if defined(CONFIG_TSEC_ENET) tsec_standard_init(bis); #endif - return 0; } diff --git a/cpu/mpc85xx/cpu.c b/cpu/mpc85xx/cpu.c index d9e099c..02ac67d 100644 --- a/cpu/mpc85xx/cpu.c +++ b/cpu/mpc85xx/cpu.c @@ -383,6 +383,24 @@ int cpu_eth_init(bd_t *bis) #if defined(CONFIG_ETHER_ON_FCC) fec_initialize(bis); #endif +#if defined(CONFIG_UEC_ETH1) + uec_initialize(0); +#endif +#if defined(CONFIG_UEC_ETH2) + uec_initialize(1); +#endif +#if defined(CONFIG_UEC_ETH3) + uec_initialize(2); +#endif +#if defined(CONFIG_UEC_ETH4) + uec_initialize(3); +#endif +#if defined(CONFIG_UEC_ETH5) + uec_initialize(4); +#endif +#if defined(CONFIG_UEC_ETH6) + uec_initialize(5); +#endif #if defined(CONFIG_TSEC_ENET) tsec_standard_init(bis); #endif diff --git a/include/netdev.h b/include/netdev.h index 0d1b0d5..3b11961 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -65,6 +65,7 @@ int rtl8139_initialize(bd_t *bis); int rtl8169_initialize(bd_t *bis); int skge_initialize(bd_t *bis); int tsi108_eth_initialize(bd_t *bis); +int uec_initialize(int index); int uli526x_initialize(bd_t *bis);
/* Boards with PCI network controllers can call this from their board_eth_init() diff --git a/net/eth.c b/net/eth.c index 6cf53f4..3793dd7 100644 --- a/net/eth.c +++ b/net/eth.c @@ -44,7 +44,6 @@ extern int mv6436x_eth_initialize(bd_t *); extern int mv6446x_eth_initialize(bd_t *); extern int ppc_4xx_eth_initialize(bd_t *); extern int scc_initialize(bd_t*); -extern int uec_initialize(int);
#ifdef CONFIG_API extern void (*push_packet)(volatile void *, int); @@ -165,24 +164,6 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_MPC8220_FEC) mpc8220_fec_initialize(bis); #endif -#if defined(CONFIG_UEC_ETH1) - uec_initialize(0); -#endif -#if defined(CONFIG_UEC_ETH2) - uec_initialize(1); -#endif -#if defined(CONFIG_UEC_ETH3) - uec_initialize(2); -#endif -#if defined(CONFIG_UEC_ETH4) - uec_initialize(3); -#endif -#if defined(CONFIG_UEC_ETH5) - uec_initialize(4); -#endif -#if defined(CONFIG_UEC_ETH6) - uec_initialize(5); -#endif if (!eth_devices) { puts ("No ethernet found.\n"); show_boot_progress (-64);

Removed initialization of the driver from net/eth.c
Signed-off-by: Ben Warren biggerbadderben@gmail.com --- board/sorcery/sorcery.c | 2 ++ cpu/mpc8220/cpu.c | 13 +++++++++++++ include/netdev.h | 1 + net/eth.c | 4 ---- 4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/board/sorcery/sorcery.c b/board/sorcery/sorcery.c index 3e1bd6f..90d4298 100644 --- a/board/sorcery/sorcery.c +++ b/board/sorcery/sorcery.c @@ -62,5 +62,7 @@ void pci_init_board (void)
int board_eth_init(bd_t *bis) { + /* Initialize built-in FEC first */ + cpu_eth_init(bis); return pci_eth_init(bis); } diff --git a/cpu/mpc8220/cpu.c b/cpu/mpc8220/cpu.c index 5b3fdd3..563cfe0 100644 --- a/cpu/mpc8220/cpu.c +++ b/cpu/mpc8220/cpu.c @@ -29,6 +29,7 @@ #include <watchdog.h> #include <command.h> #include <mpc8220.h> +#include <netdev.h> #include <asm/processor.h>
DECLARE_GLOBAL_DATA_PTR; @@ -89,3 +90,15 @@ unsigned long get_tbclk (void) }
/* ------------------------------------------------------------------------- */ + +/* + * Initializes on-chip ethernet controllers. + * to override, implement board_eth_init() + */ +int cpu_eth_init(bd_t *bis) +{ +#if defined(CONFIG_MPC8220_FEC) + mpc8220_fec_initialize(bis); +#endif + return 0; +} diff --git a/include/netdev.h b/include/netdev.h index 3b11961..55183e8 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -56,6 +56,7 @@ int mcdmafec_initialize(bd_t *bis); int mcffec_initialize(bd_t *bis); int mpc512x_fec_initialize(bd_t *bis); int mpc5xxx_fec_initialize(bd_t *bis); +int mpc8220_fec_initialize(bd_t *bis); int natsemi_initialize(bd_t *bis); int npe_initialize(bd_t *bis); int ns8382x_initialize(bd_t *bis); diff --git a/net/eth.c b/net/eth.c index 3793dd7..d543163 100644 --- a/net/eth.c +++ b/net/eth.c @@ -39,7 +39,6 @@ static int __def_eth_init(bd_t *bis) 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 mpc8220_fec_initialize(bd_t*); extern int mv6436x_eth_initialize(bd_t *); extern int mv6446x_eth_initialize(bd_t *); extern int ppc_4xx_eth_initialize(bd_t *); @@ -161,9 +160,6 @@ int eth_initialize(bd_t *bis) #ifdef SCC_ENET scc_initialize(bis); #endif -#if defined(CONFIG_MPC8220_FEC) - mpc8220_fec_initialize(bis); -#endif if (!eth_devices) { puts ("No ethernet found.\n"); show_boot_progress (-64);

Removed initialization of the driver from net/eth.c
Signed-off-by: Ben Warren biggerbadderben@gmail.com --- cpu/mpc8xx/cpu.c | 4 ++++ include/netdev.h | 1 + net/eth.c | 4 ---- 3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/cpu/mpc8xx/cpu.c b/cpu/mpc8xx/cpu.c index de3d679..40f81ef 100644 --- a/cpu/mpc8xx/cpu.c +++ b/cpu/mpc8xx/cpu.c @@ -37,6 +37,7 @@ #include <watchdog.h> #include <command.h> #include <mpc8xx.h> +#include <commproc.h> #include <netdev.h> #include <asm/cache.h>
@@ -643,6 +644,9 @@ void reset_8xx_watchdog (volatile immap_t * immr) */ int cpu_eth_init(bd_t *bis) { +#if defined(SCC_ENET) + scc_initialize(bis); +#endif #if defined(FEC_ENET) fec_initialize(bis); #endif diff --git a/include/netdev.h b/include/netdev.h index 55183e8..45e59b6 100644 --- a/include/netdev.h +++ b/include/netdev.h @@ -64,6 +64,7 @@ int pcnet_initialize(bd_t *bis); int plb2800_eth_initialize(bd_t *bis); int rtl8139_initialize(bd_t *bis); int rtl8169_initialize(bd_t *bis); +int scc_initialize(bd_t *bis); int skge_initialize(bd_t *bis); int tsi108_eth_initialize(bd_t *bis); int uec_initialize(int index); diff --git a/net/eth.c b/net/eth.c index d543163..0b954ed 100644 --- a/net/eth.c +++ b/net/eth.c @@ -42,7 +42,6 @@ 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 *); extern int ppc_4xx_eth_initialize(bd_t *); -extern int scc_initialize(bd_t*);
#ifdef CONFIG_API extern void (*push_packet)(volatile void *, int); @@ -157,9 +156,6 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_4xx) && !defined(CONFIG_IOP480) && !defined(CONFIG_AP1000) ppc_4xx_eth_initialize(bis); #endif -#ifdef SCC_ENET - scc_initialize(bis); -#endif if (!eth_devices) { puts ("No ethernet found.\n"); show_boot_progress (-64);

On Thu, Oct 30, 2008 at 12:53 AM, Ben Warren biggerbadderben@gmail.com wrote:
This is no longer used by any boards, the last one was removed in commit 6de5bf24004c8d9c9b070bb8f7418d1c45e5eb27.
Signed-off-by: Ben Warren biggerbadderben@gmail.com
Um....8540ADS uses it. And the 8572 has one, even though we don't have any boards which expose it at this time. Unless I've missed something. If you look at drivers/net/tsec.c, you'll see it's used in the standard tsec init array.
Andy

On Thu, Oct 30, 2008 at 3:30 PM, Andy Fleming afleming@gmail.com wrote:
On Thu, Oct 30, 2008 at 12:53 AM, Ben Warren biggerbadderben@gmail.com wrote:
This is no longer used by any boards, the last one was removed in commit 6de5bf24004c8d9c9b070bb8f7418d1c45e5eb27.
Signed-off-by: Ben Warren biggerbadderben@gmail.com
As a follow-up, it should be noted that the FEC on the 85xx is different from the FEC on older chips. The older FEC is a variant of the FCC. The 85xx FEC is just a tsec without gigabit (and lacking a few other accompanying features that don't affect u-boot).
This has caused frequent confusion.

Andy Fleming wrote:
On Thu, Oct 30, 2008 at 12:53 AM, Ben Warren biggerbadderben@gmail.com wrote:
This is no longer used by any boards, the last one was removed in commit 6de5bf24004c8d9c9b070bb8f7418d1c45e5eb27.
Signed-off-by: Ben Warren biggerbadderben@gmail.com
Um....8540ADS uses it. And the 8572 has one, even though we don't have any boards which expose it at this time. Unless I've missed something. If you look at drivers/net/tsec.c, you'll see it's used in the standard tsec init array.
Andy
I see... check this out:
bwarren@bwarren-linux:~/src/u-boot$ grep -R MPC85xx_FEC * cpu/mpc85xx/cpu.c:#if defined(CONFIG_TSEC_ENET) || defined(CONFIG_MPC85xx_FEC)
bwarren@bwarren-linux:~/src/u-boot$ grep -R MPC85XX_FEC * drivers/net/tsec.c:#ifdef CONFIG_MPC85XX_FEC drivers/net/tsec.c: .devname = CONFIG_MPC85XX_FEC_NAME, include/configs/MPC8540EVAL.h:#define CONFIG_MPC85XX_FEC 1 include/configs/MPC8540EVAL.h:#define CONFIG_MPC85XX_FEC_NAME "FE C" include/configs/sbc8548.h:#undef CONFIG_MPC85XX_FEC include/configs/ATUM8548.h:#undef CONFIG_MPC85XX_FEC include/configs/PM854.h:#define CONFIG_MPC85XX_FEC 1 include/configs/PM854.h:#define CONFIG_MPC85XX_FEC_NAME "FEC" include/configs/MPC8540ADS.h:#define CONFIG_MPC85XX_FEC 1 include/configs/MPC8540ADS.h:#define CONFIG_MPC85XX_FEC_NAME "FEC" include/configs/TQM85xx.h:#define CONFIG_MPC85XX_FEC 1 include/configs/TQM85xx.h:#define CONFIG_MPC85XX_FEC_NAME "FEC" include/configs/MPC8548CDS.h:#undef CONFIG_MPC85XX_FEC include/configs/socrates.h:#undef CONFIG_MPC85XX_FEC
participants (2)
-
Andy Fleming
-
Ben Warren