From 89973f8a82c28ad893c4c3cc56839a8e10fe5f13 Mon Sep 17 00:00:00 2001 From: Ben Warren Date: Sun, 31 Aug 2008 22:22:04 -0700 Subject: [PATCH] Introduce netdev.h header file and remove externs This addresses all drivers whose initializers have already been moved to board_eth_init()/cpu_eth_init(). Signed-off-by: Ben Warren --- board/atmel/atngw100/atngw100.c | 3 +- board/atmel/atstk1000/atstk1000.c | 3 +- board/bf537-stamp/bf537-stamp.c | 3 +- board/earthlcd/favr-32-ezkit/favr-32-ezkit.c | 3 +- board/freescale/mpc8610hpcd/mpc8610hpcd.c | 8 +-- board/mimc/mimc200/mimc200.c | 3 +- board/miromico/hammerhead/hammerhead.c | 3 +- board/sl8245/sl8245.c | 3 +- cpu/leon2/cpu.c | 3 +- cpu/leon3/cpu.c | 2 +- cpu/mcf523x/cpu.c | 3 +- cpu/mcf52x2/cpu.c | 3 +- cpu/mcf532x/cpu.c | 3 +- cpu/mcf5445x/cpu.c | 3 +- cpu/mcf547x_8x/cpu.c | 4 +- drivers/net/bfin_mac.c | 1 + drivers/net/greth.c | 1 + drivers/net/macb.c | 1 + drivers/net/mcffec.c | 1 + drivers/net/sk98lin/uboot_drv.c | 1 + drivers/net/uli526x.c | 1 + include/netdev.h | 66 ++++++++++++++++++++ 22 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 include/netdev.h diff --git a/board/atmel/atngw100/atngw100.c b/board/atmel/atngw100/atngw100.c index 7f3e48541d..fa1a2aa7c1 100644 --- a/board/atmel/atngw100/atngw100.c +++ b/board/atmel/atngw100/atngw100.c @@ -26,6 +26,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -93,8 +94,6 @@ void board_init_info(void) gd->bd->bi_phy_id[1] = 0x03; } -extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); - #ifdef CONFIG_CMD_NET int board_eth_init(bd_t *bi) { diff --git a/board/atmel/atstk1000/atstk1000.c b/board/atmel/atstk1000/atstk1000.c index 915b1c3539..94523b5a3b 100644 --- a/board/atmel/atstk1000/atstk1000.c +++ b/board/atmel/atstk1000/atstk1000.c @@ -26,6 +26,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -116,8 +117,6 @@ void board_init_info(void) gd->bd->bi_phy_id[1] = 0x11; } -extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); - #ifdef CONFIG_CMD_NET int board_eth_init(bd_t *bi) { diff --git a/board/bf537-stamp/bf537-stamp.c b/board/bf537-stamp/bf537-stamp.c index a9b7a68c54..4567213111 100644 --- a/board/bf537-stamp/bf537-stamp.c +++ b/board/bf537-stamp/bf537-stamp.c @@ -32,6 +32,7 @@ #include #include #include +#include /** * is_valid_ether_addr - Determine if the given Ethernet address is valid @@ -156,8 +157,6 @@ int misc_init_r(void) #if defined(CONFIG_BFIN_MAC) -extern int bfin_EMAC_initialize(bd_t *bis); - int board_eth_init(bd_t *bis) { return bfin_EMAC_initialize(bis); diff --git a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c index da69e754f9..da055899f5 100644 --- a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c +++ b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c @@ -18,6 +18,7 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include #include #include @@ -87,8 +88,6 @@ void board_init_info(void) } #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET) -extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); - int board_eth_init(bd_t *bi) { return macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]); diff --git a/board/freescale/mpc8610hpcd/mpc8610hpcd.c b/board/freescale/mpc8610hpcd/mpc8610hpcd.c index af79fc2c67..130f7aa8ce 100644 --- a/board/freescale/mpc8610hpcd/mpc8610hpcd.c +++ b/board/freescale/mpc8610hpcd/mpc8610hpcd.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "../common/pixis.h" @@ -520,12 +521,7 @@ get_board_sys_clk(ulong dummy) return val; } -extern int uli526x_initialize(bd_t *); - int board_eth_init(bd_t *bis) { -#if defined(CONFIG_ULI526) - uli526x_initialize(bis); -#endif - return 0; + return pci_eth_init(bis); } diff --git a/board/mimc/mimc200/mimc200.c b/board/mimc/mimc200/mimc200.c index 4ece11ac87..8516dcb828 100644 --- a/board/mimc/mimc200/mimc200.c +++ b/board/mimc/mimc200/mimc200.c @@ -20,6 +20,7 @@ * MA 02111-1307 USA */ #include +#include #include #include @@ -195,8 +196,6 @@ void spi_cs_deactivate(struct spi_slave *slave) #endif /* CONFIG_ATMEL_SPI */ #ifdef CONFIG_CMD_NET -extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); - int board_eth_init(bd_t *bi) { macb_eth_initialize(0, (void *)MACB0_BASE, bi->bi_phy_id[0]); diff --git a/board/miromico/hammerhead/hammerhead.c b/board/miromico/hammerhead/hammerhead.c index 738ece2fe3..d3875f449d 100644 --- a/board/miromico/hammerhead/hammerhead.c +++ b/board/miromico/hammerhead/hammerhead.c @@ -25,6 +25,7 @@ #include "../cpu/at32ap/at32ap700x/sm.h" #include +#include #include #include @@ -51,8 +52,6 @@ static const struct sdram_config sdram_config = { .refresh_period = (781 * (SDRAMC_BUS_HZ / 1000)) / 100000, }; -extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); - #ifdef CONFIG_CMD_NET int board_eth_init(bd_t *bis) { diff --git a/board/sl8245/sl8245.c b/board/sl8245/sl8245.c index c853755a1c..e66272ecb9 100644 --- a/board/sl8245/sl8245.c +++ b/board/sl8245/sl8245.c @@ -24,6 +24,7 @@ #include #include #include +#include int checkboard (void) { @@ -67,8 +68,6 @@ void pci_init_board(void) pci_mpc824x_init(&hose); } -extern int skge_initialize(bd_t *bis); - int board_eth_init(bd_t *bis) { int rc = 0; diff --git a/cpu/leon2/cpu.c b/cpu/leon2/cpu.c index 5de1c521aa..d6e23b129c 100644 --- a/cpu/leon2/cpu.c +++ b/cpu/leon2/cpu.c @@ -25,6 +25,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -57,8 +58,6 @@ int do_reset(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) /* ------------------------------------------------------------------------- */ -extern int greth_initialize(bd_t *bis); - #ifdef CONFIG_GRETH int cpu_eth_init(bd_t *bis) { diff --git a/cpu/leon3/cpu.c b/cpu/leon3/cpu.c index 1725fdb090..976f311348 100644 --- a/cpu/leon3/cpu.c +++ b/cpu/leon3/cpu.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -65,7 +66,6 @@ u64 flash_read64(void *addr) } /* ------------------------------------------------------------------------- */ -extern int greth_initialize(bd_t *bis); #ifdef CONFIG_GRETH int cpu_eth_init(bd_t *bis) diff --git a/cpu/mcf523x/cpu.c b/cpu/mcf523x/cpu.c index 8d2152d9c9..bdc152f078 100644 --- a/cpu/mcf523x/cpu.c +++ b/cpu/mcf523x/cpu.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -114,8 +115,6 @@ int watchdog_init(void) * int board_eth_init(bd_t *bis) */ -extern int mcffec_initialize(bd_t*); - int cpu_eth_init(bd_t *bis) { return mcffec_initialize(bis); diff --git a/cpu/mcf52x2/cpu.c b/cpu/mcf52x2/cpu.c index 2af31cbb98..167097a797 100644 --- a/cpu/mcf52x2/cpu.c +++ b/cpu/mcf52x2/cpu.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef CONFIG_M5271 /* @@ -328,8 +329,6 @@ int do_reset(cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[]) * int board_eth_init(bd_t *bis) */ -extern int mcffec_initialize(bd_t*); - int cpu_eth_init(bd_t *bis) { return mcffec_initialize(bis); diff --git a/cpu/mcf532x/cpu.c b/cpu/mcf532x/cpu.c index 20d0d5cf27..260d6e6755 100644 --- a/cpu/mcf532x/cpu.c +++ b/cpu/mcf532x/cpu.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -136,8 +137,6 @@ int watchdog_init(void) * int board_eth_init(bd_t *bis) */ -extern int mcffec_initialize(bd_t*); - int cpu_eth_init(bd_t *bis) { return mcffec_initialize(bis); diff --git a/cpu/mcf5445x/cpu.c b/cpu/mcf5445x/cpu.c index ab342ddeb0..a30c327dd7 100644 --- a/cpu/mcf5445x/cpu.c +++ b/cpu/mcf5445x/cpu.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -102,8 +103,6 @@ int checkcpu(void) * int board_eth_init(bd_t *bis) */ -extern int mcffec_initialize(bd_t*); - int cpu_eth_init(bd_t *bis) { return mcffec_initialize(bis); diff --git a/cpu/mcf547x_8x/cpu.c b/cpu/mcf547x_8x/cpu.c index 1ba7aa80a3..ab4ad2889c 100644 --- a/cpu/mcf547x_8x/cpu.c +++ b/cpu/mcf547x_8x/cpu.c @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -148,9 +149,6 @@ int watchdog_init(void) * int board_eth_init(bd_t *bis) */ -extern int mcdmafec_initialize(bd_t *bis); -extern int mcffec_initialize(bd_t*); - int cpu_eth_init(bd_t *bis) { #if defined(CONFIG_FSLDMAFEC) diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c index 3ee5d9603a..c5e74b8b5d 100644 --- a/drivers/net/bfin_mac.c +++ b/drivers/net/bfin_mac.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/drivers/net/greth.c b/drivers/net/greth.c index 90c5338837..79bc4d9d26 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/macb.c b/drivers/net/macb.c index aa39284d1d..08bebf74a5 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -40,6 +40,7 @@ */ #include +#include #include #include diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c index 50d6508fb4..f93cf598e2 100644 --- a/drivers/net/mcffec.c +++ b/drivers/net/mcffec.c @@ -32,6 +32,7 @@ #include #include +#include #include #undef ET_DEBUG diff --git a/drivers/net/sk98lin/uboot_drv.c b/drivers/net/sk98lin/uboot_drv.c index 205e7d2e99..0199b33fe8 100644 --- a/drivers/net/sk98lin/uboot_drv.c +++ b/drivers/net/sk98lin/uboot_drv.c @@ -24,6 +24,7 @@ */ #include +#include #include "h/skdrv1st.h" #include "h/skdrv2nd.h" diff --git a/drivers/net/uli526x.c b/drivers/net/uli526x.c index d87638c138..9ea5ac2013 100644 --- a/drivers/net/uli526x.c +++ b/drivers/net/uli526x.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/include/netdev.h b/include/netdev.h new file mode 100644 index 0000000000..3ec9212ce1 --- /dev/null +++ b/include/netdev.h @@ -0,0 +1,66 @@ +/* + * (C) Copyright 2008 + * Benjamin Warren, biggerbadderben@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_ + +/* + * 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 bfin_EMAC_initialize(bd_t *bis); +int greth_initialize(bd_t *bis); +int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); +int mcdmafec_initialize(bd_t *bis); +int mcffec_initialize(bd_t *bis); +int skge_initialize(bd_t *bis); +int uli526x_initialize(bd_t *bis); + +/* Boards with PCI network controllers can call this from their board_eth_init() + * function to initialize whatever's on board. + * Return value is total # of devices found */ + +static inline int pci_eth_init(bd_t *bis) +{ + int num = 0; +#if defined(CONFIG_ULI526) + num += uli526x_initialize(bis); +#endif + return num; +} + +#endif /* _NETDEV_H_ */ + -- 2.39.5