]> git.sur5r.net Git - u-boot/commitdiff
net: asix: split out basic reset function
authorLucas Stach <dev@lynxeye.de>
Wed, 22 Aug 2012 11:04:58 +0000 (11:04 +0000)
committerJoe Hershberger <joe.hershberger@ni.com>
Wed, 26 Sep 2012 17:36:30 +0000 (12:36 -0500)
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>
drivers/usb/eth/asix.c

index 8fb7fc8c90e5a0e79d8241f2b4b6da39d0c4c74d..50cbbbd09a23b905bc687e2ba7635aee328888ba 100644 (file)
@@ -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;
 }