11ccea77eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 2e2ca90c2SFreddy Xin /* 3e2ca90c2SFreddy Xin * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices 4e2ca90c2SFreddy Xin * 5e2ca90c2SFreddy Xin * Copyright (C) 2011-2013 ASIX 6e2ca90c2SFreddy Xin */ 7e2ca90c2SFreddy Xin 8e2ca90c2SFreddy Xin #include <linux/module.h> 9e2ca90c2SFreddy Xin #include <linux/etherdevice.h> 10e2ca90c2SFreddy Xin #include <linux/mii.h> 11e2ca90c2SFreddy Xin #include <linux/usb.h> 12e2ca90c2SFreddy Xin #include <linux/crc32.h> 13e2ca90c2SFreddy Xin #include <linux/usb/usbnet.h> 14e98d69baSFreddy Xin #include <uapi/linux/mdio.h> 15e98d69baSFreddy Xin #include <linux/mdio.h> 16e2ca90c2SFreddy Xin 17e2ca90c2SFreddy Xin #define AX88179_PHY_ID 0x03 18e2ca90c2SFreddy Xin #define AX_EEPROM_LEN 0x100 19e2ca90c2SFreddy Xin #define AX88179_EEPROM_MAGIC 0x17900b95 20e2ca90c2SFreddy Xin #define AX_MCAST_FLTSIZE 8 21e2ca90c2SFreddy Xin #define AX_MAX_MCAST 64 22e2ca90c2SFreddy Xin #define AX_INT_PPLS_LINK ((u32)BIT(16)) 23e2ca90c2SFreddy Xin #define AX_RXHDR_L4_TYPE_MASK 0x1c 24e2ca90c2SFreddy Xin #define AX_RXHDR_L4_TYPE_UDP 4 25e2ca90c2SFreddy Xin #define AX_RXHDR_L4_TYPE_TCP 16 26e2ca90c2SFreddy Xin #define AX_RXHDR_L3CSUM_ERR 2 27e2ca90c2SFreddy Xin #define AX_RXHDR_L4CSUM_ERR 1 287e78b83cSFreddy Xin #define AX_RXHDR_CRC_ERR ((u32)BIT(29)) 297e78b83cSFreddy Xin #define AX_RXHDR_DROP_ERR ((u32)BIT(31)) 30e2ca90c2SFreddy Xin #define AX_ACCESS_MAC 0x01 31e2ca90c2SFreddy Xin #define AX_ACCESS_PHY 0x02 32e2ca90c2SFreddy Xin #define AX_ACCESS_EEPROM 0x04 33e2ca90c2SFreddy Xin #define AX_ACCESS_EFUS 0x05 3478734404SBjorn Andersson #define AX_RELOAD_EEPROM_EFUSE 0x06 35e2ca90c2SFreddy Xin #define AX_PAUSE_WATERLVL_HIGH 0x54 36e2ca90c2SFreddy Xin #define AX_PAUSE_WATERLVL_LOW 0x55 37e2ca90c2SFreddy Xin 38e2ca90c2SFreddy Xin #define PHYSICAL_LINK_STATUS 0x02 39e2ca90c2SFreddy Xin #define AX_USB_SS 0x04 40e2ca90c2SFreddy Xin #define AX_USB_HS 0x02 41e2ca90c2SFreddy Xin 42e2ca90c2SFreddy Xin #define GENERAL_STATUS 0x03 43e2ca90c2SFreddy Xin /* Check AX88179 version. UA1:Bit2 = 0, UA2:Bit2 = 1 */ 44e2ca90c2SFreddy Xin #define AX_SECLD 0x04 45e2ca90c2SFreddy Xin 46e2ca90c2SFreddy Xin #define AX_SROM_ADDR 0x07 47e2ca90c2SFreddy Xin #define AX_SROM_CMD 0x0a 48e2ca90c2SFreddy Xin #define EEP_RD 0x04 49e2ca90c2SFreddy Xin #define EEP_BUSY 0x10 50e2ca90c2SFreddy Xin 51e2ca90c2SFreddy Xin #define AX_SROM_DATA_LOW 0x08 52e2ca90c2SFreddy Xin #define AX_SROM_DATA_HIGH 0x09 53e2ca90c2SFreddy Xin 54e2ca90c2SFreddy Xin #define AX_RX_CTL 0x0b 55e2ca90c2SFreddy Xin #define AX_RX_CTL_DROPCRCERR 0x0100 56e2ca90c2SFreddy Xin #define AX_RX_CTL_IPE 0x0200 57e2ca90c2SFreddy Xin #define AX_RX_CTL_START 0x0080 58e2ca90c2SFreddy Xin #define AX_RX_CTL_AP 0x0020 59e2ca90c2SFreddy Xin #define AX_RX_CTL_AM 0x0010 60e2ca90c2SFreddy Xin #define AX_RX_CTL_AB 0x0008 61e2ca90c2SFreddy Xin #define AX_RX_CTL_AMALL 0x0002 62e2ca90c2SFreddy Xin #define AX_RX_CTL_PRO 0x0001 63e2ca90c2SFreddy Xin #define AX_RX_CTL_STOP 0x0000 64e2ca90c2SFreddy Xin 65e2ca90c2SFreddy Xin #define AX_NODE_ID 0x10 66e2ca90c2SFreddy Xin #define AX_MULFLTARY 0x16 67e2ca90c2SFreddy Xin 68e2ca90c2SFreddy Xin #define AX_MEDIUM_STATUS_MODE 0x22 69e2ca90c2SFreddy Xin #define AX_MEDIUM_GIGAMODE 0x01 70e2ca90c2SFreddy Xin #define AX_MEDIUM_FULL_DUPLEX 0x02 71e2ca90c2SFreddy Xin #define AX_MEDIUM_EN_125MHZ 0x08 72e2ca90c2SFreddy Xin #define AX_MEDIUM_RXFLOW_CTRLEN 0x10 73e2ca90c2SFreddy Xin #define AX_MEDIUM_TXFLOW_CTRLEN 0x20 74e2ca90c2SFreddy Xin #define AX_MEDIUM_RECEIVE_EN 0x100 75e2ca90c2SFreddy Xin #define AX_MEDIUM_PS 0x200 76e2ca90c2SFreddy Xin #define AX_MEDIUM_JUMBO_EN 0x8040 77e2ca90c2SFreddy Xin 78e2ca90c2SFreddy Xin #define AX_MONITOR_MOD 0x24 79e2ca90c2SFreddy Xin #define AX_MONITOR_MODE_RWLC 0x02 80e2ca90c2SFreddy Xin #define AX_MONITOR_MODE_RWMP 0x04 81e2ca90c2SFreddy Xin #define AX_MONITOR_MODE_PMEPOL 0x20 82e2ca90c2SFreddy Xin #define AX_MONITOR_MODE_PMETYPE 0x40 83e2ca90c2SFreddy Xin 84e2ca90c2SFreddy Xin #define AX_GPIO_CTRL 0x25 85e2ca90c2SFreddy Xin #define AX_GPIO_CTRL_GPIO3EN 0x80 86e2ca90c2SFreddy Xin #define AX_GPIO_CTRL_GPIO2EN 0x40 87e2ca90c2SFreddy Xin #define AX_GPIO_CTRL_GPIO1EN 0x20 88e2ca90c2SFreddy Xin 89e2ca90c2SFreddy Xin #define AX_PHYPWR_RSTCTL 0x26 90e2ca90c2SFreddy Xin #define AX_PHYPWR_RSTCTL_BZ 0x0010 91e2ca90c2SFreddy Xin #define AX_PHYPWR_RSTCTL_IPRL 0x0020 92e2ca90c2SFreddy Xin #define AX_PHYPWR_RSTCTL_AT 0x1000 93e2ca90c2SFreddy Xin 94e2ca90c2SFreddy Xin #define AX_RX_BULKIN_QCTRL 0x2e 95e2ca90c2SFreddy Xin #define AX_CLK_SELECT 0x33 96e2ca90c2SFreddy Xin #define AX_CLK_SELECT_BCS 0x01 97e2ca90c2SFreddy Xin #define AX_CLK_SELECT_ACS 0x02 98e2ca90c2SFreddy Xin #define AX_CLK_SELECT_ULR 0x08 99e2ca90c2SFreddy Xin 100e2ca90c2SFreddy Xin #define AX_RXCOE_CTL 0x34 101e2ca90c2SFreddy Xin #define AX_RXCOE_IP 0x01 102e2ca90c2SFreddy Xin #define AX_RXCOE_TCP 0x02 103e2ca90c2SFreddy Xin #define AX_RXCOE_UDP 0x04 104e2ca90c2SFreddy Xin #define AX_RXCOE_TCPV6 0x20 105e2ca90c2SFreddy Xin #define AX_RXCOE_UDPV6 0x40 106e2ca90c2SFreddy Xin 107e2ca90c2SFreddy Xin #define AX_TXCOE_CTL 0x35 108e2ca90c2SFreddy Xin #define AX_TXCOE_IP 0x01 109e2ca90c2SFreddy Xin #define AX_TXCOE_TCP 0x02 110e2ca90c2SFreddy Xin #define AX_TXCOE_UDP 0x04 111e2ca90c2SFreddy Xin #define AX_TXCOE_TCPV6 0x20 112e2ca90c2SFreddy Xin #define AX_TXCOE_UDPV6 0x40 113e2ca90c2SFreddy Xin 114e2ca90c2SFreddy Xin #define AX_LEDCTRL 0x73 115e2ca90c2SFreddy Xin 116e2ca90c2SFreddy Xin #define GMII_PHY_PHYSR 0x11 117e2ca90c2SFreddy Xin #define GMII_PHY_PHYSR_SMASK 0xc000 118e2ca90c2SFreddy Xin #define GMII_PHY_PHYSR_GIGA 0x8000 119e2ca90c2SFreddy Xin #define GMII_PHY_PHYSR_100 0x4000 120e2ca90c2SFreddy Xin #define GMII_PHY_PHYSR_FULL 0x2000 121e2ca90c2SFreddy Xin #define GMII_PHY_PHYSR_LINK 0x400 122e2ca90c2SFreddy Xin 123e2ca90c2SFreddy Xin #define GMII_LED_ACT 0x1a 124e2ca90c2SFreddy Xin #define GMII_LED_ACTIVE_MASK 0xff8f 125e2ca90c2SFreddy Xin #define GMII_LED0_ACTIVE BIT(4) 126e2ca90c2SFreddy Xin #define GMII_LED1_ACTIVE BIT(5) 127e2ca90c2SFreddy Xin #define GMII_LED2_ACTIVE BIT(6) 128e2ca90c2SFreddy Xin 129e2ca90c2SFreddy Xin #define GMII_LED_LINK 0x1c 130e2ca90c2SFreddy Xin #define GMII_LED_LINK_MASK 0xf888 131e2ca90c2SFreddy Xin #define GMII_LED0_LINK_10 BIT(0) 132e2ca90c2SFreddy Xin #define GMII_LED0_LINK_100 BIT(1) 133e2ca90c2SFreddy Xin #define GMII_LED0_LINK_1000 BIT(2) 134e2ca90c2SFreddy Xin #define GMII_LED1_LINK_10 BIT(4) 135e2ca90c2SFreddy Xin #define GMII_LED1_LINK_100 BIT(5) 136e2ca90c2SFreddy Xin #define GMII_LED1_LINK_1000 BIT(6) 137e2ca90c2SFreddy Xin #define GMII_LED2_LINK_10 BIT(8) 138e2ca90c2SFreddy Xin #define GMII_LED2_LINK_100 BIT(9) 139e2ca90c2SFreddy Xin #define GMII_LED2_LINK_1000 BIT(10) 140e2ca90c2SFreddy Xin #define LED0_ACTIVE BIT(0) 141e2ca90c2SFreddy Xin #define LED0_LINK_10 BIT(1) 142e2ca90c2SFreddy Xin #define LED0_LINK_100 BIT(2) 143e2ca90c2SFreddy Xin #define LED0_LINK_1000 BIT(3) 144e2ca90c2SFreddy Xin #define LED0_FD BIT(4) 145e2ca90c2SFreddy Xin #define LED0_USB3_MASK 0x001f 146e2ca90c2SFreddy Xin #define LED1_ACTIVE BIT(5) 147e2ca90c2SFreddy Xin #define LED1_LINK_10 BIT(6) 148e2ca90c2SFreddy Xin #define LED1_LINK_100 BIT(7) 149e2ca90c2SFreddy Xin #define LED1_LINK_1000 BIT(8) 150e2ca90c2SFreddy Xin #define LED1_FD BIT(9) 151e2ca90c2SFreddy Xin #define LED1_USB3_MASK 0x03e0 152e2ca90c2SFreddy Xin #define LED2_ACTIVE BIT(10) 153e2ca90c2SFreddy Xin #define LED2_LINK_1000 BIT(13) 154e2ca90c2SFreddy Xin #define LED2_LINK_100 BIT(12) 155e2ca90c2SFreddy Xin #define LED2_LINK_10 BIT(11) 156e2ca90c2SFreddy Xin #define LED2_FD BIT(14) 157e2ca90c2SFreddy Xin #define LED_VALID BIT(15) 158e2ca90c2SFreddy Xin #define LED2_USB3_MASK 0x7c00 159e2ca90c2SFreddy Xin 160e2ca90c2SFreddy Xin #define GMII_PHYPAGE 0x1e 161e2ca90c2SFreddy Xin #define GMII_PHY_PAGE_SELECT 0x1f 162e2ca90c2SFreddy Xin #define GMII_PHY_PGSEL_EXT 0x0007 163e2ca90c2SFreddy Xin #define GMII_PHY_PGSEL_PAGE0 0x0000 164e98d69baSFreddy Xin #define GMII_PHY_PGSEL_PAGE3 0x0003 165e98d69baSFreddy Xin #define GMII_PHY_PGSEL_PAGE5 0x0005 166e2ca90c2SFreddy Xin 167*9718f9ceSJustin Chen static int ax88179_reset(struct usbnet *dev); 168*9718f9ceSJustin Chen 169e2ca90c2SFreddy Xin struct ax88179_data { 170e98d69baSFreddy Xin u8 eee_enabled; 171e98d69baSFreddy Xin u8 eee_active; 172e2ca90c2SFreddy Xin u16 rxctl; 173e2ca90c2SFreddy Xin u16 reserved; 174e2ca90c2SFreddy Xin }; 175e2ca90c2SFreddy Xin 176e2ca90c2SFreddy Xin struct ax88179_int_data { 177e2ca90c2SFreddy Xin __le32 intdata1; 178e2ca90c2SFreddy Xin __le32 intdata2; 179e2ca90c2SFreddy Xin }; 180e2ca90c2SFreddy Xin 181e2ca90c2SFreddy Xin static const struct { 182e2ca90c2SFreddy Xin unsigned char ctrl, timer_l, timer_h, size, ifg; 183e2ca90c2SFreddy Xin } AX88179_BULKIN_SIZE[] = { 184e2ca90c2SFreddy Xin {7, 0x4f, 0, 0x12, 0xff}, 185e2ca90c2SFreddy Xin {7, 0x20, 3, 0x16, 0xff}, 186e2ca90c2SFreddy Xin {7, 0xae, 7, 0x18, 0xff}, 187e2ca90c2SFreddy Xin {7, 0xcc, 0x4c, 0x18, 8}, 188e2ca90c2SFreddy Xin }; 189e2ca90c2SFreddy Xin 190e2ca90c2SFreddy Xin static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 191e2ca90c2SFreddy Xin u16 size, void *data, int in_pm) 192e2ca90c2SFreddy Xin { 193e2ca90c2SFreddy Xin int ret; 194e2ca90c2SFreddy Xin int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); 195e2ca90c2SFreddy Xin 196e2ca90c2SFreddy Xin BUG_ON(!dev); 197e2ca90c2SFreddy Xin 198e2ca90c2SFreddy Xin if (!in_pm) 199e2ca90c2SFreddy Xin fn = usbnet_read_cmd; 200e2ca90c2SFreddy Xin else 201e2ca90c2SFreddy Xin fn = usbnet_read_cmd_nopm; 202e2ca90c2SFreddy Xin 203e2ca90c2SFreddy Xin ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 204e2ca90c2SFreddy Xin value, index, data, size); 205e2ca90c2SFreddy Xin 206e2ca90c2SFreddy Xin if (unlikely(ret < 0)) 207e2ca90c2SFreddy Xin netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", 208e2ca90c2SFreddy Xin index, ret); 209e2ca90c2SFreddy Xin 210e2ca90c2SFreddy Xin return ret; 211e2ca90c2SFreddy Xin } 212e2ca90c2SFreddy Xin 213e2ca90c2SFreddy Xin static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 21476660757SJakub Kicinski u16 size, const void *data, int in_pm) 215e2ca90c2SFreddy Xin { 216e2ca90c2SFreddy Xin int ret; 217e2ca90c2SFreddy Xin int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); 218e2ca90c2SFreddy Xin 219e2ca90c2SFreddy Xin BUG_ON(!dev); 220e2ca90c2SFreddy Xin 221e2ca90c2SFreddy Xin if (!in_pm) 222e2ca90c2SFreddy Xin fn = usbnet_write_cmd; 223e2ca90c2SFreddy Xin else 224e2ca90c2SFreddy Xin fn = usbnet_write_cmd_nopm; 225e2ca90c2SFreddy Xin 226e2ca90c2SFreddy Xin ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 227e2ca90c2SFreddy Xin value, index, data, size); 228e2ca90c2SFreddy Xin 229e2ca90c2SFreddy Xin if (unlikely(ret < 0)) 230e2ca90c2SFreddy Xin netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", 231e2ca90c2SFreddy Xin index, ret); 232e2ca90c2SFreddy Xin 233e2ca90c2SFreddy Xin return ret; 234e2ca90c2SFreddy Xin } 235e2ca90c2SFreddy Xin 236e2ca90c2SFreddy Xin static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, 237e2ca90c2SFreddy Xin u16 index, u16 size, void *data) 238e2ca90c2SFreddy Xin { 239e2ca90c2SFreddy Xin u16 buf; 240e2ca90c2SFreddy Xin 241e2ca90c2SFreddy Xin if (2 == size) { 242e2ca90c2SFreddy Xin buf = *((u16 *)data); 243e2ca90c2SFreddy Xin cpu_to_le16s(&buf); 244e2ca90c2SFreddy Xin usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | 245e2ca90c2SFreddy Xin USB_RECIP_DEVICE, value, index, &buf, 246e2ca90c2SFreddy Xin size); 247e2ca90c2SFreddy Xin } else { 248e2ca90c2SFreddy Xin usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | 249e2ca90c2SFreddy Xin USB_RECIP_DEVICE, value, index, data, 250e2ca90c2SFreddy Xin size); 251e2ca90c2SFreddy Xin } 252e2ca90c2SFreddy Xin } 253e2ca90c2SFreddy Xin 254e2ca90c2SFreddy Xin static int ax88179_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, 255e2ca90c2SFreddy Xin u16 index, u16 size, void *data) 256e2ca90c2SFreddy Xin { 257e2ca90c2SFreddy Xin int ret; 258e2ca90c2SFreddy Xin 259e2ca90c2SFreddy Xin if (2 == size) { 260e2ca90c2SFreddy Xin u16 buf; 261e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); 262e2ca90c2SFreddy Xin le16_to_cpus(&buf); 263e2ca90c2SFreddy Xin *((u16 *)data) = buf; 264e2ca90c2SFreddy Xin } else if (4 == size) { 265e2ca90c2SFreddy Xin u32 buf; 266e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); 267e2ca90c2SFreddy Xin le32_to_cpus(&buf); 268e2ca90c2SFreddy Xin *((u32 *)data) = buf; 269e2ca90c2SFreddy Xin } else { 270e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 1); 271e2ca90c2SFreddy Xin } 272e2ca90c2SFreddy Xin 273e2ca90c2SFreddy Xin return ret; 274e2ca90c2SFreddy Xin } 275e2ca90c2SFreddy Xin 276e2ca90c2SFreddy Xin static int ax88179_write_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, 27776660757SJakub Kicinski u16 index, u16 size, const void *data) 278e2ca90c2SFreddy Xin { 279e2ca90c2SFreddy Xin int ret; 280e2ca90c2SFreddy Xin 281e2ca90c2SFreddy Xin if (2 == size) { 282e2ca90c2SFreddy Xin u16 buf; 283e2ca90c2SFreddy Xin buf = *((u16 *)data); 284e2ca90c2SFreddy Xin cpu_to_le16s(&buf); 285e2ca90c2SFreddy Xin ret = __ax88179_write_cmd(dev, cmd, value, index, 286e2ca90c2SFreddy Xin size, &buf, 1); 287e2ca90c2SFreddy Xin } else { 288e2ca90c2SFreddy Xin ret = __ax88179_write_cmd(dev, cmd, value, index, 289e2ca90c2SFreddy Xin size, data, 1); 290e2ca90c2SFreddy Xin } 291e2ca90c2SFreddy Xin 292e2ca90c2SFreddy Xin return ret; 293e2ca90c2SFreddy Xin } 294e2ca90c2SFreddy Xin 295e2ca90c2SFreddy Xin static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 296e2ca90c2SFreddy Xin u16 size, void *data) 297e2ca90c2SFreddy Xin { 298e2ca90c2SFreddy Xin int ret; 299e2ca90c2SFreddy Xin 300e2ca90c2SFreddy Xin if (2 == size) { 301bd78980bSPhillip Potter u16 buf = 0; 302e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); 303e2ca90c2SFreddy Xin le16_to_cpus(&buf); 304e2ca90c2SFreddy Xin *((u16 *)data) = buf; 305e2ca90c2SFreddy Xin } else if (4 == size) { 306bd78980bSPhillip Potter u32 buf = 0; 307e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); 308e2ca90c2SFreddy Xin le32_to_cpus(&buf); 309e2ca90c2SFreddy Xin *((u32 *)data) = buf; 310e2ca90c2SFreddy Xin } else { 311e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 0); 312e2ca90c2SFreddy Xin } 313e2ca90c2SFreddy Xin 314e2ca90c2SFreddy Xin return ret; 315e2ca90c2SFreddy Xin } 316e2ca90c2SFreddy Xin 317e2ca90c2SFreddy Xin static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 31876660757SJakub Kicinski u16 size, const void *data) 319e2ca90c2SFreddy Xin { 320e2ca90c2SFreddy Xin int ret; 321e2ca90c2SFreddy Xin 322e2ca90c2SFreddy Xin if (2 == size) { 323e2ca90c2SFreddy Xin u16 buf; 324e2ca90c2SFreddy Xin buf = *((u16 *)data); 325e2ca90c2SFreddy Xin cpu_to_le16s(&buf); 326e2ca90c2SFreddy Xin ret = __ax88179_write_cmd(dev, cmd, value, index, 327e2ca90c2SFreddy Xin size, &buf, 0); 328e2ca90c2SFreddy Xin } else { 329e2ca90c2SFreddy Xin ret = __ax88179_write_cmd(dev, cmd, value, index, 330e2ca90c2SFreddy Xin size, data, 0); 331e2ca90c2SFreddy Xin } 332e2ca90c2SFreddy Xin 333e2ca90c2SFreddy Xin return ret; 334e2ca90c2SFreddy Xin } 335e2ca90c2SFreddy Xin 336e2ca90c2SFreddy Xin static void ax88179_status(struct usbnet *dev, struct urb *urb) 337e2ca90c2SFreddy Xin { 338e2ca90c2SFreddy Xin struct ax88179_int_data *event; 339e2ca90c2SFreddy Xin u32 link; 340e2ca90c2SFreddy Xin 341e2ca90c2SFreddy Xin if (urb->actual_length < 8) 342e2ca90c2SFreddy Xin return; 343e2ca90c2SFreddy Xin 344e2ca90c2SFreddy Xin event = urb->transfer_buffer; 345e2ca90c2SFreddy Xin le32_to_cpus((void *)&event->intdata1); 346e2ca90c2SFreddy Xin 347e2ca90c2SFreddy Xin link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16; 348e2ca90c2SFreddy Xin 349e2ca90c2SFreddy Xin if (netif_carrier_ok(dev->net) != link) { 3507a97856eSMing Lei usbnet_link_change(dev, link, 1); 351e2ca90c2SFreddy Xin netdev_info(dev->net, "ax88179 - Link status is: %d\n", link); 352e2ca90c2SFreddy Xin } 353e2ca90c2SFreddy Xin } 354e2ca90c2SFreddy Xin 355e2ca90c2SFreddy Xin static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc) 356e2ca90c2SFreddy Xin { 357e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(netdev); 358e2ca90c2SFreddy Xin u16 res; 359e2ca90c2SFreddy Xin 360e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); 361e2ca90c2SFreddy Xin return res; 362e2ca90c2SFreddy Xin } 363e2ca90c2SFreddy Xin 364e2ca90c2SFreddy Xin static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, 365e2ca90c2SFreddy Xin int val) 366e2ca90c2SFreddy Xin { 367e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(netdev); 368e2ca90c2SFreddy Xin u16 res = (u16) val; 369e2ca90c2SFreddy Xin 370e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); 371e2ca90c2SFreddy Xin } 372e2ca90c2SFreddy Xin 373e98d69baSFreddy Xin static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad, 374e98d69baSFreddy Xin u16 devad) 375e98d69baSFreddy Xin { 376e98d69baSFreddy Xin u16 tmp16; 377e98d69baSFreddy Xin int ret; 378e98d69baSFreddy Xin 379e98d69baSFreddy Xin tmp16 = devad; 380e98d69baSFreddy Xin ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 381e98d69baSFreddy Xin MII_MMD_CTRL, 2, &tmp16); 382e98d69baSFreddy Xin 383e98d69baSFreddy Xin tmp16 = prtad; 384e98d69baSFreddy Xin ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 385e98d69baSFreddy Xin MII_MMD_DATA, 2, &tmp16); 386e98d69baSFreddy Xin 387e98d69baSFreddy Xin tmp16 = devad | MII_MMD_CTRL_NOINCR; 388e98d69baSFreddy Xin ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 389e98d69baSFreddy Xin MII_MMD_CTRL, 2, &tmp16); 390e98d69baSFreddy Xin 391e98d69baSFreddy Xin return ret; 392e98d69baSFreddy Xin } 393e98d69baSFreddy Xin 394e98d69baSFreddy Xin static int 395e98d69baSFreddy Xin ax88179_phy_read_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad) 396e98d69baSFreddy Xin { 397e98d69baSFreddy Xin int ret; 398e98d69baSFreddy Xin u16 tmp16; 399e98d69baSFreddy Xin 400e98d69baSFreddy Xin ax88179_phy_mmd_indirect(dev, prtad, devad); 401e98d69baSFreddy Xin 402e98d69baSFreddy Xin ret = ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 403e98d69baSFreddy Xin MII_MMD_DATA, 2, &tmp16); 404e98d69baSFreddy Xin if (ret < 0) 405e98d69baSFreddy Xin return ret; 406e98d69baSFreddy Xin 407e98d69baSFreddy Xin return tmp16; 408e98d69baSFreddy Xin } 409e98d69baSFreddy Xin 410e98d69baSFreddy Xin static int 411e98d69baSFreddy Xin ax88179_phy_write_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad, 412e98d69baSFreddy Xin u16 data) 413e98d69baSFreddy Xin { 414e98d69baSFreddy Xin int ret; 415e98d69baSFreddy Xin 416e98d69baSFreddy Xin ax88179_phy_mmd_indirect(dev, prtad, devad); 417e98d69baSFreddy Xin 418e98d69baSFreddy Xin ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 419e98d69baSFreddy Xin MII_MMD_DATA, 2, &data); 420e98d69baSFreddy Xin 421e98d69baSFreddy Xin if (ret < 0) 422e98d69baSFreddy Xin return ret; 423e98d69baSFreddy Xin 424e98d69baSFreddy Xin return 0; 425e98d69baSFreddy Xin } 426e98d69baSFreddy Xin 427e2ca90c2SFreddy Xin static int ax88179_suspend(struct usb_interface *intf, pm_message_t message) 428e2ca90c2SFreddy Xin { 429e2ca90c2SFreddy Xin struct usbnet *dev = usb_get_intfdata(intf); 430e2ca90c2SFreddy Xin u16 tmp16; 431e2ca90c2SFreddy Xin u8 tmp8; 432e2ca90c2SFreddy Xin 433e2ca90c2SFreddy Xin usbnet_suspend(intf, message); 434e2ca90c2SFreddy Xin 435e2ca90c2SFreddy Xin /* Disable RX path */ 436e2ca90c2SFreddy Xin ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 437e2ca90c2SFreddy Xin 2, 2, &tmp16); 438e2ca90c2SFreddy Xin tmp16 &= ~AX_MEDIUM_RECEIVE_EN; 439e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 440e2ca90c2SFreddy Xin 2, 2, &tmp16); 441e2ca90c2SFreddy Xin 442e2ca90c2SFreddy Xin /* Force bulk-in zero length */ 443e2ca90c2SFreddy Xin ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 444e2ca90c2SFreddy Xin 2, 2, &tmp16); 445e2ca90c2SFreddy Xin 446e2ca90c2SFreddy Xin tmp16 |= AX_PHYPWR_RSTCTL_BZ | AX_PHYPWR_RSTCTL_IPRL; 447e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 448e2ca90c2SFreddy Xin 2, 2, &tmp16); 449e2ca90c2SFreddy Xin 450e2ca90c2SFreddy Xin /* change clock */ 451e2ca90c2SFreddy Xin tmp8 = 0; 452e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 453e2ca90c2SFreddy Xin 454e2ca90c2SFreddy Xin /* Configure RX control register => stop operation */ 455e2ca90c2SFreddy Xin tmp16 = AX_RX_CTL_STOP; 456e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); 457e2ca90c2SFreddy Xin 458e2ca90c2SFreddy Xin return 0; 459e2ca90c2SFreddy Xin } 460e2ca90c2SFreddy Xin 461e2ca90c2SFreddy Xin /* This function is used to enable the autodetach function. */ 462e2ca90c2SFreddy Xin /* This function is determined by offset 0x43 of EEPROM */ 463e2ca90c2SFreddy Xin static int ax88179_auto_detach(struct usbnet *dev, int in_pm) 464e2ca90c2SFreddy Xin { 465e2ca90c2SFreddy Xin u16 tmp16; 466e2ca90c2SFreddy Xin u8 tmp8; 467e2ca90c2SFreddy Xin int (*fnr)(struct usbnet *, u8, u16, u16, u16, void *); 46876660757SJakub Kicinski int (*fnw)(struct usbnet *, u8, u16, u16, u16, const void *); 469e2ca90c2SFreddy Xin 470e2ca90c2SFreddy Xin if (!in_pm) { 471e2ca90c2SFreddy Xin fnr = ax88179_read_cmd; 472e2ca90c2SFreddy Xin fnw = ax88179_write_cmd; 473e2ca90c2SFreddy Xin } else { 474e2ca90c2SFreddy Xin fnr = ax88179_read_cmd_nopm; 475e2ca90c2SFreddy Xin fnw = ax88179_write_cmd_nopm; 476e2ca90c2SFreddy Xin } 477e2ca90c2SFreddy Xin 478e2ca90c2SFreddy Xin if (fnr(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0) 479e2ca90c2SFreddy Xin return 0; 480e2ca90c2SFreddy Xin 481e2ca90c2SFreddy Xin if ((tmp16 == 0xFFFF) || (!(tmp16 & 0x0100))) 482e2ca90c2SFreddy Xin return 0; 483e2ca90c2SFreddy Xin 484e2ca90c2SFreddy Xin /* Enable Auto Detach bit */ 485e2ca90c2SFreddy Xin tmp8 = 0; 486e2ca90c2SFreddy Xin fnr(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 487e2ca90c2SFreddy Xin tmp8 |= AX_CLK_SELECT_ULR; 488e2ca90c2SFreddy Xin fnw(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 489e2ca90c2SFreddy Xin 490e2ca90c2SFreddy Xin fnr(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); 491e2ca90c2SFreddy Xin tmp16 |= AX_PHYPWR_RSTCTL_AT; 492e2ca90c2SFreddy Xin fnw(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); 493e2ca90c2SFreddy Xin 494e2ca90c2SFreddy Xin return 0; 495e2ca90c2SFreddy Xin } 496e2ca90c2SFreddy Xin 497e2ca90c2SFreddy Xin static int ax88179_resume(struct usb_interface *intf) 498e2ca90c2SFreddy Xin { 499e2ca90c2SFreddy Xin struct usbnet *dev = usb_get_intfdata(intf); 500e2ca90c2SFreddy Xin u16 tmp16; 501e2ca90c2SFreddy Xin u8 tmp8; 502e2ca90c2SFreddy Xin 5037a97856eSMing Lei usbnet_link_change(dev, 0, 0); 504e2ca90c2SFreddy Xin 505e2ca90c2SFreddy Xin /* Power up ethernet PHY */ 506e2ca90c2SFreddy Xin tmp16 = 0; 507e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 508e2ca90c2SFreddy Xin 2, 2, &tmp16); 509e2ca90c2SFreddy Xin udelay(1000); 510e2ca90c2SFreddy Xin 511e2ca90c2SFreddy Xin tmp16 = AX_PHYPWR_RSTCTL_IPRL; 512e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 513e2ca90c2SFreddy Xin 2, 2, &tmp16); 514e2ca90c2SFreddy Xin msleep(200); 515e2ca90c2SFreddy Xin 516e2ca90c2SFreddy Xin /* Ethernet PHY Auto Detach*/ 517e2ca90c2SFreddy Xin ax88179_auto_detach(dev, 1); 518e2ca90c2SFreddy Xin 519e2ca90c2SFreddy Xin /* Enable clock */ 520e2ca90c2SFreddy Xin ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 521e2ca90c2SFreddy Xin tmp8 |= AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; 522e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); 523e2ca90c2SFreddy Xin msleep(100); 524e2ca90c2SFreddy Xin 525e2ca90c2SFreddy Xin /* Configure RX control register => start operation */ 526e2ca90c2SFreddy Xin tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | 527e2ca90c2SFreddy Xin AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; 528e2ca90c2SFreddy Xin ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); 529e2ca90c2SFreddy Xin 530e2ca90c2SFreddy Xin return usbnet_resume(intf); 531e2ca90c2SFreddy Xin } 532e2ca90c2SFreddy Xin 533e2ca90c2SFreddy Xin static void 534e2ca90c2SFreddy Xin ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) 535e2ca90c2SFreddy Xin { 536e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 537e2ca90c2SFreddy Xin u8 opt; 538e2ca90c2SFreddy Xin 539e2ca90c2SFreddy Xin if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 540e2ca90c2SFreddy Xin 1, 1, &opt) < 0) { 541e2ca90c2SFreddy Xin wolinfo->supported = 0; 542e2ca90c2SFreddy Xin wolinfo->wolopts = 0; 543e2ca90c2SFreddy Xin return; 544e2ca90c2SFreddy Xin } 545e2ca90c2SFreddy Xin 546e2ca90c2SFreddy Xin wolinfo->supported = WAKE_PHY | WAKE_MAGIC; 547e2ca90c2SFreddy Xin wolinfo->wolopts = 0; 548e2ca90c2SFreddy Xin if (opt & AX_MONITOR_MODE_RWLC) 549e2ca90c2SFreddy Xin wolinfo->wolopts |= WAKE_PHY; 550e2ca90c2SFreddy Xin if (opt & AX_MONITOR_MODE_RWMP) 551e2ca90c2SFreddy Xin wolinfo->wolopts |= WAKE_MAGIC; 552e2ca90c2SFreddy Xin } 553e2ca90c2SFreddy Xin 554e2ca90c2SFreddy Xin static int 555e2ca90c2SFreddy Xin ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) 556e2ca90c2SFreddy Xin { 557e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 558e2ca90c2SFreddy Xin u8 opt = 0; 559e2ca90c2SFreddy Xin 5605ba6b4aaSFlorian Fainelli if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) 5615ba6b4aaSFlorian Fainelli return -EINVAL; 5625ba6b4aaSFlorian Fainelli 563e2ca90c2SFreddy Xin if (wolinfo->wolopts & WAKE_PHY) 564e2ca90c2SFreddy Xin opt |= AX_MONITOR_MODE_RWLC; 565e2ca90c2SFreddy Xin if (wolinfo->wolopts & WAKE_MAGIC) 566e2ca90c2SFreddy Xin opt |= AX_MONITOR_MODE_RWMP; 567e2ca90c2SFreddy Xin 568e2ca90c2SFreddy Xin if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 569e2ca90c2SFreddy Xin 1, 1, &opt) < 0) 570e2ca90c2SFreddy Xin return -EINVAL; 571e2ca90c2SFreddy Xin 572e2ca90c2SFreddy Xin return 0; 573e2ca90c2SFreddy Xin } 574e2ca90c2SFreddy Xin 575e2ca90c2SFreddy Xin static int ax88179_get_eeprom_len(struct net_device *net) 576e2ca90c2SFreddy Xin { 577e2ca90c2SFreddy Xin return AX_EEPROM_LEN; 578e2ca90c2SFreddy Xin } 579e2ca90c2SFreddy Xin 580e2ca90c2SFreddy Xin static int 581e2ca90c2SFreddy Xin ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, 582e2ca90c2SFreddy Xin u8 *data) 583e2ca90c2SFreddy Xin { 584e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 585e2ca90c2SFreddy Xin u16 *eeprom_buff; 586e2ca90c2SFreddy Xin int first_word, last_word; 587e2ca90c2SFreddy Xin int i, ret; 588e2ca90c2SFreddy Xin 589e2ca90c2SFreddy Xin if (eeprom->len == 0) 590e2ca90c2SFreddy Xin return -EINVAL; 591e2ca90c2SFreddy Xin 592e2ca90c2SFreddy Xin eeprom->magic = AX88179_EEPROM_MAGIC; 593e2ca90c2SFreddy Xin 594e2ca90c2SFreddy Xin first_word = eeprom->offset >> 1; 595e2ca90c2SFreddy Xin last_word = (eeprom->offset + eeprom->len - 1) >> 1; 5966da2ec56SKees Cook eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), 597e2ca90c2SFreddy Xin GFP_KERNEL); 598e2ca90c2SFreddy Xin if (!eeprom_buff) 599e2ca90c2SFreddy Xin return -ENOMEM; 600e2ca90c2SFreddy Xin 601e2ca90c2SFreddy Xin /* ax88179/178A returns 2 bytes from eeprom on read */ 602e2ca90c2SFreddy Xin for (i = first_word; i <= last_word; i++) { 603e2ca90c2SFreddy Xin ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, 604e2ca90c2SFreddy Xin &eeprom_buff[i - first_word], 605e2ca90c2SFreddy Xin 0); 606e2ca90c2SFreddy Xin if (ret < 0) { 607e2ca90c2SFreddy Xin kfree(eeprom_buff); 608e2ca90c2SFreddy Xin return -EIO; 609e2ca90c2SFreddy Xin } 610e2ca90c2SFreddy Xin } 611e2ca90c2SFreddy Xin 612e2ca90c2SFreddy Xin memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); 613e2ca90c2SFreddy Xin kfree(eeprom_buff); 614e2ca90c2SFreddy Xin return 0; 615e2ca90c2SFreddy Xin } 616e2ca90c2SFreddy Xin 61778734404SBjorn Andersson static int 61878734404SBjorn Andersson ax88179_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, 61978734404SBjorn Andersson u8 *data) 62078734404SBjorn Andersson { 62178734404SBjorn Andersson struct usbnet *dev = netdev_priv(net); 62278734404SBjorn Andersson u16 *eeprom_buff; 62378734404SBjorn Andersson int first_word; 62478734404SBjorn Andersson int last_word; 62578734404SBjorn Andersson int ret; 62678734404SBjorn Andersson int i; 62778734404SBjorn Andersson 62878734404SBjorn Andersson netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n", 62978734404SBjorn Andersson eeprom->len, eeprom->offset, eeprom->magic); 63078734404SBjorn Andersson 63178734404SBjorn Andersson if (eeprom->len == 0) 63278734404SBjorn Andersson return -EINVAL; 63378734404SBjorn Andersson 63478734404SBjorn Andersson if (eeprom->magic != AX88179_EEPROM_MAGIC) 63578734404SBjorn Andersson return -EINVAL; 63678734404SBjorn Andersson 63778734404SBjorn Andersson first_word = eeprom->offset >> 1; 63878734404SBjorn Andersson last_word = (eeprom->offset + eeprom->len - 1) >> 1; 63978734404SBjorn Andersson 64078734404SBjorn Andersson eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), 64178734404SBjorn Andersson GFP_KERNEL); 64278734404SBjorn Andersson if (!eeprom_buff) 64378734404SBjorn Andersson return -ENOMEM; 64478734404SBjorn Andersson 64578734404SBjorn Andersson /* align data to 16 bit boundaries, read the missing data from 64678734404SBjorn Andersson the EEPROM */ 64778734404SBjorn Andersson if (eeprom->offset & 1) { 64878734404SBjorn Andersson ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, first_word, 1, 2, 64978734404SBjorn Andersson &eeprom_buff[0]); 65078734404SBjorn Andersson if (ret < 0) { 65178734404SBjorn Andersson netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word); 65278734404SBjorn Andersson goto free; 65378734404SBjorn Andersson } 65478734404SBjorn Andersson } 65578734404SBjorn Andersson 65678734404SBjorn Andersson if ((eeprom->offset + eeprom->len) & 1) { 65778734404SBjorn Andersson ret = ax88179_read_cmd(dev, AX_ACCESS_EEPROM, last_word, 1, 2, 65878734404SBjorn Andersson &eeprom_buff[last_word - first_word]); 65978734404SBjorn Andersson if (ret < 0) { 66078734404SBjorn Andersson netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word); 66178734404SBjorn Andersson goto free; 66278734404SBjorn Andersson } 66378734404SBjorn Andersson } 66478734404SBjorn Andersson 66578734404SBjorn Andersson memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len); 66678734404SBjorn Andersson 66778734404SBjorn Andersson for (i = first_word; i <= last_word; i++) { 66878734404SBjorn Andersson netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n", 66978734404SBjorn Andersson i, eeprom_buff[i - first_word]); 67078734404SBjorn Andersson ret = ax88179_write_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, 67178734404SBjorn Andersson &eeprom_buff[i - first_word]); 67278734404SBjorn Andersson if (ret < 0) { 67378734404SBjorn Andersson netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", i); 67478734404SBjorn Andersson goto free; 67578734404SBjorn Andersson } 67678734404SBjorn Andersson msleep(20); 67778734404SBjorn Andersson } 67878734404SBjorn Andersson 67978734404SBjorn Andersson /* reload EEPROM data */ 68078734404SBjorn Andersson ret = ax88179_write_cmd(dev, AX_RELOAD_EEPROM_EFUSE, 0x0000, 0, 0, NULL); 68178734404SBjorn Andersson if (ret < 0) { 68278734404SBjorn Andersson netdev_err(net, "Failed to reload EEPROM data\n"); 68378734404SBjorn Andersson goto free; 68478734404SBjorn Andersson } 68578734404SBjorn Andersson 68678734404SBjorn Andersson ret = 0; 68778734404SBjorn Andersson free: 68878734404SBjorn Andersson kfree(eeprom_buff); 68978734404SBjorn Andersson return ret; 69078734404SBjorn Andersson } 69178734404SBjorn Andersson 6923c9b803bSPhilippe Reynes static int ax88179_get_link_ksettings(struct net_device *net, 6933c9b803bSPhilippe Reynes struct ethtool_link_ksettings *cmd) 694e2ca90c2SFreddy Xin { 695e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 69682c01a84Syuval.shaia@oracle.com 69782c01a84Syuval.shaia@oracle.com mii_ethtool_get_link_ksettings(&dev->mii, cmd); 69882c01a84Syuval.shaia@oracle.com 69982c01a84Syuval.shaia@oracle.com return 0; 700e2ca90c2SFreddy Xin } 701e2ca90c2SFreddy Xin 7023c9b803bSPhilippe Reynes static int ax88179_set_link_ksettings(struct net_device *net, 7033c9b803bSPhilippe Reynes const struct ethtool_link_ksettings *cmd) 704e2ca90c2SFreddy Xin { 705e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 7063c9b803bSPhilippe Reynes return mii_ethtool_set_link_ksettings(&dev->mii, cmd); 707e2ca90c2SFreddy Xin } 708e2ca90c2SFreddy Xin 709e98d69baSFreddy Xin static int 710e98d69baSFreddy Xin ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_eee *data) 711e98d69baSFreddy Xin { 712e98d69baSFreddy Xin int val; 713e98d69baSFreddy Xin 714e98d69baSFreddy Xin /* Get Supported EEE */ 715e98d69baSFreddy Xin val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE, 716e98d69baSFreddy Xin MDIO_MMD_PCS); 717e98d69baSFreddy Xin if (val < 0) 718e98d69baSFreddy Xin return val; 719e98d69baSFreddy Xin data->supported = mmd_eee_cap_to_ethtool_sup_t(val); 720e98d69baSFreddy Xin 721e98d69baSFreddy Xin /* Get advertisement EEE */ 722e98d69baSFreddy Xin val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV, 723e98d69baSFreddy Xin MDIO_MMD_AN); 724e98d69baSFreddy Xin if (val < 0) 725e98d69baSFreddy Xin return val; 726e98d69baSFreddy Xin data->advertised = mmd_eee_adv_to_ethtool_adv_t(val); 727e98d69baSFreddy Xin 728e98d69baSFreddy Xin /* Get LP advertisement EEE */ 729e98d69baSFreddy Xin val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE, 730e98d69baSFreddy Xin MDIO_MMD_AN); 731e98d69baSFreddy Xin if (val < 0) 732e98d69baSFreddy Xin return val; 733e98d69baSFreddy Xin data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val); 734e98d69baSFreddy Xin 735e98d69baSFreddy Xin return 0; 736e98d69baSFreddy Xin } 737e98d69baSFreddy Xin 738e98d69baSFreddy Xin static int 739e98d69baSFreddy Xin ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data) 740e98d69baSFreddy Xin { 741e98d69baSFreddy Xin u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised); 742e98d69baSFreddy Xin 743e98d69baSFreddy Xin return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV, 744e98d69baSFreddy Xin MDIO_MMD_AN, tmp16); 745e98d69baSFreddy Xin } 746e98d69baSFreddy Xin 747e98d69baSFreddy Xin static int ax88179_chk_eee(struct usbnet *dev) 748e98d69baSFreddy Xin { 749e98d69baSFreddy Xin struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; 750e98d69baSFreddy Xin struct ax88179_data *priv = (struct ax88179_data *)dev->data; 751e98d69baSFreddy Xin 752e98d69baSFreddy Xin mii_ethtool_gset(&dev->mii, &ecmd); 753e98d69baSFreddy Xin 754e98d69baSFreddy Xin if (ecmd.duplex & DUPLEX_FULL) { 755e98d69baSFreddy Xin int eee_lp, eee_cap, eee_adv; 756e98d69baSFreddy Xin u32 lp, cap, adv, supported = 0; 757e98d69baSFreddy Xin 758e98d69baSFreddy Xin eee_cap = ax88179_phy_read_mmd_indirect(dev, 759e98d69baSFreddy Xin MDIO_PCS_EEE_ABLE, 760e98d69baSFreddy Xin MDIO_MMD_PCS); 761e98d69baSFreddy Xin if (eee_cap < 0) { 762e98d69baSFreddy Xin priv->eee_active = 0; 763e98d69baSFreddy Xin return false; 764e98d69baSFreddy Xin } 765e98d69baSFreddy Xin 766e98d69baSFreddy Xin cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap); 767e98d69baSFreddy Xin if (!cap) { 768e98d69baSFreddy Xin priv->eee_active = 0; 769e98d69baSFreddy Xin return false; 770e98d69baSFreddy Xin } 771e98d69baSFreddy Xin 772e98d69baSFreddy Xin eee_lp = ax88179_phy_read_mmd_indirect(dev, 773e98d69baSFreddy Xin MDIO_AN_EEE_LPABLE, 774e98d69baSFreddy Xin MDIO_MMD_AN); 775e98d69baSFreddy Xin if (eee_lp < 0) { 776e98d69baSFreddy Xin priv->eee_active = 0; 777e98d69baSFreddy Xin return false; 778e98d69baSFreddy Xin } 779e98d69baSFreddy Xin 780e98d69baSFreddy Xin eee_adv = ax88179_phy_read_mmd_indirect(dev, 781e98d69baSFreddy Xin MDIO_AN_EEE_ADV, 782e98d69baSFreddy Xin MDIO_MMD_AN); 783e98d69baSFreddy Xin 784e98d69baSFreddy Xin if (eee_adv < 0) { 785e98d69baSFreddy Xin priv->eee_active = 0; 786e98d69baSFreddy Xin return false; 787e98d69baSFreddy Xin } 788e98d69baSFreddy Xin 789e98d69baSFreddy Xin adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); 790e98d69baSFreddy Xin lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); 791e98d69baSFreddy Xin supported = (ecmd.speed == SPEED_1000) ? 792e98d69baSFreddy Xin SUPPORTED_1000baseT_Full : 793e98d69baSFreddy Xin SUPPORTED_100baseT_Full; 794e98d69baSFreddy Xin 795e98d69baSFreddy Xin if (!(lp & adv & supported)) { 796e98d69baSFreddy Xin priv->eee_active = 0; 797e98d69baSFreddy Xin return false; 798e98d69baSFreddy Xin } 799e98d69baSFreddy Xin 800e98d69baSFreddy Xin priv->eee_active = 1; 801e98d69baSFreddy Xin return true; 802e98d69baSFreddy Xin } 803e98d69baSFreddy Xin 804e98d69baSFreddy Xin priv->eee_active = 0; 805e98d69baSFreddy Xin return false; 806e98d69baSFreddy Xin } 807e98d69baSFreddy Xin 808e98d69baSFreddy Xin static void ax88179_disable_eee(struct usbnet *dev) 809e98d69baSFreddy Xin { 810e98d69baSFreddy Xin u16 tmp16; 811e98d69baSFreddy Xin 812e98d69baSFreddy Xin tmp16 = GMII_PHY_PGSEL_PAGE3; 813e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 814e98d69baSFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp16); 815e98d69baSFreddy Xin 816e98d69baSFreddy Xin tmp16 = 0x3246; 817e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 818e98d69baSFreddy Xin MII_PHYADDR, 2, &tmp16); 819e98d69baSFreddy Xin 820e98d69baSFreddy Xin tmp16 = GMII_PHY_PGSEL_PAGE0; 821e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 822e98d69baSFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp16); 823e98d69baSFreddy Xin } 824e98d69baSFreddy Xin 825e98d69baSFreddy Xin static void ax88179_enable_eee(struct usbnet *dev) 826e98d69baSFreddy Xin { 827e98d69baSFreddy Xin u16 tmp16; 828e98d69baSFreddy Xin 829e98d69baSFreddy Xin tmp16 = GMII_PHY_PGSEL_PAGE3; 830e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 831e98d69baSFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp16); 832e98d69baSFreddy Xin 833e98d69baSFreddy Xin tmp16 = 0x3247; 834e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 835e98d69baSFreddy Xin MII_PHYADDR, 2, &tmp16); 836e98d69baSFreddy Xin 837e98d69baSFreddy Xin tmp16 = GMII_PHY_PGSEL_PAGE5; 838e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 839e98d69baSFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp16); 840e98d69baSFreddy Xin 841e98d69baSFreddy Xin tmp16 = 0x0680; 842e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 843e98d69baSFreddy Xin MII_BMSR, 2, &tmp16); 844e98d69baSFreddy Xin 845e98d69baSFreddy Xin tmp16 = GMII_PHY_PGSEL_PAGE0; 846e98d69baSFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 847e98d69baSFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp16); 848e98d69baSFreddy Xin } 849e98d69baSFreddy Xin 850e98d69baSFreddy Xin static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata) 851e98d69baSFreddy Xin { 852e98d69baSFreddy Xin struct usbnet *dev = netdev_priv(net); 853e98d69baSFreddy Xin struct ax88179_data *priv = (struct ax88179_data *)dev->data; 854e98d69baSFreddy Xin 855e98d69baSFreddy Xin edata->eee_enabled = priv->eee_enabled; 856e98d69baSFreddy Xin edata->eee_active = priv->eee_active; 857e98d69baSFreddy Xin 858e98d69baSFreddy Xin return ax88179_ethtool_get_eee(dev, edata); 859e98d69baSFreddy Xin } 860e98d69baSFreddy Xin 861e98d69baSFreddy Xin static int ax88179_set_eee(struct net_device *net, struct ethtool_eee *edata) 862e98d69baSFreddy Xin { 863e98d69baSFreddy Xin struct usbnet *dev = netdev_priv(net); 864e98d69baSFreddy Xin struct ax88179_data *priv = (struct ax88179_data *)dev->data; 865d728e640SColin Ian King int ret; 866e98d69baSFreddy Xin 867e98d69baSFreddy Xin priv->eee_enabled = edata->eee_enabled; 868e98d69baSFreddy Xin if (!priv->eee_enabled) { 869e98d69baSFreddy Xin ax88179_disable_eee(dev); 870e98d69baSFreddy Xin } else { 871e98d69baSFreddy Xin priv->eee_enabled = ax88179_chk_eee(dev); 872e98d69baSFreddy Xin if (!priv->eee_enabled) 873e98d69baSFreddy Xin return -EOPNOTSUPP; 874e98d69baSFreddy Xin 875e98d69baSFreddy Xin ax88179_enable_eee(dev); 876e98d69baSFreddy Xin } 877e98d69baSFreddy Xin 878e98d69baSFreddy Xin ret = ax88179_ethtool_set_eee(dev, edata); 879e98d69baSFreddy Xin if (ret) 880e98d69baSFreddy Xin return ret; 881e98d69baSFreddy Xin 882e98d69baSFreddy Xin mii_nway_restart(&dev->mii); 883e98d69baSFreddy Xin 884e98d69baSFreddy Xin usbnet_link_change(dev, 0, 0); 885e98d69baSFreddy Xin 886e98d69baSFreddy Xin return ret; 887e98d69baSFreddy Xin } 888e2ca90c2SFreddy Xin 889e2ca90c2SFreddy Xin static int ax88179_ioctl(struct net_device *net, struct ifreq *rq, int cmd) 890e2ca90c2SFreddy Xin { 891e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 892e2ca90c2SFreddy Xin return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); 893e2ca90c2SFreddy Xin } 894e2ca90c2SFreddy Xin 895e2ca90c2SFreddy Xin static const struct ethtool_ops ax88179_ethtool_ops = { 896e2ca90c2SFreddy Xin .get_link = ethtool_op_get_link, 897e2ca90c2SFreddy Xin .get_msglevel = usbnet_get_msglevel, 898e2ca90c2SFreddy Xin .set_msglevel = usbnet_set_msglevel, 899e2ca90c2SFreddy Xin .get_wol = ax88179_get_wol, 900e2ca90c2SFreddy Xin .set_wol = ax88179_set_wol, 901e2ca90c2SFreddy Xin .get_eeprom_len = ax88179_get_eeprom_len, 902e2ca90c2SFreddy Xin .get_eeprom = ax88179_get_eeprom, 90378734404SBjorn Andersson .set_eeprom = ax88179_set_eeprom, 904e98d69baSFreddy Xin .get_eee = ax88179_get_eee, 905e98d69baSFreddy Xin .set_eee = ax88179_set_eee, 906e2ca90c2SFreddy Xin .nway_reset = usbnet_nway_reset, 9073c9b803bSPhilippe Reynes .get_link_ksettings = ax88179_get_link_ksettings, 9083c9b803bSPhilippe Reynes .set_link_ksettings = ax88179_set_link_ksettings, 909dc83ef22SAndreas K. Besslein .get_ts_info = ethtool_op_get_ts_info, 910e2ca90c2SFreddy Xin }; 911e2ca90c2SFreddy Xin 912e2ca90c2SFreddy Xin static void ax88179_set_multicast(struct net_device *net) 913e2ca90c2SFreddy Xin { 914e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 915e2ca90c2SFreddy Xin struct ax88179_data *data = (struct ax88179_data *)dev->data; 916e2ca90c2SFreddy Xin u8 *m_filter = ((u8 *)dev->data) + 12; 917e2ca90c2SFreddy Xin 918e2ca90c2SFreddy Xin data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE); 919e2ca90c2SFreddy Xin 920e2ca90c2SFreddy Xin if (net->flags & IFF_PROMISC) { 921e2ca90c2SFreddy Xin data->rxctl |= AX_RX_CTL_PRO; 922e2ca90c2SFreddy Xin } else if (net->flags & IFF_ALLMULTI || 923e2ca90c2SFreddy Xin netdev_mc_count(net) > AX_MAX_MCAST) { 924e2ca90c2SFreddy Xin data->rxctl |= AX_RX_CTL_AMALL; 925e2ca90c2SFreddy Xin } else if (netdev_mc_empty(net)) { 926e2ca90c2SFreddy Xin /* just broadcast and directed */ 927e2ca90c2SFreddy Xin } else { 928e2ca90c2SFreddy Xin /* We use the 20 byte dev->data for our 8 byte filter buffer 929e2ca90c2SFreddy Xin * to avoid allocating memory that is tricky to free later 930e2ca90c2SFreddy Xin */ 931e2ca90c2SFreddy Xin u32 crc_bits; 932e2ca90c2SFreddy Xin struct netdev_hw_addr *ha; 933e2ca90c2SFreddy Xin 934e2ca90c2SFreddy Xin memset(m_filter, 0, AX_MCAST_FLTSIZE); 935e2ca90c2SFreddy Xin 936e2ca90c2SFreddy Xin netdev_for_each_mc_addr(ha, net) { 937e2ca90c2SFreddy Xin crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; 938e2ca90c2SFreddy Xin *(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7)); 939e2ca90c2SFreddy Xin } 940e2ca90c2SFreddy Xin 941e2ca90c2SFreddy Xin ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY, 942e2ca90c2SFreddy Xin AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE, 943e2ca90c2SFreddy Xin m_filter); 944e2ca90c2SFreddy Xin 945e2ca90c2SFreddy Xin data->rxctl |= AX_RX_CTL_AM; 946e2ca90c2SFreddy Xin } 947e2ca90c2SFreddy Xin 948e2ca90c2SFreddy Xin ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, 949e2ca90c2SFreddy Xin 2, 2, &data->rxctl); 950e2ca90c2SFreddy Xin } 951e2ca90c2SFreddy Xin 952e2ca90c2SFreddy Xin static int 953e2ca90c2SFreddy Xin ax88179_set_features(struct net_device *net, netdev_features_t features) 954e2ca90c2SFreddy Xin { 955e2ca90c2SFreddy Xin u8 tmp; 956e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 957e2ca90c2SFreddy Xin netdev_features_t changed = net->features ^ features; 958e2ca90c2SFreddy Xin 959e2ca90c2SFreddy Xin if (changed & NETIF_F_IP_CSUM) { 960e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 961e2ca90c2SFreddy Xin tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP; 962e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 963e2ca90c2SFreddy Xin } 964e2ca90c2SFreddy Xin 965e2ca90c2SFreddy Xin if (changed & NETIF_F_IPV6_CSUM) { 966e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 967e2ca90c2SFreddy Xin tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; 968e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); 969e2ca90c2SFreddy Xin } 970e2ca90c2SFreddy Xin 971e2ca90c2SFreddy Xin if (changed & NETIF_F_RXCSUM) { 972e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); 973e2ca90c2SFreddy Xin tmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | 974e2ca90c2SFreddy Xin AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; 975e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); 976e2ca90c2SFreddy Xin } 977e2ca90c2SFreddy Xin 978e2ca90c2SFreddy Xin return 0; 979e2ca90c2SFreddy Xin } 980e2ca90c2SFreddy Xin 981e2ca90c2SFreddy Xin static int ax88179_change_mtu(struct net_device *net, int new_mtu) 982e2ca90c2SFreddy Xin { 983e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 984e2ca90c2SFreddy Xin u16 tmp16; 985e2ca90c2SFreddy Xin 986e2ca90c2SFreddy Xin net->mtu = new_mtu; 987e2ca90c2SFreddy Xin dev->hard_mtu = net->mtu + net->hard_header_len; 988e2ca90c2SFreddy Xin 989e2ca90c2SFreddy Xin if (net->mtu > 1500) { 990e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 991e2ca90c2SFreddy Xin 2, 2, &tmp16); 992e2ca90c2SFreddy Xin tmp16 |= AX_MEDIUM_JUMBO_EN; 993e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 994e2ca90c2SFreddy Xin 2, 2, &tmp16); 995e2ca90c2SFreddy Xin } else { 996e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 997e2ca90c2SFreddy Xin 2, 2, &tmp16); 998e2ca90c2SFreddy Xin tmp16 &= ~AX_MEDIUM_JUMBO_EN; 999e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1000e2ca90c2SFreddy Xin 2, 2, &tmp16); 1001e2ca90c2SFreddy Xin } 1002e2ca90c2SFreddy Xin 1003a88c32aeSMing Lei /* max qlen depend on hard_mtu and rx_urb_size */ 1004a88c32aeSMing Lei usbnet_update_max_qlen(dev); 1005a88c32aeSMing Lei 1006e2ca90c2SFreddy Xin return 0; 1007e2ca90c2SFreddy Xin } 1008e2ca90c2SFreddy Xin 1009e2ca90c2SFreddy Xin static int ax88179_set_mac_addr(struct net_device *net, void *p) 1010e2ca90c2SFreddy Xin { 1011e2ca90c2SFreddy Xin struct usbnet *dev = netdev_priv(net); 1012e2ca90c2SFreddy Xin struct sockaddr *addr = p; 101395ff8868SIan Morgan int ret; 1014e2ca90c2SFreddy Xin 1015e2ca90c2SFreddy Xin if (netif_running(net)) 1016e2ca90c2SFreddy Xin return -EBUSY; 1017e2ca90c2SFreddy Xin if (!is_valid_ether_addr(addr->sa_data)) 1018e2ca90c2SFreddy Xin return -EADDRNOTAVAIL; 1019e2ca90c2SFreddy Xin 102016813717SJakub Kicinski eth_hw_addr_set(net, addr->sa_data); 1021e2ca90c2SFreddy Xin 1022e2ca90c2SFreddy Xin /* Set the MAC address */ 102395ff8868SIan Morgan ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, 1024e2ca90c2SFreddy Xin ETH_ALEN, net->dev_addr); 102595ff8868SIan Morgan if (ret < 0) 102695ff8868SIan Morgan return ret; 102795ff8868SIan Morgan 102895ff8868SIan Morgan return 0; 1029e2ca90c2SFreddy Xin } 1030e2ca90c2SFreddy Xin 1031e2ca90c2SFreddy Xin static const struct net_device_ops ax88179_netdev_ops = { 1032e2ca90c2SFreddy Xin .ndo_open = usbnet_open, 1033e2ca90c2SFreddy Xin .ndo_stop = usbnet_stop, 1034e2ca90c2SFreddy Xin .ndo_start_xmit = usbnet_start_xmit, 1035e2ca90c2SFreddy Xin .ndo_tx_timeout = usbnet_tx_timeout, 1036323955a0SHeiner Kallweit .ndo_get_stats64 = dev_get_tstats64, 1037e2ca90c2SFreddy Xin .ndo_change_mtu = ax88179_change_mtu, 1038e2ca90c2SFreddy Xin .ndo_set_mac_address = ax88179_set_mac_addr, 1039e2ca90c2SFreddy Xin .ndo_validate_addr = eth_validate_addr, 1040a7605370SArnd Bergmann .ndo_eth_ioctl = ax88179_ioctl, 1041e2ca90c2SFreddy Xin .ndo_set_rx_mode = ax88179_set_multicast, 1042e2ca90c2SFreddy Xin .ndo_set_features = ax88179_set_features, 1043e2ca90c2SFreddy Xin }; 1044e2ca90c2SFreddy Xin 1045e2ca90c2SFreddy Xin static int ax88179_check_eeprom(struct usbnet *dev) 1046e2ca90c2SFreddy Xin { 1047e2ca90c2SFreddy Xin u8 i, buf, eeprom[20]; 1048e2ca90c2SFreddy Xin u16 csum, delay = HZ / 10; 1049e2ca90c2SFreddy Xin unsigned long jtimeout; 1050e2ca90c2SFreddy Xin 1051e2ca90c2SFreddy Xin /* Read EEPROM content */ 1052e2ca90c2SFreddy Xin for (i = 0; i < 6; i++) { 1053e2ca90c2SFreddy Xin buf = i; 1054e2ca90c2SFreddy Xin if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, 1055e2ca90c2SFreddy Xin 1, 1, &buf) < 0) 1056e2ca90c2SFreddy Xin return -EINVAL; 1057e2ca90c2SFreddy Xin 1058e2ca90c2SFreddy Xin buf = EEP_RD; 1059e2ca90c2SFreddy Xin if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 1060e2ca90c2SFreddy Xin 1, 1, &buf) < 0) 1061e2ca90c2SFreddy Xin return -EINVAL; 1062e2ca90c2SFreddy Xin 1063e2ca90c2SFreddy Xin jtimeout = jiffies + delay; 1064e2ca90c2SFreddy Xin do { 1065e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 1066e2ca90c2SFreddy Xin 1, 1, &buf); 1067e2ca90c2SFreddy Xin 1068e2ca90c2SFreddy Xin if (time_after(jiffies, jtimeout)) 1069e2ca90c2SFreddy Xin return -EINVAL; 1070e2ca90c2SFreddy Xin 1071e2ca90c2SFreddy Xin } while (buf & EEP_BUSY); 1072e2ca90c2SFreddy Xin 1073e2ca90c2SFreddy Xin __ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, 1074e2ca90c2SFreddy Xin 2, 2, &eeprom[i * 2], 0); 1075e2ca90c2SFreddy Xin 1076e2ca90c2SFreddy Xin if ((i == 0) && (eeprom[0] == 0xFF)) 1077e2ca90c2SFreddy Xin return -EINVAL; 1078e2ca90c2SFreddy Xin } 1079e2ca90c2SFreddy Xin 1080e2ca90c2SFreddy Xin csum = eeprom[6] + eeprom[7] + eeprom[8] + eeprom[9]; 1081e2ca90c2SFreddy Xin csum = (csum >> 8) + (csum & 0xff); 1082e2ca90c2SFreddy Xin if ((csum + eeprom[10]) != 0xff) 1083e2ca90c2SFreddy Xin return -EINVAL; 1084e2ca90c2SFreddy Xin 1085e2ca90c2SFreddy Xin return 0; 1086e2ca90c2SFreddy Xin } 1087e2ca90c2SFreddy Xin 1088e2ca90c2SFreddy Xin static int ax88179_check_efuse(struct usbnet *dev, u16 *ledmode) 1089e2ca90c2SFreddy Xin { 1090e2ca90c2SFreddy Xin u8 i; 1091e2ca90c2SFreddy Xin u8 efuse[64]; 1092e2ca90c2SFreddy Xin u16 csum = 0; 1093e2ca90c2SFreddy Xin 1094e2ca90c2SFreddy Xin if (ax88179_read_cmd(dev, AX_ACCESS_EFUS, 0, 64, 64, efuse) < 0) 1095e2ca90c2SFreddy Xin return -EINVAL; 1096e2ca90c2SFreddy Xin 1097e2ca90c2SFreddy Xin if (*efuse == 0xFF) 1098e2ca90c2SFreddy Xin return -EINVAL; 1099e2ca90c2SFreddy Xin 1100e2ca90c2SFreddy Xin for (i = 0; i < 64; i++) 1101e2ca90c2SFreddy Xin csum = csum + efuse[i]; 1102e2ca90c2SFreddy Xin 1103e2ca90c2SFreddy Xin while (csum > 255) 1104e2ca90c2SFreddy Xin csum = (csum & 0x00FF) + ((csum >> 8) & 0x00FF); 1105e2ca90c2SFreddy Xin 1106e2ca90c2SFreddy Xin if (csum != 0xFF) 1107e2ca90c2SFreddy Xin return -EINVAL; 1108e2ca90c2SFreddy Xin 1109e2ca90c2SFreddy Xin *ledmode = (efuse[51] << 8) | efuse[52]; 1110e2ca90c2SFreddy Xin 1111e2ca90c2SFreddy Xin return 0; 1112e2ca90c2SFreddy Xin } 1113e2ca90c2SFreddy Xin 1114e2ca90c2SFreddy Xin static int ax88179_convert_old_led(struct usbnet *dev, u16 *ledvalue) 1115e2ca90c2SFreddy Xin { 1116e2ca90c2SFreddy Xin u16 led; 1117e2ca90c2SFreddy Xin 1118e2ca90c2SFreddy Xin /* Loaded the old eFuse LED Mode */ 1119e2ca90c2SFreddy Xin if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x3C, 1, 2, &led) < 0) 1120e2ca90c2SFreddy Xin return -EINVAL; 1121e2ca90c2SFreddy Xin 1122e2ca90c2SFreddy Xin led >>= 8; 1123e2ca90c2SFreddy Xin switch (led) { 1124e2ca90c2SFreddy Xin case 0xFF: 1125e2ca90c2SFreddy Xin led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | 1126e2ca90c2SFreddy Xin LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | 1127e2ca90c2SFreddy Xin LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; 1128e2ca90c2SFreddy Xin break; 1129e2ca90c2SFreddy Xin case 0xFE: 1130e2ca90c2SFreddy Xin led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | LED_VALID; 1131e2ca90c2SFreddy Xin break; 1132e2ca90c2SFreddy Xin case 0xFD: 1133e2ca90c2SFreddy Xin led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | 1134e2ca90c2SFreddy Xin LED2_LINK_10 | LED_VALID; 1135e2ca90c2SFreddy Xin break; 1136e2ca90c2SFreddy Xin case 0xFC: 1137e2ca90c2SFreddy Xin led = LED0_ACTIVE | LED1_ACTIVE | LED1_LINK_1000 | LED2_ACTIVE | 1138e2ca90c2SFreddy Xin LED2_LINK_100 | LED2_LINK_10 | LED_VALID; 1139e2ca90c2SFreddy Xin break; 1140e2ca90c2SFreddy Xin default: 1141e2ca90c2SFreddy Xin led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | 1142e2ca90c2SFreddy Xin LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | 1143e2ca90c2SFreddy Xin LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; 1144e2ca90c2SFreddy Xin break; 1145e2ca90c2SFreddy Xin } 1146e2ca90c2SFreddy Xin 1147e2ca90c2SFreddy Xin *ledvalue = led; 1148e2ca90c2SFreddy Xin 1149e2ca90c2SFreddy Xin return 0; 1150e2ca90c2SFreddy Xin } 1151e2ca90c2SFreddy Xin 1152e2ca90c2SFreddy Xin static int ax88179_led_setting(struct usbnet *dev) 1153e2ca90c2SFreddy Xin { 1154e2ca90c2SFreddy Xin u8 ledfd, value = 0; 1155e2ca90c2SFreddy Xin u16 tmp, ledact, ledlink, ledvalue = 0, delay = HZ / 10; 1156e2ca90c2SFreddy Xin unsigned long jtimeout; 1157e2ca90c2SFreddy Xin 1158e2ca90c2SFreddy Xin /* Check AX88179 version. UA1 or UA2*/ 1159e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, GENERAL_STATUS, 1, 1, &value); 1160e2ca90c2SFreddy Xin 1161e2ca90c2SFreddy Xin if (!(value & AX_SECLD)) { /* UA1 */ 1162e2ca90c2SFreddy Xin value = AX_GPIO_CTRL_GPIO3EN | AX_GPIO_CTRL_GPIO2EN | 1163e2ca90c2SFreddy Xin AX_GPIO_CTRL_GPIO1EN; 1164e2ca90c2SFreddy Xin if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_GPIO_CTRL, 1165e2ca90c2SFreddy Xin 1, 1, &value) < 0) 1166e2ca90c2SFreddy Xin return -EINVAL; 1167e2ca90c2SFreddy Xin } 1168e2ca90c2SFreddy Xin 1169e2ca90c2SFreddy Xin /* Check EEPROM */ 1170e2ca90c2SFreddy Xin if (!ax88179_check_eeprom(dev)) { 1171e2ca90c2SFreddy Xin value = 0x42; 1172e2ca90c2SFreddy Xin if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, 1173e2ca90c2SFreddy Xin 1, 1, &value) < 0) 1174e2ca90c2SFreddy Xin return -EINVAL; 1175e2ca90c2SFreddy Xin 1176e2ca90c2SFreddy Xin value = EEP_RD; 1177e2ca90c2SFreddy Xin if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 1178e2ca90c2SFreddy Xin 1, 1, &value) < 0) 1179e2ca90c2SFreddy Xin return -EINVAL; 1180e2ca90c2SFreddy Xin 1181e2ca90c2SFreddy Xin jtimeout = jiffies + delay; 1182e2ca90c2SFreddy Xin do { 1183e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, 1184e2ca90c2SFreddy Xin 1, 1, &value); 1185e2ca90c2SFreddy Xin 1186e2ca90c2SFreddy Xin if (time_after(jiffies, jtimeout)) 1187e2ca90c2SFreddy Xin return -EINVAL; 1188e2ca90c2SFreddy Xin 1189e2ca90c2SFreddy Xin } while (value & EEP_BUSY); 1190e2ca90c2SFreddy Xin 1191e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_HIGH, 1192e2ca90c2SFreddy Xin 1, 1, &value); 1193e2ca90c2SFreddy Xin ledvalue = (value << 8); 1194e2ca90c2SFreddy Xin 1195e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, 1196e2ca90c2SFreddy Xin 1, 1, &value); 1197e2ca90c2SFreddy Xin ledvalue |= value; 1198e2ca90c2SFreddy Xin 1199e2ca90c2SFreddy Xin /* load internal ROM for defaule setting */ 1200e2ca90c2SFreddy Xin if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) 1201e2ca90c2SFreddy Xin ax88179_convert_old_led(dev, &ledvalue); 1202e2ca90c2SFreddy Xin 1203e2ca90c2SFreddy Xin } else if (!ax88179_check_efuse(dev, &ledvalue)) { 1204e2ca90c2SFreddy Xin if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) 1205e2ca90c2SFreddy Xin ax88179_convert_old_led(dev, &ledvalue); 1206e2ca90c2SFreddy Xin } else { 1207e2ca90c2SFreddy Xin ax88179_convert_old_led(dev, &ledvalue); 1208e2ca90c2SFreddy Xin } 1209e2ca90c2SFreddy Xin 1210e2ca90c2SFreddy Xin tmp = GMII_PHY_PGSEL_EXT; 1211e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1212e2ca90c2SFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp); 1213e2ca90c2SFreddy Xin 1214e2ca90c2SFreddy Xin tmp = 0x2c; 1215e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1216e2ca90c2SFreddy Xin GMII_PHYPAGE, 2, &tmp); 1217e2ca90c2SFreddy Xin 1218e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1219e2ca90c2SFreddy Xin GMII_LED_ACT, 2, &ledact); 1220e2ca90c2SFreddy Xin 1221e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1222e2ca90c2SFreddy Xin GMII_LED_LINK, 2, &ledlink); 1223e2ca90c2SFreddy Xin 1224e2ca90c2SFreddy Xin ledact &= GMII_LED_ACTIVE_MASK; 1225e2ca90c2SFreddy Xin ledlink &= GMII_LED_LINK_MASK; 1226e2ca90c2SFreddy Xin 1227e2ca90c2SFreddy Xin if (ledvalue & LED0_ACTIVE) 1228e2ca90c2SFreddy Xin ledact |= GMII_LED0_ACTIVE; 1229e2ca90c2SFreddy Xin 1230e2ca90c2SFreddy Xin if (ledvalue & LED1_ACTIVE) 1231e2ca90c2SFreddy Xin ledact |= GMII_LED1_ACTIVE; 1232e2ca90c2SFreddy Xin 1233e2ca90c2SFreddy Xin if (ledvalue & LED2_ACTIVE) 1234e2ca90c2SFreddy Xin ledact |= GMII_LED2_ACTIVE; 1235e2ca90c2SFreddy Xin 1236e2ca90c2SFreddy Xin if (ledvalue & LED0_LINK_10) 1237e2ca90c2SFreddy Xin ledlink |= GMII_LED0_LINK_10; 1238e2ca90c2SFreddy Xin 1239e2ca90c2SFreddy Xin if (ledvalue & LED1_LINK_10) 1240e2ca90c2SFreddy Xin ledlink |= GMII_LED1_LINK_10; 1241e2ca90c2SFreddy Xin 1242e2ca90c2SFreddy Xin if (ledvalue & LED2_LINK_10) 1243e2ca90c2SFreddy Xin ledlink |= GMII_LED2_LINK_10; 1244e2ca90c2SFreddy Xin 1245e2ca90c2SFreddy Xin if (ledvalue & LED0_LINK_100) 1246e2ca90c2SFreddy Xin ledlink |= GMII_LED0_LINK_100; 1247e2ca90c2SFreddy Xin 1248e2ca90c2SFreddy Xin if (ledvalue & LED1_LINK_100) 1249e2ca90c2SFreddy Xin ledlink |= GMII_LED1_LINK_100; 1250e2ca90c2SFreddy Xin 1251e2ca90c2SFreddy Xin if (ledvalue & LED2_LINK_100) 1252e2ca90c2SFreddy Xin ledlink |= GMII_LED2_LINK_100; 1253e2ca90c2SFreddy Xin 1254e2ca90c2SFreddy Xin if (ledvalue & LED0_LINK_1000) 1255e2ca90c2SFreddy Xin ledlink |= GMII_LED0_LINK_1000; 1256e2ca90c2SFreddy Xin 1257e2ca90c2SFreddy Xin if (ledvalue & LED1_LINK_1000) 1258e2ca90c2SFreddy Xin ledlink |= GMII_LED1_LINK_1000; 1259e2ca90c2SFreddy Xin 1260e2ca90c2SFreddy Xin if (ledvalue & LED2_LINK_1000) 1261e2ca90c2SFreddy Xin ledlink |= GMII_LED2_LINK_1000; 1262e2ca90c2SFreddy Xin 1263e2ca90c2SFreddy Xin tmp = ledact; 1264e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1265e2ca90c2SFreddy Xin GMII_LED_ACT, 2, &tmp); 1266e2ca90c2SFreddy Xin 1267e2ca90c2SFreddy Xin tmp = ledlink; 1268e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1269e2ca90c2SFreddy Xin GMII_LED_LINK, 2, &tmp); 1270e2ca90c2SFreddy Xin 1271e2ca90c2SFreddy Xin tmp = GMII_PHY_PGSEL_PAGE0; 1272e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1273e2ca90c2SFreddy Xin GMII_PHY_PAGE_SELECT, 2, &tmp); 1274e2ca90c2SFreddy Xin 1275e2ca90c2SFreddy Xin /* LED full duplex setting */ 1276e2ca90c2SFreddy Xin ledfd = 0; 1277e2ca90c2SFreddy Xin if (ledvalue & LED0_FD) 1278e2ca90c2SFreddy Xin ledfd |= 0x01; 1279e2ca90c2SFreddy Xin else if ((ledvalue & LED0_USB3_MASK) == 0) 1280e2ca90c2SFreddy Xin ledfd |= 0x02; 1281e2ca90c2SFreddy Xin 1282e2ca90c2SFreddy Xin if (ledvalue & LED1_FD) 1283e2ca90c2SFreddy Xin ledfd |= 0x04; 1284e2ca90c2SFreddy Xin else if ((ledvalue & LED1_USB3_MASK) == 0) 1285e2ca90c2SFreddy Xin ledfd |= 0x08; 1286e2ca90c2SFreddy Xin 1287e2ca90c2SFreddy Xin if (ledvalue & LED2_FD) 1288e2ca90c2SFreddy Xin ledfd |= 0x10; 1289e2ca90c2SFreddy Xin else if ((ledvalue & LED2_USB3_MASK) == 0) 1290e2ca90c2SFreddy Xin ledfd |= 0x20; 1291e2ca90c2SFreddy Xin 1292e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_LEDCTRL, 1, 1, &ledfd); 1293e2ca90c2SFreddy Xin 1294e2ca90c2SFreddy Xin return 0; 1295e2ca90c2SFreddy Xin } 1296e2ca90c2SFreddy Xin 12979fb137aeSPeter Fink static void ax88179_get_mac_addr(struct usbnet *dev) 12989fb137aeSPeter Fink { 12999fb137aeSPeter Fink u8 mac[ETH_ALEN]; 13009fb137aeSPeter Fink 1301bd78980bSPhillip Potter memset(mac, 0, sizeof(mac)); 1302bd78980bSPhillip Potter 13039fb137aeSPeter Fink /* Maybe the boot loader passed the MAC address via device tree */ 13049fb137aeSPeter Fink if (!eth_platform_get_mac_address(&dev->udev->dev, mac)) { 13059fb137aeSPeter Fink netif_dbg(dev, ifup, dev->net, 13069fb137aeSPeter Fink "MAC address read from device tree"); 13079fb137aeSPeter Fink } else { 13089fb137aeSPeter Fink ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, 13099fb137aeSPeter Fink ETH_ALEN, mac); 13109fb137aeSPeter Fink netif_dbg(dev, ifup, dev->net, 13119fb137aeSPeter Fink "MAC address read from ASIX chip"); 13129fb137aeSPeter Fink } 13139fb137aeSPeter Fink 13149fb137aeSPeter Fink if (is_valid_ether_addr(mac)) { 131516813717SJakub Kicinski eth_hw_addr_set(dev->net, mac); 13169fb137aeSPeter Fink } else { 13179fb137aeSPeter Fink netdev_info(dev->net, "invalid MAC address, using random\n"); 13189fb137aeSPeter Fink eth_hw_addr_random(dev->net); 13199fb137aeSPeter Fink } 13201635520aSPeter Fink 13211635520aSPeter Fink ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN, 13221635520aSPeter Fink dev->net->dev_addr); 13239fb137aeSPeter Fink } 13249fb137aeSPeter Fink 1325c0725502SDavid S. Miller static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) 1326e2ca90c2SFreddy Xin { 1327e2ca90c2SFreddy Xin struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; 1328e2ca90c2SFreddy Xin 1329c0725502SDavid S. Miller usbnet_get_endpoints(dev, intf); 1330c0725502SDavid S. Miller 1331e2ca90c2SFreddy Xin memset(ax179_data, 0, sizeof(*ax179_data)); 1332e2ca90c2SFreddy Xin 1333e2ca90c2SFreddy Xin dev->net->netdev_ops = &ax88179_netdev_ops; 1334e2ca90c2SFreddy Xin dev->net->ethtool_ops = &ax88179_ethtool_ops; 1335e2ca90c2SFreddy Xin dev->net->needed_headroom = 8; 1336f77f0aeeSJarod Wilson dev->net->max_mtu = 4088; 1337e2ca90c2SFreddy Xin 1338e2ca90c2SFreddy Xin /* Initialize MII structure */ 1339e2ca90c2SFreddy Xin dev->mii.dev = dev->net; 1340e2ca90c2SFreddy Xin dev->mii.mdio_read = ax88179_mdio_read; 1341e2ca90c2SFreddy Xin dev->mii.mdio_write = ax88179_mdio_write; 1342e2ca90c2SFreddy Xin dev->mii.phy_id_mask = 0xff; 1343e2ca90c2SFreddy Xin dev->mii.reg_num_mask = 0xff; 1344e2ca90c2SFreddy Xin dev->mii.phy_id = 0x03; 1345e2ca90c2SFreddy Xin dev->mii.supports_gmii = 1; 1346e2ca90c2SFreddy Xin 134716b1c4e0SJacky Chou dev->net->features |= NETIF_F_SG | NETIF_F_IP_CSUM | 134816b1c4e0SJacky Chou NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO; 1349e2ca90c2SFreddy Xin 135016b1c4e0SJacky Chou dev->net->hw_features |= dev->net->features; 135116b1c4e0SJacky Chou 1352ee8b7a11SJakub Kicinski netif_set_tso_max_size(dev->net, 16384); 1353e2ca90c2SFreddy Xin 1354*9718f9ceSJustin Chen ax88179_reset(dev); 1355e2ca90c2SFreddy Xin 1356e2ca90c2SFreddy Xin return 0; 1357e2ca90c2SFreddy Xin } 1358e2ca90c2SFreddy Xin 1359e2ca90c2SFreddy Xin static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) 1360e2ca90c2SFreddy Xin { 1361e2ca90c2SFreddy Xin u16 tmp16; 1362e2ca90c2SFreddy Xin 1363e2ca90c2SFreddy Xin /* Configure RX control register => stop operation */ 1364e2ca90c2SFreddy Xin tmp16 = AX_RX_CTL_STOP; 1365e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); 1366e2ca90c2SFreddy Xin 1367e2ca90c2SFreddy Xin tmp16 = 0; 1368e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16); 1369e2ca90c2SFreddy Xin 1370e2ca90c2SFreddy Xin /* Power down ethernet PHY */ 1371e2ca90c2SFreddy Xin tmp16 = 0; 1372e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); 1373e2ca90c2SFreddy Xin } 1374e2ca90c2SFreddy Xin 1375e2ca90c2SFreddy Xin static void 1376e2ca90c2SFreddy Xin ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr) 1377e2ca90c2SFreddy Xin { 1378e2ca90c2SFreddy Xin skb->ip_summed = CHECKSUM_NONE; 1379e2ca90c2SFreddy Xin 1380e2ca90c2SFreddy Xin /* checksum error bit is set */ 1381e2ca90c2SFreddy Xin if ((*pkt_hdr & AX_RXHDR_L3CSUM_ERR) || 1382e2ca90c2SFreddy Xin (*pkt_hdr & AX_RXHDR_L4CSUM_ERR)) 1383e2ca90c2SFreddy Xin return; 1384e2ca90c2SFreddy Xin 1385e2ca90c2SFreddy Xin /* It must be a TCP or UDP packet with a valid checksum */ 1386e2ca90c2SFreddy Xin if (((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_TCP) || 1387e2ca90c2SFreddy Xin ((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_UDP)) 1388e2ca90c2SFreddy Xin skb->ip_summed = CHECKSUM_UNNECESSARY; 1389e2ca90c2SFreddy Xin } 1390e2ca90c2SFreddy Xin 1391e2ca90c2SFreddy Xin static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 1392e2ca90c2SFreddy Xin { 1393e2ca90c2SFreddy Xin struct sk_buff *ax_skb; 1394e2ca90c2SFreddy Xin int pkt_cnt; 1395e2ca90c2SFreddy Xin u32 rx_hdr; 1396e2ca90c2SFreddy Xin u16 hdr_off; 1397e2ca90c2SFreddy Xin u32 *pkt_hdr; 1398e2ca90c2SFreddy Xin 139957bc3d3aSJann Horn /* At the end of the SKB, there's a header telling us how many packets 140057bc3d3aSJann Horn * are bundled into this buffer and where we can find an array of 140157bc3d3aSJann Horn * per-packet metadata (which contains elements encoded into u16). 140257bc3d3aSJann Horn */ 1403f8ebb3acSJose Alonso 1404f8ebb3acSJose Alonso /* SKB contents for current firmware: 1405f8ebb3acSJose Alonso * <packet 1> <padding> 1406f8ebb3acSJose Alonso * ... 1407f8ebb3acSJose Alonso * <packet N> <padding> 1408f8ebb3acSJose Alonso * <per-packet metadata entry 1> <dummy header> 1409f8ebb3acSJose Alonso * ... 1410f8ebb3acSJose Alonso * <per-packet metadata entry N> <dummy header> 1411f8ebb3acSJose Alonso * <padding2> <rx_hdr> 1412f8ebb3acSJose Alonso * 1413f8ebb3acSJose Alonso * where: 1414f8ebb3acSJose Alonso * <packet N> contains pkt_len bytes: 1415f8ebb3acSJose Alonso * 2 bytes of IP alignment pseudo header 1416f8ebb3acSJose Alonso * packet received 1417f8ebb3acSJose Alonso * <per-packet metadata entry N> contains 4 bytes: 1418f8ebb3acSJose Alonso * pkt_len and fields AX_RXHDR_* 1419f8ebb3acSJose Alonso * <padding> 0-7 bytes to terminate at 1420f8ebb3acSJose Alonso * 8 bytes boundary (64-bit). 1421f8ebb3acSJose Alonso * <padding2> 4 bytes to make rx_hdr terminate at 1422f8ebb3acSJose Alonso * 8 bytes boundary (64-bit) 1423f8ebb3acSJose Alonso * <dummy-header> contains 4 bytes: 1424f8ebb3acSJose Alonso * pkt_len=0 and AX_RXHDR_DROP_ERR 1425f8ebb3acSJose Alonso * <rx-hdr> contains 4 bytes: 1426f8ebb3acSJose Alonso * pkt_cnt and hdr_off (offset of 1427f8ebb3acSJose Alonso * <per-packet metadata entry 1>) 1428f8ebb3acSJose Alonso * 1429f8ebb3acSJose Alonso * pkt_cnt is number of entrys in the per-packet metadata. 1430f8ebb3acSJose Alonso * In current firmware there is 2 entrys per packet. 1431f8ebb3acSJose Alonso * The first points to the packet and the 1432f8ebb3acSJose Alonso * second is a dummy header. 1433f8ebb3acSJose Alonso * This was done probably to align fields in 64-bit and 1434f8ebb3acSJose Alonso * maintain compatibility with old firmware. 1435f8ebb3acSJose Alonso * This code assumes that <dummy header> and <padding2> are 1436f8ebb3acSJose Alonso * optional. 1437f8ebb3acSJose Alonso */ 1438f8ebb3acSJose Alonso 143957bc3d3aSJann Horn if (skb->len < 4) 1440eb85569fSEmil Goode return 0; 1441e2ca90c2SFreddy Xin skb_trim(skb, skb->len - 4); 1442d1854d50SChuhong Yuan rx_hdr = get_unaligned_le32(skb_tail_pointer(skb)); 1443e2ca90c2SFreddy Xin pkt_cnt = (u16)rx_hdr; 1444e2ca90c2SFreddy Xin hdr_off = (u16)(rx_hdr >> 16); 144557bc3d3aSJann Horn 144657bc3d3aSJann Horn if (pkt_cnt == 0) 144757bc3d3aSJann Horn return 0; 144857bc3d3aSJann Horn 144957bc3d3aSJann Horn /* Make sure that the bounds of the metadata array are inside the SKB 145057bc3d3aSJann Horn * (and in front of the counter at the end). 145157bc3d3aSJann Horn */ 1452f8ebb3acSJose Alonso if (pkt_cnt * 4 + hdr_off > skb->len) 145357bc3d3aSJann Horn return 0; 1454e2ca90c2SFreddy Xin pkt_hdr = (u32 *)(skb->data + hdr_off); 1455e2ca90c2SFreddy Xin 145657bc3d3aSJann Horn /* Packets must not overlap the metadata array */ 145757bc3d3aSJann Horn skb_trim(skb, hdr_off); 145857bc3d3aSJann Horn 1459f8ebb3acSJose Alonso for (; pkt_cnt > 0; pkt_cnt--, pkt_hdr++) { 1460f8ebb3acSJose Alonso u16 pkt_len_plus_padd; 1461e2ca90c2SFreddy Xin u16 pkt_len; 1462e2ca90c2SFreddy Xin 1463e2ca90c2SFreddy Xin le32_to_cpus(pkt_hdr); 1464e2ca90c2SFreddy Xin pkt_len = (*pkt_hdr >> 16) & 0x1fff; 1465f8ebb3acSJose Alonso pkt_len_plus_padd = (pkt_len + 7) & 0xfff8; 1466e2ca90c2SFreddy Xin 1467f8ebb3acSJose Alonso /* Skip dummy header used for alignment 1468f8ebb3acSJose Alonso */ 1469f8ebb3acSJose Alonso if (pkt_len == 0) 1470f8ebb3acSJose Alonso continue; 1471f8ebb3acSJose Alonso 1472f8ebb3acSJose Alonso if (pkt_len_plus_padd > skb->len) 147357bc3d3aSJann Horn return 0; 147457bc3d3aSJann Horn 1475e2ca90c2SFreddy Xin /* Check CRC or runt packet */ 1476f8ebb3acSJose Alonso if ((*pkt_hdr & (AX_RXHDR_CRC_ERR | AX_RXHDR_DROP_ERR)) || 1477f8ebb3acSJose Alonso pkt_len < 2 + ETH_HLEN) { 1478f8ebb3acSJose Alonso dev->net->stats.rx_errors++; 1479f8ebb3acSJose Alonso skb_pull(skb, pkt_len_plus_padd); 1480f8ebb3acSJose Alonso continue; 1481f8ebb3acSJose Alonso } 1482e2ca90c2SFreddy Xin 1483f8ebb3acSJose Alonso /* last packet */ 1484f8ebb3acSJose Alonso if (pkt_len_plus_padd == skb->len) { 1485f8ebb3acSJose Alonso skb_trim(skb, pkt_len); 1486f8ebb3acSJose Alonso 1487f8ebb3acSJose Alonso /* Skip IP alignment pseudo header */ 1488f8ebb3acSJose Alonso skb_pull(skb, 2); 1489f8ebb3acSJose Alonso 1490f8ebb3acSJose Alonso skb->truesize = SKB_TRUESIZE(pkt_len_plus_padd); 1491f8ebb3acSJose Alonso ax88179_rx_checksum(skb, pkt_hdr); 1492f8ebb3acSJose Alonso return 1; 1493f8ebb3acSJose Alonso } 1494f8ebb3acSJose Alonso 1495e2ca90c2SFreddy Xin ax_skb = skb_clone(skb, GFP_ATOMIC); 149657bc3d3aSJann Horn if (!ax_skb) 149757bc3d3aSJann Horn return 0; 1498f8ebb3acSJose Alonso skb_trim(ax_skb, pkt_len); 1499f8ebb3acSJose Alonso 1500e869e7a1SJeremy Kerr /* Skip IP alignment pseudo header */ 1501e869e7a1SJeremy Kerr skb_pull(ax_skb, 2); 1502f8ebb3acSJose Alonso 1503f8ebb3acSJose Alonso skb->truesize = pkt_len_plus_padd + 1504f8ebb3acSJose Alonso SKB_DATA_ALIGN(sizeof(struct sk_buff)); 1505e2ca90c2SFreddy Xin ax88179_rx_checksum(ax_skb, pkt_hdr); 1506e2ca90c2SFreddy Xin usbnet_skb_return(dev, ax_skb); 1507f8ebb3acSJose Alonso 1508f8ebb3acSJose Alonso skb_pull(skb, pkt_len_plus_padd); 1509e2ca90c2SFreddy Xin } 1510e2ca90c2SFreddy Xin 151157bc3d3aSJann Horn return 0; 1512e2ca90c2SFreddy Xin } 1513e2ca90c2SFreddy Xin 1514e2ca90c2SFreddy Xin static struct sk_buff * 1515e2ca90c2SFreddy Xin ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 1516e2ca90c2SFreddy Xin { 1517e2ca90c2SFreddy Xin u32 tx_hdr1, tx_hdr2; 1518e2ca90c2SFreddy Xin int frame_size = dev->maxpacket; 1519e2ca90c2SFreddy Xin int headroom; 15207e24b4edSChuhong Yuan void *ptr; 1521e2ca90c2SFreddy Xin 1522e2ca90c2SFreddy Xin tx_hdr1 = skb->len; 152316b1c4e0SJacky Chou tx_hdr2 = skb_shinfo(skb)->gso_size; /* Set TSO mss */ 1524e2ca90c2SFreddy Xin if (((skb->len + 8) % frame_size) == 0) 1525e2ca90c2SFreddy Xin tx_hdr2 |= 0x80008000; /* Enable padding */ 1526e2ca90c2SFreddy Xin 1527f2707015SEric Dumazet headroom = skb_headroom(skb) - 8; 1528e2ca90c2SFreddy Xin 152916b1c4e0SJacky Chou if ((dev->net->features & NETIF_F_SG) && skb_linearize(skb)) 153016b1c4e0SJacky Chou return NULL; 153116b1c4e0SJacky Chou 1532f2707015SEric Dumazet if ((skb_header_cloned(skb) || headroom < 0) && 1533f2707015SEric Dumazet pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { 1534e2ca90c2SFreddy Xin dev_kfree_skb_any(skb); 1535e2ca90c2SFreddy Xin return NULL; 1536e2ca90c2SFreddy Xin } 1537e2ca90c2SFreddy Xin 15387e24b4edSChuhong Yuan ptr = skb_push(skb, 8); 15397e24b4edSChuhong Yuan put_unaligned_le32(tx_hdr1, ptr); 15407e24b4edSChuhong Yuan put_unaligned_le32(tx_hdr2, ptr + 4); 1541e2ca90c2SFreddy Xin 154216b1c4e0SJacky Chou usbnet_set_skb_tx_stats(skb, (skb_shinfo(skb)->gso_segs ?: 1), 0); 154316b1c4e0SJacky Chou 1544e2ca90c2SFreddy Xin return skb; 1545e2ca90c2SFreddy Xin } 1546e2ca90c2SFreddy Xin 1547e2ca90c2SFreddy Xin static int ax88179_link_reset(struct usbnet *dev) 1548e2ca90c2SFreddy Xin { 1549c0725502SDavid S. Miller struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; 1550c0725502SDavid S. Miller u8 tmp[5], link_sts; 1551c0725502SDavid S. Miller u16 mode, tmp16, delay = HZ / 10; 1552c0725502SDavid S. Miller u32 tmp32 = 0x40000000; 1553c0725502SDavid S. Miller unsigned long jtimeout; 1554c0725502SDavid S. Miller 1555c0725502SDavid S. Miller jtimeout = jiffies + delay; 1556c0725502SDavid S. Miller while (tmp32 & 0x40000000) { 1557c0725502SDavid S. Miller mode = 0; 1558c0725502SDavid S. Miller ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &mode); 1559c0725502SDavid S. Miller ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, 1560c0725502SDavid S. Miller &ax179_data->rxctl); 1561c0725502SDavid S. Miller 1562c0725502SDavid S. Miller /*link up, check the usb device control TX FIFO full or empty*/ 1563c0725502SDavid S. Miller ax88179_read_cmd(dev, 0x81, 0x8c, 0, 4, &tmp32); 1564c0725502SDavid S. Miller 1565c0725502SDavid S. Miller if (time_after(jiffies, jtimeout)) 1566c0725502SDavid S. Miller return 0; 1567c0725502SDavid S. Miller } 1568c0725502SDavid S. Miller 1569c0725502SDavid S. Miller mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | 1570c0725502SDavid S. Miller AX_MEDIUM_RXFLOW_CTRLEN; 1571c0725502SDavid S. Miller 1572c0725502SDavid S. Miller ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, 1573c0725502SDavid S. Miller 1, 1, &link_sts); 1574c0725502SDavid S. Miller 1575c0725502SDavid S. Miller ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, 1576c0725502SDavid S. Miller GMII_PHY_PHYSR, 2, &tmp16); 1577c0725502SDavid S. Miller 1578c0725502SDavid S. Miller if (!(tmp16 & GMII_PHY_PHYSR_LINK)) { 1579c0725502SDavid S. Miller return 0; 1580c0725502SDavid S. Miller } else if (GMII_PHY_PHYSR_GIGA == (tmp16 & GMII_PHY_PHYSR_SMASK)) { 1581c0725502SDavid S. Miller mode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_EN_125MHZ; 1582c0725502SDavid S. Miller if (dev->net->mtu > 1500) 1583c0725502SDavid S. Miller mode |= AX_MEDIUM_JUMBO_EN; 1584c0725502SDavid S. Miller 1585c0725502SDavid S. Miller if (link_sts & AX_USB_SS) 1586c0725502SDavid S. Miller memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); 1587c0725502SDavid S. Miller else if (link_sts & AX_USB_HS) 1588c0725502SDavid S. Miller memcpy(tmp, &AX88179_BULKIN_SIZE[1], 5); 1589c0725502SDavid S. Miller else 1590c0725502SDavid S. Miller memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); 1591c0725502SDavid S. Miller } else if (GMII_PHY_PHYSR_100 == (tmp16 & GMII_PHY_PHYSR_SMASK)) { 1592c0725502SDavid S. Miller mode |= AX_MEDIUM_PS; 1593c0725502SDavid S. Miller 1594c0725502SDavid S. Miller if (link_sts & (AX_USB_SS | AX_USB_HS)) 1595c0725502SDavid S. Miller memcpy(tmp, &AX88179_BULKIN_SIZE[2], 5); 1596c0725502SDavid S. Miller else 1597c0725502SDavid S. Miller memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); 1598c0725502SDavid S. Miller } else { 1599c0725502SDavid S. Miller memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); 1600c0725502SDavid S. Miller } 1601c0725502SDavid S. Miller 1602c0725502SDavid S. Miller /* RX bulk configuration */ 1603c0725502SDavid S. Miller ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); 1604c0725502SDavid S. Miller 1605c0725502SDavid S. Miller dev->rx_urb_size = (1024 * (tmp[3] + 2)); 1606c0725502SDavid S. Miller 1607c0725502SDavid S. Miller if (tmp16 & GMII_PHY_PHYSR_FULL) 1608c0725502SDavid S. Miller mode |= AX_MEDIUM_FULL_DUPLEX; 1609c0725502SDavid S. Miller ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1610c0725502SDavid S. Miller 2, 2, &mode); 1611c0725502SDavid S. Miller 1612c0725502SDavid S. Miller ax179_data->eee_enabled = ax88179_chk_eee(dev); 1613c0725502SDavid S. Miller 1614c0725502SDavid S. Miller netif_carrier_on(dev->net); 1615c0725502SDavid S. Miller 1616c0725502SDavid S. Miller return 0; 1617e2ca90c2SFreddy Xin } 1618e2ca90c2SFreddy Xin 1619e2ca90c2SFreddy Xin static int ax88179_reset(struct usbnet *dev) 1620e2ca90c2SFreddy Xin { 1621e2ca90c2SFreddy Xin u8 buf[5]; 1622e2ca90c2SFreddy Xin u16 *tmp16; 1623e2ca90c2SFreddy Xin u8 *tmp; 1624e98d69baSFreddy Xin struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; 1625e98d69baSFreddy Xin struct ethtool_eee eee_data; 1626e2ca90c2SFreddy Xin 1627e2ca90c2SFreddy Xin tmp16 = (u16 *)buf; 1628e2ca90c2SFreddy Xin tmp = (u8 *)buf; 1629e2ca90c2SFreddy Xin 1630e2ca90c2SFreddy Xin /* Power up ethernet PHY */ 1631e2ca90c2SFreddy Xin *tmp16 = 0; 1632e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); 1633e2ca90c2SFreddy Xin 1634e2ca90c2SFreddy Xin *tmp16 = AX_PHYPWR_RSTCTL_IPRL; 1635e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); 1636e2ca90c2SFreddy Xin msleep(200); 1637e2ca90c2SFreddy Xin 1638e2ca90c2SFreddy Xin *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; 1639e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); 1640e2ca90c2SFreddy Xin msleep(100); 1641e2ca90c2SFreddy Xin 1642e2ca90c2SFreddy Xin /* Ethernet PHY Auto Detach*/ 1643e2ca90c2SFreddy Xin ax88179_auto_detach(dev, 0); 1644e2ca90c2SFreddy Xin 16459fb137aeSPeter Fink /* Read MAC address from DTB or asix chip */ 16469fb137aeSPeter Fink ax88179_get_mac_addr(dev); 1647*9718f9ceSJustin Chen memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); 1648e2ca90c2SFreddy Xin 1649e2ca90c2SFreddy Xin /* RX bulk configuration */ 1650e2ca90c2SFreddy Xin memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); 1651e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); 1652e2ca90c2SFreddy Xin 1653e2ca90c2SFreddy Xin dev->rx_urb_size = 1024 * 20; 1654e2ca90c2SFreddy Xin 1655e2ca90c2SFreddy Xin *tmp = 0x34; 1656e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); 1657e2ca90c2SFreddy Xin 1658e2ca90c2SFreddy Xin *tmp = 0x52; 1659e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, 1660e2ca90c2SFreddy Xin 1, 1, tmp); 1661e2ca90c2SFreddy Xin 1662e2ca90c2SFreddy Xin /* Enable checksum offload */ 1663e2ca90c2SFreddy Xin *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | 1664e2ca90c2SFreddy Xin AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; 1665e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); 1666e2ca90c2SFreddy Xin 1667e2ca90c2SFreddy Xin *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | 1668e2ca90c2SFreddy Xin AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; 1669e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); 1670e2ca90c2SFreddy Xin 1671e2ca90c2SFreddy Xin /* Configure RX control register => start operation */ 1672e2ca90c2SFreddy Xin *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | 1673e2ca90c2SFreddy Xin AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; 1674e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); 1675e2ca90c2SFreddy Xin 1676e2ca90c2SFreddy Xin *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | 1677e2ca90c2SFreddy Xin AX_MONITOR_MODE_RWMP; 1678e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); 1679e2ca90c2SFreddy Xin 1680e2ca90c2SFreddy Xin /* Configure default medium type => giga */ 1681e2ca90c2SFreddy Xin *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | 16824c8e84b2SFreddy Xin AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX | 16834c8e84b2SFreddy Xin AX_MEDIUM_GIGAMODE; 1684e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1685e2ca90c2SFreddy Xin 2, 2, tmp16); 1686e2ca90c2SFreddy Xin 1687e2ca90c2SFreddy Xin ax88179_led_setting(dev); 1688e2ca90c2SFreddy Xin 1689e98d69baSFreddy Xin ax179_data->eee_enabled = 0; 1690e98d69baSFreddy Xin ax179_data->eee_active = 0; 1691e98d69baSFreddy Xin 1692e98d69baSFreddy Xin ax88179_disable_eee(dev); 1693e98d69baSFreddy Xin 1694e98d69baSFreddy Xin ax88179_ethtool_get_eee(dev, &eee_data); 1695e98d69baSFreddy Xin eee_data.advertised = 0; 1696e98d69baSFreddy Xin ax88179_ethtool_set_eee(dev, &eee_data); 1697e98d69baSFreddy Xin 1698e2ca90c2SFreddy Xin /* Restart autoneg */ 1699e2ca90c2SFreddy Xin mii_nway_restart(&dev->mii); 1700e2ca90c2SFreddy Xin 17017a97856eSMing Lei usbnet_link_change(dev, 0, 0); 1702e2ca90c2SFreddy Xin 1703e2ca90c2SFreddy Xin return 0; 1704e2ca90c2SFreddy Xin } 1705e2ca90c2SFreddy Xin 1706e2ca90c2SFreddy Xin static int ax88179_stop(struct usbnet *dev) 1707e2ca90c2SFreddy Xin { 1708e2ca90c2SFreddy Xin u16 tmp16; 1709e2ca90c2SFreddy Xin 1710e2ca90c2SFreddy Xin ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1711e2ca90c2SFreddy Xin 2, 2, &tmp16); 1712e2ca90c2SFreddy Xin tmp16 &= ~AX_MEDIUM_RECEIVE_EN; 1713e2ca90c2SFreddy Xin ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 1714e2ca90c2SFreddy Xin 2, 2, &tmp16); 1715e2ca90c2SFreddy Xin 1716e2ca90c2SFreddy Xin return 0; 1717e2ca90c2SFreddy Xin } 1718e2ca90c2SFreddy Xin 1719e2ca90c2SFreddy Xin static const struct driver_info ax88179_info = { 1720803dee95SDavid Chang .description = "ASIX AX88179 USB 3.0 Gigabit Ethernet", 1721e2ca90c2SFreddy Xin .bind = ax88179_bind, 1722e2ca90c2SFreddy Xin .unbind = ax88179_unbind, 1723e2ca90c2SFreddy Xin .status = ax88179_status, 1724e2ca90c2SFreddy Xin .link_reset = ax88179_link_reset, 1725e2ca90c2SFreddy Xin .reset = ax88179_reset, 1726e2ca90c2SFreddy Xin .stop = ax88179_stop, 172736a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1728e2ca90c2SFreddy Xin .rx_fixup = ax88179_rx_fixup, 1729e2ca90c2SFreddy Xin .tx_fixup = ax88179_tx_fixup, 1730e2ca90c2SFreddy Xin }; 1731e2ca90c2SFreddy Xin 1732e2ca90c2SFreddy Xin static const struct driver_info ax88178a_info = { 1733803dee95SDavid Chang .description = "ASIX AX88178A USB 2.0 Gigabit Ethernet", 1734e2ca90c2SFreddy Xin .bind = ax88179_bind, 1735e2ca90c2SFreddy Xin .unbind = ax88179_unbind, 1736e2ca90c2SFreddy Xin .status = ax88179_status, 1737e2ca90c2SFreddy Xin .link_reset = ax88179_link_reset, 1738e2ca90c2SFreddy Xin .reset = ax88179_reset, 1739e2ca90c2SFreddy Xin .stop = ax88179_stop, 174036a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1741e2ca90c2SFreddy Xin .rx_fixup = ax88179_rx_fixup, 1742e2ca90c2SFreddy Xin .tx_fixup = ax88179_tx_fixup, 1743e2ca90c2SFreddy Xin }; 1744e2ca90c2SFreddy Xin 17458da3cf2aSAllan Chou static const struct driver_info cypress_GX3_info = { 17468da3cf2aSAllan Chou .description = "Cypress GX3 SuperSpeed to Gigabit Ethernet Controller", 17478da3cf2aSAllan Chou .bind = ax88179_bind, 17488da3cf2aSAllan Chou .unbind = ax88179_unbind, 17498da3cf2aSAllan Chou .status = ax88179_status, 17508da3cf2aSAllan Chou .link_reset = ax88179_link_reset, 17518da3cf2aSAllan Chou .reset = ax88179_reset, 17528da3cf2aSAllan Chou .stop = ax88179_stop, 175336a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 17548da3cf2aSAllan Chou .rx_fixup = ax88179_rx_fixup, 17558da3cf2aSAllan Chou .tx_fixup = ax88179_tx_fixup, 17568da3cf2aSAllan Chou }; 17578da3cf2aSAllan Chou 1758635d61a3SGerry Demaret static const struct driver_info dlink_dub1312_info = { 1759635d61a3SGerry Demaret .description = "D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter", 1760635d61a3SGerry Demaret .bind = ax88179_bind, 1761635d61a3SGerry Demaret .unbind = ax88179_unbind, 1762635d61a3SGerry Demaret .status = ax88179_status, 1763635d61a3SGerry Demaret .link_reset = ax88179_link_reset, 1764635d61a3SGerry Demaret .reset = ax88179_reset, 1765635d61a3SGerry Demaret .stop = ax88179_stop, 176636a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1767635d61a3SGerry Demaret .rx_fixup = ax88179_rx_fixup, 1768635d61a3SGerry Demaret .tx_fixup = ax88179_tx_fixup, 1769635d61a3SGerry Demaret }; 1770635d61a3SGerry Demaret 1771e2ca90c2SFreddy Xin static const struct driver_info sitecom_info = { 1772e2ca90c2SFreddy Xin .description = "Sitecom USB 3.0 to Gigabit Adapter", 1773e2ca90c2SFreddy Xin .bind = ax88179_bind, 1774e2ca90c2SFreddy Xin .unbind = ax88179_unbind, 1775e2ca90c2SFreddy Xin .status = ax88179_status, 1776e2ca90c2SFreddy Xin .link_reset = ax88179_link_reset, 1777e2ca90c2SFreddy Xin .reset = ax88179_reset, 1778e2ca90c2SFreddy Xin .stop = ax88179_stop, 177936a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1780e2ca90c2SFreddy Xin .rx_fixup = ax88179_rx_fixup, 1781e2ca90c2SFreddy Xin .tx_fixup = ax88179_tx_fixup, 1782e2ca90c2SFreddy Xin }; 1783e2ca90c2SFreddy Xin 1784f11a5bc1SFreddy Xin static const struct driver_info samsung_info = { 1785f11a5bc1SFreddy Xin .description = "Samsung USB Ethernet Adapter", 1786f11a5bc1SFreddy Xin .bind = ax88179_bind, 1787f11a5bc1SFreddy Xin .unbind = ax88179_unbind, 1788f11a5bc1SFreddy Xin .status = ax88179_status, 1789f11a5bc1SFreddy Xin .link_reset = ax88179_link_reset, 1790f11a5bc1SFreddy Xin .reset = ax88179_reset, 1791f11a5bc1SFreddy Xin .stop = ax88179_stop, 179236a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1793f11a5bc1SFreddy Xin .rx_fixup = ax88179_rx_fixup, 1794f11a5bc1SFreddy Xin .tx_fixup = ax88179_tx_fixup, 1795f11a5bc1SFreddy Xin }; 1796f11a5bc1SFreddy Xin 1797e5fe0cd4SFreddy Xin static const struct driver_info lenovo_info = { 1798e5fe0cd4SFreddy Xin .description = "Lenovo OneLinkDock Gigabit LAN", 1799e5fe0cd4SFreddy Xin .bind = ax88179_bind, 1800e5fe0cd4SFreddy Xin .unbind = ax88179_unbind, 1801e5fe0cd4SFreddy Xin .status = ax88179_status, 1802e5fe0cd4SFreddy Xin .link_reset = ax88179_link_reset, 1803e5fe0cd4SFreddy Xin .reset = ax88179_reset, 1804e5fe0cd4SFreddy Xin .stop = ax88179_stop, 180536a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1806e5fe0cd4SFreddy Xin .rx_fixup = ax88179_rx_fixup, 1807e5fe0cd4SFreddy Xin .tx_fixup = ax88179_tx_fixup, 1808e5fe0cd4SFreddy Xin }; 1809e5fe0cd4SFreddy Xin 1810e20bd60bSAndrew F. Davis static const struct driver_info belkin_info = { 1811e20bd60bSAndrew F. Davis .description = "Belkin USB Ethernet Adapter", 1812e20bd60bSAndrew F. Davis .bind = ax88179_bind, 1813e20bd60bSAndrew F. Davis .unbind = ax88179_unbind, 1814e20bd60bSAndrew F. Davis .status = ax88179_status, 1815e20bd60bSAndrew F. Davis .link_reset = ax88179_link_reset, 1816e20bd60bSAndrew F. Davis .reset = ax88179_reset, 18179666ea66SWilken Gottwalt .stop = ax88179_stop, 181836a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1819e20bd60bSAndrew F. Davis .rx_fixup = ax88179_rx_fixup, 1820e20bd60bSAndrew F. Davis .tx_fixup = ax88179_tx_fixup, 1821e20bd60bSAndrew F. Davis }; 1822e20bd60bSAndrew F. Davis 1823e42d72feSWilken Gottwalt static const struct driver_info toshiba_info = { 1824e42d72feSWilken Gottwalt .description = "Toshiba USB Ethernet Adapter", 1825e42d72feSWilken Gottwalt .bind = ax88179_bind, 1826e42d72feSWilken Gottwalt .unbind = ax88179_unbind, 1827e42d72feSWilken Gottwalt .status = ax88179_status, 1828e42d72feSWilken Gottwalt .link_reset = ax88179_link_reset, 1829e42d72feSWilken Gottwalt .reset = ax88179_reset, 1830e42d72feSWilken Gottwalt .stop = ax88179_stop, 183136a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1832e42d72feSWilken Gottwalt .rx_fixup = ax88179_rx_fixup, 1833e42d72feSWilken Gottwalt .tx_fixup = ax88179_tx_fixup, 1834e42d72feSWilken Gottwalt }; 1835e42d72feSWilken Gottwalt 1836c92a7982SWilken Gottwalt static const struct driver_info mct_info = { 1837c92a7982SWilken Gottwalt .description = "MCT USB 3.0 Gigabit Ethernet Adapter", 1838c92a7982SWilken Gottwalt .bind = ax88179_bind, 1839c92a7982SWilken Gottwalt .unbind = ax88179_unbind, 1840c92a7982SWilken Gottwalt .status = ax88179_status, 1841c92a7982SWilken Gottwalt .link_reset = ax88179_link_reset, 1842c92a7982SWilken Gottwalt .reset = ax88179_reset, 1843c92a7982SWilken Gottwalt .stop = ax88179_stop, 184436a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 1845c92a7982SWilken Gottwalt .rx_fixup = ax88179_rx_fixup, 1846c92a7982SWilken Gottwalt .tx_fixup = ax88179_tx_fixup, 1847c92a7982SWilken Gottwalt }; 1848c92a7982SWilken Gottwalt 18499fe087ddSGreg Jesionowski static const struct driver_info at_umc2000_info = { 18509fe087ddSGreg Jesionowski .description = "AT-UMC2000 USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter", 18519fe087ddSGreg Jesionowski .bind = ax88179_bind, 18529fe087ddSGreg Jesionowski .unbind = ax88179_unbind, 18539fe087ddSGreg Jesionowski .status = ax88179_status, 18549fe087ddSGreg Jesionowski .link_reset = ax88179_link_reset, 18559fe087ddSGreg Jesionowski .reset = ax88179_reset, 18569fe087ddSGreg Jesionowski .stop = ax88179_stop, 185736a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 18589fe087ddSGreg Jesionowski .rx_fixup = ax88179_rx_fixup, 18599fe087ddSGreg Jesionowski .tx_fixup = ax88179_tx_fixup, 18609fe087ddSGreg Jesionowski }; 18619fe087ddSGreg Jesionowski 18629fe087ddSGreg Jesionowski static const struct driver_info at_umc200_info = { 18639fe087ddSGreg Jesionowski .description = "AT-UMC200 USB 3.0/USB 3.1 Gen 1 to Fast Ethernet Adapter", 18649fe087ddSGreg Jesionowski .bind = ax88179_bind, 18659fe087ddSGreg Jesionowski .unbind = ax88179_unbind, 18669fe087ddSGreg Jesionowski .status = ax88179_status, 18679fe087ddSGreg Jesionowski .link_reset = ax88179_link_reset, 18689fe087ddSGreg Jesionowski .reset = ax88179_reset, 18699fe087ddSGreg Jesionowski .stop = ax88179_stop, 187036a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 18719fe087ddSGreg Jesionowski .rx_fixup = ax88179_rx_fixup, 18729fe087ddSGreg Jesionowski .tx_fixup = ax88179_tx_fixup, 18739fe087ddSGreg Jesionowski }; 18749fe087ddSGreg Jesionowski 18759fe087ddSGreg Jesionowski static const struct driver_info at_umc2000sp_info = { 18769fe087ddSGreg Jesionowski .description = "AT-UMC2000/SP USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter", 18779fe087ddSGreg Jesionowski .bind = ax88179_bind, 18789fe087ddSGreg Jesionowski .unbind = ax88179_unbind, 18799fe087ddSGreg Jesionowski .status = ax88179_status, 18809fe087ddSGreg Jesionowski .link_reset = ax88179_link_reset, 18819fe087ddSGreg Jesionowski .reset = ax88179_reset, 18829fe087ddSGreg Jesionowski .stop = ax88179_stop, 188336a15e1cSJose Alonso .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP, 18849fe087ddSGreg Jesionowski .rx_fixup = ax88179_rx_fixup, 18859fe087ddSGreg Jesionowski .tx_fixup = ax88179_tx_fixup, 18869fe087ddSGreg Jesionowski }; 18879fe087ddSGreg Jesionowski 1888e2ca90c2SFreddy Xin static const struct usb_device_id products[] = { 1889e2ca90c2SFreddy Xin { 1890e2ca90c2SFreddy Xin /* ASIX AX88179 10/100/1000 */ 1891e2ca90c2SFreddy Xin USB_DEVICE(0x0b95, 0x1790), 1892e2ca90c2SFreddy Xin .driver_info = (unsigned long)&ax88179_info, 1893e2ca90c2SFreddy Xin }, { 1894e2ca90c2SFreddy Xin /* ASIX AX88178A 10/100/1000 */ 1895e2ca90c2SFreddy Xin USB_DEVICE(0x0b95, 0x178a), 1896e2ca90c2SFreddy Xin .driver_info = (unsigned long)&ax88178a_info, 1897e2ca90c2SFreddy Xin }, { 18988da3cf2aSAllan Chou /* Cypress GX3 SuperSpeed to Gigabit Ethernet Bridge Controller */ 18998da3cf2aSAllan Chou USB_DEVICE(0x04b4, 0x3610), 19008da3cf2aSAllan Chou .driver_info = (unsigned long)&cypress_GX3_info, 19018da3cf2aSAllan Chou }, { 1902635d61a3SGerry Demaret /* D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter */ 1903635d61a3SGerry Demaret USB_DEVICE(0x2001, 0x4a00), 1904635d61a3SGerry Demaret .driver_info = (unsigned long)&dlink_dub1312_info, 1905635d61a3SGerry Demaret }, { 1906e2ca90c2SFreddy Xin /* Sitecom USB 3.0 to Gigabit Adapter */ 1907e2ca90c2SFreddy Xin USB_DEVICE(0x0df6, 0x0072), 1908e2ca90c2SFreddy Xin .driver_info = (unsigned long)&sitecom_info, 1909f11a5bc1SFreddy Xin }, { 1910f11a5bc1SFreddy Xin /* Samsung USB Ethernet Adapter */ 1911f11a5bc1SFreddy Xin USB_DEVICE(0x04e8, 0xa100), 1912f11a5bc1SFreddy Xin .driver_info = (unsigned long)&samsung_info, 1913e5fe0cd4SFreddy Xin }, { 1914e5fe0cd4SFreddy Xin /* Lenovo OneLinkDock Gigabit LAN */ 1915e5fe0cd4SFreddy Xin USB_DEVICE(0x17ef, 0x304b), 1916e5fe0cd4SFreddy Xin .driver_info = (unsigned long)&lenovo_info, 1917e20bd60bSAndrew F. Davis }, { 1918e20bd60bSAndrew F. Davis /* Belkin B2B128 USB 3.0 Hub + Gigabit Ethernet Adapter */ 1919e20bd60bSAndrew F. Davis USB_DEVICE(0x050d, 0x0128), 1920e20bd60bSAndrew F. Davis .driver_info = (unsigned long)&belkin_info, 1921e42d72feSWilken Gottwalt }, { 1922e42d72feSWilken Gottwalt /* Toshiba USB 3.0 GBit Ethernet Adapter */ 1923e42d72feSWilken Gottwalt USB_DEVICE(0x0930, 0x0a13), 1924e42d72feSWilken Gottwalt .driver_info = (unsigned long)&toshiba_info, 1925c92a7982SWilken Gottwalt }, { 1926c92a7982SWilken Gottwalt /* Magic Control Technology U3-A9003 USB 3.0 Gigabit Ethernet Adapter */ 1927c92a7982SWilken Gottwalt USB_DEVICE(0x0711, 0x0179), 1928c92a7982SWilken Gottwalt .driver_info = (unsigned long)&mct_info, 19299fe087ddSGreg Jesionowski }, { 19309fe087ddSGreg Jesionowski /* Allied Telesis AT-UMC2000 USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter */ 19319fe087ddSGreg Jesionowski USB_DEVICE(0x07c9, 0x000e), 19329fe087ddSGreg Jesionowski .driver_info = (unsigned long)&at_umc2000_info, 19339fe087ddSGreg Jesionowski }, { 19349fe087ddSGreg Jesionowski /* Allied Telesis AT-UMC200 USB 3.0/USB 3.1 Gen 1 to Fast Ethernet Adapter */ 19359fe087ddSGreg Jesionowski USB_DEVICE(0x07c9, 0x000f), 19369fe087ddSGreg Jesionowski .driver_info = (unsigned long)&at_umc200_info, 19379fe087ddSGreg Jesionowski }, { 19389fe087ddSGreg Jesionowski /* Allied Telesis AT-UMC2000/SP USB 3.0/USB 3.1 Gen 1 to Gigabit Ethernet Adapter */ 19399fe087ddSGreg Jesionowski USB_DEVICE(0x07c9, 0x0010), 19409fe087ddSGreg Jesionowski .driver_info = (unsigned long)&at_umc2000sp_info, 1941e2ca90c2SFreddy Xin }, 1942e2ca90c2SFreddy Xin { }, 1943e2ca90c2SFreddy Xin }; 1944e2ca90c2SFreddy Xin MODULE_DEVICE_TABLE(usb, products); 1945e2ca90c2SFreddy Xin 1946e2ca90c2SFreddy Xin static struct usb_driver ax88179_178a_driver = { 1947e2ca90c2SFreddy Xin .name = "ax88179_178a", 1948e2ca90c2SFreddy Xin .id_table = products, 1949e2ca90c2SFreddy Xin .probe = usbnet_probe, 1950e2ca90c2SFreddy Xin .suspend = ax88179_suspend, 1951e2ca90c2SFreddy Xin .resume = ax88179_resume, 1952b8553b89SDavid Chang .reset_resume = ax88179_resume, 1953e2ca90c2SFreddy Xin .disconnect = usbnet_disconnect, 1954e2ca90c2SFreddy Xin .supports_autosuspend = 1, 1955e2ca90c2SFreddy Xin .disable_hub_initiated_lpm = 1, 1956e2ca90c2SFreddy Xin }; 1957e2ca90c2SFreddy Xin 1958e2ca90c2SFreddy Xin module_usb_driver(ax88179_178a_driver); 1959e2ca90c2SFreddy Xin 1960e2ca90c2SFreddy Xin MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices"); 1961e2ca90c2SFreddy Xin MODULE_LICENSE("GPL"); 1962