From patchwork Fri Jun 10 15:04:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 99906 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 E1956B702D for ; Sat, 11 Jun 2011 01:05:20 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4A99E28336; Fri, 10 Jun 2011 17:05:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 PkbMubOWqwU3; Fri, 10 Jun 2011 17:05:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F1061282FB; Fri, 10 Jun 2011 17:05:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9986D282F9 for ; Fri, 10 Jun 2011 17:04:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 bGEXG6vRNqqJ for ; Fri, 10 Jun 2011 17:04:58 +0200 (CEST) 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 smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by theia.denx.de (Postfix) with ESMTPS id 8114A282D7 for ; Fri, 10 Jun 2011 17:04:50 +0200 (CEST) Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id p5AF4Yjt009605; Fri, 10 Jun 2011 08:04:34 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by wpaz37.hot.corp.google.com with ESMTP id p5AF4Ssg021347; Fri, 10 Jun 2011 08:04:28 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id 9E0DA1412AF; Fri, 10 Jun 2011 08:04:25 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Fri, 10 Jun 2011 08:04:11 -0700 Message-Id: <1307718251-15947-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1307718251-15947-1-git-send-email-sjg@chromium.org> References: <1307718251-15947-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true Cc: Andy Fleming Subject: [U-Boot] [PATCH v7 RESEND 5/5] usbeth: asix: Do a fast init if link already established X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The Asix driver takes the link down during init() and then brings it back up. This commit changes this so that if a link has already been established successfully we simply check that the link is still good. This reduces the delay between successive network commands. Signed-off-by: Simon Glass --- drivers/usb/eth/asix.c | 36 +++++++++++++++++++++++------------- include/usb_ether.h | 5 +++-- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index 9b012e4..18e5457 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -307,20 +307,12 @@ static int mii_nway_restart(struct ueth_data *dev) return r; } -/* - * Asix callbacks - */ -static int asix_init(struct eth_device *eth, bd_t *bd) +static int full_init(struct eth_device *eth) { + struct ueth_data *dev = (struct ueth_data *)eth->priv; int embd_phy; unsigned char buf[ETH_ALEN]; u16 rx_ctl; - struct ueth_data *dev = (struct ueth_data *)eth->priv; - int timeout = 0; -#define TIMEOUT_RESOLUTION 50 /* ms */ - int link_detected; - - debug("** %s()\n", __func__); if (asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5) < 0) @@ -395,6 +387,25 @@ static int asix_init(struct eth_device *eth, bd_t *bd) if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0) goto out_err; + return 0; +out_err: + return -1; +} + +/* + * Asix callbacks + */ +static int asix_init(struct eth_device *eth, bd_t *bd) +{ + struct ueth_data *dev = (struct ueth_data *)eth->priv; + int timeout = 0; +#define TIMEOUT_RESOLUTION 50 /* ms */ + int link_detected; + + debug("** %s()\n", __func__); + + if (!dev->has_been_running && full_init(eth)) + return -1; do { link_detected = asix_mdio_read(dev, dev->phy_id, MII_BMSR) & @@ -411,12 +422,11 @@ static int asix_init(struct eth_device *eth, bd_t *bd) printf("done.\n"); } else { printf("unable to connect.\n"); - goto out_err; + return -1; } + dev->has_been_running = 1; return 0; -out_err: - return -1; } static int asix_send(struct eth_device *eth, volatile void *packet, int length) diff --git a/include/usb_ether.h b/include/usb_ether.h index a7fb26b..73b085d 100644 --- a/include/usb_ether.h +++ b/include/usb_ether.h @@ -37,8 +37,9 @@ struct ueth_data { /* eth info */ - struct eth_device eth_dev; /* used with eth_register */ - int phy_id; /* mii phy id */ + struct eth_device eth_dev; /* used with eth_register */ + int phy_id; /* mii phy id */ + int has_been_running; /* 1 if we have had a link up */ /* usb info */ struct usb_device *pusb_dev; /* this usb_device */