summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-04-13 20:35:58 -0700
committerSimon Glass <sjg@chromium.org>2011-08-24 09:56:22 -0700
commit965d042da6fe36b26b85391ad852d05f3f9e50a0 (patch)
tree94307bda707af43a54dd2aada8155d503f85c2b5 /drivers/usb
parent9530dc99ee3539909935e8a60a2bb756499c8318 (diff)
usbeth: asix: Do a fast init if link already established
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. Change-Id: I044e6d12f6c175a87ee3c93bf874b497f9379c3e BUG=chromium-os:14082 TEST=run U-boot; usb start; bootp; bootp See that second bootp happens quickly and link stays up. Change-Id: I79fdf4f099041ed0a077e8a833d66076c1b28402 Reviewed-on: http://gerrit.chromium.org/gerrit/200 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Warren <twarren@nvidia.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/eth/asix.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c
index 9b012e4a66a..173f2e60c03 100644
--- a/drivers/usb/eth/asix.c
+++ b/drivers/usb/eth/asix.c
@@ -81,6 +81,7 @@
#define AX_DEFAULT_RX_CTL \
(AX_RX_CTL_SO | AX_RX_CTL_AB)
+#define AX_DISABLE_RX_CTL AX_RX_CTL_AB
/* GPIO 2 toggles */
#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
@@ -307,20 +308,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)
@@ -392,10 +385,28 @@ static int asix_init(struct eth_device *eth, bd_t *bd)
debug("Write IPG,IPG1,IPG2 failed\n");
goto out_err;
}
+ return 0;
+out_err:
+ return -1;
+}
- if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0)
- goto out_err;
+/*
+ * 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;
+ if (asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL) < 0)
+ return -1;
do {
link_detected = asix_mdio_read(dev, dev->phy_id, MII_BMSR) &
BMSR_LSTATUS;
@@ -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)
@@ -516,7 +526,11 @@ static int asix_recv(struct eth_device *eth)
static void asix_halt(struct eth_device *eth)
{
+ struct ueth_data *dev = (struct ueth_data *)eth->priv;
+
+ /* Disable packet reception */
debug("** %s()\n", __func__);
+ (void)asix_write_rx_ctl(dev, AX_DISABLE_RX_CTL);
}
/*