[U-Boot] [PATCH v5 5/5] usbeth: asix: Do a fast init if link already established

Simon Glass sjg at chromium.org
Wed Apr 20 04:29:45 CEST 2011


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.

TEST=bootp; tftp ...  - see that delay is now shorter than before.

Signed-off-by: Simon Glass <sjg at chromium.org>
---
 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 */
-- 
1.7.3.1



More information about the U-Boot mailing list