summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2015-06-10 13:32:47 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2015-06-10 13:32:47 +0200
commit0aa8350c3e98bcfebd55ab7d07e70baafcb55811 (patch)
tree622489ad7ff752ccb942f0b8c10bb612b3973125 /drivers
parent54d69d3f5fb56f8315df12593d3c3d550f4ffbaf (diff)
net: usb: asix: integrate driver 4.17.0
Integrate latest ASIX proprietary driver version 4.17.0 (AX88772C_772B_772A_760_772_178_LINUX_DRIVER_v4.17.0_Source.tar.bz2).
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/usb/asix.c2607
-rw-r--r--drivers/net/usb/asix.h193
-rw-r--r--drivers/net/usb/axusbnet.c734
-rw-r--r--drivers/net/usb/axusbnet.h4
4 files changed, 2006 insertions, 1532 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index f2d5822338d7..e317a1e53bb2 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -19,10 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-//#define DEBUG // debug messages, extra info
+/* debug messages, extra info */
+/* #define DEBUG */
#include <linux/version.h>
-//#include <linux/config.h>
+/* #include <linux/config.h> */
#ifdef CONFIG_USB_DEBUG
# define DEBUG
#endif
@@ -41,65 +42,32 @@
#include "axusbnet.c"
#include "asix.h"
-#define DRV_VERSION "4.4.0"
+#define DRV_VERSION "4.17.0"
static char version[] =
-KERN_INFO "ASIX USB Ethernet Adapter:v" DRV_VERSION
+KERN_INFO "ASIX USB Ethernet Adapter:v" DRV_VERSION
" " __TIME__ " " __DATE__ "\n"
-KERN_INFO " http://www.asix.com.tw\n";
-
-static char g_mac_addr[ETH_ALEN];
-static int g_usr_mac = 0;
+ " http://www.asix.com.tw\n";
/* configuration of maximum bulk in size */
static int bsize = AX88772B_MAX_BULKIN_16K;
-module_param (bsize, int, 0);
-MODULE_PARM_DESC (bsize, "Maximum transfer size per bulk");
+module_param(bsize, int, 0);
+MODULE_PARM_DESC(bsize, "Maximum transfer size per bulk");
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void ax88772b_link_reset (void *data);
-static void ax88772a_link_reset (void *data);
-static void ax88772_link_reset (void *data);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void ax88772b_link_reset(void *data);
+static void ax88772a_link_reset(void *data);
+static void ax88772_link_reset(void *data);
#else
-static void ax88772b_link_reset (struct work_struct *work);
-static void ax88772a_link_reset (struct work_struct *work);
-static void ax88772_link_reset (struct work_struct *work);
+static void ax88772b_link_reset(struct work_struct *work);
+static void ax88772a_link_reset(struct work_struct *work);
+static void ax88772_link_reset(struct work_struct *work);
#endif
-static int ax88772a_phy_powerup (struct usbnet *dev);
-
-/* Retrieve user set MAC address */
-static int __init setup_asix_mac(char *macstr)
-{
- int i, j;
- unsigned char result, value;
-
- for (i = 0; i < ETH_ALEN; i++) {
- result = 0;
-
- if (i != 5 && *(macstr + 2) != ':')
- return -1;
-
- for (j = 0; j < 2; j++) {
- if (isxdigit(*macstr)
- && (value =
- isdigit(*macstr) ? *macstr -
- '0' : toupper(*macstr) - 'A' + 10) < 16) {
- result = result * 16 + value;
- macstr++;
- } else
- return -1;
- }
-
- macstr++;
- g_mac_addr[i] = result;
- }
-
- g_usr_mac = 1;
-
- return 0;
-}
-
-__setup("asix_mac=", setup_asix_mac);
+static int ax88772a_phy_powerup(struct usbnet *dev);
+static void ax8817x_mdio_write_le(struct net_device *netdev, int phy_id,
+ int loc, int val);
+static int ax8817x_mdio_read_le(struct net_device *netdev, int phy_id, int loc);
+static int ax88772b_set_csums(struct usbnet *dev);
/* ASIX AX8817X based USB 2.0 Ethernet Devices */
@@ -133,7 +101,7 @@ static int ax8817x_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
USB_CTRL_SET_TIMEOUT);
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs)
#else
static void ax8817x_async_cmd_callback(struct urb *urb)
@@ -149,16 +117,16 @@ static void ax8817x_async_cmd_callback(struct urb *urb)
usb_free_urb(urb);
}
-static int ax8817x_set_mac_addr (struct net_device *net, void *p)
+static int ax8817x_set_mac_addr(struct net_device *net, void *p)
{
struct usbnet *dev = netdev_priv(net);
struct sockaddr *addr = p;
- memcpy (net->dev_addr, addr->sa_data, ETH_ALEN);
+ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
/* Set the MAC address */
- return ax8817x_write_cmd (dev, AX88772_CMD_WRITE_NODE_ID,
- 0, 0, ETH_ALEN, net->dev_addr);
+ return ax8817x_write_cmd(dev, AX88772_CMD_WRITE_NODE_ID,
+ 0, 0, ETH_ALEN, net->dev_addr);
}
@@ -179,7 +147,7 @@ static void ax88178_status(struct usbnet *dev, struct urb *urb)
if (netif_carrier_ok(dev->net) != link) {
if (link) {
netif_carrier_on(dev->net);
- axusbnet_defer_kevent (dev, EVENT_LINK_RESET);
+ axusbnet_defer_kevent(dev, EVENT_LINK_RESET);
} else
netif_carrier_off(dev->net);
devwarn(dev, "ax88178 - Link status is: %d", link);
@@ -199,7 +167,7 @@ static void ax8817x_status(struct usbnet *dev, struct urb *urb)
if (netif_carrier_ok(dev->net) != link) {
if (link) {
netif_carrier_on(dev->net);
- axusbnet_defer_kevent (dev, EVENT_LINK_RESET );
+ axusbnet_defer_kevent(dev, EVENT_LINK_RESET);
} else
netif_carrier_off(dev->net);
devwarn(dev, "ax8817x - Link status is: %d", link);
@@ -211,13 +179,13 @@ static void ax88772_status(struct usbnet *dev, struct urb *urb)
struct ax88172_int_data *event;
struct ax88772_data *ax772_data = (struct ax88772_data *)dev->priv;
int link;
-
+
if (urb->actual_length < 8)
return;
event = urb->transfer_buffer;
link = event->link & 0x01;
-
+
if (netif_carrier_ok(dev->net) != link) {
if (link) {
netif_carrier_on(dev->net);
@@ -232,9 +200,9 @@ static void ax88772_status(struct usbnet *dev, struct urb *urb)
devwarn(dev, "ax88772 - Link status is: %d", link);
}
-
+
if (ax772_data->Event)
- queue_work (ax772_data->ax_work, &ax772_data->check_link);
+ queue_work(ax772_data->ax_work, &ax772_data->check_link);
}
static void ax88772a_status(struct usbnet *dev, struct urb *urb)
@@ -242,7 +210,7 @@ static void ax88772a_status(struct usbnet *dev, struct urb *urb)
struct ax88172_int_data *event;
struct ax88772a_data *ax772a_data = (struct ax88772a_data *)dev->priv;
int link;
- int PowSave = (ax772a_data->EepromData >> 14);
+ int powsave = (ax772a_data->EepromData >> 14);
if (urb->actual_length < 8)
return;
@@ -255,7 +223,7 @@ static void ax88772a_status(struct usbnet *dev, struct urb *urb)
if (link) {
netif_carrier_on(dev->net);
ax772a_data->Event = AX_SET_RX_CFG;
- } else if ((PowSave == 0x3) || (PowSave == 0x1)) {
+ } else if ((powsave == 0x3) || (powsave == 0x1)) {
netif_carrier_off(dev->net);
if (ax772a_data->Event == AX_NOP) {
ax772a_data->Event = CHK_CABLE_EXIST;
@@ -268,41 +236,53 @@ static void ax88772a_status(struct usbnet *dev, struct urb *urb)
devwarn(dev, "ax88772a - Link status is: %d", link);
}
-
+
if (ax772a_data->Event)
- queue_work (ax772a_data->ax_work, &ax772a_data->check_link);
+ queue_work(ax772a_data->ax_work, &ax772a_data->check_link);
}
static int ax88772b_stop(struct usbnet *dev)
{
u16 *medium;
- medium = kmalloc (2, GFP_ATOMIC);
+ medium = kmalloc(2, GFP_ATOMIC);
if (medium) {
- ax8817x_read_cmd (dev, AX_CMD_READ_MEDIUM_MODE, 0, 0, 2, medium);
- ax8817x_write_cmd (dev, AX_CMD_WRITE_MEDIUM_MODE,
- (*medium & ~AX88772_MEDIUM_RX_ENABLE), 0, 0, NULL);
+ ax8817x_read_cmd(dev, AX_CMD_READ_MEDIUM_MODE, 0, 0, 2, medium);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
+ (*medium & ~AX88772_MEDIUM_RX_ENABLE),
+ 0, 0, NULL);
- kfree (medium);
+ kfree(medium);
return 0;
}
return -EINVAL;
-
}
static int ax88772b_reset(struct usbnet *dev)
{
int ret;
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- AX88772_MEDIUM_DEFAULT, 0, 0, NULL)) < 0) {
+ /* Set the MAC address */
+ ret = ax8817x_write_cmd(dev, AX88772_CMD_WRITE_NODE_ID,
+ 0, 0, ETH_ALEN, dev->net->dev_addr);
+ if (ret < 0)
+ deverr(dev, "set MAC address failed: %d", ret);
+
+ /* stop MAC operation */
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, AX_RX_CTL_STOP,
+ 0, 0, NULL);
+ if (ret < 0)
+ deverr(dev, "Reset RX_CTL failed: %d", ret);
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
+ AX88772_MEDIUM_DEFAULT, 0, 0,
+ NULL);
+ if (ret < 0)
deverr(dev, "Write medium mode register: %d", ret);
- }
+
return ret;
-
}
-
static void ax88772b_status(struct usbnet *dev, struct urb *urb)
{
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
@@ -316,9 +296,9 @@ static void ax88772b_status(struct usbnet *dev, struct urb *urb)
return;
event = urb->transfer_buffer;
- if (ax772b_data->PhySelect == 0 && ax772b_data->OperationMode
- == OPERATION_MAC_MODE)
- link = event->link & AX_INT_SPLS_LINK;
+ if (ax772b_data->PhySelect == 0 &&
+ ax772b_data->OperationMode == OPERATION_MAC_MODE)
+ link = (event->link & AX_INT_SPLS_LINK) >> 1;
else
link = event->link & AX_INT_PPLS_LINK;
@@ -338,22 +318,83 @@ static void ax88772b_status(struct usbnet *dev, struct urb *urb)
int no_cable = (event->link & AX_INT_CABOFF_UNPLUG) ? 1 : 0;
if (no_cable) {
- if ((ax772b_data->psc &
+ if ((ax772b_data->psc &
(AX_SWRESET_IPPSL_0 | AX_SWRESET_IPPSL_1)) &&
!ax772b_data->pw_enabled) {
- /*
+ /*
* AX88772B already entered power saving state
*/
ax772b_data->pw_enabled = 1;
}
-/* Disable failing auto detach stuff for now */
-#if 0
- ax772b_data->Event = AX_CHK_AUTODETACH;
-#endif
+ if (ax772b_data->psc & AX_SWRESET_AUTODETACH)
+ ax772b_data->Event = AX_CHK_AUTODETACH;
+
+ } else {
+ /* AX88772B resumed from power saving state */
+ if (ax772b_data->pw_enabled ||
+ (jiffies > (ax772b_data->time_to_chk +
+ AX88772B_WATCHDOG))) {
+ if (ax772b_data->pw_enabled)
+ ax772b_data->pw_enabled = 0;
+ ax772b_data->Event = PHY_POWER_UP;
+ ax772b_data->time_to_chk = jiffies;
+ }
+ }
+ }
+
+ if (ax772b_data->Event)
+ queue_work(ax772b_data->ax_work, &ax772b_data->check_link);
+}
+
+static void ax88772c_status(struct usbnet *dev, struct urb *urb)
+{
+ struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
+ struct ax88172_int_data *event;
+ int link;
+
+ if (urb->actual_length < 8)
+ return;
+
+ if (ax772b_data->OperationMode == OPERATION_PHY_MODE)
+ return;
+
+ event = urb->transfer_buffer;
+ if (ax772b_data->PhySelect == 0 &&
+ ax772b_data->OperationMode == OPERATION_MAC_MODE)
+ link = (event->link & AX_INT_SPLS_LINK) >> 1;
+ else
+ link = event->link & AX_INT_PPLS_LINK;
+
+ if (netif_carrier_ok(dev->net) != link) {
+ if (link) {
+ netif_carrier_on(dev->net);
+ ax772b_data->Event = AX_SET_RX_CFG;
+ } else {
+ netif_carrier_off(dev->net);
+ ax772b_data->time_to_chk = jiffies;
+ }
+ devwarn(dev, "ax88772c - Link status is: %d", link);
+ }
+
+ if (!link) {
+
+ int no_cable = (event->link & AX_INT_CABOFF_UNPLUG) ? 1 : 0;
+
+ if (no_cable) {
+ if ((ax772b_data->psc &
+ (AX_SWRESET_IPPSL_0 | AX_SWRESET_IPPSL_1)) &&
+ !ax772b_data->pw_enabled) {
+ /*
+ * AX88772B already entered power saving state
+ */
+ ax772b_data->pw_enabled = 1;
+ }
+ if (ax772b_data->psc & AX_SWRESET_AUTODETACH)
+ ax772b_data->Event = AX_CHK_AUTODETACH;
} else {
/* AX88772B resumed from power saving state */
- if (ax772b_data->pw_enabled ||
- (jiffies > (ax772b_data->time_to_chk +
+ if (ax772b_data->pw_enabled ||
+ (jiffies > (ax772b_data->time_to_chk +
AX88772B_WATCHDOG))) {
if (ax772b_data->pw_enabled)
ax772b_data->pw_enabled = 0;
@@ -364,7 +405,7 @@ static void ax88772b_status(struct usbnet *dev, struct urb *urb)
}
if (ax772b_data->Event)
- queue_work (ax772b_data->ax_work, &ax772b_data->check_link);
+ queue_work(ax772b_data->ax_work, &ax772b_data->check_link);
}
void
@@ -375,13 +416,14 @@ ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
int status;
struct urb *urb;
- if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
+ if (urb == NULL) {
deverr(dev, "Error allocating URB in write_cmd_async!");
return;
}
- if ((req = kmalloc (sizeof (struct usb_ctrlrequest),
- GFP_ATOMIC)) == NULL) {
+ req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
+ if (req == NULL) {
deverr(dev, "Failed to allocate memory for control request");
usb_free_urb(urb);
return;
@@ -398,7 +440,8 @@ ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
(void *)req, data, size,
ax8817x_async_cmd_callback, req);
- if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status < 0) {
deverr(dev, "Error submitting the control message: status=%d",
status);
kfree(req);
@@ -413,10 +456,10 @@ static void ax8817x_set_multicast(struct net_device *net)
u8 rx_ctl = AX_RX_CTL_START | AX_RX_CTL_AB;
int mc_count;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
mc_count = net->mc_count;
#else
- mc_count = netdev_mc_count (net);
+ mc_count = netdev_mc_count(net);
#endif
if (net->flags & IFF_PROMISC) {
@@ -432,7 +475,7 @@ static void ax8817x_set_multicast(struct net_device *net)
* to avoid allocating memory that
* is tricky to free later */
u32 crc_bits;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
struct dev_mc_list *mc_list = net->mc_list;
int i;
@@ -450,7 +493,7 @@ static void ax8817x_set_multicast(struct net_device *net)
#else
struct netdev_hw_addr *ha;
memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
- netdev_for_each_mc_addr (ha, net) {
+ netdev_for_each_mc_addr(ha, net) {
crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
data->multi_filter[crc_bits >> 3] |=
1 << (crc_bits & 7);
@@ -472,10 +515,10 @@ static void ax88178_set_multicast(struct net_device *net)
u16 rx_ctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_MFB);
int mc_count;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
mc_count = net->mc_count;
#else
- mc_count = netdev_mc_count (net);
+ mc_count = netdev_mc_count(net);
#endif
if (net->flags & IFF_PROMISC) {
@@ -492,7 +535,7 @@ static void ax88178_set_multicast(struct net_device *net)
* is tricky to free later */
u32 crc_bits;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
struct dev_mc_list *mc_list = net->mc_list;
int i;
@@ -510,7 +553,7 @@ static void ax88178_set_multicast(struct net_device *net)
#else
struct netdev_hw_addr *ha;
memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
- netdev_for_each_mc_addr (ha, net) {
+ netdev_for_each_mc_addr(ha, net) {
crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
data->multi_filter[crc_bits >> 3] |=
1 << (crc_bits & 7);
@@ -532,10 +575,10 @@ static void ax88772b_set_multicast(struct net_device *net)
u16 rx_ctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_HEADER_DEFAULT);
int mc_count;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
mc_count = net->mc_count;
#else
- mc_count = netdev_mc_count (net);
+ mc_count = netdev_mc_count(net);
#endif
if (net->flags & IFF_PROMISC) {
@@ -552,7 +595,7 @@ static void ax88772b_set_multicast(struct net_device *net)
* is tricky to free later */
u32 crc_bits;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
struct dev_mc_list *mc_list = net->mc_list;
int i;
@@ -570,7 +613,7 @@ static void ax88772b_set_multicast(struct net_device *net)
#else
struct netdev_hw_addr *ha;
memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
- netdev_for_each_mc_addr (ha, net) {
+ netdev_for_each_mc_addr(ha, net) {
crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
data->multi_filter[crc_bits >> 3] |=
1 << (crc_bits & 7);
@@ -588,31 +631,39 @@ static void ax88772b_set_multicast(struct net_device *net)
static int ax8817x_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
struct usbnet *dev = netdev_priv(netdev);
- u16 *res;
- u16 ret;
+ u16 *res, ret;
+ u8 smsr;
+ int i = 0;
- res = kmalloc (2, GFP_ATOMIC);
+ res = kmalloc(2, GFP_ATOMIC);
if (!res)
return 0;
- ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+ do {
+ ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+
+ msleep(1);
+
+ ax8817x_read_cmd(dev, AX_CMD_READ_STATMNGSTS_REG, 0, 0, 1, &smsr);
+ } while (!(smsr & AX_HOST_EN) && (i++ < 30));
+
ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, res);
ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL);
ret = *res & 0xffff;
- kfree (res);
+ kfree(res);
return ret;
}
-static int
+static int
ax8817x_swmii_mdio_read(struct net_device *netdev, int phy_id, int loc)
{
struct usbnet *dev = netdev_priv(netdev);
u16 *res;
u16 ret;
- res = kmalloc (2, GFP_ATOMIC);
+ res = kmalloc(2, GFP_ATOMIC);
if (!res)
return 0;
@@ -620,7 +671,7 @@ ax8817x_swmii_mdio_read(struct net_device *netdev, int phy_id, int loc)
(__u16)loc, 2, res);
ret = *res & 0xffff;
- kfree (res);
+ kfree(res);
return ret;
}
@@ -628,13 +679,13 @@ ax8817x_swmii_mdio_read(struct net_device *netdev, int phy_id, int loc)
/* same as above, but converts resulting value to cpu byte order */
static int ax8817x_mdio_read_le(struct net_device *netdev, int phy_id, int loc)
{
- return le16_to_cpu(ax8817x_mdio_read(netdev,phy_id, loc));
+ return le16_to_cpu(ax8817x_mdio_read(netdev, phy_id, loc));
}
-static int
+static int
ax8817x_swmii_mdio_read_le(struct net_device *netdev, int phy_id, int loc)
{
- return le16_to_cpu(ax8817x_swmii_mdio_read(netdev,phy_id, loc));
+ return le16_to_cpu(ax8817x_swmii_mdio_read(netdev, phy_id, loc));
}
static void
@@ -642,27 +693,36 @@ ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
{
struct usbnet *dev = netdev_priv(netdev);
u16 *res;
+ u8 smsr;
+ int i = 0;
- res = kmalloc (2, GFP_ATOMIC);
+ res = kmalloc(2, GFP_ATOMIC);
if (!res)
return;
*res = val;
- ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+ do {
+ ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+
+ msleep(1);
+
+ ax8817x_read_cmd(dev, AX_CMD_READ_STATMNGSTS_REG, 0, 0, 1, &smsr);
+ } while (!(smsr & AX_HOST_EN) && (i++ < 30));
+
ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
- (__u16)loc, 2, res);
+ (__u16)loc, 2, res);
ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL);
- kfree (res);
+ kfree(res);
}
-static void ax8817x_swmii_mdio_write(struct net_device *netdev,
- int phy_id, int loc, int val)
+static void ax8817x_swmii_mdio_write(struct net_device *netdev, int phy_id,
+ int loc, int val)
{
struct usbnet *dev = netdev_priv(netdev);
u16 *res;
- res = kmalloc (2, GFP_ATOMIC);
+ res = kmalloc(2, GFP_ATOMIC);
if (!res)
return;
*res = val;
@@ -670,7 +730,7 @@ static void ax8817x_swmii_mdio_write(struct net_device *netdev,
ax8817x_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
(__u16)loc, 2, res);
- kfree (res);
+ kfree(res);
}
static void
@@ -679,7 +739,7 @@ ax88772b_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
struct usbnet *dev = netdev_priv(netdev);
u16 *res;
- res = kmalloc (2, GFP_ATOMIC);
+ res = kmalloc(2, GFP_ATOMIC);
if (!res)
return;
*res = val;
@@ -696,126 +756,145 @@ ax88772b_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL);
- kfree (res);
+ kfree(res);
}
/* same as above, but converts new value to le16 byte order before writing */
static void
ax8817x_mdio_write_le(struct net_device *netdev, int phy_id, int loc, int val)
{
- ax8817x_mdio_write( netdev, phy_id, loc, cpu_to_le16(val) );
+ ax8817x_mdio_write(netdev, phy_id, loc, cpu_to_le16(val));
}
static void ax8817x_swmii_mdio_write_le(struct net_device *netdev,
int phy_id, int loc, int val)
{
- ax8817x_swmii_mdio_write( netdev, phy_id, loc, cpu_to_le16(val) );
+ ax8817x_swmii_mdio_write(netdev, phy_id, loc, cpu_to_le16(val));
}
static void
ax88772b_mdio_write_le(struct net_device *netdev, int phy_id, int loc, int val)
{
- ax88772b_mdio_write( netdev, phy_id, loc, cpu_to_le16(val) );
+ ax88772b_mdio_write(netdev, phy_id, loc, cpu_to_le16(val));
}
-static int ax88772_suspend (struct usb_interface *intf,
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
- pm_message_t message)
+static int ax88772_suspend(struct usb_interface *intf,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10)
+ pm_message_t message)
#else
- u32 message)
+ u32 message)
#endif
{
struct usbnet *dev = usb_get_intfdata(intf);
u16 *medium;
- medium = kmalloc (2, GFP_ATOMIC);
+ medium = kmalloc(2, GFP_ATOMIC);
if (!medium)
- return axusbnet_suspend (intf, message);
+ return axusbnet_suspend(intf, message);
- ax8817x_read_cmd (dev, AX_CMD_READ_MEDIUM_MODE, 0, 0, 2, medium);
- ax8817x_write_cmd (dev, AX_CMD_WRITE_MEDIUM_MODE,
+ ax8817x_read_cmd(dev, AX_CMD_READ_MEDIUM_MODE, 0, 0, 2, medium);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
(*medium & ~AX88772_MEDIUM_RX_ENABLE), 0, 0, NULL);
- kfree (medium);
- return axusbnet_suspend (intf, message);
+ kfree(medium);
+ return axusbnet_suspend(intf, message);
}
-static int ax88772b_suspend (struct usb_interface *intf,
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
- pm_message_t message)
+static int ax88772b_suspend(struct usb_interface *intf,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10)
+ pm_message_t message)
#else
- u32 message)
+ u32 message)
#endif
{
struct usbnet *dev = usb_get_intfdata(intf);
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
u16 *tmp16;
u8 *opt;
+// u32 tmp32;
- tmp16 = kmalloc (2, GFP_ATOMIC);
+ tmp16 = kmalloc(2, GFP_ATOMIC);
if (!tmp16)
- return axusbnet_suspend (intf, message);
+ return axusbnet_suspend(intf, message);
opt = (u8 *)tmp16;
+#if 0
+ /* Read Wake-up Frame Array Register (Mask Wakeup Timer) */
+ ax8817x_read_cmd(dev, AX_CMD_READ_WKFARY, 0x0b, 0, 4, &tmp32);
+ tmp32 &= 0xFFF0FFFF;
+ /* 8 second */
+ tmp32 |= 0xFFF2FFFF;
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_WKFARY, 0x0b, 0, 4, &tmp32);
+#endif
+ /* Preserve BMCR for restoring */
+ ax772b_data->presvd_phy_bmcr = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_BMCR);
- ax8817x_read_cmd (dev, AX_CMD_READ_MEDIUM_MODE, 0, 0, 2, tmp16);
- ax8817x_write_cmd (dev, AX_CMD_WRITE_MEDIUM_MODE,
- (*tmp16 & ~AX88772_MEDIUM_RX_ENABLE), 0, 0, NULL);
+ /* Preserve Advertisement control reg for restoring */
+ ax772b_data->presvd_phy_advertise = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE);
+
+ ax8817x_read_cmd(dev, AX_CMD_READ_MEDIUM_MODE, 0, 0, 2, tmp16);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
+ (*tmp16 & ~AX88772_MEDIUM_RX_ENABLE),
+ 0, 0, NULL);
ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt);
if (!(*opt & AX_MONITOR_LINK) && !(*opt & AX_MONITOR_MAGIC)) {
- ax8817x_write_cmd (dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | AX_SWRESET_IPPD, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPRL | AX_SWRESET_IPPD,
+ 0, 0, NULL);
} else {
if (ax772b_data->psc & AX_SWRESET_WOLLP) {
- *tmp16 = ax8817x_mdio_read_le (dev->net,
- dev->mii.phy_id, MII_BMCR);
- ax8817x_mdio_write_le (dev->net, dev->mii.phy_id,
- MII_BMCR, *tmp16 | BMCR_ANENABLE);
+ *tmp16 = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MII_BMCR);
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id,
+ MII_BMCR, *tmp16 | BMCR_ANENABLE);
- ax8817x_write_cmd (dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | ax772b_data->psc, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPRL | ax772b_data->psc,
+ 0, 0, NULL);
}
if (ax772b_data->psc &
(AX_SWRESET_IPPSL_0 | AX_SWRESET_IPPSL_1)) {
*opt |= AX_MONITOR_LINK;
- ax8817x_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE,
- *opt, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, *opt,
+ 0, 0, NULL);
}
}
- kfree (tmp16);
- return axusbnet_suspend (intf, message);
+ kfree(tmp16);
+ return axusbnet_suspend(intf, message);
}
-static int ax88772_resume (struct usb_interface *intf)
+static int ax88772_resume(struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);
- netif_carrier_off (dev->net);
+ netif_carrier_off(dev->net);
- return axusbnet_resume (intf);
+ return axusbnet_resume(intf);
}
-static int ax88772b_resume (struct usb_interface *intf)
+static int ax88772b_resume(struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
if (ax772b_data->psc & AX_SWRESET_WOLLP) {
- ax8817x_write_cmd (dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | (ax772b_data->psc & 0x7FFF),
- 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPRL | (ax772b_data->psc & 0x7FFF),
+ 0, 0, NULL);
}
- if (ax772b_data->psc & (AX_SWRESET_IPPSL_0 | AX_SWRESET_IPPSL_1)) {
- ax88772a_phy_powerup (dev);
- }
+ if (ax772b_data->psc & (AX_SWRESET_IPPSL_0 | AX_SWRESET_IPPSL_1))
+ ax88772a_phy_powerup(dev);
- netif_carrier_off (dev->net);
+ netif_carrier_off(dev->net);
+
+ if (ax772b_data->OperationMode == OPERATION_PHY_MODE)
+ netif_carrier_on(dev->net);
- return axusbnet_resume (intf);
+ return axusbnet_resume(intf);
}
static int ax88172_link_reset(struct usbnet *dev)
@@ -845,12 +924,14 @@ ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
wolinfo->supported = 0;
wolinfo->wolopts = 0;
- opt = kmalloc (1, GFP_KERNEL);
+ opt = kmalloc(1, GFP_KERNEL);
if (!opt)
return;
- if (ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt) < 0)
+ if (ax8817x_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, opt) < 0) {
+ kfree(opt);
return;
+ }
wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
@@ -859,7 +940,7 @@ ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
if (*opt & AX_MONITOR_MAGIC)
wolinfo->wolopts |= WAKE_MAGIC;
- kfree (opt);
+ kfree(opt);
}
static int
@@ -868,7 +949,7 @@ ax8817x_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
struct usbnet *dev = netdev_priv(net);
u8 *opt;
- opt = kmalloc (1, GFP_KERNEL);
+ opt = kmalloc(1, GFP_KERNEL);
if (!opt)
return -ENOMEM;
@@ -880,7 +961,7 @@ ax8817x_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
ax8817x_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, *opt, 0, 0, NULL);
- kfree (opt);
+ kfree(opt);
return 0;
}
@@ -905,16 +986,17 @@ static int ax8817x_get_eeprom(struct net_device *net,
eeprom->magic = AX_EEPROM_MAGIC;
/* ax8817x returns 2 bytes from eeprom on read */
- for (i=0; i < eeprom->len / 2; i++) {
+ for (i = 0; i < eeprom->len / 2; i++) {
if (ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM,
- eeprom->offset + i, 0, 2, &ebuf[i]) < 0)
+ eeprom->offset + i, 0, 2,
+ &ebuf[i]) < 0)
return -EINVAL;
}
return 0;
}
-static void ax8817x_get_drvinfo (struct net_device *net,
- struct ethtool_drvinfo *info)
+static void ax8817x_get_drvinfo(struct net_device *net,
+ struct ethtool_drvinfo *info)
{
/* Inherit standard device info */
axusbnet_get_drvinfo(net, info);
@@ -924,13 +1006,13 @@ static void ax8817x_get_drvinfo (struct net_device *net,
static int ax8817x_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
{
struct usbnet *dev = netdev_priv(net);
- return mii_ethtool_gset(&dev->mii,cmd);
+ return mii_ethtool_gset(&dev->mii, cmd);
}
static int ax8817x_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
{
struct usbnet *dev = netdev_priv(net);
- return mii_ethtool_sset(&dev->mii,cmd);
+ return mii_ethtool_sset(&dev->mii, cmd);
}
/* We need to override some ethtool_ops so we require our
@@ -949,14 +1031,14 @@ static struct ethtool_ops ax8817x_ethtool_ops = {
.set_settings = ax8817x_set_settings,
};
-static int ax8817x_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
+static int ax8817x_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
{
struct usbnet *dev = netdev_priv(net);
return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
}
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
static const struct net_device_ops ax88x72_netdev_ops = {
.ndo_open = axusbnet_open,
.ndo_stop = axusbnet_stop,
@@ -967,7 +1049,7 @@ static const struct net_device_ops ax88x72_netdev_ops = {
.ndo_do_ioctl = ax8817x_ioctl,
.ndo_set_mac_address = ax8817x_set_mac_addr,
.ndo_validate_addr = eth_validate_addr,
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,2,0)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 2, 0)
.ndo_set_multicast_list = ax8817x_set_multicast,
#else
.ndo_set_rx_mode = ax8817x_set_multicast,
@@ -975,7 +1057,7 @@ static const struct net_device_ops ax88x72_netdev_ops = {
};
#endif
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
static const struct net_device_ops ax88178_netdev_ops = {
.ndo_open = axusbnet_open,
.ndo_stop = axusbnet_stop,
@@ -986,7 +1068,7 @@ static const struct net_device_ops ax88178_netdev_ops = {
.ndo_do_ioctl = ax8817x_ioctl,
.ndo_set_mac_address = ax8817x_set_mac_addr,
.ndo_validate_addr = eth_validate_addr,
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,2,0)
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 2, 0)
.ndo_set_multicast_list = ax88178_set_multicast,
#else
.ndo_set_rx_mode = ax88178_set_multicast,
@@ -994,6 +1076,146 @@ static const struct net_device_ops ax88178_netdev_ops = {
};
#endif
+static int access_eeprom_mac(struct usbnet *dev, u8 *buf, u8 offset, bool wflag)
+{
+ int ret = 0, i;
+ u16* tmp = (u16*)buf;
+
+ if (wflag) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_EEPROM_EN,
+ 0, 0, 0, NULL);
+ if (ret < 0)
+ return ret;
+
+ mdelay(15);
+ }
+
+ for (i = 0; i < (ETH_ALEN >> 1); i++) {
+ if (wflag) {
+ u16 wd = cpu_to_le16(*(tmp + i));
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_EEPROM, offset + i,
+ wd, 0, NULL);
+ if (ret < 0)
+ break;
+
+ mdelay(15);
+ }
+ else {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM,
+ offset + i, 0, 2, tmp + i);
+ if (ret < 0)
+ break;
+ }
+ }
+
+ if (!wflag) {
+ if (ret < 0) {
+ netdev_dbg(dev->net, "Failed to read MAC address from EEPROM: %d\n", ret);
+ return ret;
+ }
+ memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+ }
+ else {
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_EEPROM_DIS,
+ 0, 0, 0, NULL);
+ if (ret < 0)
+ return ret;
+
+ /* reload eeprom data */
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ AXGPIOS_RSE, 0, 0, NULL);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int ax8817x_check_ether_addr(struct usbnet *dev)
+{
+ unsigned char *tmp = (unsigned char*)dev->net->dev_addr;
+ u8 default_mac[6] = {0, 0x0e, 0xc6, 0x87, 0x72, 0x01};
+
+ if (((*((u8*)tmp) == 0) && (*((u8*)tmp + 1) == 0) && (*((u8*)tmp + 2) == 0)) ||
+ !is_valid_ether_addr((u8*)tmp) ||
+ !memcmp(dev->net->dev_addr, default_mac, ETH_ALEN)) {
+ int i;
+
+ printk("Found invalid EEPROM MAC address value ");
+
+ for (i = 0; i < ETH_ALEN; i++) {
+ printk("%02X", *((u8*)tmp + i));
+ if (i != 5)
+ printk("-");
+ }
+ printk("\n");
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
+ eth_hw_addr_random(dev->net);
+#else
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
+ dev->net->addr_assign_type |= NET_ADDR_RANDOM;
+#endif
+ random_ether_addr(dev->net->dev_addr);
+#endif
+ *tmp = 0;
+ *(tmp + 1) = 0x0E;
+ *(tmp + 2) = 0xC6;
+ *(tmp + 3) = 0x8F;
+
+ return -EADDRNOTAVAIL;
+ }
+ return 0;
+}
+
+static int ax8817x_get_mac(struct usbnet *dev, u8* buf)
+{
+ int ret, i;
+
+
+ ret = access_eeprom_mac(dev, buf, 0x04, 0);
+ if (ret < 0)
+ goto out;
+
+ if (ax8817x_check_ether_addr(dev)) {
+ ret = access_eeprom_mac(dev, dev->net->dev_addr, 0x04, 1);
+ if (ret < 0) {
+ deverr(dev, "Failed to write MAC to EEPROM: %d", ret);
+ goto out;
+ }
+
+ msleep(5);
+
+ ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID,
+ 0, 0, ETH_ALEN, buf);
+ if (ret < 0) {
+ deverr(dev, "Failed to read MAC address: %d", ret);
+ goto out;
+ }
+
+ for (i = 0; i < ETH_ALEN; i++)
+ if (*(dev->net->dev_addr + i) != *((u8*)buf + i)) {
+ devwarn(dev, "Found invalid EEPROM part or non-EEPROM");
+ break;
+ }
+ }
+
+ memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN);
+
+ /* Set the MAC address */
+ ax8817x_write_cmd (dev, AX88772_CMD_WRITE_NODE_ID, 0, 0,
+ ETH_ALEN, dev->net->dev_addr);
+
+ if (ret < 0) {
+ deverr(dev, "Failed to write MAC address: %d", ret);
+ goto out;
+ }
+
+ return 0;
+out:
+ return ret;
+}
+
static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
{
int ret = 0;
@@ -1002,41 +1224,43 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
unsigned long gpio_bits = dev->driver_info->data;
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
- axusbnet_get_endpoints(dev,intf);
+ axusbnet_get_endpoints(dev, intf);
buf = kmalloc(ETH_ALEN, GFP_KERNEL);
- if(!buf) {
+ if (!buf) {
ret = -ENOMEM;
goto out1;
}
/* Toggle the GPIOs in a manufacturer/model specific way */
for (i = 2; i >= 0; i--) {
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
- (gpio_bits >> (i * 8)) & 0xff, 0, 0,
- NULL)) < 0)
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ (gpio_bits >> (i * 8)) & 0xff,
+ 0, 0, NULL);
+ if (ret < 0)
goto out2;
+
msleep(5);
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- 0x80, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "send AX_CMD_WRITE_RX_CTL failed: %d", ret);
goto out2;
}
/* Get the MAC address */
memset(buf, 0, ETH_ALEN);
- if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID,
- 0, 0, 6, buf)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf);
+ if (ret < 0) {
deverr(dev, "read AX_CMD_READ_NODE_ID failed: %d", ret);
goto out2;
}
memcpy(dev->net->dev_addr, buf, ETH_ALEN);
/* Get the PHY id */
- if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID,
- 0, 0, 2, buf)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
+ if (ret < 0) {
deverr(dev, "error on read AX_CMD_READ_PHY_ID: %02x", ret);
goto out2;
} else if (ret < 2) {
@@ -1055,7 +1279,7 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
dev->mii.reg_num_mask = 0x1f;
dev->mii.phy_id = *((u8 *)buf + 1);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
dev->net->do_ioctl = ax8817x_ioctl;
dev->net->set_multicast_list = ax8817x_set_multicast;
dev->net->set_mac_address = ax8817x_set_mac_addr;
@@ -1074,7 +1298,7 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
mii_nway_restart(&dev->mii);
- printk (version);
+ printk(version);
return 0;
out2:
@@ -1103,41 +1327,42 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
struct ax88772_data *ax772_data = NULL;
- axusbnet_get_endpoints(dev,intf);
+ axusbnet_get_endpoints(dev, intf);
buf = kmalloc(6, GFP_KERNEL);
- if(!buf) {
+ if (!buf) {
deverr(dev, "Cannot allocate memory for buffer");
ret = -ENOMEM;
goto out1;
}
- ax772_data = kmalloc (sizeof(*ax772_data), GFP_KERNEL);
- if (!ax772_data) {
- deverr(dev, "Cannot allocate memory for AX88772 data");
- kfree (buf);
- return -ENOMEM;
- }
- memset (ax772_data, 0, sizeof(*ax772_data));
- dev->priv = ax772_data;
-
- ax772_data->ax_work = create_singlethread_workqueue ("ax88772");
- if (!ax772_data->ax_work) {
- kfree (ax772_data);
- kfree (buf);
- return -ENOMEM;
- }
-
- ax772_data->dev = dev;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- INIT_WORK (&ax772_data->check_link, ax88772_link_reset, dev);
+ ax772_data = kmalloc(sizeof(*ax772_data), GFP_KERNEL);
+ if (!ax772_data) {
+ deverr(dev, "Cannot allocate memory for AX88772 data");
+ kfree(buf);
+ return -ENOMEM;
+ }
+
+ memset(ax772_data, 0, sizeof(*ax772_data));
+ dev->priv = ax772_data;
+
+ ax772_data->ax_work = create_singlethread_workqueue("ax88772");
+ if (!ax772_data->ax_work) {
+ kfree(ax772_data);
+ kfree(buf);
+ return -ENOMEM;
+ }
+
+ ax772_data->dev = dev;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ INIT_WORK(&ax772_data->check_link, ax88772_link_reset, dev);
#else
- INIT_WORK (&ax772_data->check_link, ax88772_link_reset);
+ INIT_WORK(&ax772_data->check_link, ax88772_link_reset);
#endif
/* reload eeprom data */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
- 0x00B0, 0, 0, NULL)) < 0)
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, 0x00B0, 0, 0, NULL);
+ if (ret < 0)
goto out2;
msleep(5);
@@ -1150,8 +1375,8 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
dev->mii.reg_num_mask = 0xff;
/* Get the PHY id */
- if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID,
- 0, 0, 2, buf)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
+ if (ret < 0) {
deverr(dev, "Error reading PHY ID: %02x", ret);
goto out2;
} else if (ret < 2) {
@@ -1163,106 +1388,112 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
}
dev->mii.phy_id = *((u8 *)buf + 1);
- if (dev->mii.phy_id == 0x10)
- {
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
- 0x0001, 0, 0, NULL)) < 0) {
+ if (dev->mii.phy_id == 0x10) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
+ 0x0001, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Select PHY #1 failed: %d", ret);
goto out2;
}
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPPD,
- 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to power down PHY: %d", ret);
goto out2;
}
msleep(150);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_CLEAR,
- 0, 0, NULL)) < 0) {
- deverr(dev,
- "Failed to perform software reset: %d", ret);
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR,
+ 0, 0, NULL);
+ if (ret < 0) {
+ deverr(dev, "Failed to perform software reset: %d",
+ ret);
goto out2;
}
msleep(150);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | AX_SWRESET_PRL,
- 0, 0, NULL)) < 0) {
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPRL | AX_SWRESET_PRL,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev,
"Failed to set PHY reset control: %d", ret);
goto out2;
}
- }
- else
- {
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
- 0x0000, 0, 0, NULL)) < 0) {
+ } else {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
+ 0x0000, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Select PHY #1 failed: %d", ret);
goto out2;
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
AX_SWRESET_IPPD | AX_SWRESET_PRL,
- 0, 0, NULL)) < 0) {
- deverr(dev,
- "Failed to power down internal PHY: %d", ret);
+ 0, 0, NULL);
+ if (ret < 0) {
+ deverr(dev, "Failed to power down internal PHY: %d",
+ ret);
goto out2;
}
}
msleep(150);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- 0x0000, 0, 0, NULL)) < 0) {
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
+ 0x0000, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to reset RX_CTL: %d", ret);
goto out2;
}
/* Get the MAC address */
memset(buf, 0, ETH_ALEN);
- if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID,
- 0, 0, ETH_ALEN, buf)) < 0) {
- deverr(dev, "Failed to read MAC address: %d", ret);
+ ret = ax8817x_get_mac(dev, buf);
+ if (ret < 0) {
+ deverr(dev, "Get HW address failed: %d", ret);
goto out2;
}
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Enabling software MII failed: %d", ret);
goto out2;
}
- if (dev->mii.phy_id == 0x10)
- {
- if ((ret = ax8817x_mdio_read_le(dev->net,
- dev->mii.phy_id, 2)) != 0x003b) {
+ if (dev->mii.phy_id == 0x10) {
+ ret = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, 2);
+ if (ret != 0x003b) {
deverr(dev, "Read PHY register 2 must be 0x3b00: %d",
- ret);
+ ret);
goto out2;
}
-
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_PRL,
- 0, 0, NULL)) < 0) {
- deverr(dev, "Set external PHY reset pin level: %d", ret);
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL,
+ 0, 0, NULL);
+ if (ret < 0) {
+ deverr(dev, "Set external PHY reset pin level: %d",
+ ret);
goto out2;
}
msleep(150);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | AX_SWRESET_PRL,
- 0, 0, NULL)) < 0) {
- deverr(dev,
- "Set Internal/External PHY reset control: %d",
- ret);
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPRL | AX_SWRESET_PRL,
+ 0, 0, NULL);
+ if (ret < 0) {
+ deverr(dev,
+ "Set Internal/External PHY reset control: %d",
+ ret);
goto out2;
}
msleep(150);
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
dev->net->do_ioctl = ax8817x_ioctl;
dev->net->set_multicast_list = ax8817x_set_multicast;
dev->net->set_mac_address = ax8817x_set_mac_addr;
@@ -1281,31 +1512,33 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
ADVERTISE_ALL | ADVERTISE_CSMA);
mii_nway_restart(&dev->mii);
- ax772_data->autoneg_start = jiffies;
- ax772_data->Event = WAIT_AUTONEG_COMPLETE;
+ ax772_data->autoneg_start = jiffies;
+ ax772_data->Event = WAIT_AUTONEG_COMPLETE;
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Write medium mode register: %d", ret);
goto out2;
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
- AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT << 8,
- AX88772_IPG2_DEFAULT, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
+ AX88772_IPG0_DEFAULT |
+ (AX88772_IPG1_DEFAULT << 8),
+ AX88772_IPG2_DEFAULT, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Write IPG,IPG1,IPG2 failed: %d", ret);
goto out2;
}
- if ((ret =
- ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL)) < 0) {
+
+ ret = ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to set hardware MII: %02x", ret);
goto out2;
}
/* Set RX_CTL to default values with 2k buffer, and enable cactus */
- if ((ret =
- ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0,
- NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto out2;
}
@@ -1317,13 +1550,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
dev->rx_urb_size = 2048;
}
- kfree (buf);
- printk (version);
+ kfree(buf);
+ printk(version);
return 0;
out2:
- destroy_workqueue (ax772_data->ax_work);
- kfree (ax772_data);
+ destroy_workqueue(ax772_data->ax_work);
+ kfree(ax772_data);
kfree(buf);
out1:
return ret;
@@ -1334,38 +1567,38 @@ static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
struct ax88772_data *ax772_data = (struct ax88772_data *)dev->priv;
if (ax772_data) {
-
- flush_workqueue (ax772_data->ax_work);
- destroy_workqueue (ax772_data->ax_work);
+ flush_workqueue(ax772_data->ax_work);
+ destroy_workqueue(ax772_data->ax_work);
/* stop MAC operation */
- ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- AX_RX_CTL_STOP, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, AX_RX_CTL_STOP,
+ 0, 0, NULL);
/* Power down PHY */
- ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPPD, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD,
+ 0, 0, NULL);
- kfree (ax772_data);
+ kfree(ax772_data);
}
}
-static int ax88772a_phy_powerup (struct usbnet *dev)
+static int ax88772a_phy_powerup(struct usbnet *dev)
{
int ret;
/* set the embedded Ethernet PHY in power-down state */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPPD | AX_SWRESET_IPRL, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPPD | AX_SWRESET_IPRL, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to power down PHY: %d", ret);
return ret;
}
msleep(10);
-
/* set the embedded Ethernet PHY in power-up state */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to reset PHY: %d", ret);
return ret;
}
@@ -1373,15 +1606,17 @@ static int ax88772a_phy_powerup (struct usbnet *dev)
msleep(600);
/* set the embedded Ethernet PHY in reset state */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_CLEAR, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to power up PHY: %d", ret);
return ret;
}
/* set the embedded Ethernet PHY in power-up state */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to reset PHY: %d", ret);
return ret;
}
@@ -1396,50 +1631,54 @@ static int ax88772a_bind(struct usbnet *dev, struct usb_interface *intf)
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
struct ax88772a_data *ax772a_data = NULL;
- axusbnet_get_endpoints(dev,intf);
+ printk(version);
+
+ axusbnet_get_endpoints(dev, intf);
buf = kmalloc(6, GFP_KERNEL);
- if(!buf) {
+ if (!buf) {
deverr(dev, "Cannot allocate memory for buffer");
ret = -ENOMEM;
goto out1;
}
- ax772a_data = kmalloc (sizeof(*ax772a_data), GFP_KERNEL);
+ ax772a_data = kmalloc(sizeof(*ax772a_data), GFP_KERNEL);
if (!ax772a_data) {
deverr(dev, "Cannot allocate memory for AX88772A data");
- kfree (buf);
+ kfree(buf);
return -ENOMEM;
}
- memset (ax772a_data, 0, sizeof(*ax772a_data));
+ memset(ax772a_data, 0, sizeof(*ax772a_data));
dev->priv = ax772a_data;
- ax772a_data->ax_work = create_singlethread_workqueue ("ax88772a");
+ ax772a_data->ax_work = create_singlethread_workqueue("ax88772a");
if (!ax772a_data->ax_work) {
- kfree (ax772a_data);
- kfree (buf);
+ kfree(ax772a_data);
+ kfree(buf);
return -ENOMEM;
}
ax772a_data->dev = dev;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- INIT_WORK (&ax772a_data->check_link, ax88772a_link_reset, dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ INIT_WORK(&ax772a_data->check_link, ax88772a_link_reset, dev);
#else
- INIT_WORK (&ax772a_data->check_link, ax88772a_link_reset);
+ INIT_WORK(&ax772a_data->check_link, ax88772a_link_reset);
#endif
/* Get the EEPROM data*/
- if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM,
- 0x0017, 0, 2, (void *)&ax772a_data->EepromData)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2,
+ (void *)&ax772a_data->EepromData);
+ if (ret < 0) {
deverr(dev, "read SROM address 17h failed: %d", ret);
goto out2;
}
- le16_to_cpus (&ax772a_data->EepromData);
+ le16_to_cpus(&ax772a_data->EepromData);
/* End of get EEPROM data */
/* reload eeprom data */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
- AXGPIOS_RSE, 0, 0, NULL)) < 0)
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ AXGPIOS_RSE, 0, 0, NULL);
+ if (ret < 0)
goto out2;
msleep(5);
@@ -1452,8 +1691,8 @@ static int ax88772a_bind(struct usbnet *dev, struct usb_interface *intf)
dev->mii.reg_num_mask = 0xff;
/* Get the PHY id */
- if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID,
- 0, 0, 2, buf)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
+ if (ret < 0) {
deverr(dev, "Error reading PHY ID: %02x", ret);
goto out2;
} else if (ret < 2) {
@@ -1464,46 +1703,48 @@ static int ax88772a_bind(struct usbnet *dev, struct usb_interface *intf)
}
dev->mii.phy_id = *((u8 *)buf + 1);
- if(dev->mii.phy_id != 0x10) {
+ if (dev->mii.phy_id != 0x10) {
deverr(dev, "Got wrong PHY ID: %02x", dev->mii.phy_id);
goto out2;
}
/* select the embedded 10/100 Ethernet PHY */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
AX_PHYSEL_SSEN | AX_PHYSEL_PSEL | AX_PHYSEL_SSMII,
- 0, 0, NULL)) < 0) {
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Select PHY #1 failed: %d", ret);
goto out2;
}
- if ((ret = ax88772a_phy_powerup (dev)) < 0)
+ ret = ax88772a_phy_powerup(dev);
+ if (ret < 0)
goto out2;
/* stop MAC operation */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- AX_RX_CTL_STOP, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, AX_RX_CTL_STOP,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto out2;
}
/* Get the MAC address */
memset(buf, 0, ETH_ALEN);
- if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID,
- 0, 0, ETH_ALEN, buf)) < 0) {
- deverr(dev, "Failed to read MAC address: %d", ret);
+ ret = ax8817x_get_mac(dev, buf);
+ if (ret < 0) {
+ deverr(dev, "Get HW address failed: %d", ret);
goto out2;
- }
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
+ }
/* make sure the driver can enable sw mii operation */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Enabling software MII failed: %d", ret);
goto out2;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
dev->net->do_ioctl = ax8817x_ioctl;
dev->net->set_multicast_list = ax8817x_set_multicast;
dev->net->set_mac_address = ax8817x_set_mac_addr;
@@ -1525,23 +1766,43 @@ static int ax88772a_bind(struct usbnet *dev, struct usb_interface *intf)
ax772a_data->autoneg_start = jiffies;
ax772a_data->Event = WAIT_AUTONEG_COMPLETE;
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
+ 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Write medium mode register: %d", ret);
goto out2;
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
AX88772A_IPG0_DEFAULT | AX88772A_IPG1_DEFAULT << 8,
- AX88772A_IPG2_DEFAULT, 0, NULL)) < 0) {
+ AX88772A_IPG2_DEFAULT, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Write IPG,IPG1,IPG2 failed: %d", ret);
goto out2;
}
+ memset(buf, 0, 4);
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_IPG012, 0, 0, 3, buf);
+ *((u8 *)buf + 3) = 0x00;
+ if (ret < 0) {
+ deverr(dev, "Failed to read IPG,IPG1,IPG2 failed: %d", ret);
+ goto out2;
+ } else {
+ __u32 tmp32 = *((u32*)buf);
+ le32_to_cpus(&tmp32);
+ if (tmp32 != (AX88772A_IPG2_DEFAULT << 16 |
+ AX88772A_IPG1_DEFAULT << 8 | AX88772A_IPG0_DEFAULT)) {
+ printk("Non-authentic ASIX product\nASIX does not support it\n");
+ ret = -ENODEV;
+ goto out2;
+ }
+ }
+
/* Set RX_CTL to default values with 2k buffer, and enable cactus */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
(AX_RX_CTL_START | AX_RX_CTL_AB),
- 0, 0, NULL)) < 0) {
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto out2;
}
@@ -1553,15 +1814,13 @@ static int ax88772a_bind(struct usbnet *dev, struct usb_interface *intf)
dev->rx_urb_size = 2048;
}
- kfree (buf);
-
- printk (version);
+ kfree(buf);
return ret;
out2:
- destroy_workqueue (ax772a_data->ax_work);
- kfree (ax772a_data);
- kfree (buf);
+ destroy_workqueue(ax772a_data->ax_work);
+ kfree(ax772a_data);
+ kfree(buf);
out1:
return ret;
}
@@ -1572,8 +1831,8 @@ static void ax88772a_unbind(struct usbnet *dev, struct usb_interface *intf)
if (ax772a_data) {
- flush_workqueue (ax772a_data->ax_work);
- destroy_workqueue (ax772a_data->ax_work);
+ flush_workqueue(ax772a_data->ax_work);
+ destroy_workqueue(ax772a_data->ax_work);
/* stop MAC operation */
ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
@@ -1583,7 +1842,7 @@ static void ax88772a_unbind(struct usbnet *dev, struct usb_interface *intf)
ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
AX_SWRESET_IPPD, 0, 0, NULL);
- kfree (ax772a_data);
+ kfree(ax772a_data);
}
}
@@ -1597,7 +1856,7 @@ static int ax88772b_set_csums(struct usbnet *dev)
else
checksum = 0;
- ax8817x_write_cmd (dev, AX_CMD_WRITE_RXCOE_CTL,
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_RXCOE_CTL,
checksum, 0, 0, NULL);
if (ax772b_data->checksum & AX_TX_CHECKSUM)
@@ -1605,18 +1864,18 @@ static int ax88772b_set_csums(struct usbnet *dev)
else
checksum = 0;
- ax8817x_write_cmd (dev, AX_CMD_WRITE_TXCOE_CTL,
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_TXCOE_CTL,
checksum, 0, 0, NULL);
return 0;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
static u32 ax88772b_get_tx_csum(struct net_device *netdev)
{
struct usbnet *dev = netdev_priv(netdev);
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
- return (ax772b_data->checksum & AX_TX_CHECKSUM);
+ return ax772b_data->checksum & AX_TX_CHECKSUM;
}
static u32 ax88772b_get_rx_csum(struct net_device *netdev)
@@ -1624,7 +1883,7 @@ static u32 ax88772b_get_rx_csum(struct net_device *netdev)
struct usbnet *dev = netdev_priv(netdev);
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
- return (ax772b_data->checksum & AX_RX_CHECKSUM);
+ return ax772b_data->checksum & AX_RX_CHECKSUM;
}
static int ax88772b_set_rx_csum(struct net_device *netdev, u32 val)
@@ -1666,7 +1925,7 @@ static struct ethtool_ops ax88772b_ethtool_ops = {
.get_eeprom = ax8817x_get_eeprom,
.get_settings = ax8817x_get_settings,
.set_settings = ax8817x_set_settings,
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
.set_tx_csum = ax88772b_set_tx_csum,
.get_tx_csum = ax88772b_get_tx_csum,
.get_rx_csum = ax88772b_get_rx_csum,
@@ -1674,18 +1933,18 @@ static struct ethtool_ops ax88772b_ethtool_ops = {
#endif
};
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
static const struct net_device_ops ax88772b_netdev_ops = {
- .ndo_open = axusbnet_open,
- .ndo_stop = axusbnet_stop,
- .ndo_start_xmit = axusbnet_start_xmit,
- .ndo_tx_timeout = axusbnet_tx_timeout,
- .ndo_change_mtu = axusbnet_change_mtu,
+ .ndo_open = axusbnet_open,
+ .ndo_stop = axusbnet_stop,
+ .ndo_start_xmit = axusbnet_start_xmit,
+ .ndo_tx_timeout = axusbnet_tx_timeout,
+ .ndo_change_mtu = axusbnet_change_mtu,
.ndo_do_ioctl = ax8817x_ioctl,
.ndo_get_stats = axusbnet_get_stats,
- .ndo_set_mac_address = ax8817x_set_mac_addr,
- .ndo_validate_addr = eth_validate_addr,
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,2,0)
+ .ndo_set_mac_address = ax8817x_set_mac_addr,
+ .ndo_validate_addr = eth_validate_addr,
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 2, 0)
.ndo_set_multicast_list = ax88772b_set_multicast,
#else
.ndo_set_rx_mode = ax88772b_set_multicast,
@@ -1700,83 +1959,83 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
struct ax88772b_data *ax772b_data;
u16 *tmp16;
- u8 i;
- u8 TempPhySelect;
- bool InternalPhy;
- u8 default_asix_mac[ETH_ALEN] = { 0x00, 0x0e, 0xc6, 0x87, 0x72, 0x01 };
+ u8 tempphyselect;
+ bool internalphy;
+
+ printk(version);
- axusbnet_get_endpoints(dev,intf);
+ axusbnet_get_endpoints(dev, intf);
- buf = kmalloc (6, GFP_KERNEL);
+ buf = kmalloc(6, GFP_KERNEL);
if (!buf) {
deverr(dev, "Cannot allocate memory for buffer");
return -ENOMEM;
}
tmp16 = (u16 *)buf;
- ax772b_data = kmalloc (sizeof(*ax772b_data), GFP_KERNEL);
+ ax772b_data = kmalloc(sizeof(*ax772b_data), GFP_KERNEL);
if (!ax772b_data) {
deverr(dev, "Cannot allocate memory for AX88772B data");
- kfree (buf);
+ kfree(buf);
return -ENOMEM;
}
- memset (ax772b_data, 0, sizeof(*ax772b_data));
+ memset(ax772b_data, 0, sizeof(*ax772b_data));
dev->priv = ax772b_data;
- ax772b_data->ax_work = create_singlethread_workqueue ("ax88772b");
+ ax772b_data->ax_work = create_singlethread_workqueue("ax88772b");
if (!ax772b_data->ax_work) {
- kfree (buf);
- kfree (ax772b_data);
+ kfree(buf);
+ kfree(ax772b_data);
return -ENOMEM;
}
ax772b_data->dev = dev;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- INIT_WORK (&ax772b_data->check_link, ax88772b_link_reset, dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ INIT_WORK(&ax772b_data->check_link, ax88772b_link_reset, dev);
#else
- INIT_WORK (&ax772b_data->check_link, ax88772b_link_reset);
+ INIT_WORK(&ax772b_data->check_link, ax88772b_link_reset);
#endif
-
- if ((ret = ax8817x_read_cmd (dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1,
- &TempPhySelect)) < 0) {
- deverr(dev, "read SW interface selection status register"
- "failed: %d\n", ret);
+ ret = ax8817x_read_cmd(dev, AX_CMD_SW_PHY_STATUS,
+ 0, 0, 1, &tempphyselect);
+ if (ret < 0) {
+ deverr(dev,
+ "read SW interface selection status register failed: %d\n",
+ ret);
goto err_out;
}
- TempPhySelect &= 0x0C;
+ tempphyselect &= 0x0C;
- if (TempPhySelect == AX_PHYSEL_SSRMII) {
- InternalPhy = false;
+ if (tempphyselect == AX_PHYSEL_SSRMII) {
+ internalphy = false;
ax772b_data->OperationMode = OPERATION_MAC_MODE;
ax772b_data->PhySelect = 0x00;
- }
- else if (TempPhySelect == AX_PHYSEL_SSRRMII) {
- InternalPhy = true;
+ } else if (tempphyselect == AX_PHYSEL_SSRRMII) {
+ internalphy = true;
ax772b_data->OperationMode = OPERATION_PHY_MODE;
ax772b_data->PhySelect = 0x00;
- }
- else if (TempPhySelect == AX_PHYSEL_SSMII) {
- InternalPhy = true;
+ } else if (tempphyselect == AX_PHYSEL_SSMII) {
+ internalphy = true;
ax772b_data->OperationMode = OPERATION_MAC_MODE;
ax772b_data->PhySelect = 0x01;
- }
- else {
+ } else {
deverr(dev, "Unknown MII type\n");
goto err_out;
}
/* reload eeprom data */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
- AXGPIOS_RSE, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, AXGPIOS_RSE,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to enable GPIO finction: %d", ret);
goto err_out;
}
msleep(5);
/* Get the EEPROM data*/
- if ((ret = ax8817x_read_cmd (dev, AX_CMD_READ_EEPROM,
- 0x18, 0, 2, (void *)tmp16)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM, 0x18, 0, 2,
+ (void *)tmp16);
+ if (ret < 0) {
deverr(dev, "read SROM address 18h failed: %d", ret);
goto err_out;
}
@@ -1784,36 +2043,11 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
ax772b_data->psc = *tmp16 & 0xFF00;
/* End of get EEPROM data */
- /* Get the MAC address from EEPROM */
+ /* Get the MAC address */
memset(buf, 0, ETH_ALEN);
- for (i = 0; i < (ETH_ALEN >> 1); i++) {
- if ((ret = ax8817x_read_cmd (dev, AX_CMD_READ_EEPROM,
- 0x04 + i, 0, 2, (buf + i * 2))) < 0) {
- deverr(dev, "read SROM address 04h failed: %d", ret);
- goto err_out;
- }
- }
-
- /* Check for default ASIX MAC (e.g. 00:0e:c6:87:72:01) in case of no EEPROM being present */
- if (!memcmp(buf, default_asix_mac, ETH_ALEN)) {
- if (g_usr_mac && (g_usr_mac < 3)) {
- /* Get user set MAC address */
- if (g_usr_mac == 2) {
- /* 0x100000 offset for 2nd Ethernet MAC */
- g_mac_addr[3] += 0x10;
- if (g_mac_addr[3] < 0x10)
- devwarn(dev, "MAC address byte 3 (0x%02x) wrap around", g_mac_addr[3]);
- }
- memcpy(buf, g_mac_addr, ETH_ALEN);
- g_usr_mac++;
- } else devwarn(dev, "using default ASIX MAC");
- }
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
-
- /* Set the MAC address */
- if ((ret = ax8817x_write_cmd (dev, AX88772_CMD_WRITE_NODE_ID,
- 0, 0, ETH_ALEN, buf)) < 0) {
- deverr(dev, "set MAC address failed: %d", ret);
+ ret = ax8817x_get_mac(dev, buf);
+ if (ret < 0) {
+ deverr(dev, "Get HW address failed: %d", ret);
goto err_out;
}
@@ -1825,8 +2059,8 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
dev->mii.reg_num_mask = 0xff;
/* Get the PHY id */
- if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID,
- 0, 0, 2, buf)) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
+ if (ret < 0) {
deverr(dev, "Error reading PHY ID: %02x", ret);
goto err_out;
} else if (ret < 2) {
@@ -1837,50 +2071,54 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
goto err_out;
}
- if (InternalPhy)
+ if (internalphy)
dev->mii.phy_id = *((u8 *)buf + 1);
else
dev->mii.phy_id = *((u8 *)buf);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
- ax772b_data->PhySelect, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
+ ax772b_data->PhySelect, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Select PHY #1 failed: %d", ret);
goto err_out;
}
#if 0
/* select the embedded 10/100 Ethernet PHY */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
- AX_PHYSEL_SSEN | AX_PHYSEL_PSEL | AX_PHYSEL_SSMII
- , 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
+ AX_PHYSEL_SSEN | AX_PHYSEL_PSEL | AX_PHYSEL_SSMII,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Select PHY #1 failed: %d", ret);
goto err_out;
}
- if(dev->mii.phy_id != 0x10) {
+ if (dev->mii.phy_id != 0x10) {
deverr(dev, "Got wrong PHY ID: %02x", dev->mii.phy_id);
ret = -EIO;
goto err_out;
}
#endif
- if ((ret = ax88772a_phy_powerup (dev)) < 0)
+ ret = ax88772a_phy_powerup(dev);
+ if (ret < 0)
goto err_out;
/* stop MAC operation */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- AX_RX_CTL_STOP, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
+ AX_RX_CTL_STOP, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto err_out;
}
/* make sure the driver can enable sw mii operation */
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Enabling software MII failed: %d", ret);
goto err_out;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
dev->net->do_ioctl = ax8817x_ioctl;
dev->net->set_multicast_list = ax88772b_set_multicast;
dev->net->set_mac_address = ax8817x_set_mac_addr;
@@ -1900,41 +2138,60 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
if (dev->mii.phy_id != 0x10)
ax8817x_mdio_write_le(dev->net, 0x10, MII_BMCR, 0x3900);
-
- if (dev->mii.phy_id == 0x10 && ax772b_data->OperationMode
+ if (dev->mii.phy_id == 0x10 && ax772b_data->OperationMode
!= OPERATION_PHY_MODE) {
*tmp16 = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, 0x12);
ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, 0x12,
((*tmp16 & 0xFF9F) | 0x0040));
}
-
+
ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
mii_nway_restart(&dev->mii);
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
+ 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to write medium mode: %d", ret);
goto err_out;
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
AX88772A_IPG0_DEFAULT | AX88772A_IPG1_DEFAULT << 8,
- AX88772A_IPG2_DEFAULT, 0, NULL)) < 0) {
+ AX88772A_IPG2_DEFAULT, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Failed to write interframe gap: %d", ret);
goto err_out;
}
+ memset(buf, 0, 4);
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_IPG012, 0, 0, 3, buf);
+ *((u8 *)buf + 3) = 0x00;
+ if (ret < 0) {
+ deverr(dev, "Failed to read IPG,IPG1,IPG2 failed: %d", ret);
+ goto err_out;
+ } else {
+ __u32 tmp32 = *((u32*)buf);
+ le32_to_cpus(&tmp32);
+ if (tmp32 != (AX88772A_IPG2_DEFAULT << 16 |
+ AX88772A_IPG1_DEFAULT << 8 | AX88772A_IPG0_DEFAULT)) {
+ printk("Non-authentic ASIX product\nASIX does not support it\n");
+ ret = -ENODEV;
+ goto err_out;
+ }
+ }
+
dev->net->features |= NETIF_F_IP_CSUM;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
dev->net->features |= NETIF_F_IPV6_CSUM;
#endif
ax772b_data->checksum = AX_RX_CHECKSUM | AX_TX_CHECKSUM;
- if ((ret = ax88772b_set_csums(dev)) < 0) {
+ ret = ax88772b_set_csums(dev);
+ if (ret < 0) {
deverr(dev, "Write RX_COE/TX_COE failed: %d", ret);
goto err_out;
}
@@ -1942,18 +2199,20 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
dev->rx_size = bsize & 0x07;
if (dev->udev->speed == USB_SPEED_HIGH) {
- if ((ret = ax8817x_write_cmd (dev, 0x2A,
+ ret = ax8817x_write_cmd(dev, 0x2A,
AX88772B_BULKIN_SIZE[dev->rx_size].byte_cnt,
AX88772B_BULKIN_SIZE[dev->rx_size].threshold,
- 0, NULL)) < 0) {
+ 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto err_out;
}
dev->rx_urb_size = AX88772B_BULKIN_SIZE[dev->rx_size].size;
} else {
- if ((ret = ax8817x_write_cmd (dev, 0x2A,
- 0x8000, 0x8001, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, 0x2A,
+ 0x8000, 0x8001, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto err_out;
}
@@ -1961,16 +2220,19 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
}
/* Configure RX header type */
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_RX_CTL,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
(AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_HEADER_DEFAULT),
- 0, 0, NULL)) < 0) {
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Reset RX_CTL failed: %d", ret);
goto err_out;
}
/* Overwrite power saving configuration from eeprom */
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | (ax772b_data->psc & 0x7FFF), 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL |
+ (ax772b_data->psc & 0x7FFF), 0, 0, NULL);
+
+ if (ret < 0) {
deverr(dev, "Failed to configure PHY power saving: %d", ret);
goto err_out;
}
@@ -1978,14 +2240,13 @@ static int ax88772b_bind(struct usbnet *dev, struct usb_interface *intf)
if (ax772b_data->OperationMode == OPERATION_PHY_MODE)
netif_carrier_on(dev->net);
- kfree (buf);
- printk (version);
+ kfree(buf);
return ret;
err_out:
- destroy_workqueue (ax772b_data->ax_work);
- kfree (buf);
- kfree (ax772b_data);
+ destroy_workqueue(ax772b_data->ax_work);
+ kfree(buf);
+ kfree(ax772b_data);
return ret;
}
@@ -1994,21 +2255,9 @@ static void ax88772b_unbind(struct usbnet *dev, struct usb_interface *intf)
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
if (ax772b_data) {
- /* Check for user set MAC address */
- if (!memcmp(dev->net->dev_addr, g_mac_addr, ETH_ALEN)) {
- /* Release user set MAC address */
- g_usr_mac--;
-
- if (g_usr_mac == 2) {
- /* 0x100000 offset for 2nd Ethernet MAC */
- g_mac_addr[3] -= 0x10;
- if (g_mac_addr[3] > 0xf0)
- devwarn(dev, "MAC address byte 3 (0x%02x) wrap around", g_mac_addr[3]);
- }
- }
- flush_workqueue (ax772b_data->ax_work);
- destroy_workqueue (ax772b_data->ax_work);
+ flush_workqueue(ax772b_data->ax_work);
+ destroy_workqueue(ax772b_data->ax_work);
/* stop MAC operation */
ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
@@ -2018,45 +2267,57 @@ static void ax88772b_unbind(struct usbnet *dev, struct usb_interface *intf)
ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
AX_SWRESET_IPPD, 0, 0, NULL);
- kfree (ax772b_data);
+ kfree(ax772b_data);
}
}
-static int
-ax88178_media_check (struct usbnet *dev, struct ax88178_data *ax178dataptr)
+static int
+ax88178_media_check(struct usbnet *dev, struct ax88178_data *ax178dataptr)
{
- int fullduplex;
+ int fullduplex, i = 0;
u16 tempshort = 0;
u16 media;
- u16 advertise, lpa, result, stat1000;
+ u16 advertise, lpa, result, stat1000, _lpa, _stat1000, delay = 5 * HZ;
+ unsigned long jtimeout;
- advertise = ax8817x_mdio_read_le (dev->net,
- dev->mii.phy_id, MII_ADVERTISE);
- lpa = ax8817x_mdio_read_le (dev->net, dev->mii.phy_id, MII_LPA);
- result = advertise & lpa;
+ jtimeout = jiffies + delay;
+ do {
+ _lpa = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_LPA);
+ _stat1000 = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MII_STAT1000);
+
+ lpa = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_LPA);
+ stat1000 = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MII_STAT1000);
- stat1000 = ax8817x_mdio_read_le (dev->net,
- dev->mii.phy_id, MII_STAT1000);
+ if (time_after(jiffies, jtimeout))
+ break;
+
+ } while ((_lpa != lpa) || (_stat1000 != stat1000) || i++ < 3);
+
+ advertise = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MII_ADVERTISE);
+ result = advertise & lpa;
if ((ax178dataptr->PhyMode == PHY_MODE_MARVELL) &&
- (ax178dataptr->LedMode == 1)) {
- tempshort = ax8817x_mdio_read_le (dev->net,
- dev->mii.phy_id, MARVELL_MANUAL_LED) & 0xfc0f;
+ (ax178dataptr->LedMode == 1)) {
+ tempshort = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MARVELL_MANUAL_LED) & 0xfc0f;
}
- fullduplex=1;
+ fullduplex = 1;
if (stat1000 & LPA_1000FULL) {
media = MEDIUM_GIGA_MODE | MEDIUM_FULL_DUPLEX_MODE |
MEDIUM_ENABLE_125MHZ | MEDIUM_ENABLE_RECEIVE;
if ((ax178dataptr->PhyMode == PHY_MODE_MARVELL) &&
(ax178dataptr->LedMode == 1))
- tempshort|= 0x3e0;
+ tempshort |= 0x3e0;
} else if (result & LPA_100FULL) {
media = MEDIUM_FULL_DUPLEX_MODE | MEDIUM_ENABLE_RECEIVE |
MEDIUM_MII_100M_MODE;
if ((ax178dataptr->PhyMode == PHY_MODE_MARVELL) &&
(ax178dataptr->LedMode == 1))
- tempshort|= 0x3b0;
+ tempshort |= 0x3b0;
} else if (result & LPA_100HALF) {
fullduplex = 0;
media = MEDIUM_ENABLE_RECEIVE | MEDIUM_MII_100M_MODE;
@@ -2070,7 +2331,7 @@ ax88178_media_check (struct usbnet *dev, struct ax88178_data *ax178dataptr)
tempshort |= 0x2f0;
} else {
media = MEDIUM_ENABLE_RECEIVE;
- fullduplex=0;
+ fullduplex = 0;
if ((ax178dataptr->PhyMode == PHY_MODE_MARVELL) &&
(ax178dataptr->LedMode == 1))
tempshort |= 0x02f0;
@@ -2078,148 +2339,148 @@ ax88178_media_check (struct usbnet *dev, struct ax88178_data *ax178dataptr)
if ((ax178dataptr->PhyMode == PHY_MODE_MARVELL) &&
(ax178dataptr->LedMode == 1)) {
- ax8817x_mdio_write_le (dev->net,
+ ax8817x_mdio_write_le(dev->net,
dev->mii.phy_id, MARVELL_MANUAL_LED, tempshort);
}
media |= 0x0004;
- if(ax178dataptr->UseRgmii)
+ if (ax178dataptr->UseRgmii)
media |= 0x0008;
- if(fullduplex) {
- media |= 0x0020; //ebable tx flow control as default;
- media |= 0x0010; //ebable rx flow control as default;
+ if (fullduplex) {
+ media |= 0x0020; /* ebable tx flow control as default; */
+ media |= 0x0010; /* ebable rx flow control as default; */
}
return media;
}
-static void Vitess_8601_Init (struct usbnet *dev, int State)
+static void Vitess_8601_Init(struct usbnet *dev, int state)
{
u16 reg;
- switch (State) {
- case 0: // tx, rx clock skew
- ax8817x_swmii_mdio_write_le (dev->net, dev->mii.phy_id, 31, 1);
- ax8817x_swmii_mdio_write_le (dev->net, dev->mii.phy_id, 28, 0);
- ax8817x_swmii_mdio_write_le (dev->net, dev->mii.phy_id, 31, 0);
+ switch (state) {
+ case 0: /* tx, rx clock skew */
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id, 31, 1);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id, 28, 0);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id, 31, 0);
break;
case 1:
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 31, 0x52B5);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18, 0x009E);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xDD39);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87AA);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0xA7B4);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18,
- ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 18));
- reg = (ax8817x_swmii_mdio_read_le (dev->net,
+ reg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 17) & ~0x003f) | 0x003c;
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, reg);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87B4);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0xa794);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18,
- ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 18));
- reg = (ax8817x_swmii_mdio_read_le (dev->net,
+ reg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 17) & ~0x003f) | 0x003e;
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, reg);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x8794);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18, 0x00f7);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xbe36);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x879e);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0xa7a0);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 18,
- ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 18,
+ ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 18));
- reg = (ax8817x_swmii_mdio_read_le (dev->net,
+ reg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 17) & ~0x003f) | 0x0034;
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, reg);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87a0);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18, 0x003c);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xf3cf);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87a2);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18, 0x003c);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xf3cf);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87a4);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 18, 0x003c);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xd287);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87a6);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0xa7a8);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 18,
- ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 18,
+ ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 18));
- reg = (ax8817x_swmii_mdio_read_le (dev->net,
+ reg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 17) & ~0x0fff) | 0x0125;
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, reg);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87a8);
- // Enable Smart Pre-emphasis
- ax8817x_swmii_mdio_write_le (dev->net,
+ /* Enable Smart Pre-emphasis */
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0xa7fa);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 18,
- ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 18,
+ ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 18));
- reg = (ax8817x_swmii_mdio_read_le (dev->net,
+ reg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 17) & ~0x0008) | 0x0008;
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, reg);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x87fa);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 31, 0);
break;
@@ -2229,46 +2490,46 @@ static void Vitess_8601_Init (struct usbnet *dev, int State)
static void
marvell_88E1510_magic_init(struct usbnet *dev)
{
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 22, 0xff);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0x214b);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x2144);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0x0c28);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x2146);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xb233);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x214d);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 17, 0xcc0c);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 16, 0x2159);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 22, 0x00fb);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 7, 0xc00d);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 22, 0);
}
-static int
-ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
+static int
+ax88178_phy_init(struct usbnet *dev, struct ax88178_data *ax178dataptr)
{
int i;
- u16 PhyAnar, PhyAuxCtrl, PhyCtrl, TempShort, PhyID1;
- u16 PhyReg = 0;
+ u16 phyanar, phyauxctrl, phyctrl, tempshort, phyid1;
+ u16 phyreg = 0;
- //Disable MII operation of AX88178 Hardware
- ax8817x_write_cmd (dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
+ /* Disable MII operation of AX88178 Hardware */
+ ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
- //Read SROM - MiiPhy Address (ID)
- ax8817x_read_cmd (dev, AX_CMD_READ_PHY_ID, 0, 0, 2, &dev->mii.phy_id);
- le32_to_cpus (&dev->mii.phy_id);
+ /* Read SROM - MiiPhy Address (ID) */
+ ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, &dev->mii.phy_id);
+ le32_to_cpus(&dev->mii.phy_id);
/* Initialize MII structure */
dev->mii.phy_id >>= 8;
@@ -2278,12 +2539,11 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
dev->mii.mdio_write = ax8817x_mdio_write_le;
dev->mii.phy_id_mask = 0x3f;
dev->mii.reg_num_mask = 0x1f;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 11)
dev->mii.supports_gmii = 1;
#endif
- if (ax178dataptr->PhyMode == PHY_MODE_MAC_TO_MAC_GMII)
- {
+ if (ax178dataptr->PhyMode == PHY_MODE_MAC_TO_MAC_GMII) {
ax178dataptr->UseRgmii = 0;
ax178dataptr->MediaLink = MEDIUM_GIGA_MODE |
MEDIUM_FULL_DUPLEX_MODE |
@@ -2291,20 +2551,19 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
MEDIUM_ENABLE_RECEIVE |
MEDIUM_ENABLE_RX_FLOWCTRL |
MEDIUM_ENABLE_TX_FLOWCTRL;
-
- goto SkipPhySetting;
+ goto SKIPPHYSETTING;
}
- // test read phy register 2
+ /* test read phy register 2 */
if (!ax178dataptr->UseGpio0) {
i = 1000;
while (i--) {
- PhyID1 = ax8817x_swmii_mdio_read_le (dev->net,
+ phyid1 = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, GMII_PHY_OUI);
- if ((PhyID1 == 0x000f) || (PhyID1 == 0x0141) ||
- (PhyID1 == 0x0282) || (PhyID1 == 0x004d) ||
- (PhyID1 == 0x0243) || (PhyID1 == 0x001C) ||
- (PhyID1 == 0x0007))
+ if ((phyid1 == 0x000f) || (phyid1 == 0x0141) ||
+ (phyid1 == 0x0282) || (phyid1 == 0x004d) ||
+ (phyid1 == 0x0243) || (phyid1 == 0x001C) ||
+ (phyid1 == 0x0007))
break;
msleep(5);
}
@@ -2314,11 +2573,11 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
ax178dataptr->UseRgmii = 0;
if (ax178dataptr->PhyMode == PHY_MODE_MARVELL) {
- PhyReg = ax8817x_swmii_mdio_read_le(dev->net,
+ phyreg = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 27);
- if (!(PhyReg & 4) && !(ax178dataptr->LedMode & 0x10)) {
+ if (!(phyreg & 4) && !(ax178dataptr->LedMode & 0x10)) {
ax178dataptr->UseRgmii = 1;
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 20, 0x82);
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
} else if (ax178dataptr->LedMode & 0x10) {
@@ -2327,19 +2586,18 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
marvell_88E1510_magic_init(dev);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 22, 2);
- PhyReg = ax8817x_swmii_mdio_read_le(dev->net,
+ phyreg = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 21);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 21, PhyReg | 0x30);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 21, phyreg | 0x30);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 22, 0);
-
- }
+ }
} else if ((ax178dataptr->PhyMode == PHY_MODE_AGERE_V0) ||
(ax178dataptr->PhyMode == PHY_MODE_AGERE_V0_GMII)) {
if (ax178dataptr->PhyMode == PHY_MODE_AGERE_V0) {
@@ -2347,46 +2605,44 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
}
} else if (ax178dataptr->PhyMode == PHY_MODE_CICADA_V1) {
- // not Cameo
+ /* not Cameo */
if (!ax178dataptr->UseGpio0 || ax178dataptr->LedMode) {
ax178dataptr->UseRgmii = 1;
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
}
- for (i = 0; i < (sizeof(CICADA_FAMILY_HWINIT) /
- sizeof(CICADA_FAMILY_HWINIT[0])); i++) {
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id,
+ for (i = 0; i < (sizeof(CICADA_FAMILY_HWINIT) /
+ sizeof(CICADA_FAMILY_HWINIT[0])); i++) {
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id,
CICADA_FAMILY_HWINIT[i].offset,
CICADA_FAMILY_HWINIT[i].value);
}
} else if (ax178dataptr->PhyMode == PHY_MODE_CICADA_V2) {
- // not Cameo
- if (!ax178dataptr->UseGpio0 || ax178dataptr->LedMode)
- {
+ /* not Cameo */
+ if (!ax178dataptr->UseGpio0 || ax178dataptr->LedMode) {
ax178dataptr->UseRgmii = 1;
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
}
- for (i = 0; i < (sizeof(CICADA_V2_HWINIT) /
+ for (i = 0; i < (sizeof(CICADA_V2_HWINIT) /
sizeof(CICADA_V2_HWINIT[0])); i++) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, CICADA_V2_HWINIT[i].offset,
CICADA_V2_HWINIT[i].value);
}
} else if (ax178dataptr->PhyMode == PHY_MODE_CICADA_V2_ASIX) {
- // not Cameo
- if (!ax178dataptr->UseGpio0 || ax178dataptr->LedMode)
- {
+ /* not Cameo */
+ if (!ax178dataptr->UseGpio0 || ax178dataptr->LedMode) {
ax178dataptr->UseRgmii = 1;
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
}
- for (i = 0; i < (sizeof(CICADA_V2_HWINIT) /
+ for (i = 0; i < (sizeof(CICADA_V2_HWINIT) /
sizeof(CICADA_V2_HWINIT[0])); i++) {
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, CICADA_V2_HWINIT[i].offset,
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, CICADA_V2_HWINIT[i].offset,
CICADA_V2_HWINIT[i].value);
}
} else if (ax178dataptr->PhyMode == PHY_MODE_RTL8211CL) {
@@ -2401,32 +2657,30 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
} else if (ax178dataptr->PhyMode == PHY_MODE_VSC8601) {
ax178dataptr->UseRgmii = 1;
ax178dataptr->MediaLink |= MEDIUM_ENABLE_125MHZ;
-// Vitess_8601_Init (dev, 0);
+ /* Vitess_8601_Init (dev, 0); */
}
if (ax178dataptr->PhyMode != PHY_MODE_ATTANSIC_V0) {
- // software reset
- ax8817x_swmii_mdio_write_le (
+ /* software reset */
+ ax8817x_swmii_mdio_write_le(
dev->net, dev->mii.phy_id, GMII_PHY_CONTROL,
- ax8817x_swmii_mdio_read_le (
+ ax8817x_swmii_mdio_read_le(
dev->net, dev->mii.phy_id, GMII_PHY_CONTROL)
| GMII_CONTROL_RESET);
- msleep (1);
+ msleep(1);
}
if ((ax178dataptr->PhyMode == PHY_MODE_AGERE_V0) ||
(ax178dataptr->PhyMode == PHY_MODE_AGERE_V0_GMII)) {
- if (ax178dataptr->PhyMode == PHY_MODE_AGERE_V0)
- {
+ if (ax178dataptr->PhyMode == PHY_MODE_AGERE_V0) {
i = 1000;
- while (i--)
- {
- ax8817x_swmii_mdio_write_le (dev->net,
+ while (i--) {
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 21, 0x1001);
- PhyReg = ax8817x_swmii_mdio_read_le (dev->net,
+ phyreg = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 21);
- if ((PhyReg & 0xf00f) == 0x1001)
+ if ((phyreg & 0xf00f) == 0x1001)
break;
}
if (i < 0)
@@ -2434,110 +2688,105 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
}
if (ax178dataptr->LedMode == 4) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 28, 0x7417);
} else if (ax178dataptr->LedMode == 9) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 28, 0x7a10);
} else if (ax178dataptr->LedMode == 10) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 28, 0x7a13);
}
for (i = 0; i < (sizeof(AGERE_FAMILY_HWINIT) /
sizeof(AGERE_FAMILY_HWINIT[0])); i++) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, AGERE_FAMILY_HWINIT[i].offset,
AGERE_FAMILY_HWINIT[i].value);
}
} else if (ax178dataptr->PhyMode == PHY_MODE_RTL8211CL) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 0x1f, 0x0005);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 0x0c, 0);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 0x01,
- (ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id, 0x01,
+ (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 0x01) | 0x0080));
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 0x1f, 0);
if (ax178dataptr->LedMode == 12) {
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 0x1f, 0x0002);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 0x1a, 0x00cb);
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, 0x1f, 0);
}
} else if (ax178dataptr->PhyMode == PHY_MODE_VSC8601) {
- Vitess_8601_Init (dev, 1);
+ Vitess_8601_Init(dev, 1);
}
- // read phy register 0
- PhyCtrl = ax8817x_swmii_mdio_read_le (dev->net,
+ /* read phy register 0 */
+ phyctrl = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, GMII_PHY_CONTROL);
- TempShort = PhyCtrl;
- PhyCtrl &= ~(GMII_CONTROL_POWER_DOWN | GMII_CONTROL_ISOLATE);
- if (PhyCtrl != TempShort) {
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, GMII_PHY_CONTROL, PhyCtrl);
+ tempshort = phyctrl;
+ phyctrl &= ~(GMII_CONTROL_POWER_DOWN | GMII_CONTROL_ISOLATE);
+ if (phyctrl != tempshort) {
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, GMII_PHY_CONTROL, phyctrl);
}
- // led
+ /* LED */
if (ax178dataptr->PhyMode == PHY_MODE_MARVELL) {
if (ax178dataptr->LedMode == 1) {
- PhyReg = (ax8817x_swmii_mdio_read_le (dev->net,
+ phyreg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 24) & 0xf8ff) | (1 + 0x100);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 24, PhyReg);
- PhyReg = ax8817x_swmii_mdio_read_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 24, phyreg);
+ phyreg = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 25) & 0xfc0f;
-
} else if (ax178dataptr->LedMode == 2) {
- PhyReg = (ax8817x_swmii_mdio_read_le (dev->net,
- dev->mii.phy_id, 24) & 0xf886) |
+ phyreg = (ax8817x_swmii_mdio_read_le(dev->net,
+ dev->mii.phy_id, 24) & 0xf886) |
(1 + 0x10 + 0x300);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 24, PhyReg);
-
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 24, phyreg);
} else if (ax178dataptr->LedMode == 5) {
- PhyReg = (ax8817x_swmii_mdio_read_le (dev->net,
- dev->mii.phy_id, 24) & 0xf8be) |
+ phyreg = (ax8817x_swmii_mdio_read_le(dev->net,
+ dev->mii.phy_id, 24) & 0xf8be) |
(1 + 0x40 + 0x300);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 24, PhyReg);
-
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 24, phyreg);
} else if (ax178dataptr->LedMode == 7) {
- PhyReg = (ax8817x_swmii_mdio_read_le (dev->net,
+ phyreg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 24) & 0xf8ff) |
(1 + 0x100);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 24, PhyReg);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 24, phyreg);
} else if (ax178dataptr->LedMode == 8) {
- PhyReg = (ax8817x_swmii_mdio_read_le (dev->net,
- dev->mii.phy_id, 24) & 0xf8be) |
+ phyreg = (ax8817x_swmii_mdio_read_le(dev->net,
+ dev->mii.phy_id, 24) & 0xf8be) |
(1 + 0x40 + 0x100);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 24, PhyReg);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 24, phyreg);
} else if (ax178dataptr->LedMode == 11) {
- PhyReg = ax8817x_swmii_mdio_read_le (dev->net,
+ phyreg = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 24) & 0x4106;
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 24, PhyReg);
-
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 24, phyreg);
} else if (ax178dataptr->LedMode == 0x10) {
- //MARVEL 88e1510 use default led setting
+ /* MARVEL 88e1510 use default led setting */
}
} else if ((ax178dataptr->PhyMode == PHY_MODE_CICADA_V1) ||
@@ -2546,86 +2795,83 @@ ax88178_phy_init (struct usbnet *dev, struct ax88178_data *ax178dataptr)
if (ax178dataptr->LedMode == 3) {
- PhyReg = (ax8817x_swmii_mdio_read_le (dev->net,
+ phyreg = (ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 27) & 0xFCFF) | 0x0100;
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 27, PhyReg);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 27, phyreg);
}
}
- if (ax178dataptr->PhyMode == PHY_MODE_MARVELL)
- {
+ if (ax178dataptr->PhyMode == PHY_MODE_MARVELL) {
if (ax178dataptr->LedMode == 1)
- PhyReg |= 0x3f0;
+ phyreg |= 0x3f0;
}
- PhyAnar = 1 | (GMII_ANAR_PAUSE | GMII_ANAR_100TXFD | GMII_ANAR_100TX |
+ phyanar = 1 | (GMII_ANAR_PAUSE | GMII_ANAR_100TXFD | GMII_ANAR_100TX |
GMII_ANAR_10TFD | GMII_ANAR_10T | GMII_ANAR_ASYM_PAUSE);
- PhyAuxCtrl = GMII_1000_AUX_CTRL_FD_CAPABLE;
+ phyauxctrl = GMII_1000_AUX_CTRL_FD_CAPABLE;
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, GMII_PHY_ANAR, PhyAnar);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, GMII_PHY_1000BT_CONTROL, PhyAuxCtrl);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, GMII_PHY_ANAR, phyanar);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, GMII_PHY_1000BT_CONTROL, phyauxctrl);
- if (ax178dataptr->PhyMode == PHY_MODE_VSC8601)
- {
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 31, 0x52B5);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 16, 0xA7F8);
+ if (ax178dataptr->PhyMode == PHY_MODE_VSC8601) {
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id,
+ 31, 0x52B5);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id,
+ 16, 0xA7F8);
- TempShort = ax8817x_swmii_mdio_read_le (dev->net,
+ tempshort = ax8817x_swmii_mdio_read_le(dev->net,
dev->mii.phy_id, 17) & (~0x0018);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 17, TempShort);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id,
+ 17, tempshort);
- TempShort = ax8817x_swmii_mdio_read_le (dev->net,
- dev->mii.phy_id, 18);
+ tempshort = ax8817x_swmii_mdio_read_le(dev->net,
+ dev->mii.phy_id, 18);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 18, TempShort);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id, 18,
+ tempshort);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 16, 0x87F8);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 31, 0);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id,
+ 16, 0x87F8);
+ ax8817x_swmii_mdio_write_le(dev->net, dev->mii.phy_id,
+ 31, 0);
}
if (ax178dataptr->PhyMode == PHY_MODE_ATTANSIC_V0) {
-
- ax8817x_swmii_mdio_write_le (dev->net,
+ ax8817x_swmii_mdio_write_le(dev->net,
dev->mii.phy_id, GMII_PHY_CONTROL, 0x9000);
} else {
- PhyCtrl &= ~GMII_CONTROL_LOOPBACK;
- PhyCtrl |= (GMII_CONTROL_ENABLE_AUTO | GMII_CONTROL_START_AUTO);
+ phyctrl &= ~GMII_CONTROL_LOOPBACK;
+ phyctrl |= (GMII_CONTROL_ENABLE_AUTO | GMII_CONTROL_START_AUTO);
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, GMII_PHY_CONTROL, PhyCtrl);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, GMII_PHY_CONTROL, phyctrl);
}
if (ax178dataptr->PhyMode == PHY_MODE_MARVELL) {
if (ax178dataptr->LedMode == 1)
- ax8817x_swmii_mdio_write_le (dev->net,
- dev->mii.phy_id, 25, PhyReg);
+ ax8817x_swmii_mdio_write_le(dev->net,
+ dev->mii.phy_id, 25, phyreg);
}
-SkipPhySetting:
+SKIPPHYSETTING:
- ax8817x_write_cmd (dev, AX_CMD_WRITE_MEDIUM_MODE,
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
ax178dataptr->MediaLink, 0, 0, NULL);
- ax8817x_write_cmd (dev, AX_CMD_WRITE_IPG0,
- AX88772_IPG0_DEFAULT | (AX88772_IPG1_DEFAULT << 8),
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0,
+ AX88772_IPG0_DEFAULT | (AX88772_IPG1_DEFAULT << 8),
AX88772_IPG2_DEFAULT, 0, NULL);
- msleep (1);
+ msleep(1);
- ax8817x_write_cmd (dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, NULL);
return 0;
}
@@ -2637,227 +2883,237 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
struct ax88178_data *ax178dataptr = NULL;
- axusbnet_get_endpoints(dev,intf);
+ axusbnet_get_endpoints(dev, intf);
buf = kmalloc(6, GFP_KERNEL);
- if(!buf) {
+ if (!buf) {
deverr(dev, "Cannot allocate memory for buffer");
return -ENOMEM;
}
/* allocate 178 data */
- ax178dataptr = kmalloc (sizeof (*ax178dataptr), GFP_KERNEL);
+ ax178dataptr = kmalloc(sizeof(*ax178dataptr), GFP_KERNEL);
if (!ax178dataptr) {
deverr(dev, "Cannot allocate memory for AX88178 data");
ret = -ENOMEM;
goto error_out;
}
- memset (ax178dataptr, 0, sizeof (struct ax88178_data));
+ memset(ax178dataptr, 0, sizeof(struct ax88178_data));
dev->priv = ax178dataptr;
/* end of allocate 178 data */
/* Get the EEPROM data*/
- if ((ret = ax8817x_read_cmd (dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2,
- (void *)(&ax178dataptr->EepromData))) < 0) {
+ ret = ax8817x_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2,
+ (void *)(&ax178dataptr->EepromData));
+ if (ret < 0) {
deverr(dev, "read SROM address 17h failed: %d", ret);
goto error_out;
}
- le16_to_cpus (&ax178dataptr->EepromData);
+ le16_to_cpus(&ax178dataptr->EepromData);
/* End of get EEPROM data */
if (ax178dataptr->EepromData == 0xffff) {
ax178dataptr->PhyMode = PHY_MODE_MARVELL;
ax178dataptr->LedMode = 0;
- ax178dataptr->UseGpio0 = 1; //True
+ ax178dataptr->UseGpio0 = 1; /* True */
} else {
- ax178dataptr->PhyMode = (u8)(ax178dataptr->EepromData &
- EEPROMMASK);
+ ax178dataptr->PhyMode = (u8)(ax178dataptr->EepromData &
+ EEPROMMASK);
ax178dataptr->LedMode = (u8)(ax178dataptr->EepromData >> 8);
- if (ax178dataptr->LedMode == 6) // for buffalo new (use gpio2)
+
+ /* for buffalo new (use gpio2) */
+ if (ax178dataptr->LedMode == 6)
ax178dataptr->LedMode = 1;
else if (ax178dataptr->LedMode == 1)
ax178dataptr->BuffaloOld = 1;
- if(ax178dataptr->EepromData & 0x80) {
- ax178dataptr->UseGpio0=0; //MARVEL se and other
- } else {
- ax178dataptr->UseGpio0=1; //cameo
- }
+ if (ax178dataptr->EepromData & 0x80)
+ ax178dataptr->UseGpio0 = 0; /* MARVEL se and other */
+ else
+ ax178dataptr->UseGpio0 = 1; /* cameo */
}
if (ax178dataptr->UseGpio0) {
if (ax178dataptr->PhyMode == PHY_MODE_MARVELL) {
-
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
AXGPIOS_GPO0EN | AXGPIOS_RSE,
- 0, 0, NULL)) < 0) {
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (25);
+ msleep(25);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(AXGPIOS_GPO2 | AXGPIOS_GPO2EN |
- AXGPIOS_GPO0EN), 0, 0, NULL)) < 0) {
+ AXGPIOS_GPO0EN), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (15);
+ msleep(15);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
AXGPIOS_GPO2EN | AXGPIOS_GPO0EN,
- 0, 0, NULL)) < 0) {
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (245);
+ msleep(245);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(AXGPIOS_GPO2 | AXGPIOS_GPO2EN |
- AXGPIOS_GPO0EN), 0, 0, NULL)) < 0) {
+ AXGPIOS_GPO0EN), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- } else { // vitesse
+ } else { /* vitesse */
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(AXGPIOS_RSE | AXGPIOS_GPO0EN |
- AXGPIOS_GPO0), 0, 0, NULL)) < 0) {
+ AXGPIOS_GPO0), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (25);
+ msleep(25);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(AXGPIOS_GPO0EN | AXGPIOS_GPO0 |
AXGPIOS_GPO2EN | AXGPIOS_GPO2),
- 0, 0, NULL)) < 0) {
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (25);
+ msleep(25);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
(AXGPIOS_GPO0EN | AXGPIOS_GPO0 |
- AXGPIOS_GPO2EN), 0, 0, NULL)) < 0) {
+ AXGPIOS_GPO2EN), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (245);
+ msleep(245);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- (AXGPIOS_GPO0EN | AXGPIOS_GPO0 |
- AXGPIOS_GPO2EN | AXGPIOS_GPO2),
- 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ (AXGPIOS_GPO0EN | AXGPIOS_GPO0 |
+ AXGPIOS_GPO2EN | AXGPIOS_GPO2),
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
}
- } else { // use gpio1
-
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- (AXGPIOS_GPO1 |AXGPIOS_GPO1EN | AXGPIOS_RSE),
- 0, 0, NULL)) < 0) {
+ } else { /* use gpio1 */
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ (AXGPIOS_GPO1 | AXGPIOS_GPO1EN |
+ AXGPIOS_RSE), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
if (ax178dataptr->BuffaloOld) {
+ msleep(350);
- msleep (350);
-
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- AXGPIOS_GPO1EN, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ AXGPIOS_GPO1EN, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (350);
+ msleep(350);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- AXGPIOS_GPO1EN | AXGPIOS_GPO1,
- 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ AXGPIOS_GPO1EN | AXGPIOS_GPO1,
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- }
- else
- {
- msleep (25);
+ } else {
+ msleep(25);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- (AXGPIOS_GPO1EN | AXGPIOS_GPO1 |
- AXGPIOS_GPO2EN | AXGPIOS_GPO2),
- 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ (AXGPIOS_GPO1EN | AXGPIOS_GPO1 |
+ AXGPIOS_GPO2EN | AXGPIOS_GPO2),
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (25);
+ msleep(25);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- (AXGPIOS_GPO1EN | AXGPIOS_GPO1 |
- AXGPIOS_GPO2EN), 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ (AXGPIOS_GPO1EN | AXGPIOS_GPO1 |
+ AXGPIOS_GPO2EN), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
- msleep (245);
+ msleep(245);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_WRITE_GPIOS,
- (AXGPIOS_GPO1EN | AXGPIOS_GPO1 |
- AXGPIOS_GPO2EN | AXGPIOS_GPO2),
- 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
+ (AXGPIOS_GPO1EN | AXGPIOS_GPO1 |
+ AXGPIOS_GPO2EN | AXGPIOS_GPO2),
+ 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write GPIO failed: %d", ret);
goto error_out;
}
}
}
- if ((ret = ax8817x_write_cmd(dev,
- AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Select PHY failed: %d", ret);
goto error_out;
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPPD | AX_SWRESET_PRL, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD |
+ AX_SWRESET_PRL, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Issue sw reset failed: %d", ret);
goto error_out;
}
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- 0, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0, 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "Issue rx ctrl failed: %d", ret);
goto error_out;
}
/* Get the MAC address */
memset(buf, 0, ETH_ALEN);
- if ((ret = ax8817x_read_cmd (dev, AX88772_CMD_READ_NODE_ID,
- 0, 0, ETH_ALEN, buf)) < 0) {
- deverr(dev, "read AX_CMD_READ_NODE_ID failed: %d", ret);
+ ax8817x_get_mac(dev, buf);
+ if (ret < 0)
goto error_out;
- }
- memcpy(dev->net->dev_addr, buf, ETH_ALEN);
/* End of get MAC address */
- if ((ret = ax88178_phy_init (dev, ax178dataptr)) < 0)
+ ret = ax88178_phy_init(dev, ax178dataptr);
+ if (ret < 0)
goto error_out;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
dev->net->do_ioctl = ax8817x_ioctl;
dev->net->set_multicast_list = ax88178_set_multicast;
- dev->net->set_mac_address = ax88178_set_mac_addr;
+ dev->net->set_mac_address = ax8817x_set_mac_addr;
#else
dev->net->netdev_ops = &ax88178_netdev_ops;
#endif
@@ -2867,25 +3123,23 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
data->suspend = ax88772_suspend;
data->resume = ax88772_resume;
- if (dev->driver_info->flags & FLAG_FRAMING_AX) {
+ if (dev->driver_info->flags & FLAG_FRAMING_AX)
dev->rx_urb_size = 16384;
- }
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
- (AX_RX_CTL_MFB | AX_RX_CTL_START | AX_RX_CTL_AB),
- 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, (AX_RX_CTL_MFB |
+ AX_RX_CTL_START | AX_RX_CTL_AB), 0, 0, NULL);
+ if (ret < 0) {
deverr(dev, "write RX ctrl reg failed: %d", ret);
goto error_out;
}
- kfree (buf);
- printk (version);
+ kfree(buf);
+ printk(version);
return ret;
error_out:
- if (ax178dataptr)
- kfree (ax178dataptr);
- kfree (buf);
+ kfree(ax178dataptr);
+ kfree(buf);
return ret;
}
@@ -2899,7 +3153,7 @@ static void ax88178_unbind(struct usbnet *dev, struct usb_interface *intf)
ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL,
AX_RX_CTL_STOP, 0, 0, NULL);
- kfree (ax178dataptr);
+ kfree(ax178dataptr);
}
}
@@ -2919,27 +3173,29 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
skb_pull(skb, 4);
while (skb->len > 0) {
- if ((short)(header & 0x0000ffff) !=
- ~((short)((header & 0xffff0000) >> 16))) {
+ if ((short)(header & 0x00007ff) !=
+ ~((short)(((header & 0xffff0000) | 0xf8000000) >> 16))) {
deverr(dev, "header length data is error 0x%08x, %d\n",
header, skb->len);
}
/* get the packet length */
- size = (u16) (header & 0x0000ffff);
+ size = (u16) (header & 0x00007ff);
if ((skb->len) - ((size + 1) & 0xfffe) == 0) {
/* Make sure ip header is aligned on 32-bit boundary */
if (!((unsigned long)skb->data & 0x02)) {
- memmove (skb->data - 2, skb->data, size);
+ memmove(skb->data - 2, skb->data, size);
skb->data -= 2;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
skb->tail = skb->data + size;
#else
- skb_set_tail_pointer (skb, size);
+ skb_set_tail_pointer(skb, size);
#endif
}
skb->truesize = size + sizeof(struct sk_buff);
+ skb->len = size;
+
return 2;
}
@@ -2947,19 +3203,29 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
deverr(dev, "invalid rx length %d", size);
return 0;
}
+#ifndef RX_SKB_COPY
ax_skb = skb_clone(skb, GFP_ATOMIC);
+#else
+ ax_skb = alloc_skb(size + NET_IP_ALIGN, GFP_ATOMIC);
+ skb_reserve(ax_skb, NET_IP_ALIGN);
+#endif
if (ax_skb) {
-
+#ifndef RX_SKB_COPY
/* Make sure ip header is aligned on 32-bit boundary */
if (!((unsigned long)packet & 0x02)) {
- memmove (packet - 2, packet, size);
+ memmove(packet - 2, packet, size);
packet -= 2;
}
ax_skb->data = packet;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
ax_skb->tail = packet + size;
#else
- skb_set_tail_pointer (ax_skb, size);
+ skb_set_tail_pointer(ax_skb, size);
+#endif
+
+#else
+ skb_put(ax_skb, size);
+ memcpy(ax_skb->data, packet , size);
#endif
ax_skb->truesize = size + sizeof(struct sk_buff);
axusbnet_skb_return(dev, ax_skb);
@@ -2987,7 +3253,8 @@ static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
return 1;
}
-static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
+static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
+ gfp_t flags)
{
int padlen = ((skb->len + 4) % 512) ? 0 : 4;
u32 packet_len;
@@ -3001,10 +3268,10 @@ static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
&& ((headroom + tailroom) >= (4 + padlen))) {
if ((headroom < 4) || (tailroom < padlen)) {
skb->data = memmove(skb->head + 4, skb->data, skb->len);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
skb->tail = skb->data + skb->len;
#else
- skb_set_tail_pointer (skb, skb->len);
+ skb_set_tail_pointer(skb, skb->len);
#endif
}
} else
@@ -3021,7 +3288,7 @@ static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
skb_push(skb, 4);
packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
cpu_to_le32s(&packet_len);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
memcpy(skb->data, &packet_len, sizeof(packet_len));
#else
skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
@@ -3029,7 +3296,7 @@ static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
if ((skb->len % 512) == 0) {
cpu_to_le32s(&padbytes);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
memcpy(skb->tail, &padbytes, sizeof(padbytes));
#else
memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
@@ -3040,14 +3307,13 @@ static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
}
static void
-ax88772b_rx_checksum (struct sk_buff *skb, struct ax88772b_rx_header *rx_hdr)
+ax88772b_rx_checksum(struct sk_buff *skb, struct ax88772b_rx_header *rx_hdr)
{
skb->ip_summed = CHECKSUM_NONE;
/* checksum error bit is set */
- if (rx_hdr->l3_csum_err || rx_hdr->l4_csum_err) {
+ if (rx_hdr->l3_csum_err || rx_hdr->l4_csum_err)
return;
- }
/* It must be a TCP or UDP packet with a valid checksum */
if ((rx_hdr->l4_type == AX_RXHDR_L4_TYPE_TCP) ||
@@ -3067,24 +3333,23 @@ static int ax88772b_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
le16_to_cpus((u16 *)skb->data);
le16_to_cpus(((u16 *)skb->data) + 1);
- memcpy (&rx_hdr, skb->data, sizeof (struct ax88772b_rx_header));
+ memcpy(&rx_hdr, skb->data, sizeof(struct ax88772b_rx_header));
- if ((short)rx_hdr.len != (~((short)rx_hdr.len_bar) & 0x7FF)) {
+ if ((short)rx_hdr.len != (~((short)rx_hdr.len_bar) & 0x7FF))
return 0;
- }
if (rx_hdr.len > (ETH_FRAME_LEN + 4)) {
deverr(dev, "invalid rx length %d", rx_hdr.len);
return 0;
}
- if (skb->len - ((rx_hdr.len +
- sizeof (struct ax88772b_rx_header) + 3) &
+ if (skb->len - ((rx_hdr.len +
+ sizeof(struct ax88772b_rx_header) + 3) &
0xfffc) == 0) {
- skb_pull(skb, sizeof (struct ax88772b_rx_header));
+ skb_pull(skb, sizeof(struct ax88772b_rx_header));
skb->len = rx_hdr.len;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
skb->tail = skb->data + rx_hdr.len;
#else
skb_set_tail_pointer(skb, rx_hdr.len);
@@ -3092,27 +3357,37 @@ static int ax88772b_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
skb->truesize = rx_hdr.len + sizeof(struct sk_buff);
if (ax772b_data->checksum & AX_RX_CHECKSUM)
- ax88772b_rx_checksum (skb, &rx_hdr);
+ ax88772b_rx_checksum(skb, &rx_hdr);
return 2;
}
-
+#ifndef RX_SKB_COPY
ax_skb = skb_clone(skb, GFP_ATOMIC);
+#else
+ ax_skb = alloc_skb(rx_hdr.len + NET_IP_ALIGN, GFP_ATOMIC);
+ skb_reserve(ax_skb, NET_IP_ALIGN);
+#endif
if (ax_skb) {
+#ifndef RX_SKB_COPY
ax_skb->len = rx_hdr.len;
- ax_skb->data = skb->data +
- sizeof (struct ax88772b_rx_header);
+ ax_skb->data = skb->data +
+ sizeof(struct ax88772b_rx_header);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
ax_skb->tail = ax_skb->data + rx_hdr.len;
#else
skb_set_tail_pointer(ax_skb, rx_hdr.len);
#endif
+
+#else
+ skb_put(ax_skb, rx_hdr.len);
+ memcpy(ax_skb->data, skb->data + sizeof(struct ax88772b_rx_header), rx_hdr.len);
+#endif
+
ax_skb->truesize = rx_hdr.len + sizeof(struct sk_buff);
- if (ax772b_data->checksum & AX_RX_CHECKSUM) {
- ax88772b_rx_checksum (ax_skb, &rx_hdr);
- }
+ if (ax772b_data->checksum & AX_RX_CHECKSUM)
+ ax88772b_rx_checksum(ax_skb, &rx_hdr);
axusbnet_skb_return(dev, ax_skb);
@@ -3120,8 +3395,8 @@ static int ax88772b_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
return 0;
}
- skb_pull(skb, ((rx_hdr.len +
- sizeof (struct ax88772b_rx_header) + 3)
+ skb_pull(skb, ((rx_hdr.len +
+ sizeof(struct ax88772b_rx_header) + 3)
& 0xfffc));
}
@@ -3147,7 +3422,7 @@ ax88772b_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
&& ((headroom + tailroom) >= (4 + padlen))) {
if ((headroom < 4) || (tailroom < padlen)) {
skb->data = memmove(skb->head + 4, skb->data, skb->len);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
skb->tail = skb->data + skb->len;
#else
skb_set_tail_pointer(skb, skb->len);
@@ -3167,16 +3442,16 @@ ax88772b_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
skb_push(skb, 4);
packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
- cpu_to_le32s (&packet_len);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+ cpu_to_le32s(&packet_len);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
memcpy(skb->data, &packet_len, sizeof(packet_len));
#else
skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
#endif
if ((skb->len % 512) == 0) {
- cpu_to_le32s (&padbytes);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
+ cpu_to_le32s(&padbytes);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
memcpy(skb->tail, &padbytes, sizeof(padbytes));
#else
memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
@@ -3187,8 +3462,7 @@ ax88772b_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
return skb;
}
-static const u8 ChkCntSel [6][3] =
-{
+static const u8 chkcntsel[6][3] = {
{12, 23, 31},
{12, 31, 23},
{23, 31, 12},
@@ -3197,51 +3471,82 @@ static const u8 ChkCntSel [6][3] =
{31, 23, 12}
};
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void ax88772_link_reset (void *data)
+static void ax88772_save_bmcr_anar(struct usbnet *dev)
+{
+ struct ax88772_data *ax772_data = (struct ax88772_data *)dev->priv;
+
+ if (ax772_data) {
+ /* Preserve BMCR for restoring */
+ ax772_data->presvd_phy_bmcr =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_BMCR);
+
+ /* Preserve Advertisement control reg for restoring */
+ ax772_data->presvd_phy_advertise =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE);
+ }
+}
+
+static void ax88772_restore_bmcr_anar(struct usbnet *dev)
+{
+ struct ax88772_data *ax772_data = (struct ax88772_data *)dev->priv;
+
+ if (ax772_data && ax772_data->presvd_phy_advertise && ax772_data->presvd_phy_bmcr) {
+ /* Restore Advertisement control reg */
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE,
+ ax772_data->presvd_phy_advertise);
+ /* Restore BMCR */
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR,
+ ax772_data->presvd_phy_bmcr);
+ ax772_data->presvd_phy_advertise = 0;
+ ax772_data->presvd_phy_bmcr = 0;
+ }
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void ax88772_link_reset(void *data)
{
struct usbnet *dev = (struct usbnet *)data;
struct ax88772_data *ax772_data = (struct ax88772_data *)dev->priv;
#else
-static void ax88772_link_reset (struct work_struct *work)
+static void ax88772_link_reset(struct work_struct *work)
{
- struct ax88772_data *ax772_data = container_of (work,
- struct ax88772_data, check_link);
+ struct ax88772_data *ax772_data = container_of(work,
+ struct ax88772_data,
+ check_link);
struct usbnet *dev = ax772_data->dev;
#endif
-
if (ax772_data->Event == AX_SET_RX_CFG) {
u16 bmcr;
u16 mode;
-
+
ax772_data->Event = AX_NOP;
-
+
mode = AX88772_MEDIUM_DEFAULT;
- bmcr = ax8817x_mdio_read_le(dev->net,
- dev->mii.phy_id, MII_BMCR);
+ bmcr = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MII_BMCR);
if (!(bmcr & BMCR_FULLDPLX))
mode &= ~AX88772_MEDIUM_FULL_DUPLEX;
if (!(bmcr & BMCR_SPEED100))
mode &= ~AX88772_MEDIUM_100MB;
- ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- mode, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
+ mode, 0, 0, NULL);
return;
}
-
+
switch (ax772_data->Event) {
- case WAIT_AUTONEG_COMPLETE:
+ case WAIT_AUTONEG_COMPLETE:
if (jiffies > (ax772_data->autoneg_start + 5 * HZ)) {
ax772_data->Event = PHY_POWER_DOWN;
ax772_data->TickToExpire = 23;
}
break;
- case PHY_POWER_DOWN:
+ case PHY_POWER_DOWN:
if (ax772_data->TickToExpire == 23) {
+ ax88772_save_bmcr_anar(dev);
/* Set Phy Power Down */
- ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPPD,
+ ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD,
0, 0, NULL);
--ax772_data->TickToExpire;
} else if (--ax772_data->TickToExpire == 0) {
@@ -3259,60 +3564,79 @@ static void ax88772_link_reset (struct work_struct *work)
ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
AX_SWRESET_IPRL, 0, 0, NULL);
- ax8817x_mdio_write_le(dev->net, dev->mii.phy_id,
- MII_ADVERTISE,
- ADVERTISE_ALL | ADVERTISE_CSMA |
- ADVERTISE_PAUSE_CAP);
- mii_nway_restart(&dev->mii);
-
+ if (ax772_data->presvd_phy_advertise && ax772_data->presvd_phy_bmcr) {
+ ax88772_restore_bmcr_anar(dev);
+
+ } else {
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id,
+ MII_ADVERTISE,
+ ADVERTISE_ALL | ADVERTISE_CSMA |
+ ADVERTISE_PAUSE_CAP);
+ mii_nway_restart(&dev->mii);
+ }
+
ax772_data->Event = PHY_POWER_UP;
ax772_data->TickToExpire = 47;
}
break;
- case PHY_POWER_UP:
+ case PHY_POWER_UP:
if (--ax772_data->TickToExpire == 0) {
ax772_data->Event = PHY_POWER_DOWN;
ax772_data->TickToExpire = 23;
}
break;
- default:
+ default:
break;
}
return;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void ax88772a_link_reset (void *data)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void ax88772a_link_reset(void *data)
{
struct usbnet *dev = (struct usbnet *)data;
struct ax88772a_data *ax772a_data = (struct ax88772a_data *)dev->priv;
#else
-static void ax88772a_link_reset (struct work_struct *work)
+static void ax88772a_link_reset(struct work_struct *work)
{
- struct ax88772a_data *ax772a_data = container_of (work,
- struct ax88772a_data, check_link);
+ struct ax88772a_data *ax772a_data = container_of(work,
+ struct ax88772a_data,
+ check_link);
struct usbnet *dev = ax772a_data->dev;
#endif
- int PowSave = (ax772a_data->EepromData >> 14);
+ int powsave = (ax772a_data->EepromData >> 14);
u16 phy_reg;
-
+
if (ax772a_data->Event == AX_SET_RX_CFG) {
u16 bmcr;
u16 mode;
ax772a_data->Event = AX_NOP;
-
+
mode = AX88772_MEDIUM_DEFAULT;
- bmcr = ax8817x_mdio_read_le(dev->net,
- dev->mii.phy_id, MII_BMCR);
+ bmcr = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id,
+ MII_BMCR);
if (!(bmcr & BMCR_FULLDPLX))
mode &= ~AX88772_MEDIUM_FULL_DUPLEX;
if (!(bmcr & BMCR_SPEED100))
mode &= ~AX88772_MEDIUM_100MB;
- ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- mode, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode,
+ 0, 0, NULL);
+
+ if (ax772a_data->presvd_phy_advertise && ax772a_data->presvd_phy_bmcr) {
+
+ /* Restore Advertisement control reg */
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE,
+ ax772a_data->presvd_phy_advertise);
+ /* Restore BMCR */
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR,
+ ax772a_data->presvd_phy_bmcr);
+ ax772a_data->presvd_phy_advertise = 0;
+ ax772a_data->presvd_phy_bmcr = 0;
+ }
+
return;
}
@@ -3334,13 +3658,13 @@ static void ax88772a_link_reset (struct work_struct *work)
} else if (--ax772a_data->TickToExpire == 0) {
mii_nway_restart(&dev->mii);
ax772a_data->Event = CHK_CABLE_EXIST_AGAIN;
- if (PowSave == 0x03){
- ax772a_data->TickToExpire = 47;
- } else if (PowSave == 0x01) {
- ax772a_data->DlyIndex = (u8)(jiffies % 6);
- ax772a_data->DlySel = 0;
- ax772a_data->TickToExpire =
- ChkCntSel[ax772a_data->DlyIndex][ax772a_data->DlySel];
+ if (powsave == 0x03) {
+ ax772a_data->TickToExpire = 47;
+ } else if (powsave == 0x01) {
+ ax772a_data->DlyIndex = (u8)(jiffies % 6);
+ ax772a_data->DlySel = 0;
+ ax772a_data->TickToExpire =
+ chkcntsel[ax772a_data->DlyIndex][ax772a_data->DlySel];
}
}
break;
@@ -3352,22 +3676,31 @@ static void ax88772a_link_reset (struct work_struct *work)
ax772a_data->Event = CHK_CABLE_STATUS;
ax772a_data->TickToExpire = 31;
} else if (--ax772a_data->TickToExpire == 0) {
+ if (!ax772a_data->presvd_phy_advertise && !ax772a_data->presvd_phy_bmcr) {
+ /* Preserve BMCR for restoring */
+ ax772a_data->presvd_phy_bmcr =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_BMCR);
+
+ /* Preserve Advertisement control reg for restoring */
+ ax772a_data->presvd_phy_advertise =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE);
+ }
+
+
/* Power down PHY */
ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
AX_SWRESET_IPPD,
0, 0, NULL);
ax772a_data->Event = PHY_POWER_DOWN;
- if (PowSave == 0x03){
- ax772a_data->TickToExpire = 23;
- } else if (PowSave == 0x01) {
- ax772a_data->TickToExpire = 31;
- }
+ if (powsave == 0x03)
+ ax772a_data->TickToExpire = 23;
+ else if (powsave == 0x01)
+ ax772a_data->TickToExpire = 31;
}
break;
case PHY_POWER_DOWN:
- if (--ax772a_data->TickToExpire == 0) {
+ if (--ax772a_data->TickToExpire == 0)
ax772a_data->Event = PHY_POWER_UP;
- }
break;
case CHK_CABLE_STATUS:
if (--ax772a_data->TickToExpire == 0) {
@@ -3375,19 +3708,29 @@ static void ax88772a_link_reset (struct work_struct *work)
dev->mii.phy_id, 0x16, 0x4040);
mii_nway_restart(&dev->mii);
ax772a_data->Event = CHK_CABLE_EXIST_AGAIN;
- if (PowSave == 0x03){
- ax772a_data->TickToExpire = 47;
- } else if (PowSave == 0x01) {
- ax772a_data->DlyIndex = (u8)(jiffies % 6);
- ax772a_data->DlySel = 0;
- ax772a_data->TickToExpire =
- ChkCntSel[ax772a_data->DlyIndex][ax772a_data->DlySel];
+ if (powsave == 0x03) {
+ ax772a_data->TickToExpire = 47;
+ } else if (powsave == 0x01) {
+ ax772a_data->DlyIndex = (u8)(jiffies % 6);
+ ax772a_data->DlySel = 0;
+ ax772a_data->TickToExpire =
+ chkcntsel[ax772a_data->DlyIndex][ax772a_data->DlySel];
}
}
break;
case PHY_POWER_UP:
- ax88772a_phy_powerup (dev);
+ if (!ax772a_data->presvd_phy_advertise && !ax772a_data->presvd_phy_bmcr) {
+ /* Preserve BMCR for restoring */
+ ax772a_data->presvd_phy_bmcr =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_BMCR);
+
+ /* Preserve Advertisement control reg for restoring */
+ ax772a_data->presvd_phy_advertise =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE);
+ }
+
+ ax88772a_phy_powerup(dev);
ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
@@ -3396,17 +3739,15 @@ static void ax88772a_link_reset (struct work_struct *work)
ax772a_data->Event = CHK_CABLE_EXIST_AGAIN;
- if (PowSave == 0x03){
- ax772a_data->TickToExpire = 47;
-
- } else if (PowSave == 0x01) {
-
- if (++ax772a_data->DlySel >= 3) {
- ax772a_data->DlyIndex = (u8)(jiffies % 6);
- ax772a_data->DlySel = 0;
- }
- ax772a_data->TickToExpire =
- ChkCntSel[ax772a_data->DlyIndex][ax772a_data->DlySel];
+ if (powsave == 0x03) {
+ ax772a_data->TickToExpire = 47;
+ } else if (powsave == 0x01) {
+ if (++ax772a_data->DlySel >= 3) {
+ ax772a_data->DlyIndex = (u8)(jiffies % 6);
+ ax772a_data->DlySel = 0;
+ }
+ ax772a_data->TickToExpire =
+ chkcntsel[ax772a_data->DlyIndex][ax772a_data->DlySel];
}
break;
default:
@@ -3416,16 +3757,17 @@ static void ax88772a_link_reset (struct work_struct *work)
return;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void ax88772b_link_reset (void *data)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void ax88772b_link_reset(void *data)
{
struct usbnet *dev = (struct usbnet *)data;
struct ax88772b_data *ax772b_data = (struct ax88772b_data *)dev->priv;
#else
-static void ax88772b_link_reset (struct work_struct *work)
+static void ax88772b_link_reset(struct work_struct *work)
{
- struct ax88772b_data *ax772b_data = container_of (work,
- struct ax88772b_data, check_link);
+ struct ax88772b_data *ax772b_data = container_of(work,
+ struct ax88772b_data,
+ check_link);
struct usbnet *dev = ax772b_data->dev;
#endif
@@ -3442,43 +3784,53 @@ static void ax88772b_link_reset (struct work_struct *work)
if (!(bmcr & BMCR_SPEED100))
mode &= ~AX88772_MEDIUM_100MB;
- ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- mode, 0, 0, NULL);
+ ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode,
+ 0, 0, NULL);
break;
}
case PHY_POWER_UP:
{
u16 tmp16;
- ax88772a_phy_powerup (dev);
+ if (!ax772b_data->presvd_phy_advertise && !ax772b_data->presvd_phy_bmcr) {
+ /* Preserve BMCR for restoring */
+ ax772b_data->presvd_phy_bmcr =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_BMCR);
+
+ /* Preserve Advertisement control reg for restoring */
+ ax772b_data->presvd_phy_advertise =
+ ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE);
+ }
+
+ ax88772a_phy_powerup(dev);
tmp16 = ax8817x_mdio_read_le(dev->net, dev->mii.phy_id, 0x12);
ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, 0x12,
((tmp16 & 0xFF9F) | 0x0040));
+ /* Restore Advertisement control reg */
ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE,
- ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
+ ax772b_data->presvd_phy_advertise);
+ /* Restore BMCR */
+ ax8817x_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR,
+ ax772b_data->presvd_phy_bmcr);
+ ax772b_data->presvd_phy_advertise = 0;
+ ax772b_data->presvd_phy_bmcr = 0;
+
break;
}
+
case AX_CHK_AUTODETACH:
{
- u16 tmp16;
int ret;
- void *buf;
- buf = kmalloc(6, GFP_KERNEL);
- devwarn(dev, "EVENT: AX_CHK_AUTODETACH\n");
- /* Get the EEPROM data*/
- if ((ret = ax8817x_read_cmd (dev, AX_CMD_READ_EEPROM,
- 0x18, 0, 2, (void *)(&tmp16))) < 0) {
- deverr(dev, "read SROM address 18h failed: %d", ret);
- }
- else {
- ax772b_data->psc = le16_to_cpu(tmp16) & 0xFF00;
- devwarn(dev, "EEPROM (0x18) = : %04X", ax772b_data->psc);
- if ((ret = ax8817x_write_cmd (dev, AX_CMD_SW_RESET,
- AX_SWRESET_IPRL | (ax772b_data->psc & 0x7FFF), 0, 0, buf)) < 0) {
- deverr(dev, "Failed to configure PHY power saving: %d", ret);
- }
+ ret = ax8817x_write_cmd(dev, AX_CMD_SW_RESET,
+ AX_SWRESET_IPRL |
+ (ax772b_data->psc & 0x7FFF),
+ 0, 0, NULL);
+ if (ret < 0) {
+ deverr(dev, "Failed to configure PHY power saving: %d",
+ ret);
}
+
break;
}
default:
@@ -3486,7 +3838,7 @@ static void ax88772b_link_reset (struct work_struct *work)
}
ax772b_data->Event = AX_NOP;
-
+
return;
}
@@ -3496,12 +3848,13 @@ static int ax88178_set_media(struct usbnet *dev)
struct ax88178_data *ax178dataptr = (struct ax88178_data *)dev->priv;
int media;
- media = ax88178_media_check (dev, ax178dataptr);
+ media = ax88178_media_check(dev, ax178dataptr);
if (media < 0)
return media;
- if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE,
- media, 0, 0, NULL)) < 0) {
+ ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, media, 0,
+ 0, NULL);
+ if (ret < 0) {
deverr(dev, "write mode medium reg failed: %d", ret);
return ret;
}
@@ -3511,11 +3864,11 @@ static int ax88178_set_media(struct usbnet *dev)
static int ax88178_link_reset(struct usbnet *dev)
{
- return ax88178_set_media (dev);
+ return ax88178_set_media(dev);
}
-static int ax_suspend (struct usb_interface *intf,
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+static int ax_suspend(struct usb_interface *intf,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10)
pm_message_t message)
#else
u32 message)
@@ -3524,244 +3877,334 @@ static int ax_suspend (struct usb_interface *intf,
struct usbnet *dev = usb_get_intfdata(intf);
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
- return data->suspend (intf, message);
+ return data->suspend(intf, message);
}
-static int ax_resume (struct usb_interface *intf)
+static int ax_resume(struct usb_interface *intf)
{
struct usbnet *dev = usb_get_intfdata(intf);
struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
- return data->resume (intf);
+ return data->resume(intf);
}
static const struct driver_info ax88178_info = {
.description = "ASIX AX88178 USB 2.0 Ethernet",
- .bind = ax88178_bind,
+ .bind = ax88178_bind,
.unbind = ax88178_unbind,
.status = ax88178_status,
.link_reset = ax88178_link_reset,
- .reset = ax88178_link_reset,
- .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+ .reset = ax88178_link_reset,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#endif
.rx_fixup = ax88772_rx_fixup,
.tx_fixup = ax88772_tx_fixup,
};
static const struct driver_info belkin178_info = {
.description = "Belkin Gigabit USB 2.0 Network Adapter",
- .bind = ax88178_bind,
- .unbind = ax88178_unbind,
- .status = ax8817x_status,
+ .bind = ax88178_bind,
+ .unbind = ax88178_unbind,
+ .status = ax88178_status,
.link_reset = ax88178_link_reset,
- .reset = ax88178_link_reset,
- .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+ .reset = ax88178_link_reset,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#endif
.rx_fixup = ax88772_rx_fixup,
.tx_fixup = ax88772_tx_fixup,
};
static const struct driver_info ax8817x_info = {
.description = "ASIX AX8817x USB 2.0 Ethernet",
- .bind = ax8817x_bind,
- .status = ax8817x_status,
+ .bind = ax8817x_bind,
+ .status = ax8817x_status,
.link_reset = ax88172_link_reset,
- .reset = ax88172_link_reset,
- .flags = FLAG_ETHER,
+ .reset = ax88172_link_reset,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER,
+#endif
};
static const struct driver_info dlink_dub_e100_info = {
.description = "DLink DUB-E100 USB Ethernet",
- .bind = ax8817x_bind,
- .status = ax8817x_status,
+ .bind = ax8817x_bind,
+ .status = ax8817x_status,
.link_reset = ax88172_link_reset,
- .reset = ax88172_link_reset,
- .flags = FLAG_ETHER,
+ .reset = ax88172_link_reset,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER,
+#endif
};
static const struct driver_info netgear_fa120_info = {
.description = "Netgear FA-120 USB Ethernet",
- .bind = ax8817x_bind,
+ .bind = ax8817x_bind,
.status = ax8817x_status,
.link_reset = ax88172_link_reset,
- .reset = ax88172_link_reset,
- .flags = FLAG_ETHER,
+ .reset = ax88172_link_reset,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER,
+#endif
};
static const struct driver_info hawking_uf200_info = {
.description = "Hawking UF200 USB Ethernet",
- .bind = ax8817x_bind,
+ .bind = ax8817x_bind,
.status = ax8817x_status,
.link_reset = ax88172_link_reset,
- .reset = ax88172_link_reset,
- .flags = FLAG_ETHER,
+ .reset = ax88172_link_reset,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER,
+#endif
};
static const struct driver_info ax88772_info = {
.description = "ASIX AX88772 USB 2.0 Ethernet",
- .bind = ax88772_bind,
+ .bind = ax88772_bind,
.unbind = ax88772_unbind,
.status = ax88772_status,
- .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#endif
.rx_fixup = ax88772_rx_fixup,
.tx_fixup = ax88772_tx_fixup,
- .stop = ax88772b_stop,
- .reset = ax88772b_reset,
+ .reset = ax88772b_reset,
};
static const struct driver_info dlink_dub_e100b_info = {
.description = "D-Link DUB-E100 USB 2.0 Fast Ethernet Adapter",
- .bind = ax88772_bind,
+ .bind = ax88772_bind,
.unbind = ax88772_unbind,
.status = ax88772_status,
- .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#endif
.rx_fixup = ax88772_rx_fixup,
.tx_fixup = ax88772_tx_fixup,
- .stop = ax88772b_stop,
- .reset = ax88772b_reset,
+ .reset = ax88772b_reset,
+};
+
+static const struct driver_info dlink_dub_e100b_772b_info = {
+ .description = "D-Link DUB-E100 USB 2.0 Fast Ethernet Adapter",
+ .bind = ax88772b_bind,
+ .unbind = ax88772b_unbind,
+ .status = ax88772b_status,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT,
+#endif
+ .rx_fixup = ax88772b_rx_fixup,
+ .tx_fixup = ax88772b_tx_fixup,
+ .reset = ax88772b_reset,
};
static const struct driver_info ax88772a_info = {
.description = "ASIX AX88772A USB 2.0 Ethernet",
- .bind = ax88772a_bind,
+ .bind = ax88772a_bind,
.unbind = ax88772a_unbind,
.status = ax88772a_status,
- .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX,
+#endif
.rx_fixup = ax88772_rx_fixup,
.tx_fixup = ax88772_tx_fixup,
- .stop = ax88772b_stop,
- .reset = ax88772b_reset,
+ .reset = ax88772b_reset,
};
static const struct driver_info ax88772b_info = {
.description = "ASIX AX88772B USB 2.0 Ethernet",
- .bind = ax88772b_bind,
+ .bind = ax88772b_bind,
.unbind = ax88772b_unbind,
.status = ax88772b_status,
- .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT,
+#endif
+ .rx_fixup = ax88772b_rx_fixup,
+ .tx_fixup = ax88772b_tx_fixup,
+ .reset = ax88772b_reset,
+};
+
+static const struct driver_info ax88772c_info = {
+ .description = "ASIX AX88772C USB 2.0 Ethernet",
+ .bind = ax88772b_bind,
+ .unbind = ax88772b_unbind,
+ .status = ax88772c_status,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
+ .stop = ax88772b_stop,
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT | FLAG_AVOID_UNLINK_URBS,
+#else
+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_HW_IP_ALIGNMENT,
+#endif
.rx_fixup = ax88772b_rx_fixup,
.tx_fixup = ax88772b_tx_fixup,
- .stop = ax88772b_stop,
- .reset = ax88772b_reset,
+ .reset = ax88772b_reset,
};
-static const struct usb_device_id products [] = {
+static const struct usb_device_id products[] = {
{
- // 88178
- USB_DEVICE (0x0b95, 0x1780),
+ /* 88178 */
+ USB_DEVICE(0x0b95, 0x1780),
.driver_info = (unsigned long) &ax88178_info,
}, {
- // 88178 for billianton linksys
- USB_DEVICE (0x077b, 0x2226),
+ /* 88178 for billianton linksys */
+ USB_DEVICE(0x077b, 0x2226),
.driver_info = (unsigned long) &ax88178_info,
}, {
- // ABOCOM for linksys
- USB_DEVICE (0x1737, 0x0039),
+ /* ABOCOM for linksys */
+ USB_DEVICE(0x1737, 0x0039),
.driver_info = (unsigned long) &ax88178_info,
}, {
- // ABOCOM for pci
- USB_DEVICE (0x14ea, 0xab11),
+ /* ABOCOM for pci */
+ USB_DEVICE(0x14ea, 0xab11),
.driver_info = (unsigned long) &ax88178_info,
}, {
- // Belkin
- USB_DEVICE (0x050d, 0x5055),
+ /* Belkin */
+ USB_DEVICE(0x050d, 0x5055),
.driver_info = (unsigned long) &belkin178_info,
}, {
- // Linksys USB200M
- USB_DEVICE (0x077b, 0x2226),
+ /* Linksys USB200M */
+ USB_DEVICE(0x077b, 0x2226),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // Netgear FA120
- USB_DEVICE (0x0846, 0x1040),
+ /* Netgear FA120 */
+ USB_DEVICE(0x0846, 0x1040),
.driver_info = (unsigned long) &netgear_fa120_info,
}, {
- // DLink DUB-E100
- USB_DEVICE (0x2001, 0x1a00),
+ /* DLink DUB-E100 */
+ USB_DEVICE(0x2001, 0x1a00),
.driver_info = (unsigned long) &dlink_dub_e100_info,
}, {
- // DLink DUB-E100B
- USB_DEVICE (0x2001, 0x3c05),
+ /* DLink DUB-E100B */
+ USB_DEVICE(0x2001, 0x3c05),
.driver_info = (unsigned long) &dlink_dub_e100b_info,
}, {
- // DLink DUB-E100B
- USB_DEVICE (0x07d1, 0x3c05),
+ /* DLink DUB-E100B */
+ USB_DEVICE(0x07d1, 0x3c05),
.driver_info = (unsigned long) &dlink_dub_e100b_info,
}, {
- // Intellinet, ST Lab USB Ethernet
- USB_DEVICE (0x0b95, 0x1720),
+ /* DLink DUB-E100 (AX88772B)*/
+ USB_DEVICE(0x2001, 0x1a02),
+ .driver_info = (unsigned long) &dlink_dub_e100b_772b_info,
+}, {
+ /* Intellinet, ST Lab USB Ethernet */
+ USB_DEVICE(0x0b95, 0x1720),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // Hawking UF200, TrendNet TU2-ET100
- USB_DEVICE (0x07b8, 0x420a),
+ /* Hawking UF200, TrendNet TU2-ET100 */
+ USB_DEVICE(0x07b8, 0x420a),
.driver_info = (unsigned long) &hawking_uf200_info,
}, {
- // Billionton Systems, USB2AR
- USB_DEVICE (0x08dd, 0x90ff),
- .driver_info = (unsigned long) &ax8817x_info,
+ /* Billionton Systems, USB2AR */
+ USB_DEVICE(0x08dd, 0x90ff),
+ .driver_info = (unsigned long) &ax8817x_info,
}, {
- // ATEN UC210T
- USB_DEVICE (0x0557, 0x2009),
+ /* ATEN UC210T */
+ USB_DEVICE(0x0557, 0x2009),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // Buffalo LUA-U2-KTX
- USB_DEVICE (0x0411, 0x003d),
+ /* Buffalo LUA-U2-KTX */
+ USB_DEVICE(0x0411, 0x003d),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
- USB_DEVICE (0x6189, 0x182d),
+ /* Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" */
+ USB_DEVICE(0x6189, 0x182d),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // corega FEther USB2-TX
- USB_DEVICE (0x07aa, 0x0017),
+ /* corega FEther USB2-TX */
+ USB_DEVICE(0x07aa, 0x0017),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // Surecom EP-1427X-2
- USB_DEVICE (0x1189, 0x0893),
+ /* Surecom EP-1427X-2 */
+ USB_DEVICE(0x1189, 0x0893),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // goodway corp usb gwusb2e
- USB_DEVICE (0x1631, 0x6200),
+ /* goodway corp usb gwusb2e */
+ USB_DEVICE(0x1631, 0x6200),
.driver_info = (unsigned long) &ax8817x_info,
}, {
- // ASIX AX88772 10/100
- USB_DEVICE (0x0b95, 0x7720),
- .driver_info = (unsigned long) &ax88772_info,
+ /* ASIX AX88772 10/100 */
+ USB_DEVICE(0x0b95, 0x7720),
+ .driver_info = (unsigned long) &ax88772_info,
+}, {
+ /* ASIX AX88772 10/100 */
+ USB_DEVICE(0x125E, 0x180D),
+ .driver_info = (unsigned long) &ax88772_info,
}, {
- // ASIX AX88772 10/100
- USB_DEVICE (0x125E, 0x180D),
- .driver_info = (unsigned long) &ax88772_info,
+ /* ASIX AX88772A 10/100 */
+ USB_DEVICE(0x0b95, 0x772A),
+ .driver_info = (unsigned long) &ax88772a_info,
}, {
- // ASIX AX88772A 10/100
- USB_DEVICE (0x0b95, 0x772A),
- .driver_info = (unsigned long) &ax88772a_info,
+ /* ASIX AX88772A 10/100 */
+ USB_DEVICE(0x0db0, 0xA877),
+ .driver_info = (unsigned long) &ax88772a_info,
}, {
- // ASIX AX88772A 10/100
- USB_DEVICE (0x0db0, 0xA877),
- .driver_info = (unsigned long) &ax88772a_info,
+ /* ASIX AX88772A 10/100 */
+ USB_DEVICE(0x0421, 0x772A),
+ .driver_info = (unsigned long) &ax88772a_info,
}, {
- // ASIX AX88772A 10/100
- USB_DEVICE (0x0421, 0x772A),
- .driver_info = (unsigned long) &ax88772a_info,
+ /* Linksys 200M */
+ USB_DEVICE(0x13B1, 0x0018),
+ .driver_info = (unsigned long) &ax88772a_info,
}, {
- // Linksys 200M
- USB_DEVICE (0x13B1, 0x0018),
- .driver_info = (unsigned long) &ax88772a_info,
+ USB_DEVICE(0x05ac, 0x1402),
+ .driver_info = (unsigned long) &ax88772a_info,
}, {
- USB_DEVICE (0x05ac, 0x1402),
- .driver_info = (unsigned long) &ax88772a_info,
+ /* ASIX AX88772B 10/100 */
+ USB_DEVICE_VER(0x0b95, 0x772B, 0, 1),
+ .driver_info = (unsigned long) &ax88772b_info,
}, {
- // ASIX AX88772B 10/100
- USB_DEVICE (0x0b95, 0x772B),
- .driver_info = (unsigned long) &ax88772b_info,
+ /* Asus AX88772B 10/100 */
+ USB_DEVICE_VER(0x0b95, 0x7e2b, 0, 1),
+ .driver_info = (unsigned long) &ax88772b_info,
}, {
- // ASIX AX88772B 10/100
- USB_DEVICE (0x0b95, 0x7E2B),
- .driver_info = (unsigned long) &ax88772b_info,
+ /* Lenovo AX88772B 10/100 */
+ USB_DEVICE_VER(0x17ef, 0x7203, 0, 1),
+ .driver_info = (unsigned long) &ax88772b_info,
+},{
+ /* ASIX AX88772B ver.2 10/100 */
+ USB_DEVICE_VER(0x0b95, 0x772B, 0, 2),
+ .driver_info = (unsigned long) &ax88772c_info,
},
- { }, // END
+ { }, /* END */
};
MODULE_DEVICE_TABLE(usb, products);
static struct usb_driver asix_driver = {
-// .owner = THIS_MODULE,
+ /* .owner = THIS_MODULE, */
.name = "asix",
.id_table = products,
.probe = axusbnet_probe,
@@ -3772,13 +4215,13 @@ static struct usb_driver asix_driver = {
static int __init asix_init(void)
{
- return usb_register(&asix_driver);
+ return usb_register(&asix_driver);
}
module_init(asix_init);
static void __exit asix_exit(void)
{
- usb_deregister(&asix_driver);
+ usb_deregister(&asix_driver);
}
module_exit(asix_exit);
diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h
index ea51eb7001e2..a8b13d9794c8 100644
--- a/drivers/net/usb/asix.h
+++ b/drivers/net/usb/asix.h
@@ -11,6 +11,8 @@
*/
#define AX_FORCE_BUFF_ALIGN 0
+//#define RX_SKB_COPY
+
#define AX_MONITOR_MODE 0x01
#define AX_MONITOR_LINK 0x02
#define AX_MONITOR_MAGIC 0x04
@@ -59,11 +61,14 @@
#define AX88772_MEDIUM_DEFAULT \
(AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \
AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \
- AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE )
+ AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE)
#define AX_CMD_SET_SW_MII 0x06
#define AX_CMD_READ_MII_REG 0x07
#define AX_CMD_WRITE_MII_REG 0x08
+#define AX_CMD_READ_STATMNGSTS_REG 0x09
+ #define AX_HOST_EN 0x01
+
#define AX_CMD_SET_HW_MII 0x0a
#define AX_CMD_READ_EEPROM 0x0b
#define AX_CMD_WRITE_EEPROM 0x0c
@@ -82,7 +87,7 @@
#define AX_CMD_READ_MONITOR_MODE 0x1c
#define AX_CMD_WRITE_MONITOR_MODE 0x1d
#define AX_CMD_WRITE_GPIOS 0x1f
-#define AX_CMD_SW_RESET 0x20
+#define AX_CMD_SW_RESET 0x20
#define AX_CMD_SW_PHY_STATUS 0x21
#define AX_CMD_SW_PHY_SELECT 0x22
#define AX_PHYSEL_PSEL (1 << 0)
@@ -93,6 +98,8 @@
#define AX_PHYSEL_SSEN (1 << 4)
#define AX88772_CMD_READ_NODE_ID 0x13
#define AX88772_CMD_WRITE_NODE_ID 0x14
+#define AX_CMD_READ_WKFARY 0x23
+#define AX_CMD_WRITE_WKFARY 0x24
#define AX_CMD_READ_RXCOE_CTL 0x2b
#define AX_CMD_WRITE_RXCOE_CTL 0x2c
#define AX_CMD_READ_TXCOE_CTL 0x2d
@@ -115,7 +122,7 @@
#define AX_RXCOE_IGMV6 0x0800
#define AX_RXCOE_ICV6V6 0x1000
#define AX_RXCOE_FOPC 0x8000
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
#define AX_RXCOE_DEF_CSUM (AX_RXCOE_IPCE | AX_RXCOE_IPVE | \
AX_RXCOE_V6VE | AX_RXCOE_TCPE | \
AX_RXCOE_UDPE | AX_RXCOE_ICV6 | \
@@ -141,7 +148,7 @@
#define AX_TXCOE_ICMV6 0x0400
#define AX_TXCOE_IGMV6 0x0800
#define AX_TXCOE_ICV6V6 0x1000
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,22)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)
#define AX_TXCOE_DEF_CSUM (AX_TXCOE_TCP | AX_TXCOE_UDP | \
AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6)
#else
@@ -159,8 +166,7 @@
#define AX88772B_MAX_BULKIN_20K 5
#define AX88772B_MAX_BULKIN_24K 6
#define AX88772B_MAX_BULKIN_32K 7
-struct {unsigned short size, byte_cnt,threshold;} AX88772B_BULKIN_SIZE[] =
-{
+struct {unsigned short size, byte_cnt, threshold; } AX88772B_BULKIN_SIZE[] = {
/* 2k */
{2048, 0x8000, 0x8001},
/* 4k */
@@ -188,107 +194,107 @@ struct {unsigned short size, byte_cnt,threshold;} AX88772B_BULKIN_SIZE[] =
#define AX_RX_CTL_MFB 0x0300 /* Maximum Frame size 16384bytes */
#define AX_RX_CTL_START 0x0080 /* Ethernet MAC start */
#define AX_RX_CTL_AP 0x0020 /* Accept physcial address from Multicast array */
-#define AX_RX_CTL_AM 0x0010
+#define AX_RX_CTL_AM 0x0010
#define AX_RX_CTL_AB 0x0008 /* Accetp Brocadcast frames*/
-#define AX_RX_CTL_SEP 0x0004 /* Save error packets */
+#define AX_RX_CTL_SEP 0x0004 /* Save error packets */
#define AX_RX_CTL_AMALL 0x0002 /* Accetp all multicast frames */
#define AX_RX_CTL_PRO 0x0001 /* Promiscuous Mode */
#define AX_RX_CTL_STOP 0x0000 /* Stop MAC */
-#define AX_MONITOR_MODE 0x01
-#define AX_MONITOR_LINK 0x02
+#define AX_MONITOR_MODE 0x01
+#define AX_MONITOR_LINK 0x02
#define AX_MONITOR_MAGIC 0x04
-#define AX_MONITOR_HSFS 0x10
+#define AX_MONITOR_HSFS 0x10
#define AX_MCAST_FILTER_SIZE 8
#define AX_MAX_MCAST 64
#define AX_INTERRUPT_BUFSIZE 8
#define AX_EEPROM_LEN 0x40
-#define AX_EEPROM_MAGIC 0xdeadbeef
+#define AX_EEPROM_MAGIC 0xdeadbeef
#define EEPROMMASK 0x7f
/* GPIO REGISTER */
-#define AXGPIOS_GPO0EN 0X01 // 1 << 0
-#define AXGPIOS_GPO0 0X02 // 1 << 1
-#define AXGPIOS_GPO1EN 0X04 // 1 << 2
-#define AXGPIOS_GPO1 0X08 // 1 << 3
-#define AXGPIOS_GPO2EN 0X10 // 1 << 4
-#define AXGPIOS_GPO2 0X20 // 1 << 5
-#define AXGPIOS_RSE 0X80 // 1 << 7
+#define AXGPIOS_GPO0EN 0X01 /* 1 << 0 */
+#define AXGPIOS_GPO0 0X02 /* 1 << 1 */
+#define AXGPIOS_GPO1EN 0X04 /* 1 << 2 */
+#define AXGPIOS_GPO1 0X08 /* 1 << 3 */
+#define AXGPIOS_GPO2EN 0X10 /* 1 << 4 */
+#define AXGPIOS_GPO2 0X20 /* 1 << 5 */
+#define AXGPIOS_RSE 0X80 /* 1 << 7 */
/* TX-header format */
#define AX_TX_HDR_CPHI 0x4000
#define AX_TX_HDR_DICF 0x8000
-// GMII register definitions
-#define GMII_PHY_CONTROL 0x00 // control reg
-#define GMII_PHY_STATUS 0x01 // status reg
-#define GMII_PHY_OUI 0x02 // most of the OUI bits
-#define GMII_PHY_MODEL 0x03 // model/rev bits, and rest of OUI
-#define GMII_PHY_ANAR 0x04 // AN advertisement reg
-#define GMII_PHY_ANLPAR 0x05 // AN Link Partner
-#define GMII_PHY_ANER 0x06 // AN expansion reg
-#define GMII_PHY_1000BT_CONTROL 0x09 // control reg for 1000BT
-#define GMII_PHY_1000BT_STATUS 0x0A // status reg for 1000BT
-
-// Bit definitions: GMII Control
-#define GMII_CONTROL_RESET 0x8000 // reset bit in control reg
-#define GMII_CONTROL_LOOPBACK 0x4000 // loopback bit in control reg
-#define GMII_CONTROL_10MB 0x0000 // 10 Mbit
-#define GMII_CONTROL_100MB 0x2000 // 100Mbit
-#define GMII_CONTROL_1000MB 0x0040 // 1000Mbit
-#define GMII_CONTROL_SPEED_BITS 0x2040 // speed bit mask
-#define GMII_CONTROL_ENABLE_AUTO 0x1000 // autonegotiate enable
+/* GMII register definitions */
+#define GMII_PHY_CONTROL 0x00 /* control reg */
+#define GMII_PHY_STATUS 0x01 /* status reg */
+#define GMII_PHY_OUI 0x02 /* most of the OUI bits */
+#define GMII_PHY_MODEL 0x03 /* model/rev bits, and rest of OUI */
+#define GMII_PHY_ANAR 0x04 /* AN advertisement reg */
+#define GMII_PHY_ANLPAR 0x05 /* AN Link Partner */
+#define GMII_PHY_ANER 0x06 /* AN expansion reg */
+#define GMII_PHY_1000BT_CONTROL 0x09 /* control reg for 1000BT */
+#define GMII_PHY_1000BT_STATUS 0x0A /* status reg for 1000BT */
+
+/* Bit definitions: GMII Control */
+#define GMII_CONTROL_RESET 0x8000 /* reset bit in control reg */
+#define GMII_CONTROL_LOOPBACK 0x4000 /* loopback bit in control reg */
+#define GMII_CONTROL_10MB 0x0000 /* 10 Mbit */
+#define GMII_CONTROL_100MB 0x2000 /* 100Mbit */
+#define GMII_CONTROL_1000MB 0x0040 /* 1000Mbit */
+#define GMII_CONTROL_SPEED_BITS 0x2040 /* speed bit mask */
+#define GMII_CONTROL_ENABLE_AUTO 0x1000 /* autonegotiate enable */
#define GMII_CONTROL_POWER_DOWN 0x0800
-#define GMII_CONTROL_ISOLATE 0x0400 // islolate bit
-#define GMII_CONTROL_START_AUTO 0x0200 // restart autonegotiate
+#define GMII_CONTROL_ISOLATE 0x0400 /* islolate bit */
+#define GMII_CONTROL_START_AUTO 0x0200 /* restart autonegotiate */
#define GMII_CONTROL_FULL_DUPLEX 0x0100
-// Bit definitions: GMII Status
-#define GMII_STATUS_100MB_MASK 0xE000 // any of these indicate 100 Mbit
-#define GMII_STATUS_10MB_MASK 0x1800 // either of these indicate 10 Mbit
-#define GMII_STATUS_AUTO_DONE 0x0020 // auto negotiation complete
-#define GMII_STATUS_AUTO 0x0008 // auto negotiation is available
-#define GMII_STATUS_LINK_UP 0x0004 // link status bit
-#define GMII_STATUS_EXTENDED 0x0001 // extended regs exist
-#define GMII_STATUS_100T4 0x8000 // capable of 100BT4
-#define GMII_STATUS_100TXFD 0x4000 // capable of 100BTX full duplex
-#define GMII_STATUS_100TX 0x2000 // capable of 100BTX
-#define GMII_STATUS_10TFD 0x1000 // capable of 10BT full duplex
-#define GMII_STATUS_10T 0x0800 // capable of 10BT
-
-// Bit definitions: Auto-Negotiation Advertisement
-#define GMII_ANAR_ASYM_PAUSE 0x0800 // support asymetric pause
-#define GMII_ANAR_PAUSE 0x0400 // support pause packets
-#define GMII_ANAR_100T4 0x0200 // support 100BT4
-#define GMII_ANAR_100TXFD 0x0100 // support 100BTX full duplex
-#define GMII_ANAR_100TX 0x0080 // support 100BTX half duplex
-#define GMII_ANAR_10TFD 0x0040 // support 10BT full duplex
-#define GMII_ANAR_10T 0x0020 // support 10BT half duplex
-#define GMII_SELECTOR_FIELD 0x001F // selector field.
-
-// Bit definitions: Auto-Negotiation Link Partner Ability
-#define GMII_ANLPAR_100T4 0x0200 // support 100BT4
-#define GMII_ANLPAR_100TXFD 0x0100 // support 100BTX full duplex
-#define GMII_ANLPAR_100TX 0x0080 // support 100BTX half duplex
-#define GMII_ANLPAR_10TFD 0x0040 // support 10BT full duplex
-#define GMII_ANLPAR_10T 0x0020 // support 10BT half duplex
-#define GMII_ANLPAR_PAUSE 0x0400 // support pause packets
-#define GMII_ANLPAR_ASYM_PAUSE 0x0800 // support asymetric pause
-#define GMII_ANLPAR_ACK 0x4000 // means LCB was successfully rx'd
+/* Bit definitions: GMII Status */
+#define GMII_STATUS_100MB_MASK 0xE000 /* any of these indicate 100 Mbit */
+#define GMII_STATUS_10MB_MASK 0x1800 /* either of these indicate 10 Mbit */
+#define GMII_STATUS_AUTO_DONE 0x0020 /* auto negotiation complete */
+#define GMII_STATUS_AUTO 0x0008 /* auto negotiation is available */
+#define GMII_STATUS_LINK_UP 0x0004 /* link status bit */
+#define GMII_STATUS_EXTENDED 0x0001 /* extended regs exist */
+#define GMII_STATUS_100T4 0x8000 /* capable of 100BT4 */
+#define GMII_STATUS_100TXFD 0x4000 /* capable of 100BTX full duplex */
+#define GMII_STATUS_100TX 0x2000 /* capable of 100BTX */
+#define GMII_STATUS_10TFD 0x1000 /* capable of 10BT full duplex */
+#define GMII_STATUS_10T 0x0800 /* capable of 10BT */
+
+/* Bit definitions: Auto-Negotiation Advertisement */
+#define GMII_ANAR_ASYM_PAUSE 0x0800 /* support asymetric pause */
+#define GMII_ANAR_PAUSE 0x0400 /* support pause packets */
+#define GMII_ANAR_100T4 0x0200 /* support 100BT4 */
+#define GMII_ANAR_100TXFD 0x0100 /* support 100BTX full duplex */
+#define GMII_ANAR_100TX 0x0080 /* support 100BTX half duplex */
+#define GMII_ANAR_10TFD 0x0040 /* support 10BT full duplex */
+#define GMII_ANAR_10T 0x0020 /* support 10BT half duplex */
+#define GMII_SELECTOR_FIELD 0x001F /* selector field. */
+
+/* Bit definitions: Auto-Negotiation Link Partner Ability */
+#define GMII_ANLPAR_100T4 0x0200 /* support 100BT4 */
+#define GMII_ANLPAR_100TXFD 0x0100 /* support 100BTX full duplex */
+#define GMII_ANLPAR_100TX 0x0080 /* support 100BTX half duplex */
+#define GMII_ANLPAR_10TFD 0x0040 /* support 10BT full duplex */
+#define GMII_ANLPAR_10T 0x0020 /* support 10BT half duplex */
+#define GMII_ANLPAR_PAUSE 0x0400 /* support pause packets */
+#define GMII_ANLPAR_ASYM_PAUSE 0x0800 /* support asymetric pause */
+#define GMII_ANLPAR_ACK 0x4000 /* means LCB was successfully rx'd */
#define GMII_SELECTOR_8023 0x0001;
-// Bit definitions: 1000BaseT AUX Control
+/* Bit definitions: 1000BaseT AUX Control */
#define GMII_1000_AUX_CTRL_MASTER_SLAVE 0x1000
-#define GMII_1000_AUX_CTRL_FD_CAPABLE 0x0200 // full duplex capable
-#define GMII_1000_AUX_CTRL_HD_CAPABLE 0x0100 // half duplex capable
+#define GMII_1000_AUX_CTRL_FD_CAPABLE 0x0200 /* full duplex capable */
+#define GMII_1000_AUX_CTRL_HD_CAPABLE 0x0100 /* half duplex capable */
-// Bit definitions: 1000BaseT AUX Status
-#define GMII_1000_AUX_STATUS_FD_CAPABLE 0x0800 // full duplex capable
-#define GMII_1000_AUX_STATUS_HD_CAPABLE 0x0400 // half duplex capable
+/* Bit definitions: 1000BaseT AUX Status */
+#define GMII_1000_AUX_STATUS_FD_CAPABLE 0x0800 /* full duplex capable */
+#define GMII_1000_AUX_STATUS_HD_CAPABLE 0x0400 /* half duplex capable */
-// Cicada MII Registers
+/* Cicada MII Registers */
#define GMII_AUX_CTRL_STATUS 0x1C
#define GMII_AUX_ANEG_CPLT 0x8000
#define GMII_AUX_FDX 0x0020
@@ -307,7 +313,7 @@ struct {unsigned short size, byte_cnt,threshold;} AX88772B_BULKIN_SIZE[] =
#define LPA_1000FULL 0x0800
#endif
-// medium mode register
+/* medium mode register */
#define MEDIUM_GIGA_MODE 0x0001
#define MEDIUM_FULL_DUPLEX_MODE 0x0002
#define MEDIUM_TX_ABORT_MODE 0x0004
@@ -362,9 +368,7 @@ struct {unsigned short size, byte_cnt,threshold;} AX88772B_BULKIN_SIZE[] =
#define CICADA_EXTPAGE_EN 0x0001
#define CICADA_EXTPAGE_DIS 0x0000
-
-struct {unsigned short value, offset; } CICADA_FAMILY_HWINIT[] =
-{
+struct {unsigned short value, offset; } CICADA_FAMILY_HWINIT[] = {
{0x0001, 0x001f}, {0x1c25, 0x0017}, {0x2a30, 0x001f}, {0x234c, 0x0010},
{0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0xa7fa, 0x0000},
{0x0012, 0x0002}, {0x3002, 0x0001}, {0x87fa, 0x0000}, {0x52b5, 0x001f},
@@ -377,23 +381,20 @@ struct {unsigned short value, offset; } CICADA_FAMILY_HWINIT[] =
{0x8fae, 0x0000}, {0x2a30, 0x001f}, {0x0012, 0x0008}, {0x0000, 0x001f},
};
-struct {unsigned short value, offset; } CICADA_V2_HWINIT[] =
-{
+struct {unsigned short value, offset; } CICADA_V2_HWINIT[] = {
{0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0x000f, 0x0002},
{0x472a, 0x0001}, {0x8fa4, 0x0000}, {0x2a30, 0x001f}, {0x0212, 0x0008},
{0x0000, 0x001f},
};
-struct {unsigned short value, offset; } CICADA_V2_ASIX_HWINIT[] =
-{
+struct {unsigned short value, offset; } CICADA_V2_ASIX_HWINIT[] = {
{0x2a30, 0x001f}, {0x0212, 0x0008}, {0x52b5, 0x001f}, {0x0012, 0x0002},
{0x3002, 0x0001}, {0x87fa, 0x0000}, {0x52b5, 0x001f}, {0x000f, 0x0002},
{0x472a, 0x0001}, {0x8fa4, 0x0000}, {0x2a30, 0x001f}, {0x0212, 0x0008},
{0x0000, 0x001f},
};
-struct {unsigned short value, offset; } AGERE_FAMILY_HWINIT[] =
-{
+struct {unsigned short value, offset; } AGERE_FAMILY_HWINIT[] = {
{0x0800, 0x0000}, {0x0007, 0x0012}, {0x8805, 0x0010}, {0xb03e, 0x0011},
{0x8808, 0x0010}, {0xe110, 0x0011}, {0x8806, 0x0010}, {0xb03e, 0x0011},
{0x8807, 0x0010}, {0xff00, 0x0011}, {0x880e, 0x0010}, {0xb4d3, 0x0011},
@@ -437,10 +438,11 @@ struct ax88772b_data {
u8 checksum;
u8 PhySelect:1;
u8 OperationMode:1;
-
+ u16 presvd_phy_advertise;
+ u16 presvd_phy_bmcr;
};
-// define for MAC or PHY mode
+/* define for MAC or PHY mode */
#define OPERATION_MAC_MODE 0
#define OPERATION_PHY_MODE 1
@@ -455,6 +457,8 @@ struct ax88772a_data {
u8 DlyIndex;
u8 DlySel;
u16 EepromData;
+ u16 presvd_phy_advertise;
+ u16 presvd_phy_bmcr;
};
struct ax88772_data {
@@ -464,6 +468,8 @@ struct ax88772_data {
unsigned long autoneg_start;
u8 Event;
u8 TickToExpire;
+ u16 presvd_phy_advertise;
+ u16 presvd_phy_bmcr;
};
#define AX_RX_CHECKSUM 1
@@ -474,7 +480,7 @@ struct ax8817x_data {
u8 multi_filter[AX_MCAST_FILTER_SIZE];
int (*resume) (struct usb_interface *intf);
int (*suspend) (struct usb_interface *intf,
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10)
pm_message_t message);
#else
u32 message);
@@ -527,7 +533,7 @@ struct ax88772b_rx_header {
l4_type:3,
l3_type:2,
ce:1;
-#elif defined (__BIG_ENDIAN_BITFIELD)
+#elif defined(__BIG_ENDIAN_BITFIELD)
u16 mc_bc:1,
runt:1,
mii:1,
@@ -554,5 +560,6 @@ struct ax88772b_rx_header {
} __attribute__ ((packed));
+
#endif /* __LINUX_USBNET_ASIX_H */
diff --git a/drivers/net/usb/axusbnet.c b/drivers/net/usb/axusbnet.c
index 00393d38a379..71ad734c7f19 100644
--- a/drivers/net/usb/axusbnet.c
+++ b/drivers/net/usb/axusbnet.c
@@ -30,8 +30,10 @@
* issues can usefully be addressed by this framework.
*/
-#define DEBUG // error path messages, extra info
-// #define VERBOSE // more; success messages
+/* error path messages, extra info */
+#define DEBUG
+/* more; success messages */
+/* #define VERBOSE */
#include <linux/module.h>
#include <linux/init.h>
@@ -51,7 +53,7 @@
static void axusbnet_unlink_rx_urbs(struct usbnet *);
-extern void
+static void
ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
u16 size, void *data);
@@ -74,25 +76,25 @@ ax8817x_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
(RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
-// reawaken network queue this soon after stopping; else watchdog barks
-//#define TX_TIMEOUT_JIFFIES (5*HZ)
-#define TX_TIMEOUT_JIFFIES (30*HZ)
+/* reawaken network queue this soon after stopping; else watchdog barks */
+/* #define TX_TIMEOUT_JIFFIES (5 * HZ) */
+#define TX_TIMEOUT_JIFFIES (30 * HZ)
-// throttle rx/tx briefly after some faults, so khubd might disconnect()
-// us (it polls at HZ/4 usually) before we report too many false errors.
-#define THROTTLE_JIFFIES (HZ/8)
+/* throttle rx/tx briefly after some faults, so khubd might disconnect() */
+/* us (it polls at HZ/4 usually) before we report too many false errors. */
+#define THROTTLE_JIFFIES (HZ / 8)
-// between wakeups
+/* between wakeups */
#define UNLINK_TIMEOUT_MS 3
/*-------------------------------------------------------------------------*/
-static const char driver_name [] = "axusbnet";
+static const char driver_name[] = "axusbnet";
/* use ethtool to change the level for any given device */
static int msg_level = -1;
-module_param (msg_level, int, 0);
-MODULE_PARM_DESC (msg_level, "Override default message level");
+module_param(msg_level, int, 0);
+MODULE_PARM_DESC(msg_level, "Override default message level");
/*-------------------------------------------------------------------------*/
@@ -149,27 +151,27 @@ int axusbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
if (alt->desc.bAlternateSetting != 0
|| !(dev->driver_info->flags & FLAG_NO_SETINT)) {
- tmp = usb_set_interface (dev->udev, alt->desc.bInterfaceNumber,
+ tmp = usb_set_interface(dev->udev, alt->desc.bInterfaceNumber,
alt->desc.bAlternateSetting);
if (tmp < 0)
return tmp;
}
- dev->in = usb_rcvbulkpipe (dev->udev,
+ dev->in = usb_rcvbulkpipe(dev->udev,
in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
- dev->out = usb_sndbulkpipe (dev->udev,
+ dev->out = usb_sndbulkpipe(dev->udev,
out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
dev->status = status;
return 0;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void intr_complete (struct urb *urb, struct pt_regs *regs);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+static void intr_complete(struct urb *urb, struct pt_regs *regs);
#else
-static void intr_complete (struct urb *urb);
+static void intr_complete(struct urb *urb);
#endif
-static int init_status (struct usbnet *dev, struct usb_interface *intf)
+static int init_status(struct usbnet *dev, struct usb_interface *intf)
{
char *buf = NULL;
unsigned pipe = 0;
@@ -179,30 +181,30 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
if (!dev->driver_info->status)
return 0;
- pipe = usb_rcvintpipe (dev->udev,
+ pipe = usb_rcvintpipe(dev->udev,
dev->status->desc.bEndpointAddress
& USB_ENDPOINT_NUMBER_MASK);
- maxp = usb_maxpacket (dev->udev, pipe, 0);
+ maxp = usb_maxpacket(dev->udev, pipe, 0);
/* avoid 1 msec chatter: min 8 msec poll rate */
- period = max ((int) dev->status->desc.bInterval,
+ period = max((int) dev->status->desc.bInterval,
(dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
- buf = kmalloc (maxp, GFP_KERNEL);
+ buf = kmalloc(maxp, GFP_KERNEL);
if (buf) {
- dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
+ dev->interrupt = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->interrupt) {
- kfree (buf);
+ kfree(buf);
return -ENOMEM;
} else {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
dev->interrupt->transfer_flags |= URB_ASYNC_UNLINK;
#endif
usb_fill_int_urb(dev->interrupt, dev->udev, pipe,
buf, maxp, intr_complete, dev, period);
devdbg(dev,
- "status ep%din, %d bytes period %d",
- usb_pipeendpoint(pipe), maxp, period);
+ "status ep%din, %d bytes period %d",
+ usb_pipeendpoint(pipe), maxp, period);
}
}
return 0;
@@ -213,22 +215,22 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
* can return clones as well as just modify the original skb.
*/
static
-void axusbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
+void axusbnet_skb_return(struct usbnet *dev, struct sk_buff *skb)
{
int status;
skb->dev = dev->net;
- skb->protocol = eth_type_trans (skb, dev->net);
+ skb->protocol = eth_type_trans(skb, dev->net);
dev->stats.rx_packets++;
dev->stats.rx_bytes += skb->len;
- if (netif_msg_rx_status (dev))
- devdbg (dev, "< rx, len %zu, type 0x%x",
- skb->len + sizeof (struct ethhdr), skb->protocol);
- memset (skb->cb, 0, sizeof (struct skb_data));
- status = netif_rx (skb);
- if (status != NET_RX_SUCCESS && netif_msg_rx_err (dev))
- devdbg (dev, "netif_rx status %d", status);
+ if (netif_msg_rx_status(dev))
+ devdbg(dev, "< rx, len %zu, type 0x%x",
+ skb->len + sizeof(struct ethhdr), skb->protocol);
+ memset(skb->cb, 0, sizeof(struct skb_data));
+ status = netif_rx(skb);
+ if (status != NET_RX_SUCCESS && netif_msg_rx_err(dev))
+ devdbg(dev, "netif_rx status %d", status);
}
/*-------------------------------------------------------------------------
@@ -238,7 +240,7 @@ void axusbnet_skb_return (struct usbnet *dev, struct sk_buff *skb)
*-------------------------------------------------------------------------*/
static
-int axusbnet_change_mtu (struct net_device *net, int new_mtu)
+int axusbnet_change_mtu(struct net_device *net, int new_mtu)
{
struct usbnet *dev = netdev_priv(net);
int ll_mtu = new_mtu + net->hard_header_len;
@@ -247,7 +249,7 @@ int axusbnet_change_mtu (struct net_device *net, int new_mtu)
if (new_mtu <= 0)
return -EINVAL;
- // no second zero-length packet read wanted after mtu-sized packets
+ /* no second zero-length packet read wanted after mtu-sized packets */
if ((ll_mtu % dev->maxpacket) == 0)
return -EDOM;
net->mtu = new_mtu;
@@ -262,9 +264,9 @@ int axusbnet_change_mtu (struct net_device *net, int new_mtu)
return 0;
}
-static struct net_device_stats *axusbnet_get_stats (struct net_device *net)
+static struct net_device_stats *axusbnet_get_stats(struct net_device *net)
{
- struct usbnet *dev = netdev_priv (net);
+ struct usbnet *dev = netdev_priv(net);
return &dev->stats;
}
@@ -295,23 +297,23 @@ defer_bh(struct usbnet *dev, struct sk_buff *skb, struct sk_buff_head *list)
* but tasklet_schedule() doesn't. hope the failure is rare.
*/
static
-void axusbnet_defer_kevent (struct usbnet *dev, int work)
+void axusbnet_defer_kevent(struct usbnet *dev, int work)
{
- set_bit (work, &dev->flags);
- if (!schedule_work (&dev->kevent))
- deverr (dev, "kevent %d may have been dropped", work);
+ set_bit(work, &dev->flags);
+ if (!schedule_work(&dev->kevent))
+ deverr(dev, "kevent %d may have been dropped", work);
else
- devdbg (dev, "kevent %d scheduled", work);
+ devdbg(dev, "kevent %d scheduled", work);
}
/*-------------------------------------------------------------------------*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void rx_complete (struct urb *urb, struct pt_regs *regs);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+static void rx_complete(struct urb *urb, struct pt_regs *regs);
#else
-static void rx_complete (struct urb *urb);
+static void rx_complete(struct urb *urb);
#endif
-static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
+static void rx_submit(struct usbnet *dev, struct urb *urb, gfp_t flags)
{
struct sk_buff *skb;
struct skb_data *entry;
@@ -329,30 +331,31 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
else
align = 0;
#endif
+ skb = alloc_skb(size + align, flags);
+ if (skb == NULL) {
- if ((skb = alloc_skb (size + align, flags)) == NULL) {
+ if (netif_msg_rx_err(dev))
+ devdbg(dev, "no rx skb");
- if (netif_msg_rx_err (dev))
- devdbg (dev, "no rx skb");
-
- if((dev->rx_urb_size > 2048) && dev->rx_size) {
+ if ((dev->rx_urb_size > 2048) && dev->rx_size) {
dev->rx_size--;
- dev->rx_urb_size = AX88772B_BULKIN_SIZE[dev->rx_size].size;
+ dev->rx_urb_size =
+ AX88772B_BULKIN_SIZE[dev->rx_size].size;
- ax8817x_write_cmd_async (dev, 0x2A,
+ ax8817x_write_cmd_async(dev, 0x2A,
AX88772B_BULKIN_SIZE[dev->rx_size].byte_cnt,
AX88772B_BULKIN_SIZE[dev->rx_size].threshold,
0, NULL);
}
if (!(dev->flags & EVENT_RX_MEMORY))
- axusbnet_defer_kevent (dev, EVENT_RX_MEMORY);
- usb_free_urb (urb);
+ axusbnet_defer_kevent(dev, EVENT_RX_MEMORY);
+ usb_free_urb(urb);
return;
}
if (align)
- skb_reserve (skb, NET_IP_ALIGN);
+ skb_reserve(skb, NET_IP_ALIGN);
entry = (struct skb_data *) skb->cb;
entry->urb = urb;
@@ -360,73 +363,73 @@ static void rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
entry->state = rx_start;
entry->length = 0;
- usb_fill_bulk_urb (urb, dev->udev, dev->in,
- skb->data, size, rx_complete, skb);
+ usb_fill_bulk_urb(urb, dev->udev, dev->in, skb->data,
+ size, rx_complete, skb);
- spin_lock_irqsave (&dev->rxq.lock, lockflags);
+ spin_lock_irqsave(&dev->rxq.lock, lockflags);
- if (netif_running (dev->net)
- && netif_device_present (dev->net)
- && !test_bit (EVENT_RX_HALT, &dev->flags)) {
- switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {
+ if (netif_running(dev->net)
+ && netif_device_present(dev->net)
+ && !test_bit(EVENT_RX_HALT, &dev->flags)) {
+ switch (retval = usb_submit_urb(urb, GFP_ATOMIC)) {
case -EPIPE:
- axusbnet_defer_kevent (dev, EVENT_RX_HALT);
+ axusbnet_defer_kevent(dev, EVENT_RX_HALT);
break;
case -ENOMEM:
- axusbnet_defer_kevent (dev, EVENT_RX_MEMORY);
+ axusbnet_defer_kevent(dev, EVENT_RX_MEMORY);
break;
case -ENODEV:
- if (netif_msg_ifdown (dev))
- devdbg (dev, "device gone");
- netif_device_detach (dev->net);
+ if (netif_msg_ifdown(dev))
+ devdbg(dev, "device gone");
+ netif_device_detach(dev->net);
break;
default:
- if (netif_msg_rx_err (dev))
- devdbg (dev, "rx submit, %d", retval);
- tasklet_schedule (&dev->bh);
+ if (netif_msg_rx_err(dev))
+ devdbg(dev, "rx submit, %d", retval);
+ tasklet_schedule(&dev->bh);
break;
case 0:
- __skb_queue_tail (&dev->rxq, skb);
+ __skb_queue_tail(&dev->rxq, skb);
}
} else {
- if (netif_msg_ifdown (dev))
- devdbg (dev, "rx: stopped");
+ if (netif_msg_ifdown(dev))
+ devdbg(dev, "rx: stopped");
retval = -ENOLINK;
}
- spin_unlock_irqrestore (&dev->rxq.lock, lockflags);
+ spin_unlock_irqrestore(&dev->rxq.lock, lockflags);
if (retval) {
- dev_kfree_skb_any (skb);
- usb_free_urb (urb);
+ dev_kfree_skb_any(skb);
+ usb_free_urb(urb);
}
}
/*-------------------------------------------------------------------------*/
-static inline void rx_process (struct usbnet *dev, struct sk_buff *skb)
+static inline void rx_process(struct usbnet *dev, struct sk_buff *skb)
{
if (dev->driver_info->rx_fixup
- && !dev->driver_info->rx_fixup (dev, skb))
+ && !dev->driver_info->rx_fixup(dev, skb))
goto error;
- // else network stack removes extra byte if we forced a short packet
+ /* else network stack removes extra byte if we forced a short packet */
if (skb->len)
- axusbnet_skb_return (dev, skb);
+ axusbnet_skb_return(dev, skb);
else {
- if (netif_msg_rx_err (dev))
- devdbg (dev, "drop");
+ if (netif_msg_rx_err(dev))
+ devdbg(dev, "drop");
error:
dev->stats.rx_errors++;
- skb_queue_tail (&dev->done, skb);
+ skb_queue_tail(&dev->done, skb);
}
}
/*-------------------------------------------------------------------------*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void rx_complete (struct urb *urb, struct pt_regs *regs)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+static void rx_complete(struct urb *urb, struct pt_regs *regs)
#else
-static void rx_complete (struct urb *urb)
+static void rx_complete(struct urb *urb)
#endif
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
@@ -434,7 +437,7 @@ static void rx_complete (struct urb *urb)
struct usbnet *dev = entry->dev;
int urb_status = urb->status;
- skb_put (skb, urb->actual_length);
+ skb_put(skb, urb->actual_length);
entry->state = rx_done;
entry->urb = NULL;
@@ -445,8 +448,8 @@ static void rx_complete (struct urb *urb)
entry->state = rx_cleanup;
dev->stats.rx_errors++;
dev->stats.rx_length_errors++;
- if (netif_msg_rx_err (dev))
- devdbg (dev, "rx length %d", skb->len);
+ if (netif_msg_rx_err(dev))
+ devdbg(dev, "rx length %d", skb->len);
}
break;
@@ -457,14 +460,14 @@ static void rx_complete (struct urb *urb)
*/
case -EPIPE:
dev->stats.rx_errors++;
- axusbnet_defer_kevent (dev, EVENT_RX_HALT);
- // FALLTHROUGH
+ axusbnet_defer_kevent(dev, EVENT_RX_HALT);
+ /* FALLTHROUGH */
/* software-driven interface shutdown */
case -ECONNRESET: /* async unlink */
case -ESHUTDOWN: /* hardware gone */
- if (netif_msg_ifdown (dev))
- devdbg (dev, "rx shutdown, code %d", urb_status);
+ if (netif_msg_ifdown(dev))
+ devdbg(dev, "rx shutdown, code %d", urb_status);
goto block;
/* we get controller i/o faults during khubd disconnect() delays.
@@ -475,10 +478,10 @@ static void rx_complete (struct urb *urb)
case -ETIME:
case -EILSEQ:
dev->stats.rx_errors++;
- if (!timer_pending (&dev->delay)) {
- mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES);
- if (netif_msg_link (dev))
- devdbg (dev, "rx throttle %d", urb_status);
+ if (!timer_pending(&dev->delay)) {
+ mod_timer(&dev->delay, jiffies + THROTTLE_JIFFIES);
+ if (netif_msg_link(dev))
+ devdbg(dev, "rx throttle %d", urb_status);
}
block:
entry->state = rx_cleanup;
@@ -489,34 +492,34 @@ block:
/* data overrun ... flush fifo? */
case -EOVERFLOW:
dev->stats.rx_over_errors++;
- // FALLTHROUGH
+ /* FALLTHROUGH */
default:
entry->state = rx_cleanup;
dev->stats.rx_errors++;
- if (netif_msg_rx_err (dev))
- devdbg (dev, "rx status %d", urb_status);
+ if (netif_msg_rx_err(dev))
+ devdbg(dev, "rx status %d", urb_status);
break;
}
defer_bh(dev, skb, &dev->rxq);
if (urb) {
- if (netif_running (dev->net)
- && !test_bit (EVENT_RX_HALT, &dev->flags)) {
- rx_submit (dev, urb, GFP_ATOMIC);
+ if (netif_running(dev->net) &&
+ !test_bit(EVENT_RX_HALT, &dev->flags)) {
+ rx_submit(dev, urb, GFP_ATOMIC);
return;
}
- usb_free_urb (urb);
+ usb_free_urb(urb);
}
- if (netif_msg_rx_err (dev))
- devdbg (dev, "no read resubmitted");
+ if (netif_msg_rx_err(dev))
+ devdbg(dev, "no read resubmitted");
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void intr_complete (struct urb *urb, struct pt_regs *regs)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+static void intr_complete(struct urb *urb, struct pt_regs *regs)
#else
-static void intr_complete (struct urb *urb)
+static void intr_complete(struct urb *urb)
#endif
{
struct usbnet *dev = urb->context;
@@ -531,38 +534,38 @@ static void intr_complete (struct urb *urb)
/* software-driven interface shutdown */
case -ENOENT: /* urb killed */
case -ESHUTDOWN: /* hardware gone */
- if (netif_msg_ifdown (dev))
- devdbg (dev, "intr shutdown, code %d", status);
+ if (netif_msg_ifdown(dev))
+ devdbg(dev, "intr shutdown, code %d", status);
return;
/* NOTE: not throttling like RX/TX, since this endpoint
* already polls infrequently
*/
default:
- devdbg (dev, "intr status %d", status);
+ devdbg(dev, "intr status %d", status);
break;
}
- if (!netif_running (dev->net))
+ if (!netif_running(dev->net))
return;
memset(urb->transfer_buffer, 0, urb->transfer_buffer_length);
- status = usb_submit_urb (urb, GFP_ATOMIC);
- if (status != 0 && netif_msg_timer (dev))
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status != 0 && netif_msg_timer(dev))
deverr(dev, "intr resubmit --> %d", status);
}
/*-------------------------------------------------------------------------*/
-// unlink pending rx/tx; completion handlers do all other cleanup
+/* unlink pending rx/tx; completion handlers do all other cleanup */
-static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
+static int unlink_urbs(struct usbnet *dev, struct sk_buff_head *q)
{
unsigned long flags;
struct sk_buff *skb, *skbnext;
int count = 0;
- spin_lock_irqsave (&q->lock, flags);
+ spin_lock_irqsave(&q->lock, flags);
skb_queue_walk_safe(q, skb, skbnext) {
struct skb_data *entry;
struct urb *urb;
@@ -571,55 +574,54 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
entry = (struct skb_data *) skb->cb;
urb = entry->urb;
- // during some PM-driven resume scenarios,
- // these (async) unlinks complete immediately
- retval = usb_unlink_urb (urb);
+ /* during some PM-driven resume scenarios, */
+ /* these (async) unlinks complete immediately */
+ retval = usb_unlink_urb(urb);
if (retval != -EINPROGRESS && retval != 0)
- devdbg (dev, "unlink urb err, %d", retval);
+ devdbg(dev, "unlink urb err, %d", retval);
else
count++;
}
- spin_unlock_irqrestore (&q->lock, flags);
+ spin_unlock_irqrestore(&q->lock, flags);
return count;
}
-// Flush all pending rx urbs
-// minidrivers may need to do this when the MTU changes
+/* Flush all pending rx urbs */
+/* minidrivers may need to do this when the MTU changes */
static
void axusbnet_unlink_rx_urbs(struct usbnet *dev)
{
if (netif_running(dev->net)) {
- (void) unlink_urbs (dev, &dev->rxq);
+ (void) unlink_urbs(dev, &dev->rxq);
tasklet_schedule(&dev->bh);
}
}
/*-------------------------------------------------------------------------*/
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
static
-int axusbnet_stop (struct net_device *net)
+int axusbnet_stop(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
struct driver_info *info = dev->driver_info;
int temp;
int retval;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
- DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)
+ DECLARE_WAIT_QUEUE_HEAD_ONSTACK(unlink_wakeup);
#else
- DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup);
+ DECLARE_WAIT_QUEUE_HEAD(unlink_wakeup);
#endif
- DECLARE_WAITQUEUE (wait, current);
+ DECLARE_WAITQUEUE(wait, current);
- netif_stop_queue (net);
+ netif_stop_queue(net);
- if (netif_msg_ifdown (dev))
- devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
+ if (netif_msg_ifdown(dev))
+ devinfo(dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
dev->stats.rx_packets, dev->stats.tx_packets,
- dev->stats.rx_errors, dev->stats.tx_errors
- );
+ dev->stats.rx_errors, dev->stats.tx_errors);
/* allow minidriver to stop correctly (wireless devices to turn off
* radio etc) */
@@ -647,7 +649,7 @@ int axusbnet_stop (struct net_device *net)
msleep(UNLINK_TIMEOUT_MS);
if (netif_msg_ifdown(dev))
devdbg(dev, "waited for %d urb completions",
- temp);
+ temp);
}
dev->wait = NULL;
remove_wait_queue(&unlink_wakeup, &wait);
@@ -660,55 +662,62 @@ int axusbnet_stop (struct net_device *net)
* else workers could deadlock; so make workers a NOP.
*/
dev->flags = 0;
- del_timer_sync (&dev->delay);
- tasklet_kill (&dev->bh);
+ del_timer_sync(&dev->delay);
+ tasklet_kill(&dev->bh);
return 0;
}
/*-------------------------------------------------------------------------*/
-// posts reads, and enables write queuing
+/* posts reads, and enables write queuing */
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
static
-int axusbnet_open (struct net_device *net)
+int axusbnet_open(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
int retval = 0;
struct driver_info *info = dev->driver_info;
- // put into "known safe" state
- if (info->reset && (retval = info->reset (dev)) < 0) {
- if (netif_msg_ifup (dev))
- devinfo (dev,
- "open reset fail (%d) usbnet usb-%s-%s, %s",
- retval,
- dev->udev->bus->bus_name, dev->udev->devpath,
- info->description);
- goto done;
+ /* put into "known safe" state */
+ if (info->reset) {
+ retval = info->reset(dev);
+ if (retval < 0) {
+ if (netif_msg_ifup(dev))
+ devinfo(dev,
+ "open reset fail (%d) usbnet usb-%s-%s, %s",
+ retval,
+ dev->udev->bus->bus_name,
+ dev->udev->devpath,
+ info->description);
+ goto done;
+ }
}
- // insist peer be connected
- if (info->check_connect && (retval = info->check_connect (dev)) < 0) {
- if (netif_msg_ifup (dev))
- devdbg (dev, "can't open; %d", retval);
- goto done;
+ /* insist peer be connected */
+ if (info->check_connect) {
+ retval = info->check_connect(dev);
+ if (retval < 0) {
+ if (netif_msg_ifup(dev))
+ devdbg(dev, "can't open; %d", retval);
+ goto done;
+ }
}
/* start any status interrupt transfer */
if (dev->interrupt) {
- retval = usb_submit_urb (dev->interrupt, GFP_KERNEL);
+ retval = usb_submit_urb(dev->interrupt, GFP_KERNEL);
if (retval < 0) {
- if (netif_msg_ifup (dev))
- deverr (dev, "intr submit %d", retval);
+ if (netif_msg_ifup(dev))
+ deverr(dev, "intr submit %d", retval);
goto done;
}
}
- netif_start_queue (net);
- if (netif_msg_ifup (dev)) {
+ netif_start_queue(net);
+ if (netif_msg_ifup(dev)) {
char *framing;
if (dev->driver_info->flags & FLAG_FRAMING_NC)
@@ -724,14 +733,13 @@ int axusbnet_open (struct net_device *net)
else
framing = "simple";
- devinfo (dev, "open: enable queueing "
- "(rx %d, tx %d) mtu %d %s framing",
- (int)RX_QLEN (dev), (int)TX_QLEN (dev), dev->net->mtu,
+ devinfo(dev, "open: enable queueing (rx %d, tx %d) mtu %d %s framing",
+ (int)RX_QLEN(dev), (int)TX_QLEN(dev), dev->net->mtu,
framing);
}
- // delay posting reads until we're fully open
- tasklet_schedule (&dev->bh);
+ /* delay posting reads until we're fully open */
+ tasklet_schedule(&dev->bh);
return retval;
done:
return retval;
@@ -744,7 +752,7 @@ done:
*/
static
-int axusbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
+int axusbnet_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
{
struct usbnet *dev = netdev_priv(net);
@@ -755,7 +763,7 @@ int axusbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
}
static
-int axusbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
+int axusbnet_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
{
struct usbnet *dev = netdev_priv(net);
int retval;
@@ -774,13 +782,13 @@ int axusbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
}
static
-u32 axusbnet_get_link (struct net_device *net)
+u32 axusbnet_get_link(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
/* If a check_connect is defined, return its result */
if (dev->driver_info->check_connect)
- return dev->driver_info->check_connect (dev) == 0;
+ return dev->driver_info->check_connect(dev) == 0;
/* if the device has mii operations, use those */
if (dev->mii.mdio_read)
@@ -802,19 +810,19 @@ int axusbnet_nway_reset(struct net_device *net)
}
static
-void axusbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
+void axusbnet_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
{
struct usbnet *dev = netdev_priv(net);
- strncpy (info->driver, dev->driver_name, sizeof info->driver);
- strncpy (info->version, DRIVER_VERSION, sizeof info->version);
- strncpy (info->fw_version, dev->driver_info->description,
- sizeof info->fw_version);
- usb_make_path (dev->udev, info->bus_info, sizeof info->bus_info);
+ strncpy(info->driver, dev->driver_name, sizeof(info->driver));
+ strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
+ strncpy(info->fw_version, dev->driver_info->description,
+ sizeof(info->fw_version));
+ usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
}
static
-u32 axusbnet_get_msglevel (struct net_device *net)
+u32 axusbnet_get_msglevel(struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
@@ -822,7 +830,7 @@ u32 axusbnet_get_msglevel (struct net_device *net)
}
static
-void axusbnet_set_msglevel (struct net_device *net, u32 level)
+void axusbnet_set_msglevel(struct net_device *net, u32 level)
{
struct usbnet *dev = netdev_priv(net);
@@ -847,12 +855,12 @@ static struct ethtool_ops axusbnet_ethtool_ops = {
* NOTE: with 2.5 we could do more of this using completion callbacks,
* especially now that control transfers can be queued.
*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-static void kevent (void *data)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+static void kevent(void *data)
{
struct usbnet *dev = (struct usbnet *)data;
#else
-static void kevent (struct work_struct *work)
+static void kevent(struct work_struct *work)
{
struct usbnet *dev =
container_of(work, struct usbnet, kevent);
@@ -860,80 +868,85 @@ static void kevent (struct work_struct *work)
int status;
/* usb_clear_halt() needs a thread context */
- if (test_bit (EVENT_TX_HALT, &dev->flags)) {
+ if (test_bit(EVENT_TX_HALT, &dev->flags)) {
- unlink_urbs (dev, &dev->txq);
- status = usb_clear_halt (dev->udev, dev->out);
+ unlink_urbs(dev, &dev->txq);
+ status = usb_clear_halt(dev->udev, dev->out);
if (status < 0
&& status != -EPIPE
&& status != -ESHUTDOWN) {
- if (netif_msg_tx_err (dev))
- deverr (dev, "can't clear tx halt, status %d",
- status);
+ if (netif_msg_tx_err(dev))
+ deverr(dev, "can't clear tx halt, status %d",
+ status);
} else {
- clear_bit (EVENT_TX_HALT, &dev->flags);
+ clear_bit(EVENT_TX_HALT, &dev->flags);
if (status != -ESHUTDOWN)
- netif_wake_queue (dev->net);
+ netif_wake_queue(dev->net);
}
}
- if (test_bit (EVENT_RX_HALT, &dev->flags)) {
+ if (test_bit(EVENT_RX_HALT, &dev->flags)) {
- unlink_urbs (dev, &dev->rxq);
- status = usb_clear_halt (dev->udev, dev->in);
+ unlink_urbs(dev, &dev->rxq);
+ status = usb_clear_halt(dev->udev, dev->in);
if (status < 0
&& status != -EPIPE
&& status != -ESHUTDOWN) {
- if (netif_msg_rx_err (dev))
- deverr (dev, "can't clear rx halt, status %d",
- status);
+ if (netif_msg_rx_err(dev))
+ deverr(dev, "can't clear rx halt, status %d",
+ status);
} else {
- clear_bit (EVENT_RX_HALT, &dev->flags);
- tasklet_schedule (&dev->bh);
+ clear_bit(EVENT_RX_HALT, &dev->flags);
+ tasklet_schedule(&dev->bh);
}
}
/* tasklet could resubmit itself forever if memory is tight */
- if (test_bit (EVENT_RX_MEMORY, &dev->flags)) {
+ if (test_bit(EVENT_RX_MEMORY, &dev->flags)) {
struct urb *urb = NULL;
- if (netif_running (dev->net))
- urb = usb_alloc_urb (0, GFP_KERNEL);
+ if (netif_running(dev->net))
+ urb = usb_alloc_urb(0, GFP_KERNEL);
else
- clear_bit (EVENT_RX_MEMORY, &dev->flags);
+ clear_bit(EVENT_RX_MEMORY, &dev->flags);
if (urb != NULL) {
- clear_bit (EVENT_RX_MEMORY, &dev->flags);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+ clear_bit(EVENT_RX_MEMORY, &dev->flags);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
urb->transfer_flags |= URB_ASYNC_UNLINK;
#endif
- rx_submit (dev, urb, GFP_KERNEL);
- tasklet_schedule (&dev->bh);
+ rx_submit(dev, urb, GFP_KERNEL);
+ tasklet_schedule(&dev->bh);
}
}
- if (test_bit (EVENT_LINK_RESET, &dev->flags)) {
+ if (test_bit(EVENT_LINK_RESET, &dev->flags)) {
struct driver_info *info = dev->driver_info;
int retval = 0;
- clear_bit (EVENT_LINK_RESET, &dev->flags);
- if(info->link_reset && (retval = info->link_reset(dev)) < 0) {
- devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s",
- retval,
- dev->udev->bus->bus_name, dev->udev->devpath,
- info->description);
+ clear_bit(EVENT_LINK_RESET, &dev->flags);
+
+ if (info->link_reset) {
+ retval = info->link_reset(dev);
+ if (retval < 0) {
+ devinfo(dev,
+ "link reset failed (%d) usbnet usb-%s-%s, %s",
+ retval,
+ dev->udev->bus->bus_name,
+ dev->udev->devpath,
+ info->description);
+ }
}
}
if (dev->flags)
- devdbg (dev, "kevent done, flags = 0x%lx",
- dev->flags);
+ devdbg(dev, "kevent done, flags = 0x%lx", dev->flags);
}
/*-------------------------------------------------------------------------*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
-static void tx_complete (struct urb *urb, struct pt_regs *regs)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
+static void tx_complete(struct urb *urb, struct pt_regs *regs)
#else
-static void tx_complete (struct urb *urb)
+static void tx_complete(struct urb *urb)
#endif
{
struct sk_buff *skb = (struct sk_buff *) urb->context;
@@ -948,31 +961,31 @@ static void tx_complete (struct urb *urb)
switch (urb->status) {
case -EPIPE:
- axusbnet_defer_kevent (dev, EVENT_TX_HALT);
+ axusbnet_defer_kevent(dev, EVENT_TX_HALT);
break;
/* software-driven interface shutdown */
- case -ECONNRESET: // async unlink
- case -ESHUTDOWN: // hardware gone
+ case -ECONNRESET: /* async unlink */
+ case -ESHUTDOWN: /* hardware gone */
break;
- // like rx, tx gets controller i/o faults during khubd delays
- // and so it uses the same throttling mechanism.
+ /* like rx, tx gets controller i/o faults during khubd delays */
+ /* and so it uses the same throttling mechanism. */
case -EPROTO:
case -ETIME:
case -EILSEQ:
- if (!timer_pending (&dev->delay)) {
- mod_timer (&dev->delay,
- jiffies + THROTTLE_JIFFIES);
- if (netif_msg_link (dev))
- devdbg (dev, "tx throttle %d",
- urb->status);
+ if (!timer_pending(&dev->delay)) {
+ mod_timer(&dev->delay,
+ jiffies + THROTTLE_JIFFIES);
+ if (netif_msg_link(dev))
+ devdbg(dev, "tx throttle %d",
+ urb->status);
}
- netif_stop_queue (dev->net);
+ netif_stop_queue(dev->net);
break;
default:
- if (netif_msg_tx_err (dev))
- devdbg (dev, "tx err %d", entry->urb->status);
+ if (netif_msg_tx_err(dev))
+ devdbg(dev, "tx err %d", entry->urb->status);
break;
}
}
@@ -985,24 +998,23 @@ static void tx_complete (struct urb *urb)
/*-------------------------------------------------------------------------*/
static
-void axusbnet_tx_timeout (struct net_device *net)
+void axusbnet_tx_timeout(struct net_device *net)
{
- struct usbnet *dev = netdev_priv(net);
+ struct usbnet *dev = netdev_priv(net);
- unlink_urbs (dev, &dev->txq);
- tasklet_schedule (&dev->bh);
+ unlink_urbs(dev, &dev->txq);
+ tasklet_schedule(&dev->bh);
- // FIXME: device recovery -- reset?
+ /* FIXME: device recovery -- reset? */
}
/*-------------------------------------------------------------------------*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
static int
#else
static netdev_tx_t
#endif
-axusbnet_start_xmit (struct sk_buff *skb,
- struct net_device *net)
+axusbnet_start_xmit(struct sk_buff *skb, struct net_device *net)
{
struct usbnet *dev = netdev_priv(net);
int length;
@@ -1012,21 +1024,22 @@ axusbnet_start_xmit (struct sk_buff *skb,
unsigned long flags;
int retval;
- // some devices want funky USB-level framing, for
- // win32 driver (usually) and/or hardware quirks
+ /* some devices want funky USB-level framing, for */
+ /* win32 driver (usually) and/or hardware quirks */
if (info->tx_fixup) {
- skb = info->tx_fixup (dev, skb, GFP_ATOMIC);
+ skb = info->tx_fixup(dev, skb, GFP_ATOMIC);
if (!skb) {
- if (netif_msg_tx_err (dev))
- devdbg (dev, "can't tx_fixup skb");
+ if (netif_msg_tx_err(dev))
+ devdbg(dev, "can't tx_fixup skb");
goto drop;
}
}
length = skb->len;
- if (!(urb = usb_alloc_urb (0, GFP_ATOMIC))) {
- if (netif_msg_tx_err (dev))
- devdbg (dev, "no urb");
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
+ if (!urb) {
+ if (netif_msg_tx_err(dev))
+ devdbg(dev, "no urb");
goto drop;
}
@@ -1036,8 +1049,8 @@ axusbnet_start_xmit (struct sk_buff *skb,
entry->state = tx_start;
entry->length = length;
- usb_fill_bulk_urb (urb, dev->udev, dev->out,
- skb->data, skb->len, tx_complete, skb);
+ usb_fill_bulk_urb(urb, dev->udev, dev->out, skb->data,
+ skb->len, tx_complete, skb);
/* don't assume the hardware handles USB_ZERO_PACKET
* NOTE: strictly conforming cdc-ether devices should expect
@@ -1051,103 +1064,102 @@ axusbnet_start_xmit (struct sk_buff *skb,
}
}
- spin_lock_irqsave (&dev->txq.lock, flags);
+ spin_lock_irqsave(&dev->txq.lock, flags);
- switch ((retval = usb_submit_urb (urb, GFP_ATOMIC))) {
+ switch ((retval = usb_submit_urb(urb, GFP_ATOMIC))) {
case -EPIPE:
- netif_stop_queue (net);
- axusbnet_defer_kevent (dev, EVENT_TX_HALT);
+ netif_stop_queue(net);
+ axusbnet_defer_kevent(dev, EVENT_TX_HALT);
break;
default:
- if (netif_msg_tx_err (dev))
- devdbg (dev, "tx: submit urb err %d", retval);
+ if (netif_msg_tx_err(dev))
+ devdbg(dev, "tx: submit urb err %d", retval);
break;
case 0:
net->trans_start = jiffies;
- __skb_queue_tail (&dev->txq, skb);
- if (dev->txq.qlen >= TX_QLEN (dev))
- netif_stop_queue (net);
+ __skb_queue_tail(&dev->txq, skb);
+ if (dev->txq.qlen >= TX_QLEN(dev))
+ netif_stop_queue(net);
}
- spin_unlock_irqrestore (&dev->txq.lock, flags);
+ spin_unlock_irqrestore(&dev->txq.lock, flags);
if (retval) {
- if (netif_msg_tx_err (dev))
- devdbg (dev, "drop, code %d", retval);
+ if (netif_msg_tx_err(dev))
+ devdbg(dev, "drop, code %d", retval);
drop:
dev->stats.tx_dropped++;
if (skb)
- dev_kfree_skb_any (skb);
- usb_free_urb (urb);
- } else if (netif_msg_tx_queued (dev)) {
- devdbg (dev, "> tx, len %d, type 0x%x",
- length, skb->protocol);
+ dev_kfree_skb_any(skb);
+ usb_free_urb(urb);
+ } else if (netif_msg_tx_queued(dev)) {
+ devdbg(dev, "> tx, len %d, type 0x%x",
+ length, skb->protocol);
}
return NETDEV_TX_OK;
}
/*-------------------------------------------------------------------------*/
-// tasklet (work deferred from completions, in_irq) or timer
+/* tasklet (work deferred from completions, in_irq) or timer */
-static void axusbnet_bh (unsigned long param)
+static void axusbnet_bh(unsigned long param)
{
struct usbnet *dev = (struct usbnet *) param;
struct sk_buff *skb;
struct skb_data *entry;
- while ((skb = skb_dequeue (&dev->done))) {
+ while ((skb = skb_dequeue(&dev->done))) {
entry = (struct skb_data *) skb->cb;
switch (entry->state) {
case rx_done:
entry->state = rx_cleanup;
- rx_process (dev, skb);
+ rx_process(dev, skb);
continue;
case tx_done:
case rx_cleanup:
- usb_free_urb (entry->urb);
- dev_kfree_skb (skb);
+ usb_free_urb(entry->urb);
+ dev_kfree_skb(skb);
continue;
default:
- devdbg (dev, "bogus skb state %d", entry->state);
+ devdbg(dev, "bogus skb state %d", entry->state);
}
}
- // waiting for all pending urbs to complete?
+ /* waiting for all pending urbs to complete? */
if (dev->wait) {
- if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0) {
- wake_up (dev->wait);
- }
-
- // or are we maybe short a few urbs?
- } else if (netif_running (dev->net)
- && netif_device_present (dev->net)
- && !timer_pending (&dev->delay)
- && !test_bit (EVENT_RX_HALT, &dev->flags)) {
+ if ((dev->txq.qlen + dev->rxq.qlen + dev->done.qlen) == 0)
+ wake_up(dev->wait);
+
+ /* or are we maybe short a few urbs? */
+ } else if (netif_running(dev->net)
+ && netif_device_present(dev->net)
+ && !timer_pending(&dev->delay)
+ && !test_bit(EVENT_RX_HALT, &dev->flags)) {
int temp = dev->rxq.qlen;
- int qlen = RX_QLEN (dev);
+ int qlen = RX_QLEN(dev);
if (temp < qlen) {
struct urb *urb;
int i;
- // don't refill the queue all at once
+ /* don't refill the queue all at once */
for (i = 0; i < 10 && dev->rxq.qlen < qlen; i++) {
- urb = usb_alloc_urb (0, GFP_ATOMIC);
+ urb = usb_alloc_urb(0, GFP_ATOMIC);
if (urb != NULL) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
urb->transfer_flags |= URB_ASYNC_UNLINK;
#endif
- rx_submit (dev, urb, GFP_ATOMIC);
+ rx_submit(dev, urb, GFP_ATOMIC);
}
}
- if (temp != dev->rxq.qlen && netif_msg_link (dev))
- devdbg (dev, "rxqlen %d --> %d",
- temp, dev->rxq.qlen);
+ if (temp != dev->rxq.qlen && netif_msg_link(dev))
+ devdbg(dev, "rxqlen %d --> %d",
+ temp, dev->rxq.qlen);
if (dev->rxq.qlen < qlen)
- tasklet_schedule (&dev->bh);
+ tasklet_schedule(&dev->bh);
}
- if (dev->txq.qlen < TX_QLEN (dev))
- netif_wake_queue (dev->net);
+ if (dev->txq.qlen < TX_QLEN(dev))
+ netif_wake_queue(dev->net);
}
}
@@ -1158,10 +1170,10 @@ static void axusbnet_bh (unsigned long param)
*
*-------------------------------------------------------------------------*/
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
static
-void axusbnet_disconnect (struct usb_interface *intf)
+void axusbnet_disconnect(struct usb_interface *intf)
{
struct usbnet *dev;
struct usb_device *xdev;
@@ -1172,33 +1184,33 @@ void axusbnet_disconnect (struct usb_interface *intf)
if (!dev)
return;
- xdev = interface_to_usbdev (intf);
+ xdev = interface_to_usbdev(intf);
- if (netif_msg_probe (dev))
- devinfo (dev, "unregister '%s' usb-%s-%s, %s",
+ if (netif_msg_probe(dev))
+ devinfo(dev, "unregister '%s' usb-%s-%s, %s",
intf->dev.driver->name,
xdev->bus->bus_name, xdev->devpath,
dev->driver_info->description);
net = dev->net;
- unregister_netdev (net);
+ unregister_netdev(net);
/* we don't hold rtnl here ... */
- flush_scheduled_work ();
+ flush_scheduled_work();
if (dev->driver_info->unbind)
- dev->driver_info->unbind (dev, intf);
+ dev->driver_info->unbind(dev, intf);
free_netdev(net);
- usb_put_dev (xdev);
+ usb_put_dev(xdev);
}
/*-------------------------------------------------------------------------*/
-// precondition: never called in_interrupt
+/* precondition: never called in_interrupt */
static int
-axusbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
+axusbnet_probe(struct usb_interface *udev, const struct usb_device_id *prod)
{
struct usbnet *dev;
struct net_device *net;
@@ -1211,20 +1223,20 @@ axusbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
name = udev->dev.driver->name;
info = (struct driver_info *) prod->driver_info;
if (!info) {
- printk (KERN_ERR "blacklisted by %s\n", name);
+ printk(KERN_ERR "blacklisted by %s\n", name);
return -ENODEV;
}
- xdev = interface_to_usbdev (udev);
+ xdev = interface_to_usbdev(udev);
interface = udev->cur_altsetting;
- usb_get_dev (xdev);
+ usb_get_dev(xdev);
status = -ENOMEM;
- // set up our own records
+ /* set up our own records */
net = alloc_etherdev(sizeof(*dev));
if (!net) {
- dbg ("can't kmalloc dev");
+ printk(KERN_ERR "can't kmalloc dev");
goto out;
}
@@ -1233,23 +1245,23 @@ axusbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->intf = udev;
dev->driver_info = info;
dev->driver_name = name;
- dev->msg_enable = netif_msg_init (msg_level, NETIF_MSG_DRV
- | NETIF_MSG_PROBE | NETIF_MSG_LINK);
- skb_queue_head_init (&dev->rxq);
- skb_queue_head_init (&dev->txq);
- skb_queue_head_init (&dev->done);
+ dev->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV |
+ NETIF_MSG_PROBE | NETIF_MSG_LINK);
+ skb_queue_head_init(&dev->rxq);
+ skb_queue_head_init(&dev->txq);
+ skb_queue_head_init(&dev->done);
dev->bh.func = axusbnet_bh;
dev->bh.data = (unsigned long) dev;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
- INIT_WORK (&dev->kevent, kevent, dev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
+ INIT_WORK(&dev->kevent, kevent, dev);
#else
- INIT_WORK (&dev->kevent, kevent);
+ INIT_WORK(&dev->kevent, kevent);
#endif
dev->delay.function = axusbnet_bh;
dev->delay.data = (unsigned long) dev;
- init_timer (&dev->delay);
-// mutex_init (&dev->phy_mutex);
+ init_timer(&dev->delay);
+ /* mutex_init(&dev->phy_mutex); */
dev->net = net;
@@ -1259,13 +1271,13 @@ axusbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
dev->hard_mtu = net->mtu + net->hard_header_len;
#if 0
-// dma_supported() is deeply broken on almost all architectures
- // possible with some EHCI controllers
- if (dma_supported (&udev->dev, DMA_BIT_MASK(64)))
+ /* dma_supported() is deeply broken on almost all architectures */
+ /* possible with some EHCI controllers */
+ if (dma_supported(&udev->dev, DMA_BIT_MASK(64)))
net->features |= NETIF_F_HIGHDMA;
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
net->open = axusbnet_open,
net->stop = axusbnet_stop,
net->hard_start_xmit = axusbnet_start_xmit,
@@ -1276,9 +1288,9 @@ axusbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
net->watchdog_timeo = TX_TIMEOUT_JIFFIES;
net->ethtool_ops = &axusbnet_ethtool_ops;
- // allow device-specific bind/init procedures
- // NOTE net->name still not usable ...
- status = info->bind (dev, udev);
+ /* allow device-specific bind/init procedures */
+ /* NOTE net->name still not usable ... */
+ status = info->bind(dev, udev);
if (status < 0) {
deverr(dev, "Binding device failed: %d", status);
goto out1;
@@ -1288,39 +1300,39 @@ axusbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
if (net->mtu > (dev->hard_mtu - net->hard_header_len))
net->mtu = dev->hard_mtu - net->hard_header_len;
- status = init_status (dev, udev);
+ status = init_status(dev, udev);
if (status < 0)
goto out3;
if (!dev->rx_urb_size)
dev->rx_urb_size = dev->hard_mtu;
- dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
+ dev->maxpacket = usb_maxpacket(dev->udev, dev->out, 1);
SET_NETDEV_DEV(net, &udev->dev);
- status = register_netdev (net);
+ status = register_netdev(net);
if (status) {
deverr(dev, "net device registration failed: %d", status);
goto out3;
}
- if (netif_msg_probe (dev))
- devinfo (dev, "register '%s' at usb-%s-%s, %s, %pM",
+ if (netif_msg_probe(dev))
+ devinfo(dev, "register '%s' at usb-%s-%s, %s, %pM",
udev->dev.driver->name,
xdev->bus->bus_name, xdev->devpath,
dev->driver_info->description,
net->dev_addr);
- // ok, it's ready to go.
- usb_set_intfdata (udev, dev);
+ /* ok, it's ready to go. */
+ usb_set_intfdata(udev, dev);
- // start as if the link is up
- netif_device_attach (net);
+ /* start as if the link is up */
+ netif_device_attach(net);
return 0;
out3:
if (info->unbind)
- info->unbind (dev, udev);
+ info->unbind(dev, udev);
out1:
free_netdev(net);
out:
@@ -1335,40 +1347,52 @@ out:
* resume only when the last interface is resumed
*/
-static int axusbnet_suspend (struct usb_interface *intf,
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
+static int axusbnet_suspend(struct usb_interface *intf,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 10)
pm_message_t message)
#else
u32 message)
#endif
{
- struct usbnet *dev = usb_get_intfdata(intf);
+ struct usbnet *dev = usb_get_intfdata(intf);
if (!dev->suspend_count++) {
/*
* accelerate emptying of the rx and queues, to avoid
* having everything error out.
*/
- netif_device_detach (dev->net);
- (void) unlink_urbs (dev, &dev->rxq);
- (void) unlink_urbs (dev, &dev->txq);
+ netif_device_detach(dev->net);
+ (void) unlink_urbs(dev, &dev->rxq);
+ (void) unlink_urbs(dev, &dev->txq);
+ usb_kill_urb(dev->interrupt);
/*
* reattach so runtime management can use and
* wake the device
*/
- netif_device_attach (dev->net);
+ netif_device_attach(dev->net);
}
return 0;
}
static int
-axusbnet_resume (struct usb_interface *intf)
+axusbnet_resume(struct usb_interface *intf)
{
- struct usbnet *dev = usb_get_intfdata(intf);
+ struct usbnet *dev = usb_get_intfdata(intf);
+ int retval = 0;
if (!--dev->suspend_count)
- tasklet_schedule (&dev->bh);
+ tasklet_schedule(&dev->bh);
- return 0;
+ retval = init_status(dev, intf);
+ if (retval < 0)
+ return retval;
+
+ if (dev->interrupt) {
+ retval = usb_submit_urb(dev->interrupt, GFP_KERNEL);
+ if (retval < 0 && netif_msg_ifup(dev))
+ deverr(dev, "intr submit %d", retval);
+ }
+
+ return retval;
}
diff --git a/drivers/net/usb/axusbnet.h b/drivers/net/usb/axusbnet.h
index d492de3b80e1..af441e5c4985 100644
--- a/drivers/net/usb/axusbnet.h
+++ b/drivers/net/usb/axusbnet.h
@@ -35,7 +35,7 @@ struct usbnet {
const char *driver_name;
void *driver_priv;
wait_queue_head_t *wait;
-// struct mutex phy_mutex;
+ /* struct mutex phy_mutex; */
unsigned char suspend_count;
/* i/o info: pipes etc */
@@ -48,7 +48,7 @@ struct usbnet {
struct net_device *net;
struct net_device_stats stats;
int msg_enable;
- unsigned long data [5];
+ unsigned long data[5];
u32 xid;
u32 hard_mtu; /* count any extra framing */
size_t rx_urb_size; /* size for rx urbs */