Add mechanisms for CPU and board-specific Ethernet initialization
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
This patch is the first step in cleaning up net/eth.c, by moving Ethernet initialization to CPU or board-specific code. Initial implementation is only on the Freescale TSEC controller, but others will be added soon.
---
When we discussed this a few months ago, I was planning on defining the cpu_eth_init() and board_eth_init() functions as weak with no aliases, but in my testing this did not result in them being NULL, hence the default function.
board/atum8548/atum8548.c | 18 +++++++++++++++ board/freescale/mpc8313erdb/mpc8313erdb.c | 12 ++++++++++ board/freescale/mpc8315erdb/mpc8315erdb.c | 12 ++++++++++ board/freescale/mpc8349emds/mpc8349emds.c | 12 ++++++++++ board/freescale/mpc8349itx/mpc8349itx.c | 12 ++++++++++ board/freescale/mpc837xemds/mpc837xemds.c | 12 ++++++++++ board/freescale/mpc837xerdb/mpc837xerdb.c | 13 +++++++++++ board/freescale/mpc8540ads/mpc8540ads.c | 22 ++++++++++++++++++ board/freescale/mpc8541cds/mpc8541cds.c | 12 ++++++++++ board/freescale/mpc8544ds/mpc8544ds.c | 18 +++++++++++++++ board/freescale/mpc8548cds/mpc8548cds.c | 18 +++++++++++++++ board/freescale/mpc8555cds/mpc8555cds.c | 12 ++++++++++ board/freescale/mpc8560ads/mpc8560ads.c | 12 ++++++++++ board/freescale/mpc8568mds/mpc8568mds.c | 12 ++++++++++ board/freescale/mpc8641hpcn/mpc8641hpcn.c | 18 +++++++++++++++ board/mpc8540eval/mpc8540eval.c | 22 ++++++++++++++++++ board/pm854/pm854.c | 22 ++++++++++++++++++ board/pm856/pm856.c | 12 ++++++++++ board/sbc8349/sbc8349.c | 12 ++++++++++ board/sbc8548/sbc8548.c | 18 +++++++++++++++ board/sbc8560/sbc8560.c | 9 +++++++ board/sbc8641d/sbc8641d.c | 18 +++++++++++++++ board/stxgp3/stxgp3.c | 12 ++++++++++ board/stxssa/stxssa.c | 12 ++++++++++ board/tqm834x/tqm834x.c | 12 ++++++++++ board/tqm85xx/tqm85xx.c | 22 ++++++++++++++++++ include/netdev.h | 34 +++++++++++++++++++++++++++++ net/eth.c | 26 ++++++++------------- 28 files changed, 430 insertions(+), 16 deletions(-) create mode 100644 include/netdev.h
board/atum8548/atum8548.c +18 -0
@@ -34,6 +34,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC ) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -417,3 +418,20 @@ ft_board_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8313erdb/mpc8313erdb.c +12 -0
@@ -29,6 +29,7 @@#include <pci.h> #include <mpc83xx.h> #include <vsc7385.h> +#include <netdev.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -128,3 +129,14 @@ void ft_board_setup(void *blob, bd_t *bd) #endif }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8315erdb/mpc8315erdb.c +12 -0
@@ -30,6 +30,7 @@#endif #include <pci.h> #include <mpc83xx.h> +#include <netdev.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -130,3 +131,14 @@ void ft_board_setup(void *blob, bd_t *bd) #endif }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8349emds/mpc8349emds.c +12 -0
@@ -30,6 +30,7 @@#include <spi.h> #include <miiphy.h> #include <spd_sdram.h> +#include <netdev.h> #if defined(CONFIG_OF_LIBFDT )#include <libfdt.h>
@@ -287,3 +288,14 @@ void ft_board_setup(void *blob, bd_t *bd) #endif }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8349itx/mpc8349itx.c +12 -0
@@ -25,6 +25,7 @@#include <mpc83xx.h> #include <i2c.h> #include <miiphy.h> +#include <netdev.h> #include <vsc7385.h> #ifdef CONFIG_PCI #include <asm/mpc8349_pci.h>
@@ -400,3 +401,14 @@ void ft_board_setup(void *blob, bd_t *bd) #endif }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc837xemds/mpc837xemds.c +12 -0
@@ -15,6 +15,7 @@#include <asm/io.h> #include <asm/fsl_serdes.h> #include <spd_sdram.h> +#include <netdev.h> #if defined(CONFIG_OF_LIBFDT )#include <libfdt.h> #endif
@@ -157,3 +158,14 @@ void ft_board_setup(void *blob, bd_t *bd) #endif }#endif /* CONFIG_OF_BOARD_SETUP */ + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc837xerdb/mpc837xerdb.c +13 -0
@@ -18,6 +18,7 @@#include <asm/fsl_serdes.h> #include <fdt_support.h> #include <spd_sdram.h> +#include <netdev.h> #include <vsc7385.h> #if defined(CFG_DRAM_TEST )
@@ -197,3 +198,15 @@ void ft_board_setup(void *blob, bd_t *bd) fdt_fixup_dr_usb(blob, bd); }#endif /* CONFIG_OF_BOARD_SETUP */ + + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8540ads/mpc8540ads.c +22 -0
@@ -32,6 +32,7 @@#include <spd_sdram.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC ) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -343,3 +344,24 @@ ft_board_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_MPC85XX_FEC ) +tsec_initialize (bis,2 ,CONFIG_MPC85XX_FEC_NAME ); +#else +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +#endif +return 0 ; +}
board/freescale/mpc8541cds/mpc8541cds.c +12 -0
@@ -30,6 +30,7 @@#include <spd_sdram.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #include "../common/cadmus.h" #include "../common/eeprom.h"
@@ -530,3 +531,14 @@ ft_pci_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8544ds/mpc8544ds.c +18 -0
@@ -31,6 +31,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #include "../common/pixis.h"
@@ -545,3 +546,20 @@ ft_board_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8548cds/mpc8548cds.c +18 -0
@@ -31,6 +31,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #include "../common/cadmus.h" #include "../common/eeprom.h"
@@ -548,3 +549,20 @@ ft_pci_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8555cds/mpc8555cds.c +12 -0
@@ -28,6 +28,7 @@#include <spd_sdram.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #include "../common/cadmus.h" #include "../common/eeprom.h"
@@ -530,3 +531,14 @@ ft_pci_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8560ads/mpc8560ads.c +12 -0
@@ -34,6 +34,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC ) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -562,3 +563,14 @@ ft_board_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8568mds/mpc8568mds.c +12 -0
@@ -32,6 +32,7 @@#include <ioports.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #include "bcsr.h"
@@ -561,3 +562,14 @@ ft_board_setup(void *blob, bd_t *bd) } }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/freescale/mpc8641hpcn/mpc8641hpcn.c +18 -0
@@ -29,6 +29,7 @@#include <asm/io.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #include "../common/pixis.h"
@@ -415,3 +416,20 @@ get_board_sys_clk(ulong dummy)return val; } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +return 0 ; +}
board/mpc8540eval/mpc8540eval.c +22 -0
@@ -27,6 +27,7 @@#include <asm/processor.h> #include <asm/immap_85xx.h> #include <spd_sdram.h> +#include <netdev.h> long int fixed_sdram (void );
@@ -243,3 +244,24 @@ long int fixed_sdram (void) return (CFG_SDRAM_SIZE * 1024 * 1024); }#endif /* !defined(CONFIG_SPD_EEPROM) */ + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_MPC85XX_FEC ) +tsec_initialize (bis,2 ,CONFIG_MPC85XX_FEC_NAME ); +#else +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +#endif +return 0 ; +}
board/pm854/pm854.c +22 -0
@@ -30,6 +30,7 @@#include <asm/processor.h> #include <asm/immap_85xx.h> #include <spd_sdram.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -285,3 +286,24 @@ pci_init_board(void)pci_mpc85xx_init (&hose);#endif /* CONFIG_PCI */ } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_MPC85XX_FEC ) +tsec_initialize (bis,2 ,CONFIG_MPC85XX_FEC_NAME ); +#else +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +#endif +return 0 ; +}
board/pm856/pm856.c +12 -0
@@ -32,6 +32,7 @@#include <ioports.h> #include <spd_sdram.h> #include <miiphy.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -440,3 +441,14 @@ pci_init_board(void)pci_mpc85xx_init (&hose);#endif /* CONFIG_PCI */ } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/sbc8349/sbc8349.c +12 -0
@@ -32,6 +32,7 @@#include <i2c.h> #include <spd_sdram.h> #include <miiphy.h> +#include <netdev.h> #if defined(CONFIG_OF_LIBFDT )#include <libfdt.h> #endif
@@ -240,3 +241,14 @@ void ft_board_setup(void *blob, bd_t *bd) #endif }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/sbc8548/sbc8548.c +18 -0
@@ -34,6 +34,7 @@#include <miiphy.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC ) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -566,3 +567,20 @@ ft_board_setup(void *blob, bd_t *bd) #endif }#endif + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +return 0 ; +}
board/sbc8560/sbc8560.c +9 -0
@@ -33,6 +33,7 @@#include <ioports.h> #include <spd_sdram.h> #include <miiphy.h> +#include <netdev.h> long int fixed_sdram (void );
@@ -452,3 +453,11 @@ long int fixed_sdram (void) return CFG_SDRAM_SIZE * 1024 * 1024; }#endif /* !defined(CONFIG_SPD_EEPROM) */ + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +return 0 ; +}
board/sbc8641d/sbc8641d.c +18 -0
@@ -37,6 +37,7 @@#include <spd_sdram.h> #include <libfdt.h> #include <fdt_support.h> +#include <netdev.h> #if defined(CONFIG_DDR_ECC ) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER )extern void ddr_enable_ecc (unsigned int dram_size);
@@ -415,3 +416,20 @@ unsigned long get_board_sys_clk (ulong dummy)return val; } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +return 0 ; +}
board/stxgp3/stxgp3.c +12 -0
@@ -37,6 +37,7 @@#include <asm/io.h> #include <spd_sdram.h> #include <miiphy.h> +#include <netdev.h> long int fixed_sdram (void );
@@ -373,3 +374,14 @@ pci_init_board(void)pci_mpc85xx_init (&hose);#endif /* CONFIG_PCI */ } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/stxssa/stxssa.c +12 -0
@@ -37,6 +37,7 @@#include <asm/io.h> #include <spd_sdram.h> #include <miiphy.h> +#include <netdev.h> long int fixed_sdram (void );
@@ -396,3 +397,14 @@ pci_init_board(void)pci_mpc85xx_init (hose);#endif /* CONFIG_PCI */ } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/tqm834x/tqm834x.c +12 -0
@@ -30,6 +30,7 @@#include <miiphy.h> #include <asm-ppc/mmu.h> #include <pci.h> +#include <netdev.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -431,3 +432,14 @@ static void set_ddr_config(void) {#endif } } + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +return 0 ; +}
board/tqm85xx/tqm85xx.c +22 -0
@@ -33,6 +33,7 @@#include <asm/immap_85xx.h> #include <ioports.h> #include <flash.h> +#include <netdev.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -417,3 +418,24 @@ int board_early_init_r (void) return (0); }#endif /* CONFIG_BOARD_EARLY_INIT_R */ + +int board_eth_init (bd_t *bis) +{ +#if defined(CONFIG_TSEC1 ) +tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); +#endif +#if defined(CONFIG_TSEC2 ) +tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); +#endif +#if defined(CONFIG_MPC85XX_FEC ) +tsec_initialize (bis,2 ,CONFIG_MPC85XX_FEC_NAME ); +#else +#if defined(CONFIG_TSEC3 ) +tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); +#endif +#if defined(CONFIG_TSEC4 ) +tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); +#endif +#endif +return 0 ; +}
include/netdev.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* (C) Copyright 2008 +* Benjamin Warren, biggerbadderben at gmail.com +* +* See file CREDITS for list of people who contributed to this +* project. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +/* +* netdev.h - definitions an prototypes for network devices +*/ + +#ifndef _NETDEV_H_ +#define _NETDEV_H_ + +int tsec_initialize (bd_t * bis,int index,char *devname); + +#endif /* _NETDEV_H_ */ +
net/eth.c +10 -16
@@ -28,6 +28,12 @@#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" ))); +#ifdef CFG_GT_6426xextern int gt6426x_eth_initialize (bd_t *bis);#endif
@@ -165,6 +171,10 @@ int eth_initialize(bd_t *bis)#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )miiphy_init ();#endif +/* Try CPU-specific initialization first. If it fails or isn't +* present, call the board-specific initialization */ +if (cpu_eth_init (bis) <0 ) +board_eth_init (bis);#if defined(CONFIG_DB64360 ) || defined(CONFIG_CPCI750 )mv6436x_eth_initialize (bis);
@@ -196,22 +206,6 @@ int eth_initialize(bd_t *bis)#if defined(CONFIG_SK98 )skge_initialize (bis);#endif -#if defined(CONFIG_TSEC1 ) -tsec_initialize (bis,0 ,CONFIG_TSEC1_NAME ); -#endif -#if defined(CONFIG_TSEC2 ) -tsec_initialize (bis,1 ,CONFIG_TSEC2_NAME ); -#endif -#if defined(CONFIG_MPC85XX_FEC ) -tsec_initialize (bis,2 ,CONFIG_MPC85XX_FEC_NAME ); -#else -# if defined(CONFIG_TSEC3 ) -tsec_initialize (bis,2 ,CONFIG_TSEC3_NAME ); -# endif -# if defined(CONFIG_TSEC4 ) -tsec_initialize (bis,3 ,CONFIG_TSEC4_NAME ); -# endif -#endif #if defined(CONFIG_UEC_ETH1 )uec_initialize (0 );#endif
Signature · 1 line
1.5.4.3
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Hi Ben,
Quoted 3 lines · Ben Warren
This patch is the first step in cleaning up
net/eth.c, by moving Ethernet initialization to CPU or board-specific code. Initial implementation is only on the Freescale TSEC controller, but others will be added soon.
Great, thanks.
<snip>
Quoted 18 lines
net/eth.c +5
-0@@ -28,6 +28,12 @@#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"))); +
#ifdefCFG_GT_6426x
extern intgt6426x_eth_initialize(bd_t *bis);
#endif
net/eth.c int eth_initialize(bd_t *bis) · line 176
Quoted 6 lines
net/eth.c +3
-0@@ -165,6 +171,10 @@ int eth_initialize(bd_t *bis)#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )miiphy_init ();#endif +/* Try CPU-specific initialization first. If it fails or isn't +* present, call the board-specific initialization */ +if (cpu_eth_init (bis) <0 )
Nitpicking: No space before ")" please.
net/eth.c int eth_initialize(bd_t *bis) · line 177
Quoted 1 line
net/eth.c +1
-0+board_eth_init (bis);
Shouldn't this be the other way around?
+ if (board_eth_init(bis) < 0)
+ eth_eth_init(bis);
So that the board init routine can "overwrite" the cpu init version.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 29 lines · Stefan Roese
Hi Ben,
Quoted 3 lines · Ben Warren
This patch is the first step in cleaning up
net/eth.c, by moving Ethernet initialization to CPU or board-specific code. Initial implementation is only on the Freescale TSEC controller, but others will be added soon.Great, thanks.
<snip>
Quoted 18 lines
net/eth.c +5
-0@@ -28,6 +28,12 @@#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"))); +
#ifdefCFG_GT_6426x
extern intgt6426x_eth_initialize(bd_t *bis);
#endifnet/eth.c +0
-0@@ -165,6 +171,10 @@ int eth_initialize(bd_t *bis)
Quoted 8 lines
net/eth.c int eth_initialize(bd_t *bis) · line 176
Quoted 6 lines
net/eth.c +3
-0#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )miiphy_init ();#endif +/* Try CPU-specific initialization first. If it fails or isn't +* present, call the board-specific initialization */ +if (cpu_eth_init (bis) <0 )Nitpicking: No space before ")" please.
Huh, don't know how I missed that one.
Quoted 10 lines
net/eth.c int eth_initialize(bd_t *bis) · line 177
Quoted 2 lines
net/eth.c +1
-0+board_eth_init (bis);Shouldn't this be the other way around?
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If board_eth_init() exists, it gets highest priority. New patch coming soon!
Quoted 3 lines
Best regards,
Stefan
Thanks for the review,
Ben
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 12 lines · Ben Warren
Quoted 8 lines
net/eth.c int eth_initialize(bd_t *bis) · line 176
Quoted 7 lines
net/eth.c +3
-0@@ -165,6 +171,10 @@ int eth_initialize(bd_t *bis)#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )miiphy_init ();#endif +/* Try CPU-specific initialization first. If it fails or isn't +* present, call the board-specific initialization */ +if (cpu_eth_init (bis) <0 )Nitpicking: No space before ")" please.
Huh, don't know how I missed that one.
Quoted 3 lines
net/eth.c int eth_initialize(bd_t *bis) · line 177
Quoted 1 line
net/eth.c +1
-0+board_eth_init (bis);Shouldn't this be the other way around?
Quoted 7 lines
Quoted 5 lines
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If
board_eth_init()exists, it gets highest priority.
Just wondered, does that mean we could only have either cpu_eth_init or board_eth_init at a time?
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 5 lines · Shinya Kuribayashi
Quoted 5 lines
Quoted 5 lines
Shouldn't this be the other way around?
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If
board_eth_init()exists, it gets highest priority.Just wondered, does that mean we could only have either
cpu_eth_initorboard_eth_initat a time?
Not really. board_eth_init() could call cpu_eth_init() if necessary.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 6 lines · Stefan Roese
Quoted 5 lines · Shinya Kuribayashi
Quoted 5 lines
Quoted 5 lines
Shouldn't this be the other way around?
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If
board_eth_init()exists, it gets highest priority.Just wondered, does that mean we could only have either
cpu_eth_initorboard_eth_initat a time?Not really.
board_eth_init()could callcpu_eth_init()if necessary.
Hm. What is cpu_eth_init for then? Just
board_eth_init(bis);
seems to be enough for me. I also wonder where is the best place to have cpu_eth_init?
I'm not going to argue with you, I'm just thinking about my targets. One of my targets has internal ethernet MAC, and its evaluation board has an on-board external PCI NIC. Another target has internal MAC, but doesn't have PCI NIC.
I thought it'll be something like
cpu_eth_init(bis);
board_eth_init(bis);But again, I don't have strong opinions around here. Please go ahead.
Thanks for your comments,
Shinya
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 13 lines · Shinya Kuribayashi
Quoted 12 lines · Stefan Roese
Quoted 10 lines · Shinya Kuribayashi
Quoted 8 lines
Quoted 6 lines
Shouldn't this be the other way around?
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If
board_eth_init()exists, it gets highest priority.Just wondered, does that mean we could only have either
cpu_eth_initorboard_eth_initat a time?
Quoted 9 lines
Quoted 1 line
Not really.
board_eth_init()could callcpu_eth_init()if necessary.Hm. What is
cpu_eth_initfor then? Justboard_eth_init(bis);seems to be enough for me. I also wonder where is the best place to have
cpu_eth_init?
The cpu_init() was suggested by Stefan in our original discussion, when I only had the board function. His perspective is ppc_4xx, where tons of CPUs and boards share the EMAC driver, and he didn't want to modify each board. As you'll see in the discussion with JDL, it can probably apply to TSEC as well.
Quoted 10 lines
I'm not going to argue with you, I'm just thinking about my targets. One of my targets has internal ethernet MAC, and its evaluation board has an on-board external PCI NIC. Another target has internal MAC, but doesn't have PCI NIC.
I thought it'll be something like
cpu_eth_init(bis); board_eth_init(bis);
The idea is that cpu_eth_init is a default for a CPU family, and board_eth_init is a board override, which can of course call cpu_eth_init.
Quoted 7 lines
But again, I don't have strong opinions around here. Please go ahead.
Thanks for your comments,
Shinya
Thanks for the discussion!
cheers,
Ben
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 33 lines · Ben Warren
Quoted 13 lines · Shinya Kuribayashi
Quoted 12 lines · Stefan Roese
Quoted 10 lines · Shinya Kuribayashi
Quoted 8 lines
Quoted 6 lines
Shouldn't this be the other way around?
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If
board_eth_init()exists, it gets highest priority.Just wondered, does that mean we could only have either
cpu_eth_initorboard_eth_initat a time?Quoted 9 lines
Quoted 1 line
Not really.
board_eth_init()could callcpu_eth_init()if necessary.Hm. What is
cpu_eth_initfor then? Justboard_eth_init(bis);seems to be enough for me. I also wonder where is the best place to have
cpu_eth_init?The
cpu_init()was suggested by Stefan in our original discussion, when I only had the board function. His perspective isppc_4xx, where tons of CPUs and boards share the EMAC driver, and he didn't want to modify each board. As you'll see in the discussion with JDL, it can probably apply to TSEC as well.Quoted 5 lines
I'm not going to argue with you, I'm just thinking about my targets. One of my targets has internal ethernet MAC, and its evaluation board has an on-board external PCI NIC. Another target has internal MAC, but doesn't have PCI NIC.
Quoted 7 lines
Quoted 5 lines
I thought it'll be something like
cpu_eth_init(bis); board_eth_init(bis);The idea is that
cpu_eth_initis a default for a CPU family, andboard_eth_initis a board override, which can of course callcpu_eth_init.
What about a section to declare the netdev?
In this case we can have more than 2 eth and it more generic.
Best Regards,
J.
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 51 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 40 lines · Ben Warren
Quoted 17 lines · Shinya Kuribayashi
Quoted 15 lines · Stefan Roese
Quoted 13 lines · Shinya Kuribayashi
Quoted 10 lines
Quoted 7 lines
Shouldn't this be the other way around?
(quoted diff) +2
-0+ if (board_eth_init(bis) < 0) + eth_eth_init(bis);So that the board init routine can "overwrite" the cpu init version.
Yeah, I think you're right. If
board_eth_init()exists, it gets highest priority.Just wondered, does that mean we could only have either
cpu_eth_initorboard_eth_initat a time?Quoted 10 lines
Quoted 2 lines
Not really.
board_eth_init()could callcpu_eth_init()if necessary.Hm. What is
cpu_eth_initfor then? Justboard_eth_init(bis);seems to be enough for me. I also wonder where is the best place to have
cpu_eth_init?The
cpu_init()was suggested by Stefan in our original discussion, when I only had the board function. His perspective isppc_4xx, where tons of CPUs and boards share the EMAC driver, and he didn't want to modify each board. As you'll see in the discussion with JDL, it can probably apply to TSEC as well.Quoted 5 lines
I'm not going to argue with you, I'm just thinking about my targets. One of my targets has internal ethernet MAC, and its evaluation board has an on-board external PCI NIC. Another target has internal MAC, but doesn't have PCI NIC.
Quoted 9 lines
Quoted 6 lines
I thought it'll be something like
cpu_eth_init(bis); board_eth_init(bis);The idea is that
cpu_eth_initis a default for a CPU family, andboard_eth_initis a board override, which can of course callcpu_eth_init.
Quoted 8 lines
What about a section to declare the netdev?
In this case we can have more than 2 eth and it more generic.
Best Regards,
J.
Sorry, I don't follow.
regards,
Ben
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 2 lines
The idea is that
cpu_eth_initis a default for a CPU family, andboard_eth_initis a board override, which can of course callcpu_eth_init.What about a section to declare the netdev?
Please, let's not overdo this. The patch as it stands is a huge improvement over the current situation.
Quoted 1 line
In this case we can have more than 2 eth and it more generic.
You can have that now. board_eth_init() can initialize as many interfaces as it likes.
Haavard
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 7 lines · Haavard Skinnemoen
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 3 lines
The idea is that
cpu_eth_initis a default for a CPU family, andboard_eth_initis a board override, which can of course callcpu_eth_init.What about a section to declare the netdev?
Quoted 7 lines
Please, let's not overdo this. The patch as it stands is a huge improvement over the current situation.
Quoted 1 line
In this case we can have more than 2 eth and it more generic.
You can have that now.
board_eth_init()can initialize as many interfaces as it likes.
Full ack on both statements.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
In reply to Ben WarrenQuoted 5 lines · On Tue, 10 Jun 2008 01:29:27 -0700 Ben Warren <[email protected]> wrote:
This patch is the first step in cleaning up
net/eth.c, by moving Ethernet initialization to CPU or board-specific code. Initial implementation is only on the Freescale TSEC controller, but others will be added soon.Signed-off-by Ben Warren <[email protected]>
Sweet!
Quoted 5 lines
---
When we discussed this a few months ago, I was planning on defining the
cpu_eth_init()andboard_eth_init()functions as weak with no aliases, but in my testing this did not result in them being NULL, hence the default function.
Works just as well, doesn't it?
net/eth.c line 33
Quoted 11 lines
net/eth.c +3
-0@@ -28,6 +28,12 @@#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 ;}
Just a cosmetic thing: I really think this should look like a normal function, i.e. not cuddling everything up on one line. I've seen such things being mistaken for macros before.
Haavard
PATCH 1/1 Add mechanisms for CPU and board-specific Ethernet initialization
Quoted 35 lines · Haavard Skinnemoen
Quoted 5 lines · On Tue, 10 Jun 2008 01:29:27 -0700 Ben Warren <[email protected]> wrote:
This patch is the first step in cleaning up
net/eth.c, by moving Ethernet initialization to CPU or board-specific code. Initial implementation is only on the Freescale TSEC controller, but others will be added soon.Signed-off-by Ben Warren <[email protected]>Sweet!
Quoted 5 lines
---
When we discussed this a few months ago, I was planning on defining the
cpu_eth_init()andboard_eth_init()functions as weak with no aliases, but in my testing this did not result in them being NULL, hence the default function.Works just as well, doesn't it?
net/eth.c line 33
Quoted 11 lines
net/eth.c +3
-0@@ -28,6 +28,12 @@#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 ;}Just a cosmetic thing: I really think this should look like a normal function, i.e. not cuddling everything up on one line. I've seen such things being mistaken for macros before.
Quoted 1 line
Haavard
/*
* ...and the comment style should be like this. Coding standards,
* y'know.
*/
Best regards,
gvb