From patchwork Sun Jan 17 21:51:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 569317 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 89F39140317 for ; Mon, 18 Jan 2016 08:52:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=oTh/V3gL; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2B9604BF9F; Sun, 17 Jan 2016 22:52:30 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KEK9UkLI3e_o; Sun, 17 Jan 2016 22:52:29 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F31B04BF6D; Sun, 17 Jan 2016 22:52:18 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6A6224BF71 for ; Sun, 17 Jan 2016 22:52:13 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1YxVnKn9Ta-N for ; Sun, 17 Jan 2016 22:52:13 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by theia.denx.de (Postfix) with ESMTPS id 0E8F94BF70 for ; Sun, 17 Jan 2016 22:52:09 +0100 (CET) Received: by mail-oi0-f53.google.com with SMTP id w75so133273287oie.0 for ; Sun, 17 Jan 2016 13:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PLs//Ka7XNG3lEewFA3+zQX/stbQAq/vnG2sOn4yuAA=; b=oTh/V3gLJUfQwJ2RCLNxC5cnal29o2AGTynhBLWgBTcwNAyRK8ddMjzGgr/ZtYjGYF 20vQv32oim2yQXwhjxoSWf/iXQeRN9dHgmO+0OE59bSr7Uwu1voWytk5bNnpZQGTacHk heRmXj8xfxpmCwulGj21Jj2l0UI8Ve9T99hrfrxr/lBrEYYiqRKFLs/i2NCYFdhljvu+ nMEQhGXgfZRN8jQ/qkhski34lNk7Kx+Vgq3ym3J/fAg3xdl57hGDcyB69GfI/Jmw0MzA /qhPdtpkO0R4ME1iEcgEk3ZTerCDDPSKuiGFwhYac1wfjYVl4aXz+WuthB8IMj8DtrFq Yj2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PLs//Ka7XNG3lEewFA3+zQX/stbQAq/vnG2sOn4yuAA=; b=HTLA8kA+83vmemwuhUsEZsam5NgM3JK3h0vH42CgO+Q9R6urbThl0LaMTBVUKJWCvf mmkXyTqj89ch0dSeLpRtzckpA3dKe0FNgwJSmaBJoT+ekO43kXa8aPUbj3ep7jgBiyYU OebQ54YSV5pgVRZsWuL7D0sCBOnfqr+XkLYQ1TkIxnxhTBeBwJjiNJa3k7N3dz9Yb+8Z AfGuxIpPeyM1WIMuMED4ubW241NbPW9tBqtizW4l8cCnKQZaziYh9x0gaqo8yxv6qF/d 9ogICzw399ysJl5nYtAZD3AtwfICECcay9QJ2tpVDBWfTstJwqnmeHJZZB002Hq++gjt XSmA== X-Gm-Message-State: ALoCoQmmJXdD9GmXYojhEW+uCi1BaSYXi2FuoQGoHBJMDst6eHuco6uwr8fwy6FQ3A8O2F9iFZr7eM+GJGYyiXqyGdwg7n5E1A== X-Received: by 10.202.172.80 with SMTP id v77mr16036090oie.18.1453067528422; Sun, 17 Jan 2016 13:52:08 -0800 (PST) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id i4sm11456913oel.12.2016.01.17.13.52.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jan 2016 13:52:07 -0800 (PST) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id E9567220A3E; Sun, 17 Jan 2016 14:52:04 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 17 Jan 2016 14:51:57 -0700 Message-Id: <1453067522-610-4-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1453067522-610-1-git-send-email-sjg@chromium.org> References: <1453067522-610-1-git-send-email-sjg@chromium.org> Cc: Joe Hershberger Subject: [U-Boot] [PATCH 3/8] net: Move common init into a new eth_common.c file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Only half of the init is actually common. Move that part into a new common file and call it from driver-model and legacy code. More common functions will be added in future patches. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Acked-by: Joe Hershberger --- net/Makefile | 1 + net/eth.c | 42 ++++++++++++++---------------------------- net/eth_common.c | 23 +++++++++++++++++++++++ net/eth_internal.h | 15 +++++++++++++++ 4 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 net/eth_common.c create mode 100644 net/eth_internal.h diff --git a/net/Makefile b/net/Makefile index e9cc8ad..b3a22c2 100644 --- a/net/Makefile +++ b/net/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_CMD_NET) += bootp.o obj-$(CONFIG_CMD_CDP) += cdp.o obj-$(CONFIG_CMD_DNS) += dns.o obj-$(CONFIG_CMD_NET) += eth.o +obj-$(CONFIG_CMD_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_CMD_NET) += net.o obj-$(CONFIG_CMD_NFS) += nfs.o diff --git a/net/eth.c b/net/eth.c index d96d3a5..602925d 100644 --- a/net/eth.c +++ b/net/eth.c @@ -16,6 +16,7 @@ #include #include #include +#include "eth_internal.h" DECLARE_GLOBAL_DATA_PTR; @@ -85,34 +86,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"))); -static void eth_common_init(void) -{ - bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) - miiphy_init(); -#endif - -#ifdef CONFIG_PHYLIB - phy_init(); -#endif - -#ifndef CONFIG_DM_ETH - /* - * If board-specific initialization exists, call it. - * If not, call a CPU-specific one - */ - if (board_eth_init != __def_eth_init) { - if (board_eth_init(gd->bd) < 0) - printf("Board Net Initialization Failed\n"); - } else if (cpu_eth_init != __def_eth_init) { - if (cpu_eth_init(gd->bd) < 0) - printf("CPU Net Initialization Failed\n"); - } else { - printf("Net Initialization Skipped\n"); - } -#endif -} - #ifdef CONFIG_DM_ETH /** * struct eth_device_priv - private structure for each Ethernet device @@ -865,6 +838,19 @@ int eth_initialize(void) eth_devices = NULL; eth_current = NULL; eth_common_init(); + /* + * If board-specific initialization exists, call it. + * If not, call a CPU-specific one + */ + if (board_eth_init != __def_eth_init) { + if (board_eth_init(gd->bd) < 0) + printf("Board Net Initialization Failed\n"); + } else if (cpu_eth_init != __def_eth_init) { + if (cpu_eth_init(gd->bd) < 0) + printf("CPU Net Initialization Failed\n"); + } else { + printf("Net Initialization Skipped\n"); + } if (!eth_devices) { puts("No ethernet found.\n"); diff --git a/net/eth_common.c b/net/eth_common.c new file mode 100644 index 0000000..ee0b6df --- /dev/null +++ b/net/eth_common.c @@ -0,0 +1,23 @@ +/* + * (C) Copyright 2001-2015 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * Joe Hershberger, National Instruments + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include +#include +#include "eth_internal.h" + +void eth_common_init(void) +{ + bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) + miiphy_init(); +#endif + +#ifdef CONFIG_PHYLIB + phy_init(); +#endif +} diff --git a/net/eth_internal.h b/net/eth_internal.h new file mode 100644 index 0000000..e65d898 --- /dev/null +++ b/net/eth_internal.h @@ -0,0 +1,15 @@ +/* + * (C) Copyright 2001-2015 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * Joe Hershberger, National Instruments + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __ETH_INTERNAL_H +#define __ETH_INTERNAL_H + +/* Do init that is common to driver model and legacy networking */ +void eth_common_init(void); + +#endif