David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ASIX AX8817X based USB 2.0 Ethernet Devices |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 3 | * Copyright (C) 2003-2006 David Hollis <dhollis@davehollis.com> |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 4 | * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net> |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 5 | * Copyright (C) 2006 James Painter <jamie.painter@iname.com> |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 6 | * Copyright (c) 2002-2003 TiVo Inc. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | |
Christian Riesch | 607740b | 2012-07-13 05:26:30 +0000 | [diff] [blame] | 23 | #include "asix.h" |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 24 | |
| 25 | #define PHY_MODE_MARVELL 0x0000 |
| 26 | #define MII_MARVELL_LED_CTRL 0x0018 |
| 27 | #define MII_MARVELL_STATUS 0x001b |
| 28 | #define MII_MARVELL_CTRL 0x0014 |
| 29 | |
| 30 | #define MARVELL_LED_MANUAL 0x0019 |
| 31 | |
| 32 | #define MARVELL_STATUS_HWCFG 0x0004 |
| 33 | |
| 34 | #define MARVELL_CTRL_TXDELAY 0x0002 |
| 35 | #define MARVELL_CTRL_RXDELAY 0x0080 |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 36 | |
Grant Grundler | 3486140 | 2011-11-15 07:12:39 +0000 | [diff] [blame] | 37 | #define PHY_MODE_RTL8211CL 0x000C |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 38 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 39 | struct ax88172_int_data { |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 40 | __le16 res1; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 41 | u8 link; |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 42 | __le16 res2; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 43 | u8 status; |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 44 | __le16 res3; |
Eric Dumazet | ba2d358 | 2010-06-02 18:10:09 +0000 | [diff] [blame] | 45 | } __packed; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 46 | |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 47 | static void asix_status(struct usbnet *dev, struct urb *urb) |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 48 | { |
| 49 | struct ax88172_int_data *event; |
| 50 | int link; |
| 51 | |
| 52 | if (urb->actual_length < 8) |
| 53 | return; |
| 54 | |
| 55 | event = urb->transfer_buffer; |
| 56 | link = event->link & 0x01; |
| 57 | if (netif_carrier_ok(dev->net) != link) { |
| 58 | if (link) { |
| 59 | netif_carrier_on(dev->net); |
| 60 | usbnet_defer_kevent (dev, EVENT_LINK_RESET ); |
| 61 | } else |
| 62 | netif_carrier_off(dev->net); |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 63 | netdev_dbg(dev->net, "Link Status is: %d\n", link); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 67 | /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ |
| 68 | static u32 asix_get_phyid(struct usbnet *dev) |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 69 | { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 70 | int phy_reg; |
| 71 | u32 phy_id; |
Grant Grundler | a77929a | 2011-11-15 07:12:40 +0000 | [diff] [blame] | 72 | int i; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 73 | |
Grant Grundler | a77929a | 2011-11-15 07:12:40 +0000 | [diff] [blame] | 74 | /* Poll for the rare case the FW or phy isn't ready yet. */ |
| 75 | for (i = 0; i < 100; i++) { |
| 76 | phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); |
| 77 | if (phy_reg != 0 && phy_reg != 0xFFFF) |
| 78 | break; |
| 79 | mdelay(1); |
| 80 | } |
| 81 | |
| 82 | if (phy_reg <= 0 || phy_reg == 0xFFFF) |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 83 | return 0; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 84 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 85 | phy_id = (phy_reg & 0xffff) << 16; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 86 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 87 | phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2); |
| 88 | if (phy_reg < 0) |
| 89 | return 0; |
| 90 | |
| 91 | phy_id |= (phy_reg & 0xffff); |
| 92 | |
| 93 | return phy_id; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 94 | } |
| 95 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 96 | static u32 asix_get_link(struct net_device *net) |
| 97 | { |
| 98 | struct usbnet *dev = netdev_priv(net); |
| 99 | |
| 100 | return mii_link_ok(&dev->mii); |
| 101 | } |
| 102 | |
| 103 | static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) |
| 104 | { |
| 105 | struct usbnet *dev = netdev_priv(net); |
| 106 | |
| 107 | return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /* We need to override some ethtool_ops so we require our |
| 111 | own structure so we don't interfere with other usbnet |
| 112 | devices that may be connected at the same time. */ |
Stephen Hemminger | 0fc0b73 | 2009-09-02 01:03:33 -0700 | [diff] [blame] | 113 | static const struct ethtool_ops ax88172_ethtool_ops = { |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 114 | .get_drvinfo = asix_get_drvinfo, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 115 | .get_link = asix_get_link, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 116 | .get_msglevel = usbnet_get_msglevel, |
| 117 | .set_msglevel = usbnet_set_msglevel, |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 118 | .get_wol = asix_get_wol, |
| 119 | .set_wol = asix_set_wol, |
| 120 | .get_eeprom_len = asix_get_eeprom_len, |
| 121 | .get_eeprom = asix_get_eeprom, |
Christian Riesch | cb7b24c | 2012-07-19 00:23:07 +0000 | [diff] [blame] | 122 | .set_eeprom = asix_set_eeprom, |
Arnd Bergmann | c41286f | 2006-10-09 00:08:01 +0200 | [diff] [blame] | 123 | .get_settings = usbnet_get_settings, |
| 124 | .set_settings = usbnet_set_settings, |
| 125 | .nway_reset = usbnet_nway_reset, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 126 | }; |
| 127 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 128 | static void ax88172_set_multicast(struct net_device *net) |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 129 | { |
| 130 | struct usbnet *dev = netdev_priv(net); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 131 | struct asix_data *data = (struct asix_data *)&dev->data; |
| 132 | u8 rx_ctl = 0x8c; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 133 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 134 | if (net->flags & IFF_PROMISC) { |
| 135 | rx_ctl |= 0x01; |
Joe Perches | 8e95a20 | 2009-12-03 07:58:21 +0000 | [diff] [blame] | 136 | } else if (net->flags & IFF_ALLMULTI || |
Jiri Pirko | 4cd24ea | 2010-02-08 04:30:35 +0000 | [diff] [blame] | 137 | netdev_mc_count(net) > AX_MAX_MCAST) { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 138 | rx_ctl |= 0x02; |
Jiri Pirko | 4cd24ea | 2010-02-08 04:30:35 +0000 | [diff] [blame] | 139 | } else if (netdev_mc_empty(net)) { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 140 | /* just broadcast and directed */ |
| 141 | } else { |
| 142 | /* We use the 20 byte dev->data |
| 143 | * for our 8 byte filter buffer |
| 144 | * to avoid allocating memory that |
| 145 | * is tricky to free later */ |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 146 | struct netdev_hw_addr *ha; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 147 | u32 crc_bits; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 148 | |
| 149 | memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); |
| 150 | |
| 151 | /* Build the multicast hash filter. */ |
Jiri Pirko | 22bedad3 | 2010-04-01 21:22:57 +0000 | [diff] [blame] | 152 | netdev_for_each_mc_addr(ha, net) { |
| 153 | crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 154 | data->multi_filter[crc_bits >> 3] |= |
| 155 | 1 << (crc_bits & 7); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, |
| 159 | AX_MCAST_FILTER_SIZE, data->multi_filter); |
| 160 | |
| 161 | rx_ctl |= 0x10; |
| 162 | } |
| 163 | |
| 164 | asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); |
| 165 | } |
| 166 | |
| 167 | static int ax88172_link_reset(struct usbnet *dev) |
| 168 | { |
| 169 | u8 mode; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 170 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 171 | |
| 172 | mii_check_media(&dev->mii, 1, 1); |
| 173 | mii_ethtool_gset(&dev->mii, &ecmd); |
| 174 | mode = AX88172_MEDIUM_DEFAULT; |
| 175 | |
| 176 | if (ecmd.duplex != DUPLEX_FULL) |
| 177 | mode |= ~AX88172_MEDIUM_FD; |
| 178 | |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 179 | netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", |
| 180 | ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 181 | |
| 182 | asix_write_medium_mode(dev, mode); |
| 183 | |
| 184 | return 0; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 187 | static const struct net_device_ops ax88172_netdev_ops = { |
| 188 | .ndo_open = usbnet_open, |
| 189 | .ndo_stop = usbnet_stop, |
| 190 | .ndo_start_xmit = usbnet_start_xmit, |
| 191 | .ndo_tx_timeout = usbnet_tx_timeout, |
| 192 | .ndo_change_mtu = usbnet_change_mtu, |
| 193 | .ndo_set_mac_address = eth_mac_addr, |
| 194 | .ndo_validate_addr = eth_validate_addr, |
| 195 | .ndo_do_ioctl = asix_ioctl, |
Jiri Pirko | afc4b13 | 2011-08-16 06:29:01 +0000 | [diff] [blame] | 196 | .ndo_set_rx_mode = ax88172_set_multicast, |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 197 | }; |
| 198 | |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 199 | static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf) |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 200 | { |
| 201 | int ret = 0; |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 202 | u8 buf[ETH_ALEN]; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 203 | int i; |
| 204 | unsigned long gpio_bits = dev->driver_info->data; |
| 205 | |
| 206 | usbnet_get_endpoints(dev,intf); |
| 207 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 208 | /* Toggle the GPIOs in a manufacturer/model specific way */ |
| 209 | for (i = 2; i >= 0; i--) { |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 210 | ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, |
| 211 | (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL); |
| 212 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 213 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 214 | msleep(5); |
| 215 | } |
| 216 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 217 | ret = asix_write_rx_ctl(dev, 0x80); |
| 218 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 219 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 220 | |
| 221 | /* Get the MAC address */ |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 222 | ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); |
| 223 | if (ret < 0) { |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 224 | dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 225 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 226 | } |
| 227 | memcpy(dev->net->dev_addr, buf, ETH_ALEN); |
| 228 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 229 | /* Initialize MII structure */ |
| 230 | dev->mii.dev = dev->net; |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 231 | dev->mii.mdio_read = asix_mdio_read; |
| 232 | dev->mii.mdio_write = asix_mdio_write; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 233 | dev->mii.phy_id_mask = 0x3f; |
| 234 | dev->mii.reg_num_mask = 0x1f; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 235 | dev->mii.phy_id = asix_get_phy_addr(dev); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 236 | |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 237 | dev->net->netdev_ops = &ax88172_netdev_ops; |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 238 | dev->net->ethtool_ops = &ax88172_ethtool_ops; |
Eric Dumazet | 95162d6 | 2012-07-05 04:31:01 +0000 | [diff] [blame] | 239 | dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ |
| 240 | dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 241 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 242 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); |
| 243 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 244 | ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); |
| 245 | mii_nway_restart(&dev->mii); |
| 246 | |
| 247 | return 0; |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 248 | |
| 249 | out: |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 250 | return ret; |
| 251 | } |
| 252 | |
Stephen Hemminger | 0fc0b73 | 2009-09-02 01:03:33 -0700 | [diff] [blame] | 253 | static const struct ethtool_ops ax88772_ethtool_ops = { |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 254 | .get_drvinfo = asix_get_drvinfo, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 255 | .get_link = asix_get_link, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 256 | .get_msglevel = usbnet_get_msglevel, |
| 257 | .set_msglevel = usbnet_set_msglevel, |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 258 | .get_wol = asix_get_wol, |
| 259 | .set_wol = asix_set_wol, |
| 260 | .get_eeprom_len = asix_get_eeprom_len, |
| 261 | .get_eeprom = asix_get_eeprom, |
Christian Riesch | cb7b24c | 2012-07-19 00:23:07 +0000 | [diff] [blame] | 262 | .set_eeprom = asix_set_eeprom, |
Arnd Bergmann | c41286f | 2006-10-09 00:08:01 +0200 | [diff] [blame] | 263 | .get_settings = usbnet_get_settings, |
| 264 | .set_settings = usbnet_set_settings, |
| 265 | .nway_reset = usbnet_nway_reset, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 266 | }; |
| 267 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 268 | static int ax88772_link_reset(struct usbnet *dev) |
| 269 | { |
| 270 | u16 mode; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 271 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 272 | |
| 273 | mii_check_media(&dev->mii, 1, 1); |
| 274 | mii_ethtool_gset(&dev->mii, &ecmd); |
| 275 | mode = AX88772_MEDIUM_DEFAULT; |
| 276 | |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 277 | if (ethtool_cmd_speed(&ecmd) != SPEED_100) |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 278 | mode &= ~AX_MEDIUM_PS; |
| 279 | |
| 280 | if (ecmd.duplex != DUPLEX_FULL) |
| 281 | mode &= ~AX_MEDIUM_FD; |
| 282 | |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 283 | netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", |
| 284 | ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 285 | |
| 286 | asix_write_medium_mode(dev, mode); |
| 287 | |
| 288 | return 0; |
| 289 | } |
| 290 | |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 291 | static int ax88772_reset(struct usbnet *dev) |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 292 | { |
Jussi Kivilinna | 8ef66bd | 2012-01-10 06:40:17 +0000 | [diff] [blame] | 293 | struct asix_data *data = (struct asix_data *)&dev->data; |
Andres Salomon | d0ffff8 | 2007-01-11 18:39:16 -0500 | [diff] [blame] | 294 | int ret, embd_phy; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 295 | u16 rx_ctl; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 296 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 297 | ret = asix_write_gpio(dev, |
| 298 | AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5); |
| 299 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 300 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 301 | |
Andres Salomon | d0ffff8 | 2007-01-11 18:39:16 -0500 | [diff] [blame] | 302 | embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 303 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 304 | ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); |
| 305 | if (ret < 0) { |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 306 | dbg("Select PHY #1 failed: %d", ret); |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 307 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 310 | ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); |
| 311 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 312 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 313 | |
| 314 | msleep(150); |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 315 | |
| 316 | ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); |
| 317 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 318 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 319 | |
| 320 | msleep(150); |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 321 | |
Andres Salomon | d0ffff8 | 2007-01-11 18:39:16 -0500 | [diff] [blame] | 322 | if (embd_phy) { |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 323 | ret = asix_sw_reset(dev, AX_SWRESET_IPRL); |
| 324 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 325 | goto out; |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 326 | } else { |
| 327 | ret = asix_sw_reset(dev, AX_SWRESET_PRTE); |
| 328 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 329 | goto out; |
Andres Salomon | d0ffff8 | 2007-01-11 18:39:16 -0500 | [diff] [blame] | 330 | } |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 331 | |
| 332 | msleep(150); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 333 | rx_ctl = asix_read_rx_ctl(dev); |
| 334 | dbg("RX_CTL is 0x%04x after software reset", rx_ctl); |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 335 | ret = asix_write_rx_ctl(dev, 0x0000); |
| 336 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 337 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 338 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 339 | rx_ctl = asix_read_rx_ctl(dev); |
| 340 | dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl); |
| 341 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 342 | ret = asix_sw_reset(dev, AX_SWRESET_PRL); |
| 343 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 344 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 345 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 346 | msleep(150); |
| 347 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 348 | ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL); |
| 349 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 350 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 351 | |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 352 | msleep(150); |
| 353 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 354 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); |
| 355 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 356 | ADVERTISE_ALL | ADVERTISE_CSMA); |
| 357 | mii_nway_restart(&dev->mii); |
| 358 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 359 | ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT); |
| 360 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 361 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 362 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 363 | ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 364 | AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 365 | AX88772_IPG2_DEFAULT, 0, NULL); |
| 366 | if (ret < 0) { |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 367 | dbg("Write IPG,IPG1,IPG2 failed: %d", ret); |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 368 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 369 | } |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 370 | |
Jussi Kivilinna | 8ef66bd | 2012-01-10 06:40:17 +0000 | [diff] [blame] | 371 | /* Rewrite MAC address */ |
| 372 | memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); |
| 373 | ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, |
| 374 | data->mac_addr); |
| 375 | if (ret < 0) |
| 376 | goto out; |
| 377 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 378 | /* Set RX_CTL to default values with 2k buffer, and enable cactus */ |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 379 | ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); |
| 380 | if (ret < 0) |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 381 | goto out; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 382 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 383 | rx_ctl = asix_read_rx_ctl(dev); |
| 384 | dbg("RX_CTL is 0x%04x after all initializations", rx_ctl); |
| 385 | |
| 386 | rx_ctl = asix_read_medium_status(dev); |
| 387 | dbg("Medium Status is 0x%04x after all initializations", rx_ctl); |
| 388 | |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 389 | return 0; |
| 390 | |
| 391 | out: |
| 392 | return ret; |
| 393 | |
| 394 | } |
| 395 | |
| 396 | static const struct net_device_ops ax88772_netdev_ops = { |
| 397 | .ndo_open = usbnet_open, |
| 398 | .ndo_stop = usbnet_stop, |
| 399 | .ndo_start_xmit = usbnet_start_xmit, |
| 400 | .ndo_tx_timeout = usbnet_tx_timeout, |
| 401 | .ndo_change_mtu = usbnet_change_mtu, |
| 402 | .ndo_set_mac_address = asix_set_mac_address, |
| 403 | .ndo_validate_addr = eth_validate_addr, |
| 404 | .ndo_do_ioctl = asix_ioctl, |
| 405 | .ndo_set_rx_mode = asix_set_multicast, |
| 406 | }; |
| 407 | |
| 408 | static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) |
| 409 | { |
Grant Grundler | d366518 | 2011-11-15 07:12:41 +0000 | [diff] [blame] | 410 | int ret, embd_phy; |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 411 | u8 buf[ETH_ALEN]; |
| 412 | u32 phyid; |
| 413 | |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 414 | usbnet_get_endpoints(dev,intf); |
| 415 | |
| 416 | /* Get the MAC address */ |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 417 | ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); |
| 418 | if (ret < 0) { |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 419 | dbg("Failed to read MAC address: %d", ret); |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 420 | return ret; |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 421 | } |
| 422 | memcpy(dev->net->dev_addr, buf, ETH_ALEN); |
| 423 | |
| 424 | /* Initialize MII structure */ |
| 425 | dev->mii.dev = dev->net; |
| 426 | dev->mii.mdio_read = asix_mdio_read; |
| 427 | dev->mii.mdio_write = asix_mdio_write; |
| 428 | dev->mii.phy_id_mask = 0x1f; |
| 429 | dev->mii.reg_num_mask = 0x1f; |
| 430 | dev->mii.phy_id = asix_get_phy_addr(dev); |
| 431 | |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 432 | dev->net->netdev_ops = &ax88772_netdev_ops; |
| 433 | dev->net->ethtool_ops = &ax88772_ethtool_ops; |
Eric Dumazet | 95162d6 | 2012-07-05 04:31:01 +0000 | [diff] [blame] | 434 | dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ |
| 435 | dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 436 | |
Grant Grundler | d366518 | 2011-11-15 07:12:41 +0000 | [diff] [blame] | 437 | embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); |
| 438 | |
| 439 | /* Reset the PHY to normal operation mode */ |
| 440 | ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); |
| 441 | if (ret < 0) { |
| 442 | dbg("Select PHY #1 failed: %d", ret); |
| 443 | return ret; |
| 444 | } |
| 445 | |
| 446 | ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 447 | if (ret < 0) |
| 448 | return ret; |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 449 | |
Grant Grundler | d366518 | 2011-11-15 07:12:41 +0000 | [diff] [blame] | 450 | msleep(150); |
| 451 | |
| 452 | ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); |
| 453 | if (ret < 0) |
| 454 | return ret; |
| 455 | |
| 456 | msleep(150); |
| 457 | |
| 458 | ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_PRTE); |
| 459 | |
| 460 | /* Read PHYID register *AFTER* the PHY was reset properly */ |
| 461 | phyid = asix_get_phyid(dev); |
| 462 | dbg("PHYID=0x%08x", phyid); |
| 463 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 464 | /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ |
| 465 | if (dev->driver_info->flags & FLAG_FRAMING_AX) { |
| 466 | /* hard_mtu is still the default - the device does not support |
| 467 | jumbo eth frames */ |
| 468 | dev->rx_urb_size = 2048; |
| 469 | } |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 470 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 471 | return 0; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 472 | } |
| 473 | |
stephen hemminger | bc689c9 | 2012-01-05 19:10:23 +0000 | [diff] [blame] | 474 | static const struct ethtool_ops ax88178_ethtool_ops = { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 475 | .get_drvinfo = asix_get_drvinfo, |
| 476 | .get_link = asix_get_link, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 477 | .get_msglevel = usbnet_get_msglevel, |
| 478 | .set_msglevel = usbnet_set_msglevel, |
| 479 | .get_wol = asix_get_wol, |
| 480 | .set_wol = asix_set_wol, |
| 481 | .get_eeprom_len = asix_get_eeprom_len, |
| 482 | .get_eeprom = asix_get_eeprom, |
Christian Riesch | cb7b24c | 2012-07-19 00:23:07 +0000 | [diff] [blame] | 483 | .set_eeprom = asix_set_eeprom, |
Arnd Bergmann | c41286f | 2006-10-09 00:08:01 +0200 | [diff] [blame] | 484 | .get_settings = usbnet_get_settings, |
| 485 | .set_settings = usbnet_set_settings, |
| 486 | .nway_reset = usbnet_nway_reset, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 487 | }; |
| 488 | |
| 489 | static int marvell_phy_init(struct usbnet *dev) |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 490 | { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 491 | struct asix_data *data = (struct asix_data *)&dev->data; |
| 492 | u16 reg; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 493 | |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 494 | netdev_dbg(dev->net, "marvell_phy_init()\n"); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 495 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 496 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS); |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 497 | netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 498 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 499 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL, |
| 500 | MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 501 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 502 | if (data->ledmode) { |
| 503 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, |
| 504 | MII_MARVELL_LED_CTRL); |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 505 | netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (1) = 0x%04x\n", reg); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 506 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 507 | reg &= 0xf8ff; |
| 508 | reg |= (1 + 0x0100); |
| 509 | asix_mdio_write(dev->net, dev->mii.phy_id, |
| 510 | MII_MARVELL_LED_CTRL, reg); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 511 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 512 | reg = asix_mdio_read(dev->net, dev->mii.phy_id, |
| 513 | MII_MARVELL_LED_CTRL); |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 514 | netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (2) = 0x%04x\n", reg); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 515 | reg &= 0xfc0f; |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 516 | } |
| 517 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 518 | return 0; |
| 519 | } |
| 520 | |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 521 | static int rtl8211cl_phy_init(struct usbnet *dev) |
| 522 | { |
| 523 | struct asix_data *data = (struct asix_data *)&dev->data; |
| 524 | |
| 525 | netdev_dbg(dev->net, "rtl8211cl_phy_init()\n"); |
| 526 | |
| 527 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0005); |
| 528 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x0c, 0); |
| 529 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x01, |
| 530 | asix_mdio_read (dev->net, dev->mii.phy_id, 0x01) | 0x0080); |
| 531 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0); |
| 532 | |
| 533 | if (data->ledmode == 12) { |
| 534 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0002); |
| 535 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x1a, 0x00cb); |
| 536 | asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0); |
| 537 | } |
| 538 | |
| 539 | return 0; |
| 540 | } |
| 541 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 542 | static int marvell_led_status(struct usbnet *dev, u16 speed) |
| 543 | { |
| 544 | u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL); |
| 545 | |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 546 | netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 547 | |
| 548 | /* Clear out the center LED bits - 0x03F0 */ |
| 549 | reg &= 0xfc0f; |
| 550 | |
| 551 | switch (speed) { |
| 552 | case SPEED_1000: |
| 553 | reg |= 0x03e0; |
| 554 | break; |
| 555 | case SPEED_100: |
| 556 | reg |= 0x03b0; |
| 557 | break; |
| 558 | default: |
| 559 | reg |= 0x02f0; |
| 560 | } |
| 561 | |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 562 | netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 563 | asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg); |
| 564 | |
| 565 | return 0; |
| 566 | } |
| 567 | |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 568 | static int ax88178_reset(struct usbnet *dev) |
| 569 | { |
| 570 | struct asix_data *data = (struct asix_data *)&dev->data; |
| 571 | int ret; |
| 572 | __le16 eeprom; |
| 573 | u8 status; |
| 574 | int gpio0 = 0; |
Grant Grundler | b2d3ad29 | 2011-11-15 07:12:42 +0000 | [diff] [blame] | 575 | u32 phyid; |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 576 | |
| 577 | asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status); |
| 578 | dbg("GPIO Status: 0x%04x", status); |
| 579 | |
| 580 | asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL); |
| 581 | asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom); |
| 582 | asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL); |
| 583 | |
| 584 | dbg("EEPROM index 0x17 is 0x%04x", eeprom); |
| 585 | |
| 586 | if (eeprom == cpu_to_le16(0xffff)) { |
| 587 | data->phymode = PHY_MODE_MARVELL; |
| 588 | data->ledmode = 0; |
| 589 | gpio0 = 1; |
| 590 | } else { |
Grant Grundler | b2d3ad29 | 2011-11-15 07:12:42 +0000 | [diff] [blame] | 591 | data->phymode = le16_to_cpu(eeprom) & 0x7F; |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 592 | data->ledmode = le16_to_cpu(eeprom) >> 8; |
| 593 | gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1; |
| 594 | } |
| 595 | dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode); |
| 596 | |
Grant Grundler | b2d3ad29 | 2011-11-15 07:12:42 +0000 | [diff] [blame] | 597 | /* Power up external GigaPHY through AX88178 GPIO pin */ |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 598 | asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40); |
| 599 | if ((le16_to_cpu(eeprom) >> 8) != 1) { |
| 600 | asix_write_gpio(dev, 0x003c, 30); |
| 601 | asix_write_gpio(dev, 0x001c, 300); |
| 602 | asix_write_gpio(dev, 0x003c, 30); |
| 603 | } else { |
| 604 | dbg("gpio phymode == 1 path"); |
| 605 | asix_write_gpio(dev, AX_GPIO_GPO1EN, 30); |
| 606 | asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30); |
| 607 | } |
| 608 | |
Grant Grundler | b2d3ad29 | 2011-11-15 07:12:42 +0000 | [diff] [blame] | 609 | /* Read PHYID register *AFTER* powering up PHY */ |
| 610 | phyid = asix_get_phyid(dev); |
| 611 | dbg("PHYID=0x%08x", phyid); |
| 612 | |
| 613 | /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */ |
| 614 | asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL); |
| 615 | |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 616 | asix_sw_reset(dev, 0); |
| 617 | msleep(150); |
| 618 | |
| 619 | asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); |
| 620 | msleep(150); |
| 621 | |
| 622 | asix_write_rx_ctl(dev, 0); |
| 623 | |
| 624 | if (data->phymode == PHY_MODE_MARVELL) { |
| 625 | marvell_phy_init(dev); |
| 626 | msleep(60); |
| 627 | } else if (data->phymode == PHY_MODE_RTL8211CL) |
| 628 | rtl8211cl_phy_init(dev); |
| 629 | |
| 630 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, |
| 631 | BMCR_RESET | BMCR_ANENABLE); |
| 632 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, |
| 633 | ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); |
| 634 | asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000, |
| 635 | ADVERTISE_1000FULL); |
| 636 | |
| 637 | mii_nway_restart(&dev->mii); |
| 638 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 639 | ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT); |
| 640 | if (ret < 0) |
| 641 | return ret; |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 642 | |
Jussi Kivilinna | 71bc5d9 | 2012-01-10 06:40:23 +0000 | [diff] [blame] | 643 | /* Rewrite MAC address */ |
| 644 | memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); |
| 645 | ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, |
| 646 | data->mac_addr); |
| 647 | if (ret < 0) |
| 648 | return ret; |
| 649 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 650 | ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); |
| 651 | if (ret < 0) |
| 652 | return ret; |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 653 | |
| 654 | return 0; |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 655 | } |
| 656 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 657 | static int ax88178_link_reset(struct usbnet *dev) |
| 658 | { |
| 659 | u16 mode; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 660 | struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 661 | struct asix_data *data = (struct asix_data *)&dev->data; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 662 | u32 speed; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 663 | |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 664 | netdev_dbg(dev->net, "ax88178_link_reset()\n"); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 665 | |
| 666 | mii_check_media(&dev->mii, 1, 1); |
| 667 | mii_ethtool_gset(&dev->mii, &ecmd); |
| 668 | mode = AX88178_MEDIUM_DEFAULT; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 669 | speed = ethtool_cmd_speed(&ecmd); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 670 | |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 671 | if (speed == SPEED_1000) |
Pantelis Koukousoulas | a7f75c0 | 2008-11-20 01:48:46 -0800 | [diff] [blame] | 672 | mode |= AX_MEDIUM_GM; |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 673 | else if (speed == SPEED_100) |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 674 | mode |= AX_MEDIUM_PS; |
| 675 | else |
| 676 | mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM); |
| 677 | |
Pantelis Koukousoulas | a7f75c0 | 2008-11-20 01:48:46 -0800 | [diff] [blame] | 678 | mode |= AX_MEDIUM_ENCK; |
| 679 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 680 | if (ecmd.duplex == DUPLEX_FULL) |
| 681 | mode |= AX_MEDIUM_FD; |
| 682 | else |
| 683 | mode &= ~AX_MEDIUM_FD; |
| 684 | |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 685 | netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", |
| 686 | speed, ecmd.duplex, mode); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 687 | |
| 688 | asix_write_medium_mode(dev, mode); |
| 689 | |
| 690 | if (data->phymode == PHY_MODE_MARVELL && data->ledmode) |
David Decotigny | 8ae6dac | 2011-04-27 18:32:38 +0000 | [diff] [blame] | 691 | marvell_led_status(dev, speed); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | static void ax88178_set_mfb(struct usbnet *dev) |
| 697 | { |
| 698 | u16 mfb = AX_RX_CTL_MFB_16384; |
| 699 | u16 rxctl; |
| 700 | u16 medium; |
| 701 | int old_rx_urb_size = dev->rx_urb_size; |
| 702 | |
| 703 | if (dev->hard_mtu < 2048) { |
| 704 | dev->rx_urb_size = 2048; |
| 705 | mfb = AX_RX_CTL_MFB_2048; |
| 706 | } else if (dev->hard_mtu < 4096) { |
| 707 | dev->rx_urb_size = 4096; |
| 708 | mfb = AX_RX_CTL_MFB_4096; |
| 709 | } else if (dev->hard_mtu < 8192) { |
| 710 | dev->rx_urb_size = 8192; |
| 711 | mfb = AX_RX_CTL_MFB_8192; |
| 712 | } else if (dev->hard_mtu < 16384) { |
| 713 | dev->rx_urb_size = 16384; |
| 714 | mfb = AX_RX_CTL_MFB_16384; |
| 715 | } |
| 716 | |
| 717 | rxctl = asix_read_rx_ctl(dev); |
| 718 | asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb); |
| 719 | |
| 720 | medium = asix_read_medium_status(dev); |
| 721 | if (dev->net->mtu > 1500) |
| 722 | medium |= AX_MEDIUM_JFE; |
| 723 | else |
| 724 | medium &= ~AX_MEDIUM_JFE; |
| 725 | asix_write_medium_mode(dev, medium); |
| 726 | |
| 727 | if (dev->rx_urb_size > old_rx_urb_size) |
| 728 | usbnet_unlink_rx_urbs(dev); |
| 729 | } |
| 730 | |
| 731 | static int ax88178_change_mtu(struct net_device *net, int new_mtu) |
| 732 | { |
| 733 | struct usbnet *dev = netdev_priv(net); |
| 734 | int ll_mtu = new_mtu + net->hard_header_len + 4; |
| 735 | |
Joe Perches | 60b8675 | 2010-02-17 10:30:23 +0000 | [diff] [blame] | 736 | netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 737 | |
| 738 | if (new_mtu <= 0 || ll_mtu > 16384) |
| 739 | return -EINVAL; |
| 740 | |
| 741 | if ((ll_mtu % dev->maxpacket) == 0) |
| 742 | return -EDOM; |
| 743 | |
| 744 | net->mtu = new_mtu; |
| 745 | dev->hard_mtu = net->mtu + net->hard_header_len; |
| 746 | ax88178_set_mfb(dev); |
| 747 | |
| 748 | return 0; |
| 749 | } |
| 750 | |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 751 | static const struct net_device_ops ax88178_netdev_ops = { |
| 752 | .ndo_open = usbnet_open, |
| 753 | .ndo_stop = usbnet_stop, |
| 754 | .ndo_start_xmit = usbnet_start_xmit, |
| 755 | .ndo_tx_timeout = usbnet_tx_timeout, |
Jussi Kivilinna | 7f29a3b | 2010-03-09 12:24:38 +0000 | [diff] [blame] | 756 | .ndo_set_mac_address = asix_set_mac_address, |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 757 | .ndo_validate_addr = eth_validate_addr, |
Jiri Pirko | afc4b13 | 2011-08-16 06:29:01 +0000 | [diff] [blame] | 758 | .ndo_set_rx_mode = asix_set_multicast, |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 759 | .ndo_do_ioctl = asix_ioctl, |
| 760 | .ndo_change_mtu = ax88178_change_mtu, |
| 761 | }; |
| 762 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 763 | static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) |
| 764 | { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 765 | int ret; |
Al Viro | 51bf297 | 2007-12-22 17:42:36 +0000 | [diff] [blame] | 766 | u8 buf[ETH_ALEN]; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 767 | |
| 768 | usbnet_get_endpoints(dev,intf); |
| 769 | |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 770 | /* Get the MAC address */ |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 771 | ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); |
| 772 | if (ret < 0) { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 773 | dbg("Failed to read MAC address: %d", ret); |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 774 | return ret; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 775 | } |
| 776 | memcpy(dev->net->dev_addr, buf, ETH_ALEN); |
| 777 | |
| 778 | /* Initialize MII structure */ |
| 779 | dev->mii.dev = dev->net; |
| 780 | dev->mii.mdio_read = asix_mdio_read; |
| 781 | dev->mii.mdio_write = asix_mdio_write; |
| 782 | dev->mii.phy_id_mask = 0x1f; |
| 783 | dev->mii.reg_num_mask = 0xff; |
| 784 | dev->mii.supports_gmii = 1; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 785 | dev->mii.phy_id = asix_get_phy_addr(dev); |
Stephen Hemminger | 1703338 | 2009-03-20 19:35:55 +0000 | [diff] [blame] | 786 | |
| 787 | dev->net->netdev_ops = &ax88178_netdev_ops; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 788 | dev->net->ethtool_ops = &ax88178_ethtool_ops; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 789 | |
Grant Grundler | b2d3ad29 | 2011-11-15 07:12:42 +0000 | [diff] [blame] | 790 | /* Blink LEDS so users know driver saw dongle */ |
| 791 | asix_sw_reset(dev, 0); |
| 792 | msleep(150); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 793 | |
Grant Grundler | b2d3ad29 | 2011-11-15 07:12:42 +0000 | [diff] [blame] | 794 | asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); |
| 795 | msleep(150); |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 796 | |
| 797 | /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ |
| 798 | if (dev->driver_info->flags & FLAG_FRAMING_AX) { |
| 799 | /* hard_mtu is still the default - the device does not support |
| 800 | jumbo eth frames */ |
| 801 | dev->rx_urb_size = 2048; |
| 802 | } |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 803 | |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 804 | return 0; |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 805 | } |
| 806 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 807 | static const struct driver_info ax8817x_info = { |
| 808 | .description = "ASIX AX8817x USB 2.0 Ethernet", |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 809 | .bind = ax88172_bind, |
| 810 | .status = asix_status, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 811 | .link_reset = ax88172_link_reset, |
| 812 | .reset = ax88172_link_reset, |
Ben Hutchings | 37e8273 | 2009-11-04 15:29:52 +0000 | [diff] [blame] | 813 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 814 | .data = 0x00130103, |
| 815 | }; |
| 816 | |
| 817 | static const struct driver_info dlink_dub_e100_info = { |
| 818 | .description = "DLink DUB-E100 USB Ethernet", |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 819 | .bind = ax88172_bind, |
| 820 | .status = asix_status, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 821 | .link_reset = ax88172_link_reset, |
| 822 | .reset = ax88172_link_reset, |
Ben Hutchings | 37e8273 | 2009-11-04 15:29:52 +0000 | [diff] [blame] | 823 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 824 | .data = 0x009f9d9f, |
| 825 | }; |
| 826 | |
| 827 | static const struct driver_info netgear_fa120_info = { |
| 828 | .description = "Netgear FA-120 USB Ethernet", |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 829 | .bind = ax88172_bind, |
| 830 | .status = asix_status, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 831 | .link_reset = ax88172_link_reset, |
| 832 | .reset = ax88172_link_reset, |
Ben Hutchings | 37e8273 | 2009-11-04 15:29:52 +0000 | [diff] [blame] | 833 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 834 | .data = 0x00130103, |
| 835 | }; |
| 836 | |
| 837 | static const struct driver_info hawking_uf200_info = { |
| 838 | .description = "Hawking UF200 USB Ethernet", |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 839 | .bind = ax88172_bind, |
| 840 | .status = asix_status, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 841 | .link_reset = ax88172_link_reset, |
| 842 | .reset = ax88172_link_reset, |
Ben Hutchings | 37e8273 | 2009-11-04 15:29:52 +0000 | [diff] [blame] | 843 | .flags = FLAG_ETHER | FLAG_LINK_INTR, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 844 | .data = 0x001f1d1f, |
| 845 | }; |
| 846 | |
| 847 | static const struct driver_info ax88772_info = { |
| 848 | .description = "ASIX AX88772 USB 2.0 Ethernet", |
| 849 | .bind = ax88772_bind, |
David Hollis | 48b1be6 | 2006-03-28 20:15:42 -0500 | [diff] [blame] | 850 | .status = asix_status, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 851 | .link_reset = ax88772_link_reset, |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 852 | .reset = ax88772_reset, |
Eric Dumazet | a9e0aca | 2012-03-14 20:18:32 +0000 | [diff] [blame] | 853 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 854 | .rx_fixup = asix_rx_fixup, |
| 855 | .tx_fixup = asix_tx_fixup, |
| 856 | }; |
| 857 | |
| 858 | static const struct driver_info ax88178_info = { |
| 859 | .description = "ASIX AX88178 USB 2.0 Ethernet", |
| 860 | .bind = ax88178_bind, |
| 861 | .status = asix_status, |
| 862 | .link_reset = ax88178_link_reset, |
Grant Grundler | 610d885 | 2011-10-04 09:55:17 +0000 | [diff] [blame] | 863 | .reset = ax88178_reset, |
Ben Hutchings | 37e8273 | 2009-11-04 15:29:52 +0000 | [diff] [blame] | 864 | .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 865 | .rx_fixup = asix_rx_fixup, |
| 866 | .tx_fixup = asix_tx_fixup, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 867 | }; |
| 868 | |
Christian Riesch | 16626b0 | 2012-07-13 05:26:31 +0000 | [diff] [blame] | 869 | extern const struct driver_info ax88172a_info; |
| 870 | |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 871 | static const struct usb_device_id products [] = { |
| 872 | { |
| 873 | // Linksys USB200M |
| 874 | USB_DEVICE (0x077b, 0x2226), |
| 875 | .driver_info = (unsigned long) &ax8817x_info, |
| 876 | }, { |
| 877 | // Netgear FA120 |
| 878 | USB_DEVICE (0x0846, 0x1040), |
| 879 | .driver_info = (unsigned long) &netgear_fa120_info, |
| 880 | }, { |
| 881 | // DLink DUB-E100 |
| 882 | USB_DEVICE (0x2001, 0x1a00), |
| 883 | .driver_info = (unsigned long) &dlink_dub_e100_info, |
| 884 | }, { |
| 885 | // Intellinet, ST Lab USB Ethernet |
| 886 | USB_DEVICE (0x0b95, 0x1720), |
| 887 | .driver_info = (unsigned long) &ax8817x_info, |
| 888 | }, { |
| 889 | // Hawking UF200, TrendNet TU2-ET100 |
| 890 | USB_DEVICE (0x07b8, 0x420a), |
| 891 | .driver_info = (unsigned long) &hawking_uf200_info, |
| 892 | }, { |
David Hollis | 39c4b38 | 2007-02-20 08:02:24 -0500 | [diff] [blame] | 893 | // Billionton Systems, USB2AR |
| 894 | USB_DEVICE (0x08dd, 0x90ff), |
| 895 | .driver_info = (unsigned long) &ax8817x_info, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 896 | }, { |
| 897 | // ATEN UC210T |
| 898 | USB_DEVICE (0x0557, 0x2009), |
| 899 | .driver_info = (unsigned long) &ax8817x_info, |
| 900 | }, { |
| 901 | // Buffalo LUA-U2-KTX |
| 902 | USB_DEVICE (0x0411, 0x003d), |
| 903 | .driver_info = (unsigned long) &ax8817x_info, |
| 904 | }, { |
Mattia Dongili | ac7b77f | 2008-05-06 20:42:35 -0700 | [diff] [blame] | 905 | // Buffalo LUA-U2-GT 10/100/1000 |
| 906 | USB_DEVICE (0x0411, 0x006e), |
| 907 | .driver_info = (unsigned long) &ax88178_info, |
| 908 | }, { |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 909 | // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" |
| 910 | USB_DEVICE (0x6189, 0x182d), |
| 911 | .driver_info = (unsigned long) &ax8817x_info, |
| 912 | }, { |
Joerg Neikes | 4e50391 | 2012-03-08 22:44:03 +0000 | [diff] [blame] | 913 | // Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter" |
| 914 | USB_DEVICE (0x0df6, 0x0056), |
| 915 | .driver_info = (unsigned long) &ax88178_info, |
| 916 | }, { |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 917 | // corega FEther USB2-TX |
| 918 | USB_DEVICE (0x07aa, 0x0017), |
| 919 | .driver_info = (unsigned long) &ax8817x_info, |
| 920 | }, { |
| 921 | // Surecom EP-1427X-2 |
| 922 | USB_DEVICE (0x1189, 0x0893), |
| 923 | .driver_info = (unsigned long) &ax8817x_info, |
| 924 | }, { |
| 925 | // goodway corp usb gwusb2e |
| 926 | USB_DEVICE (0x1631, 0x6200), |
| 927 | .driver_info = (unsigned long) &ax8817x_info, |
| 928 | }, { |
David Hollis | 39c4b38 | 2007-02-20 08:02:24 -0500 | [diff] [blame] | 929 | // JVC MP-PRX1 Port Replicator |
| 930 | USB_DEVICE (0x04f1, 0x3008), |
| 931 | .driver_info = (unsigned long) &ax8817x_info, |
| 932 | }, { |
Marek Vasut | 3088590 | 2011-07-20 05:57:04 +0000 | [diff] [blame] | 933 | // ASIX AX88772B 10/100 |
| 934 | USB_DEVICE (0x0b95, 0x772b), |
| 935 | .driver_info = (unsigned long) &ax88772_info, |
| 936 | }, { |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 937 | // ASIX AX88772 10/100 |
David Hollis | 39c4b38 | 2007-02-20 08:02:24 -0500 | [diff] [blame] | 938 | USB_DEVICE (0x0b95, 0x7720), |
| 939 | .driver_info = (unsigned long) &ax88772_info, |
David Hollis | 5e0f76c | 2005-12-19 13:58:38 -0500 | [diff] [blame] | 940 | }, { |
Eduard Warkentin | 7327413 | 2006-05-18 01:13:17 -0700 | [diff] [blame] | 941 | // ASIX AX88178 10/100/1000 |
| 942 | USB_DEVICE (0x0b95, 0x1780), |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 943 | .driver_info = (unsigned long) &ax88178_info, |
Eduard Warkentin | 7327413 | 2006-05-18 01:13:17 -0700 | [diff] [blame] | 944 | }, { |
Arnaud Ebalard | f4680d3 | 2010-12-15 12:16:30 +0000 | [diff] [blame] | 945 | // Logitec LAN-GTJ/U2A |
| 946 | USB_DEVICE (0x0789, 0x0160), |
| 947 | .driver_info = (unsigned long) &ax88178_info, |
| 948 | }, { |
David Hollis | 5e0f76c | 2005-12-19 13:58:38 -0500 | [diff] [blame] | 949 | // Linksys USB200M Rev 2 |
| 950 | USB_DEVICE (0x13b1, 0x0018), |
| 951 | .driver_info = (unsigned long) &ax88772_info, |
David Hollis | 5732ce8 | 2006-01-05 14:39:49 -0500 | [diff] [blame] | 952 | }, { |
| 953 | // 0Q0 cable ethernet |
| 954 | USB_DEVICE (0x1557, 0x7720), |
| 955 | .driver_info = (unsigned long) &ax88772_info, |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 956 | }, { |
| 957 | // DLink DUB-E100 H/W Ver B1 |
| 958 | USB_DEVICE (0x07d1, 0x3c05), |
| 959 | .driver_info = (unsigned long) &ax88772_info, |
| 960 | }, { |
David Hollis | b923e7f | 2006-09-21 08:09:29 -0400 | [diff] [blame] | 961 | // DLink DUB-E100 H/W Ver B1 Alternate |
| 962 | USB_DEVICE (0x2001, 0x3c05), |
| 963 | .driver_info = (unsigned long) &ax88772_info, |
| 964 | }, { |
Søren holm | ed3770a | 2012-09-17 21:50:57 +0000 | [diff] [blame] | 965 | // DLink DUB-E100 H/W Ver C1 |
| 966 | USB_DEVICE (0x2001, 0x1a02), |
| 967 | .driver_info = (unsigned long) &ax88772_info, |
| 968 | }, { |
David Hollis | 933a27d | 2006-07-29 10:12:50 -0400 | [diff] [blame] | 969 | // Linksys USB1000 |
| 970 | USB_DEVICE (0x1737, 0x0039), |
| 971 | .driver_info = (unsigned long) &ax88178_info, |
YOSHIFUJI Hideaki / 吉藤英明 | b29cf31 | 2007-01-26 22:57:38 +0900 | [diff] [blame] | 972 | }, { |
| 973 | // IO-DATA ETG-US2 |
| 974 | USB_DEVICE (0x04bb, 0x0930), |
| 975 | .driver_info = (unsigned long) &ax88178_info, |
David Hollis | 2ed22bc | 2007-05-23 07:33:17 -0400 | [diff] [blame] | 976 | }, { |
| 977 | // Belkin F5D5055 |
| 978 | USB_DEVICE(0x050d, 0x5055), |
| 979 | .driver_info = (unsigned long) &ax88178_info, |
Aurelien Nephtali | 3d60efb5 | 2008-05-14 17:04:13 -0700 | [diff] [blame] | 980 | }, { |
| 981 | // Apple USB Ethernet Adapter |
| 982 | USB_DEVICE(0x05ac, 0x1402), |
| 983 | .driver_info = (unsigned long) &ax88772_info, |
Jason Cooper | ccf9540 | 2008-11-11 13:02:53 -0500 | [diff] [blame] | 984 | }, { |
| 985 | // Cables-to-Go USB Ethernet Adapter |
| 986 | USB_DEVICE(0x0b95, 0x772a), |
| 987 | .driver_info = (unsigned long) &ax88772_info, |
Greg Kroah-Hartman | fef7cc0 | 2009-02-24 23:52:24 -0800 | [diff] [blame] | 988 | }, { |
| 989 | // ABOCOM for pci |
| 990 | USB_DEVICE(0x14ea, 0xab11), |
| 991 | .driver_info = (unsigned long) &ax88178_info, |
| 992 | }, { |
| 993 | // ASIX 88772a |
| 994 | USB_DEVICE(0x0db0, 0xa877), |
| 995 | .driver_info = (unsigned long) &ax88772_info, |
Aurelien Jacobs | e8303a3 | 2011-12-16 10:49:22 +0000 | [diff] [blame] | 996 | }, { |
| 997 | // Asus USB Ethernet Adapter |
| 998 | USB_DEVICE (0x0b95, 0x7e2b), |
| 999 | .driver_info = (unsigned long) &ax88772_info, |
Christian Riesch | 16626b0 | 2012-07-13 05:26:31 +0000 | [diff] [blame] | 1000 | }, { |
| 1001 | /* ASIX 88172a demo board */ |
| 1002 | USB_DEVICE(0x0b95, 0x172a), |
| 1003 | .driver_info = (unsigned long) &ax88172a_info, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 1004 | }, |
| 1005 | { }, // END |
| 1006 | }; |
| 1007 | MODULE_DEVICE_TABLE(usb, products); |
| 1008 | |
| 1009 | static struct usb_driver asix_driver = { |
Grant Grundler | 83e1b91 | 2011-10-04 09:55:18 +0000 | [diff] [blame] | 1010 | .name = DRIVER_NAME, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 1011 | .id_table = products, |
| 1012 | .probe = usbnet_probe, |
| 1013 | .suspend = usbnet_suspend, |
| 1014 | .resume = usbnet_resume, |
| 1015 | .disconnect = usbnet_disconnect, |
Oliver Neukum | a11a654 | 2007-08-03 13:52:19 +0200 | [diff] [blame] | 1016 | .supports_autosuspend = 1, |
Sarah Sharp | e1f12eb | 2012-04-23 10:08:51 -0700 | [diff] [blame] | 1017 | .disable_hub_initiated_lpm = 1, |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 1018 | }; |
| 1019 | |
Greg Kroah-Hartman | d632eb1 | 2011-11-18 09:44:20 -0800 | [diff] [blame] | 1020 | module_usb_driver(asix_driver); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 1021 | |
| 1022 | MODULE_AUTHOR("David Hollis"); |
Grant Grundler | 4ad1438 | 2011-10-04 09:55:16 +0000 | [diff] [blame] | 1023 | MODULE_VERSION(DRIVER_VERSION); |
David Brownell | 2e55cc7 | 2005-08-31 09:53:10 -0700 | [diff] [blame] | 1024 | MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices"); |
| 1025 | MODULE_LICENSE("GPL"); |
| 1026 | |