summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorLucas Stach <dev@lynxeye.de>2012-08-22 11:04:58 +0000
committerJoe Hershberger <joe.hershberger@ni.com>2012-09-26 12:36:30 -0500
commit5fae53d0f1554d35f159a386cd16edf94838279d (patch)
tree24963814e6252082b3c570850ee6bc9c27208aed /drivers/usb
parente1dbdf9109a2739862ccd3c39be0b8ee37721cb6 (diff)
downloadu-boot-imx-5fae53d0f1554d35f159a386cd16edf94838279d.zip
u-boot-imx-5fae53d0f1554d35f159a386cd16edf94838279d.tar.gz
u-boot-imx-5fae53d0f1554d35f159a386cd16edf94838279d.tar.bz2
net: asix: split out basic reset function
The basic device reset ensures that the device is ready to service commands and does not need to get redone before each network operation. Split out the basic reset from asix_init() and instead call it from asix_eth_get_info(), so that it only gets called once. Signed-off-by: Lucas Stach <dev@lynxeye.de> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/eth/asix.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c
index 8fb7fc8..50cbbbd 100644
--- a/drivers/usb/eth/asix.c
+++ b/drivers/usb/eth/asix.c
@@ -310,55 +310,60 @@ 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 asix_basic_reset(struct ueth_data *dev)
{
int embd_phy;
- ALLOC_CACHE_ALIGN_BUFFER(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)
- goto out_err;
+ return -1;
/* 0x10 is the phy id of the embedded 10/100 ethernet phy */
embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
if (asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
embd_phy, 0, 0, NULL) < 0) {
debug("Select PHY #1 failed\n");
- goto out_err;
+ return -1;
}
if (asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL) < 0)
- goto out_err;
+ return -1;
if (asix_sw_reset(dev, AX_SWRESET_CLEAR) < 0)
- goto out_err;
+ return -1;
if (embd_phy) {
if (asix_sw_reset(dev, AX_SWRESET_IPRL) < 0)
- goto out_err;
+ return -1;
} else {
if (asix_sw_reset(dev, AX_SWRESET_PRTE) < 0)
- goto out_err;
+ return -1;
}
rx_ctl = asix_read_rx_ctl(dev);
debug("RX_CTL is 0x%04x after software reset\n", rx_ctl);
if (asix_write_rx_ctl(dev, 0x0000) < 0)
- goto out_err;
+ return -1;
rx_ctl = asix_read_rx_ctl(dev);
debug("RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
+ return 0;
+}
+
+/*
+ * 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__);
+
/* Get the MAC address */
if (asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
0, 0, ETH_ALEN, buf) < 0) {
@@ -635,5 +640,8 @@ int asix_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
eth->halt = asix_halt;
eth->priv = ss;
+ if (asix_basic_reset(ss))
+ return 0;
+
return 1;
}