asix.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. /*
  2. * ASIX AX8817X based USB 2.0 Ethernet Devices
  3. * Copyright (C) 2003-2006 David Hollis <dhollis@davehollis.com>
  4. * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
  5. * Copyright (C) 2006 James Painter <jamie.painter@iname.com>
  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. // #define DEBUG // error path messages, extra info
  23. // #define VERBOSE // more; success messages
  24. #include <linux/module.h>
  25. #include <linux/kmod.h>
  26. #include <linux/init.h>
  27. #include <linux/netdevice.h>
  28. #include <linux/etherdevice.h>
  29. #include <linux/ethtool.h>
  30. #include <linux/workqueue.h>
  31. #include <linux/mii.h>
  32. #include <linux/usb.h>
  33. #include <linux/crc32.h>
  34. #include <linux/usb/usbnet.h>
  35. #include <linux/slab.h>
  36. #include <linux/if_vlan.h>
  37. #define DRIVER_VERSION "22-Dec-2011"
  38. #define DRIVER_NAME "asix"
  39. /* ASIX AX8817X based USB 2.0 Ethernet Devices */
  40. #define AX_CMD_SET_SW_MII 0x06
  41. #define AX_CMD_READ_MII_REG 0x07
  42. #define AX_CMD_WRITE_MII_REG 0x08
  43. #define AX_CMD_SET_HW_MII 0x0a
  44. #define AX_CMD_READ_EEPROM 0x0b
  45. #define AX_CMD_WRITE_EEPROM 0x0c
  46. #define AX_CMD_WRITE_ENABLE 0x0d
  47. #define AX_CMD_WRITE_DISABLE 0x0e
  48. #define AX_CMD_READ_RX_CTL 0x0f
  49. #define AX_CMD_WRITE_RX_CTL 0x10
  50. #define AX_CMD_READ_IPG012 0x11
  51. #define AX_CMD_WRITE_IPG0 0x12
  52. #define AX_CMD_WRITE_IPG1 0x13
  53. #define AX_CMD_READ_NODE_ID 0x13
  54. #define AX_CMD_WRITE_NODE_ID 0x14
  55. #define AX_CMD_WRITE_IPG2 0x14
  56. #define AX_CMD_WRITE_MULTI_FILTER 0x16
  57. #define AX88172_CMD_READ_NODE_ID 0x17
  58. #define AX_CMD_READ_PHY_ID 0x19
  59. #define AX_CMD_READ_MEDIUM_STATUS 0x1a
  60. #define AX_CMD_WRITE_MEDIUM_MODE 0x1b
  61. #define AX_CMD_READ_MONITOR_MODE 0x1c
  62. #define AX_CMD_WRITE_MONITOR_MODE 0x1d
  63. #define AX_CMD_READ_GPIOS 0x1e
  64. #define AX_CMD_WRITE_GPIOS 0x1f
  65. #define AX_CMD_SW_RESET 0x20
  66. #define AX_CMD_SW_PHY_STATUS 0x21
  67. #define AX_CMD_SW_PHY_SELECT 0x22
  68. #define AX_MONITOR_MODE 0x01
  69. #define AX_MONITOR_LINK 0x02
  70. #define AX_MONITOR_MAGIC 0x04
  71. #define AX_MONITOR_HSFS 0x10
  72. /* AX88172 Medium Status Register values */
  73. #define AX88172_MEDIUM_FD 0x02
  74. #define AX88172_MEDIUM_TX 0x04
  75. #define AX88172_MEDIUM_FC 0x10
  76. #define AX88172_MEDIUM_DEFAULT \
  77. ( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC )
  78. #define AX_MCAST_FILTER_SIZE 8
  79. #define AX_MAX_MCAST 64
  80. #define AX_SWRESET_CLEAR 0x00
  81. #define AX_SWRESET_RR 0x01
  82. #define AX_SWRESET_RT 0x02
  83. #define AX_SWRESET_PRTE 0x04
  84. #define AX_SWRESET_PRL 0x08
  85. #define AX_SWRESET_BZ 0x10
  86. #define AX_SWRESET_IPRL 0x20
  87. #define AX_SWRESET_IPPD 0x40
  88. #define AX88772_IPG0_DEFAULT 0x15
  89. #define AX88772_IPG1_DEFAULT 0x0c
  90. #define AX88772_IPG2_DEFAULT 0x12
  91. /* AX88772 & AX88178 Medium Mode Register */
  92. #define AX_MEDIUM_PF 0x0080
  93. #define AX_MEDIUM_JFE 0x0040
  94. #define AX_MEDIUM_TFC 0x0020
  95. #define AX_MEDIUM_RFC 0x0010
  96. #define AX_MEDIUM_ENCK 0x0008
  97. #define AX_MEDIUM_AC 0x0004
  98. #define AX_MEDIUM_FD 0x0002
  99. #define AX_MEDIUM_GM 0x0001
  100. #define AX_MEDIUM_SM 0x1000
  101. #define AX_MEDIUM_SBP 0x0800
  102. #define AX_MEDIUM_PS 0x0200
  103. #define AX_MEDIUM_RE 0x0100
  104. #define AX88178_MEDIUM_DEFAULT \
  105. (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
  106. AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
  107. AX_MEDIUM_RE)
  108. #define AX88772_MEDIUM_DEFAULT \
  109. (AX_MEDIUM_FD | AX_MEDIUM_RFC | \
  110. AX_MEDIUM_TFC | AX_MEDIUM_PS | \
  111. AX_MEDIUM_AC | AX_MEDIUM_RE)
  112. /* AX88772 & AX88178 RX_CTL values */
  113. #define AX_RX_CTL_SO 0x0080
  114. #define AX_RX_CTL_AP 0x0020
  115. #define AX_RX_CTL_AM 0x0010
  116. #define AX_RX_CTL_AB 0x0008
  117. #define AX_RX_CTL_SEP 0x0004
  118. #define AX_RX_CTL_AMALL 0x0002
  119. #define AX_RX_CTL_PRO 0x0001
  120. #define AX_RX_CTL_MFB_2048 0x0000
  121. #define AX_RX_CTL_MFB_4096 0x0100
  122. #define AX_RX_CTL_MFB_8192 0x0200
  123. #define AX_RX_CTL_MFB_16384 0x0300
  124. #define AX_DEFAULT_RX_CTL (AX_RX_CTL_SO | AX_RX_CTL_AB)
  125. /* GPIO 0 .. 2 toggles */
  126. #define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
  127. #define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */
  128. #define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */
  129. #define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */
  130. #define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
  131. #define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */
  132. #define AX_GPIO_RESERVED 0x40 /* Reserved */
  133. #define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */
  134. #define AX_EEPROM_MAGIC 0xdeadbeef
  135. #define AX88172_EEPROM_LEN 0x40
  136. #define AX88772_EEPROM_LEN 0xff
  137. #define PHY_MODE_MARVELL 0x0000
  138. #define MII_MARVELL_LED_CTRL 0x0018
  139. #define MII_MARVELL_STATUS 0x001b
  140. #define MII_MARVELL_CTRL 0x0014
  141. #define MARVELL_LED_MANUAL 0x0019
  142. #define MARVELL_STATUS_HWCFG 0x0004
  143. #define MARVELL_CTRL_TXDELAY 0x0002
  144. #define MARVELL_CTRL_RXDELAY 0x0080
  145. #define PHY_MODE_RTL8211CL 0x000C
  146. /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
  147. struct asix_data {
  148. u8 multi_filter[AX_MCAST_FILTER_SIZE];
  149. u8 mac_addr[ETH_ALEN];
  150. u8 phymode;
  151. u8 ledmode;
  152. u8 eeprom_len;
  153. };
  154. struct ax88172_int_data {
  155. __le16 res1;
  156. u8 link;
  157. __le16 res2;
  158. u8 status;
  159. __le16 res3;
  160. } __packed;
  161. static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
  162. u16 size, void *data)
  163. {
  164. void *buf;
  165. int err = -ENOMEM;
  166. netdev_dbg(dev->net, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
  167. cmd, value, index, size);
  168. buf = kmalloc(size, GFP_KERNEL);
  169. if (!buf)
  170. goto out;
  171. err = usb_control_msg(
  172. dev->udev,
  173. usb_rcvctrlpipe(dev->udev, 0),
  174. cmd,
  175. USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  176. value,
  177. index,
  178. buf,
  179. size,
  180. USB_CTRL_GET_TIMEOUT);
  181. if (err == size)
  182. memcpy(data, buf, size);
  183. else if (err >= 0)
  184. err = -EINVAL;
  185. kfree(buf);
  186. out:
  187. return err;
  188. }
  189. static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
  190. u16 size, void *data)
  191. {
  192. void *buf = NULL;
  193. int err = -ENOMEM;
  194. netdev_dbg(dev->net, "asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
  195. cmd, value, index, size);
  196. if (data) {
  197. buf = kmemdup(data, size, GFP_KERNEL);
  198. if (!buf)
  199. goto out;
  200. }
  201. err = usb_control_msg(
  202. dev->udev,
  203. usb_sndctrlpipe(dev->udev, 0),
  204. cmd,
  205. USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
  206. value,
  207. index,
  208. buf,
  209. size,
  210. USB_CTRL_SET_TIMEOUT);
  211. kfree(buf);
  212. out:
  213. return err;
  214. }
  215. static void asix_async_cmd_callback(struct urb *urb)
  216. {
  217. struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
  218. int status = urb->status;
  219. if (status < 0)
  220. printk(KERN_DEBUG "asix_async_cmd_callback() failed with %d",
  221. status);
  222. kfree(req);
  223. usb_free_urb(urb);
  224. }
  225. static void
  226. asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
  227. u16 size, void *data)
  228. {
  229. struct usb_ctrlrequest *req;
  230. int status;
  231. struct urb *urb;
  232. netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
  233. cmd, value, index, size);
  234. urb = usb_alloc_urb(0, GFP_ATOMIC);
  235. if (!urb) {
  236. netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n");
  237. return;
  238. }
  239. req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
  240. if (!req) {
  241. netdev_err(dev->net, "Failed to allocate memory for control request\n");
  242. usb_free_urb(urb);
  243. return;
  244. }
  245. req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
  246. req->bRequest = cmd;
  247. req->wValue = cpu_to_le16(value);
  248. req->wIndex = cpu_to_le16(index);
  249. req->wLength = cpu_to_le16(size);
  250. usb_fill_control_urb(urb, dev->udev,
  251. usb_sndctrlpipe(dev->udev, 0),
  252. (void *)req, data, size,
  253. asix_async_cmd_callback, req);
  254. status = usb_submit_urb(urb, GFP_ATOMIC);
  255. if (status < 0) {
  256. netdev_err(dev->net, "Error submitting the control message: status=%d\n",
  257. status);
  258. kfree(req);
  259. usb_free_urb(urb);
  260. }
  261. }
  262. static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
  263. {
  264. int offset = 0;
  265. while (offset + sizeof(u32) < skb->len) {
  266. struct sk_buff *ax_skb;
  267. u16 size;
  268. u32 header = get_unaligned_le32(skb->data + offset);
  269. offset += sizeof(u32);
  270. /* get the packet length */
  271. size = (u16) (header & 0x7ff);
  272. if (size != ((~header >> 16) & 0x07ff)) {
  273. netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n");
  274. return 0;
  275. }
  276. if ((size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) ||
  277. (size + offset > skb->len)) {
  278. netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
  279. size);
  280. return 0;
  281. }
  282. ax_skb = netdev_alloc_skb_ip_align(dev->net, size);
  283. if (!ax_skb)
  284. return 0;
  285. skb_put(ax_skb, size);
  286. memcpy(ax_skb->data, skb->data + offset, size);
  287. usbnet_skb_return(dev, ax_skb);
  288. offset += (size + 1) & 0xfffe;
  289. }
  290. if (skb->len != offset) {
  291. netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d\n",
  292. skb->len);
  293. return 0;
  294. }
  295. return 1;
  296. }
  297. static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
  298. gfp_t flags)
  299. {
  300. int padlen;
  301. int headroom = skb_headroom(skb);
  302. int tailroom = skb_tailroom(skb);
  303. u32 packet_len;
  304. u32 padbytes = 0xffff0000;
  305. padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4;
  306. /* We need to push 4 bytes in front of frame (packet_len)
  307. * and maybe add 4 bytes after the end (if padlen is 4)
  308. *
  309. * Avoid skb_copy_expand() expensive call, using following rules :
  310. * - We are allowed to push 4 bytes in headroom if skb_header_cloned()
  311. * is false (and if we have 4 bytes of headroom)
  312. * - We are allowed to put 4 bytes at tail if skb_cloned()
  313. * is false (and if we have 4 bytes of tailroom)
  314. *
  315. * TCP packets for example are cloned, but skb_header_release()
  316. * was called in tcp stack, allowing us to use headroom for our needs.
  317. */
  318. if (!skb_header_cloned(skb) &&
  319. !(padlen && skb_cloned(skb)) &&
  320. headroom + tailroom >= 4 + padlen) {
  321. /* following should not happen, but better be safe */
  322. if (headroom < 4 ||
  323. tailroom < padlen) {
  324. skb->data = memmove(skb->head + 4, skb->data, skb->len);
  325. skb_set_tail_pointer(skb, skb->len);
  326. }
  327. } else {
  328. struct sk_buff *skb2;
  329. skb2 = skb_copy_expand(skb, 4, padlen, flags);
  330. dev_kfree_skb_any(skb);
  331. skb = skb2;
  332. if (!skb)
  333. return NULL;
  334. }
  335. packet_len = ((skb->len ^ 0x0000ffff) << 16) + skb->len;
  336. skb_push(skb, 4);
  337. cpu_to_le32s(&packet_len);
  338. skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
  339. if (padlen) {
  340. cpu_to_le32s(&padbytes);
  341. memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
  342. skb_put(skb, sizeof(padbytes));
  343. }
  344. return skb;
  345. }
  346. static void asix_status(struct usbnet *dev, struct urb *urb)
  347. {
  348. struct ax88172_int_data *event;
  349. int link;
  350. if (urb->actual_length < 8)
  351. return;
  352. event = urb->transfer_buffer;
  353. link = event->link & 0x01;
  354. if (netif_carrier_ok(dev->net) != link) {
  355. if (link) {
  356. netif_carrier_on(dev->net);
  357. usbnet_defer_kevent (dev, EVENT_LINK_RESET );
  358. } else
  359. netif_carrier_off(dev->net);
  360. netdev_dbg(dev->net, "Link Status is: %d\n", link);
  361. }
  362. }
  363. static inline int asix_set_sw_mii(struct usbnet *dev)
  364. {
  365. int ret;
  366. ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
  367. if (ret < 0)
  368. netdev_err(dev->net, "Failed to enable software MII access\n");
  369. return ret;
  370. }
  371. static inline int asix_set_hw_mii(struct usbnet *dev)
  372. {
  373. int ret;
  374. ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
  375. if (ret < 0)
  376. netdev_err(dev->net, "Failed to enable hardware MII access\n");
  377. return ret;
  378. }
  379. static inline int asix_get_phy_addr(struct usbnet *dev)
  380. {
  381. u8 buf[2];
  382. int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
  383. netdev_dbg(dev->net, "asix_get_phy_addr()\n");
  384. if (ret < 0) {
  385. netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret);
  386. goto out;
  387. }
  388. netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n",
  389. *((__le16 *)buf));
  390. ret = buf[1];
  391. out:
  392. return ret;
  393. }
  394. static int asix_sw_reset(struct usbnet *dev, u8 flags)
  395. {
  396. int ret;
  397. ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
  398. if (ret < 0)
  399. netdev_err(dev->net, "Failed to send software reset: %02x\n", ret);
  400. return ret;
  401. }
  402. static u16 asix_read_rx_ctl(struct usbnet *dev)
  403. {
  404. __le16 v;
  405. int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v);
  406. if (ret < 0) {
  407. netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret);
  408. goto out;
  409. }
  410. ret = le16_to_cpu(v);
  411. out:
  412. return ret;
  413. }
  414. static int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
  415. {
  416. int ret;
  417. netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode);
  418. ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
  419. if (ret < 0)
  420. netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n",
  421. mode, ret);
  422. return ret;
  423. }
  424. static u16 asix_read_medium_status(struct usbnet *dev)
  425. {
  426. __le16 v;
  427. int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v);
  428. if (ret < 0) {
  429. netdev_err(dev->net, "Error reading Medium Status register: %02x\n",
  430. ret);
  431. return ret; /* TODO: callers not checking for error ret */
  432. }
  433. return le16_to_cpu(v);
  434. }
  435. static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
  436. {
  437. int ret;
  438. netdev_dbg(dev->net, "asix_write_medium_mode() - mode = 0x%04x\n", mode);
  439. ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
  440. if (ret < 0)
  441. netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n",
  442. mode, ret);
  443. return ret;
  444. }
  445. static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
  446. {
  447. int ret;
  448. netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value);
  449. ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
  450. if (ret < 0)
  451. netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n",
  452. value, ret);
  453. if (sleep)
  454. msleep(sleep);
  455. return ret;
  456. }
  457. /*
  458. * AX88772 & AX88178 have a 16-bit RX_CTL value
  459. */
  460. static void asix_set_multicast(struct net_device *net)
  461. {
  462. struct usbnet *dev = netdev_priv(net);
  463. struct asix_data *data = (struct asix_data *)&dev->data;
  464. u16 rx_ctl = AX_DEFAULT_RX_CTL;
  465. if (net->flags & IFF_PROMISC) {
  466. rx_ctl |= AX_RX_CTL_PRO;
  467. } else if (net->flags & IFF_ALLMULTI ||
  468. netdev_mc_count(net) > AX_MAX_MCAST) {
  469. rx_ctl |= AX_RX_CTL_AMALL;
  470. } else if (netdev_mc_empty(net)) {
  471. /* just broadcast and directed */
  472. } else {
  473. /* We use the 20 byte dev->data
  474. * for our 8 byte filter buffer
  475. * to avoid allocating memory that
  476. * is tricky to free later */
  477. struct netdev_hw_addr *ha;
  478. u32 crc_bits;
  479. memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
  480. /* Build the multicast hash filter. */
  481. netdev_for_each_mc_addr(ha, net) {
  482. crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
  483. data->multi_filter[crc_bits >> 3] |=
  484. 1 << (crc_bits & 7);
  485. }
  486. asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
  487. AX_MCAST_FILTER_SIZE, data->multi_filter);
  488. rx_ctl |= AX_RX_CTL_AM;
  489. }
  490. asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
  491. }
  492. static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
  493. {
  494. struct usbnet *dev = netdev_priv(netdev);
  495. __le16 res;
  496. mutex_lock(&dev->phy_mutex);
  497. asix_set_sw_mii(dev);
  498. asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
  499. (__u16)loc, 2, &res);
  500. asix_set_hw_mii(dev);
  501. mutex_unlock(&dev->phy_mutex);
  502. netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
  503. phy_id, loc, le16_to_cpu(res));
  504. return le16_to_cpu(res);
  505. }
  506. static void
  507. asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
  508. {
  509. struct usbnet *dev = netdev_priv(netdev);
  510. __le16 res = cpu_to_le16(val);
  511. netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
  512. phy_id, loc, val);
  513. mutex_lock(&dev->phy_mutex);
  514. asix_set_sw_mii(dev);
  515. asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
  516. asix_set_hw_mii(dev);
  517. mutex_unlock(&dev->phy_mutex);
  518. }
  519. /* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
  520. static u32 asix_get_phyid(struct usbnet *dev)
  521. {
  522. int phy_reg;
  523. u32 phy_id;
  524. int i;
  525. /* Poll for the rare case the FW or phy isn't ready yet. */
  526. for (i = 0; i < 100; i++) {
  527. phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
  528. if (phy_reg != 0 && phy_reg != 0xFFFF)
  529. break;
  530. mdelay(1);
  531. }
  532. if (phy_reg <= 0 || phy_reg == 0xFFFF)
  533. return 0;
  534. phy_id = (phy_reg & 0xffff) << 16;
  535. phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
  536. if (phy_reg < 0)
  537. return 0;
  538. phy_id |= (phy_reg & 0xffff);
  539. return phy_id;
  540. }
  541. static void
  542. asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
  543. {
  544. struct usbnet *dev = netdev_priv(net);
  545. u8 opt;
  546. if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) {
  547. wolinfo->supported = 0;
  548. wolinfo->wolopts = 0;
  549. return;
  550. }
  551. wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
  552. wolinfo->wolopts = 0;
  553. if (opt & AX_MONITOR_LINK)
  554. wolinfo->wolopts |= WAKE_PHY;
  555. if (opt & AX_MONITOR_MAGIC)
  556. wolinfo->wolopts |= WAKE_MAGIC;
  557. }
  558. static int
  559. asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
  560. {
  561. struct usbnet *dev = netdev_priv(net);
  562. u8 opt = 0;
  563. if (wolinfo->wolopts & WAKE_PHY)
  564. opt |= AX_MONITOR_LINK;
  565. if (wolinfo->wolopts & WAKE_MAGIC)
  566. opt |= AX_MONITOR_MAGIC;
  567. if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE,
  568. opt, 0, 0, NULL) < 0)
  569. return -EINVAL;
  570. return 0;
  571. }
  572. static int asix_get_eeprom_len(struct net_device *net)
  573. {
  574. struct usbnet *dev = netdev_priv(net);
  575. struct asix_data *data = (struct asix_data *)&dev->data;
  576. return data->eeprom_len;
  577. }
  578. static int asix_get_eeprom(struct net_device *net,
  579. struct ethtool_eeprom *eeprom, u8 *data)
  580. {
  581. struct usbnet *dev = netdev_priv(net);
  582. __le16 *ebuf = (__le16 *)data;
  583. int i;
  584. /* Crude hack to ensure that we don't overwrite memory
  585. * if an odd length is supplied
  586. */
  587. if (eeprom->len % 2)
  588. return -EINVAL;
  589. eeprom->magic = AX_EEPROM_MAGIC;
  590. /* ax8817x returns 2 bytes from eeprom on read */
  591. for (i=0; i < eeprom->len / 2; i++) {
  592. if (asix_read_cmd(dev, AX_CMD_READ_EEPROM,
  593. eeprom->offset + i, 0, 2, &ebuf[i]) < 0)
  594. return -EINVAL;
  595. }
  596. return 0;
  597. }
  598. static void asix_get_drvinfo (struct net_device *net,
  599. struct ethtool_drvinfo *info)
  600. {
  601. struct usbnet *dev = netdev_priv(net);
  602. struct asix_data *data = (struct asix_data *)&dev->data;
  603. /* Inherit standard device info */
  604. usbnet_get_drvinfo(net, info);
  605. strncpy (info->driver, DRIVER_NAME, sizeof info->driver);
  606. strncpy (info->version, DRIVER_VERSION, sizeof info->version);
  607. info->eedump_len = data->eeprom_len;
  608. }
  609. static u32 asix_get_link(struct net_device *net)
  610. {
  611. struct usbnet *dev = netdev_priv(net);
  612. return mii_link_ok(&dev->mii);
  613. }
  614. static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
  615. {
  616. struct usbnet *dev = netdev_priv(net);
  617. return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
  618. }
  619. static int asix_set_mac_address(struct net_device *net, void *p)
  620. {
  621. struct usbnet *dev = netdev_priv(net);
  622. struct asix_data *data = (struct asix_data *)&dev->data;
  623. struct sockaddr *addr = p;
  624. if (netif_running(net))
  625. return -EBUSY;
  626. if (!is_valid_ether_addr(addr->sa_data))
  627. return -EADDRNOTAVAIL;
  628. memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
  629. /* We use the 20 byte dev->data
  630. * for our 6 byte mac buffer
  631. * to avoid allocating memory that
  632. * is tricky to free later */
  633. memcpy(data->mac_addr, addr->sa_data, ETH_ALEN);
  634. asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
  635. data->mac_addr);
  636. return 0;
  637. }
  638. /* We need to override some ethtool_ops so we require our
  639. own structure so we don't interfere with other usbnet
  640. devices that may be connected at the same time. */
  641. static const struct ethtool_ops ax88172_ethtool_ops = {
  642. .get_drvinfo = asix_get_drvinfo,
  643. .get_link = asix_get_link,
  644. .get_msglevel = usbnet_get_msglevel,
  645. .set_msglevel = usbnet_set_msglevel,
  646. .get_wol = asix_get_wol,
  647. .set_wol = asix_set_wol,
  648. .get_eeprom_len = asix_get_eeprom_len,
  649. .get_eeprom = asix_get_eeprom,
  650. .get_settings = usbnet_get_settings,
  651. .set_settings = usbnet_set_settings,
  652. .nway_reset = usbnet_nway_reset,
  653. };
  654. static void ax88172_set_multicast(struct net_device *net)
  655. {
  656. struct usbnet *dev = netdev_priv(net);
  657. struct asix_data *data = (struct asix_data *)&dev->data;
  658. u8 rx_ctl = 0x8c;
  659. if (net->flags & IFF_PROMISC) {
  660. rx_ctl |= 0x01;
  661. } else if (net->flags & IFF_ALLMULTI ||
  662. netdev_mc_count(net) > AX_MAX_MCAST) {
  663. rx_ctl |= 0x02;
  664. } else if (netdev_mc_empty(net)) {
  665. /* just broadcast and directed */
  666. } else {
  667. /* We use the 20 byte dev->data
  668. * for our 8 byte filter buffer
  669. * to avoid allocating memory that
  670. * is tricky to free later */
  671. struct netdev_hw_addr *ha;
  672. u32 crc_bits;
  673. memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
  674. /* Build the multicast hash filter. */
  675. netdev_for_each_mc_addr(ha, net) {
  676. crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
  677. data->multi_filter[crc_bits >> 3] |=
  678. 1 << (crc_bits & 7);
  679. }
  680. asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
  681. AX_MCAST_FILTER_SIZE, data->multi_filter);
  682. rx_ctl |= 0x10;
  683. }
  684. asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
  685. }
  686. static int ax88172_link_reset(struct usbnet *dev)
  687. {
  688. u8 mode;
  689. struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
  690. mii_check_media(&dev->mii, 1, 1);
  691. mii_ethtool_gset(&dev->mii, &ecmd);
  692. mode = AX88172_MEDIUM_DEFAULT;
  693. if (ecmd.duplex != DUPLEX_FULL)
  694. mode |= ~AX88172_MEDIUM_FD;
  695. netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
  696. ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
  697. asix_write_medium_mode(dev, mode);
  698. return 0;
  699. }
  700. static const struct net_device_ops ax88172_netdev_ops = {
  701. .ndo_open = usbnet_open,
  702. .ndo_stop = usbnet_stop,
  703. .ndo_start_xmit = usbnet_start_xmit,
  704. .ndo_tx_timeout = usbnet_tx_timeout,
  705. .ndo_change_mtu = usbnet_change_mtu,
  706. .ndo_set_mac_address = eth_mac_addr,
  707. .ndo_validate_addr = eth_validate_addr,
  708. .ndo_do_ioctl = asix_ioctl,
  709. .ndo_set_rx_mode = ax88172_set_multicast,
  710. };
  711. static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
  712. {
  713. int ret = 0;
  714. u8 buf[ETH_ALEN];
  715. int i;
  716. unsigned long gpio_bits = dev->driver_info->data;
  717. struct asix_data *data = (struct asix_data *)&dev->data;
  718. data->eeprom_len = AX88172_EEPROM_LEN;
  719. usbnet_get_endpoints(dev,intf);
  720. /* Toggle the GPIOs in a manufacturer/model specific way */
  721. for (i = 2; i >= 0; i--) {
  722. ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS,
  723. (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL);
  724. if (ret < 0)
  725. goto out;
  726. msleep(5);
  727. }
  728. ret = asix_write_rx_ctl(dev, 0x80);
  729. if (ret < 0)
  730. goto out;
  731. /* Get the MAC address */
  732. ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
  733. if (ret < 0) {
  734. dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
  735. goto out;
  736. }
  737. memcpy(dev->net->dev_addr, buf, ETH_ALEN);
  738. /* Initialize MII structure */
  739. dev->mii.dev = dev->net;
  740. dev->mii.mdio_read = asix_mdio_read;
  741. dev->mii.mdio_write = asix_mdio_write;
  742. dev->mii.phy_id_mask = 0x3f;
  743. dev->mii.reg_num_mask = 0x1f;
  744. dev->mii.phy_id = asix_get_phy_addr(dev);
  745. dev->net->netdev_ops = &ax88172_netdev_ops;
  746. dev->net->ethtool_ops = &ax88172_ethtool_ops;
  747. dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */
  748. dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */
  749. asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
  750. asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
  751. ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
  752. mii_nway_restart(&dev->mii);
  753. return 0;
  754. out:
  755. return ret;
  756. }
  757. static const struct ethtool_ops ax88772_ethtool_ops = {
  758. .get_drvinfo = asix_get_drvinfo,
  759. .get_link = asix_get_link,
  760. .get_msglevel = usbnet_get_msglevel,
  761. .set_msglevel = usbnet_set_msglevel,
  762. .get_wol = asix_get_wol,
  763. .set_wol = asix_set_wol,
  764. .get_eeprom_len = asix_get_eeprom_len,
  765. .get_eeprom = asix_get_eeprom,
  766. .get_settings = usbnet_get_settings,
  767. .set_settings = usbnet_set_settings,
  768. .nway_reset = usbnet_nway_reset,
  769. };
  770. static int ax88772_link_reset(struct usbnet *dev)
  771. {
  772. u16 mode;
  773. struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
  774. mii_check_media(&dev->mii, 1, 1);
  775. mii_ethtool_gset(&dev->mii, &ecmd);
  776. mode = AX88772_MEDIUM_DEFAULT;
  777. if (ethtool_cmd_speed(&ecmd) != SPEED_100)
  778. mode &= ~AX_MEDIUM_PS;
  779. if (ecmd.duplex != DUPLEX_FULL)
  780. mode &= ~AX_MEDIUM_FD;
  781. netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
  782. ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
  783. asix_write_medium_mode(dev, mode);
  784. return 0;
  785. }
  786. static int ax88772_reset(struct usbnet *dev)
  787. {
  788. struct asix_data *data = (struct asix_data *)&dev->data;
  789. int ret, embd_phy;
  790. u16 rx_ctl;
  791. ret = asix_write_gpio(dev,
  792. AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5);
  793. if (ret < 0)
  794. goto out;
  795. embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
  796. ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
  797. if (ret < 0) {
  798. dbg("Select PHY #1 failed: %d", ret);
  799. goto out;
  800. }
  801. ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL);
  802. if (ret < 0)
  803. goto out;
  804. msleep(150);
  805. ret = asix_sw_reset(dev, AX_SWRESET_CLEAR);
  806. if (ret < 0)
  807. goto out;
  808. msleep(150);
  809. if (embd_phy) {
  810. ret = asix_sw_reset(dev, AX_SWRESET_IPRL);
  811. if (ret < 0)
  812. goto out;
  813. } else {
  814. ret = asix_sw_reset(dev, AX_SWRESET_PRTE);
  815. if (ret < 0)
  816. goto out;
  817. }
  818. msleep(150);
  819. rx_ctl = asix_read_rx_ctl(dev);
  820. dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
  821. ret = asix_write_rx_ctl(dev, 0x0000);
  822. if (ret < 0)
  823. goto out;
  824. rx_ctl = asix_read_rx_ctl(dev);
  825. dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
  826. ret = asix_sw_reset(dev, AX_SWRESET_PRL);
  827. if (ret < 0)
  828. goto out;
  829. msleep(150);
  830. ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL);
  831. if (ret < 0)
  832. goto out;
  833. msleep(150);
  834. asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
  835. asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
  836. ADVERTISE_ALL | ADVERTISE_CSMA);
  837. mii_nway_restart(&dev->mii);
  838. ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT);
  839. if (ret < 0)
  840. goto out;
  841. ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
  842. AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
  843. AX88772_IPG2_DEFAULT, 0, NULL);
  844. if (ret < 0) {
  845. dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
  846. goto out;
  847. }
  848. /* Rewrite MAC address */
  849. memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
  850. ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
  851. data->mac_addr);
  852. if (ret < 0)
  853. goto out;
  854. /* Set RX_CTL to default values with 2k buffer, and enable cactus */
  855. ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
  856. if (ret < 0)
  857. goto out;
  858. rx_ctl = asix_read_rx_ctl(dev);
  859. dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
  860. rx_ctl = asix_read_medium_status(dev);
  861. dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
  862. return 0;
  863. out:
  864. return ret;
  865. }
  866. static const struct net_device_ops ax88772_netdev_ops = {
  867. .ndo_open = usbnet_open,
  868. .ndo_stop = usbnet_stop,
  869. .ndo_start_xmit = usbnet_start_xmit,
  870. .ndo_tx_timeout = usbnet_tx_timeout,
  871. .ndo_change_mtu = usbnet_change_mtu,
  872. .ndo_set_mac_address = asix_set_mac_address,
  873. .ndo_validate_addr = eth_validate_addr,
  874. .ndo_do_ioctl = asix_ioctl,
  875. .ndo_set_rx_mode = asix_set_multicast,
  876. };
  877. static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
  878. {
  879. int ret, embd_phy;
  880. struct asix_data *data = (struct asix_data *)&dev->data;
  881. u8 buf[ETH_ALEN];
  882. u32 phyid;
  883. data->eeprom_len = AX88772_EEPROM_LEN;
  884. usbnet_get_endpoints(dev,intf);
  885. /* Get the MAC address */
  886. ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
  887. if (ret < 0) {
  888. dbg("Failed to read MAC address: %d", ret);
  889. return ret;
  890. }
  891. memcpy(dev->net->dev_addr, buf, ETH_ALEN);
  892. /* Initialize MII structure */
  893. dev->mii.dev = dev->net;
  894. dev->mii.mdio_read = asix_mdio_read;
  895. dev->mii.mdio_write = asix_mdio_write;
  896. dev->mii.phy_id_mask = 0x1f;
  897. dev->mii.reg_num_mask = 0x1f;
  898. dev->mii.phy_id = asix_get_phy_addr(dev);
  899. dev->net->netdev_ops = &ax88772_netdev_ops;
  900. dev->net->ethtool_ops = &ax88772_ethtool_ops;
  901. dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */
  902. dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */
  903. embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0);
  904. /* Reset the PHY to normal operation mode */
  905. ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
  906. if (ret < 0) {
  907. dbg("Select PHY #1 failed: %d", ret);
  908. return ret;
  909. }
  910. ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL);
  911. if (ret < 0)
  912. return ret;
  913. msleep(150);
  914. ret = asix_sw_reset(dev, AX_SWRESET_CLEAR);
  915. if (ret < 0)
  916. return ret;
  917. msleep(150);
  918. ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_PRTE);
  919. /* Read PHYID register *AFTER* the PHY was reset properly */
  920. phyid = asix_get_phyid(dev);
  921. dbg("PHYID=0x%08x", phyid);
  922. /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
  923. if (dev->driver_info->flags & FLAG_FRAMING_AX) {
  924. /* hard_mtu is still the default - the device does not support
  925. jumbo eth frames */
  926. dev->rx_urb_size = 2048;
  927. }
  928. return 0;
  929. }
  930. static const struct ethtool_ops ax88178_ethtool_ops = {
  931. .get_drvinfo = asix_get_drvinfo,
  932. .get_link = asix_get_link,
  933. .get_msglevel = usbnet_get_msglevel,
  934. .set_msglevel = usbnet_set_msglevel,
  935. .get_wol = asix_get_wol,
  936. .set_wol = asix_set_wol,
  937. .get_eeprom_len = asix_get_eeprom_len,
  938. .get_eeprom = asix_get_eeprom,
  939. .get_settings = usbnet_get_settings,
  940. .set_settings = usbnet_set_settings,
  941. .nway_reset = usbnet_nway_reset,
  942. };
  943. static int marvell_phy_init(struct usbnet *dev)
  944. {
  945. struct asix_data *data = (struct asix_data *)&dev->data;
  946. u16 reg;
  947. netdev_dbg(dev->net, "marvell_phy_init()\n");
  948. reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS);
  949. netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg);
  950. asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL,
  951. MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY);
  952. if (data->ledmode) {
  953. reg = asix_mdio_read(dev->net, dev->mii.phy_id,
  954. MII_MARVELL_LED_CTRL);
  955. netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (1) = 0x%04x\n", reg);
  956. reg &= 0xf8ff;
  957. reg |= (1 + 0x0100);
  958. asix_mdio_write(dev->net, dev->mii.phy_id,
  959. MII_MARVELL_LED_CTRL, reg);
  960. reg = asix_mdio_read(dev->net, dev->mii.phy_id,
  961. MII_MARVELL_LED_CTRL);
  962. netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (2) = 0x%04x\n", reg);
  963. reg &= 0xfc0f;
  964. }
  965. return 0;
  966. }
  967. static int rtl8211cl_phy_init(struct usbnet *dev)
  968. {
  969. struct asix_data *data = (struct asix_data *)&dev->data;
  970. netdev_dbg(dev->net, "rtl8211cl_phy_init()\n");
  971. asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0005);
  972. asix_mdio_write (dev->net, dev->mii.phy_id, 0x0c, 0);
  973. asix_mdio_write (dev->net, dev->mii.phy_id, 0x01,
  974. asix_mdio_read (dev->net, dev->mii.phy_id, 0x01) | 0x0080);
  975. asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0);
  976. if (data->ledmode == 12) {
  977. asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0002);
  978. asix_mdio_write (dev->net, dev->mii.phy_id, 0x1a, 0x00cb);
  979. asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0);
  980. }
  981. return 0;
  982. }
  983. static int marvell_led_status(struct usbnet *dev, u16 speed)
  984. {
  985. u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL);
  986. netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg);
  987. /* Clear out the center LED bits - 0x03F0 */
  988. reg &= 0xfc0f;
  989. switch (speed) {
  990. case SPEED_1000:
  991. reg |= 0x03e0;
  992. break;
  993. case SPEED_100:
  994. reg |= 0x03b0;
  995. break;
  996. default:
  997. reg |= 0x02f0;
  998. }
  999. netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg);
  1000. asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg);
  1001. return 0;
  1002. }
  1003. static int ax88178_reset(struct usbnet *dev)
  1004. {
  1005. struct asix_data *data = (struct asix_data *)&dev->data;
  1006. int ret;
  1007. __le16 eeprom;
  1008. u8 status;
  1009. int gpio0 = 0;
  1010. u32 phyid;
  1011. asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status);
  1012. dbg("GPIO Status: 0x%04x", status);
  1013. asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
  1014. asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
  1015. asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);
  1016. dbg("EEPROM index 0x17 is 0x%04x", eeprom);
  1017. if (eeprom == cpu_to_le16(0xffff)) {
  1018. data->phymode = PHY_MODE_MARVELL;
  1019. data->ledmode = 0;
  1020. gpio0 = 1;
  1021. } else {
  1022. data->phymode = le16_to_cpu(eeprom) & 0x7F;
  1023. data->ledmode = le16_to_cpu(eeprom) >> 8;
  1024. gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1;
  1025. }
  1026. dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
  1027. /* Power up external GigaPHY through AX88178 GPIO pin */
  1028. asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
  1029. if ((le16_to_cpu(eeprom) >> 8) != 1) {
  1030. asix_write_gpio(dev, 0x003c, 30);
  1031. asix_write_gpio(dev, 0x001c, 300);
  1032. asix_write_gpio(dev, 0x003c, 30);
  1033. } else {
  1034. dbg("gpio phymode == 1 path");
  1035. asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
  1036. asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
  1037. }
  1038. /* Read PHYID register *AFTER* powering up PHY */
  1039. phyid = asix_get_phyid(dev);
  1040. dbg("PHYID=0x%08x", phyid);
  1041. /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */
  1042. asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL);
  1043. asix_sw_reset(dev, 0);
  1044. msleep(150);
  1045. asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD);
  1046. msleep(150);
  1047. asix_write_rx_ctl(dev, 0);
  1048. if (data->phymode == PHY_MODE_MARVELL) {
  1049. marvell_phy_init(dev);
  1050. msleep(60);
  1051. } else if (data->phymode == PHY_MODE_RTL8211CL)
  1052. rtl8211cl_phy_init(dev);
  1053. asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
  1054. BMCR_RESET | BMCR_ANENABLE);
  1055. asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
  1056. ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
  1057. asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
  1058. ADVERTISE_1000FULL);
  1059. mii_nway_restart(&dev->mii);
  1060. ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT);
  1061. if (ret < 0)
  1062. return ret;
  1063. /* Rewrite MAC address */
  1064. memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
  1065. ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
  1066. data->mac_addr);
  1067. if (ret < 0)
  1068. return ret;
  1069. ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
  1070. if (ret < 0)
  1071. return ret;
  1072. return 0;
  1073. }
  1074. static int ax88178_link_reset(struct usbnet *dev)
  1075. {
  1076. u16 mode;
  1077. struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
  1078. struct asix_data *data = (struct asix_data *)&dev->data;
  1079. u32 speed;
  1080. netdev_dbg(dev->net, "ax88178_link_reset()\n");
  1081. mii_check_media(&dev->mii, 1, 1);
  1082. mii_ethtool_gset(&dev->mii, &ecmd);
  1083. mode = AX88178_MEDIUM_DEFAULT;
  1084. speed = ethtool_cmd_speed(&ecmd);
  1085. if (speed == SPEED_1000)
  1086. mode |= AX_MEDIUM_GM;
  1087. else if (speed == SPEED_100)
  1088. mode |= AX_MEDIUM_PS;
  1089. else
  1090. mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
  1091. mode |= AX_MEDIUM_ENCK;
  1092. if (ecmd.duplex == DUPLEX_FULL)
  1093. mode |= AX_MEDIUM_FD;
  1094. else
  1095. mode &= ~AX_MEDIUM_FD;
  1096. netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n",
  1097. speed, ecmd.duplex, mode);
  1098. asix_write_medium_mode(dev, mode);
  1099. if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
  1100. marvell_led_status(dev, speed);
  1101. return 0;
  1102. }
  1103. static void ax88178_set_mfb(struct usbnet *dev)
  1104. {
  1105. u16 mfb = AX_RX_CTL_MFB_16384;
  1106. u16 rxctl;
  1107. u16 medium;
  1108. int old_rx_urb_size = dev->rx_urb_size;
  1109. if (dev->hard_mtu < 2048) {
  1110. dev->rx_urb_size = 2048;
  1111. mfb = AX_RX_CTL_MFB_2048;
  1112. } else if (dev->hard_mtu < 4096) {
  1113. dev->rx_urb_size = 4096;
  1114. mfb = AX_RX_CTL_MFB_4096;
  1115. } else if (dev->hard_mtu < 8192) {
  1116. dev->rx_urb_size = 8192;
  1117. mfb = AX_RX_CTL_MFB_8192;
  1118. } else if (dev->hard_mtu < 16384) {
  1119. dev->rx_urb_size = 16384;
  1120. mfb = AX_RX_CTL_MFB_16384;
  1121. }
  1122. rxctl = asix_read_rx_ctl(dev);
  1123. asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb);
  1124. medium = asix_read_medium_status(dev);
  1125. if (dev->net->mtu > 1500)
  1126. medium |= AX_MEDIUM_JFE;
  1127. else
  1128. medium &= ~AX_MEDIUM_JFE;
  1129. asix_write_medium_mode(dev, medium);
  1130. if (dev->rx_urb_size > old_rx_urb_size)
  1131. usbnet_unlink_rx_urbs(dev);
  1132. }
  1133. static int ax88178_change_mtu(struct net_device *net, int new_mtu)
  1134. {
  1135. struct usbnet *dev = netdev_priv(net);
  1136. int ll_mtu = new_mtu + net->hard_header_len + 4;
  1137. netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu);
  1138. if (new_mtu <= 0 || ll_mtu > 16384)
  1139. return -EINVAL;
  1140. if ((ll_mtu % dev->maxpacket) == 0)
  1141. return -EDOM;
  1142. net->mtu = new_mtu;
  1143. dev->hard_mtu = net->mtu + net->hard_header_len;
  1144. ax88178_set_mfb(dev);
  1145. return 0;
  1146. }
  1147. static const struct net_device_ops ax88178_netdev_ops = {
  1148. .ndo_open = usbnet_open,
  1149. .ndo_stop = usbnet_stop,
  1150. .ndo_start_xmit = usbnet_start_xmit,
  1151. .ndo_tx_timeout = usbnet_tx_timeout,
  1152. .ndo_set_mac_address = asix_set_mac_address,
  1153. .ndo_validate_addr = eth_validate_addr,
  1154. .ndo_set_rx_mode = asix_set_multicast,
  1155. .ndo_do_ioctl = asix_ioctl,
  1156. .ndo_change_mtu = ax88178_change_mtu,
  1157. };
  1158. static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
  1159. {
  1160. int ret;
  1161. u8 buf[ETH_ALEN];
  1162. struct asix_data *data = (struct asix_data *)&dev->data;
  1163. data->eeprom_len = AX88772_EEPROM_LEN;
  1164. usbnet_get_endpoints(dev,intf);
  1165. /* Get the MAC address */
  1166. ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
  1167. if (ret < 0) {
  1168. dbg("Failed to read MAC address: %d", ret);
  1169. return ret;
  1170. }
  1171. memcpy(dev->net->dev_addr, buf, ETH_ALEN);
  1172. /* Initialize MII structure */
  1173. dev->mii.dev = dev->net;
  1174. dev->mii.mdio_read = asix_mdio_read;
  1175. dev->mii.mdio_write = asix_mdio_write;
  1176. dev->mii.phy_id_mask = 0x1f;
  1177. dev->mii.reg_num_mask = 0xff;
  1178. dev->mii.supports_gmii = 1;
  1179. dev->mii.phy_id = asix_get_phy_addr(dev);
  1180. dev->net->netdev_ops = &ax88178_netdev_ops;
  1181. dev->net->ethtool_ops = &ax88178_ethtool_ops;
  1182. /* Blink LEDS so users know driver saw dongle */
  1183. asix_sw_reset(dev, 0);
  1184. msleep(150);
  1185. asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD);
  1186. msleep(150);
  1187. /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
  1188. if (dev->driver_info->flags & FLAG_FRAMING_AX) {
  1189. /* hard_mtu is still the default - the device does not support
  1190. jumbo eth frames */
  1191. dev->rx_urb_size = 2048;
  1192. }
  1193. return 0;
  1194. }
  1195. static const struct driver_info ax8817x_info = {
  1196. .description = "ASIX AX8817x USB 2.0 Ethernet",
  1197. .bind = ax88172_bind,
  1198. .status = asix_status,
  1199. .link_reset = ax88172_link_reset,
  1200. .reset = ax88172_link_reset,
  1201. .flags = FLAG_ETHER | FLAG_LINK_INTR,
  1202. .data = 0x00130103,
  1203. };
  1204. static const struct driver_info dlink_dub_e100_info = {
  1205. .description = "DLink DUB-E100 USB Ethernet",
  1206. .bind = ax88172_bind,
  1207. .status = asix_status,
  1208. .link_reset = ax88172_link_reset,
  1209. .reset = ax88172_link_reset,
  1210. .flags = FLAG_ETHER | FLAG_LINK_INTR,
  1211. .data = 0x009f9d9f,
  1212. };
  1213. static const struct driver_info netgear_fa120_info = {
  1214. .description = "Netgear FA-120 USB Ethernet",
  1215. .bind = ax88172_bind,
  1216. .status = asix_status,
  1217. .link_reset = ax88172_link_reset,
  1218. .reset = ax88172_link_reset,
  1219. .flags = FLAG_ETHER | FLAG_LINK_INTR,
  1220. .data = 0x00130103,
  1221. };
  1222. static const struct driver_info hawking_uf200_info = {
  1223. .description = "Hawking UF200 USB Ethernet",
  1224. .bind = ax88172_bind,
  1225. .status = asix_status,
  1226. .link_reset = ax88172_link_reset,
  1227. .reset = ax88172_link_reset,
  1228. .flags = FLAG_ETHER | FLAG_LINK_INTR,
  1229. .data = 0x001f1d1f,
  1230. };
  1231. static const struct driver_info ax88772_info = {
  1232. .description = "ASIX AX88772 USB 2.0 Ethernet",
  1233. .bind = ax88772_bind,
  1234. .status = asix_status,
  1235. .link_reset = ax88772_link_reset,
  1236. .reset = ax88772_reset,
  1237. .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET,
  1238. .rx_fixup = asix_rx_fixup,
  1239. .tx_fixup = asix_tx_fixup,
  1240. };
  1241. static const struct driver_info ax88178_info = {
  1242. .description = "ASIX AX88178 USB 2.0 Ethernet",
  1243. .bind = ax88178_bind,
  1244. .status = asix_status,
  1245. .link_reset = ax88178_link_reset,
  1246. .reset = ax88178_reset,
  1247. .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR,
  1248. .rx_fixup = asix_rx_fixup,
  1249. .tx_fixup = asix_tx_fixup,
  1250. };
  1251. static const struct usb_device_id products [] = {
  1252. {
  1253. // Linksys USB200M
  1254. USB_DEVICE (0x077b, 0x2226),
  1255. .driver_info = (unsigned long) &ax8817x_info,
  1256. }, {
  1257. // Netgear FA120
  1258. USB_DEVICE (0x0846, 0x1040),
  1259. .driver_info = (unsigned long) &netgear_fa120_info,
  1260. }, {
  1261. // DLink DUB-E100
  1262. USB_DEVICE (0x2001, 0x1a00),
  1263. .driver_info = (unsigned long) &dlink_dub_e100_info,
  1264. }, {
  1265. // Intellinet, ST Lab USB Ethernet
  1266. USB_DEVICE (0x0b95, 0x1720),
  1267. .driver_info = (unsigned long) &ax8817x_info,
  1268. }, {
  1269. // Hawking UF200, TrendNet TU2-ET100
  1270. USB_DEVICE (0x07b8, 0x420a),
  1271. .driver_info = (unsigned long) &hawking_uf200_info,
  1272. }, {
  1273. // Billionton Systems, USB2AR
  1274. USB_DEVICE (0x08dd, 0x90ff),
  1275. .driver_info = (unsigned long) &ax8817x_info,
  1276. }, {
  1277. // ATEN UC210T
  1278. USB_DEVICE (0x0557, 0x2009),
  1279. .driver_info = (unsigned long) &ax8817x_info,
  1280. }, {
  1281. // Buffalo LUA-U2-KTX
  1282. USB_DEVICE (0x0411, 0x003d),
  1283. .driver_info = (unsigned long) &ax8817x_info,
  1284. }, {
  1285. // Buffalo LUA-U2-GT 10/100/1000
  1286. USB_DEVICE (0x0411, 0x006e),
  1287. .driver_info = (unsigned long) &ax88178_info,
  1288. }, {
  1289. // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
  1290. USB_DEVICE (0x6189, 0x182d),
  1291. .driver_info = (unsigned long) &ax8817x_info,
  1292. }, {
  1293. // Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter"
  1294. USB_DEVICE (0x0df6, 0x0056),
  1295. .driver_info = (unsigned long) &ax88178_info,
  1296. }, {
  1297. // corega FEther USB2-TX
  1298. USB_DEVICE (0x07aa, 0x0017),
  1299. .driver_info = (unsigned long) &ax8817x_info,
  1300. }, {
  1301. // Surecom EP-1427X-2
  1302. USB_DEVICE (0x1189, 0x0893),
  1303. .driver_info = (unsigned long) &ax8817x_info,
  1304. }, {
  1305. // goodway corp usb gwusb2e
  1306. USB_DEVICE (0x1631, 0x6200),
  1307. .driver_info = (unsigned long) &ax8817x_info,
  1308. }, {
  1309. // JVC MP-PRX1 Port Replicator
  1310. USB_DEVICE (0x04f1, 0x3008),
  1311. .driver_info = (unsigned long) &ax8817x_info,
  1312. }, {
  1313. // ASIX AX88772B 10/100
  1314. USB_DEVICE (0x0b95, 0x772b),
  1315. .driver_info = (unsigned long) &ax88772_info,
  1316. }, {
  1317. // ASIX AX88772 10/100
  1318. USB_DEVICE (0x0b95, 0x7720),
  1319. .driver_info = (unsigned long) &ax88772_info,
  1320. }, {
  1321. // ASIX AX88178 10/100/1000
  1322. USB_DEVICE (0x0b95, 0x1780),
  1323. .driver_info = (unsigned long) &ax88178_info,
  1324. }, {
  1325. // Logitec LAN-GTJ/U2A
  1326. USB_DEVICE (0x0789, 0x0160),
  1327. .driver_info = (unsigned long) &ax88178_info,
  1328. }, {
  1329. // Linksys USB200M Rev 2
  1330. USB_DEVICE (0x13b1, 0x0018),
  1331. .driver_info = (unsigned long) &ax88772_info,
  1332. }, {
  1333. // 0Q0 cable ethernet
  1334. USB_DEVICE (0x1557, 0x7720),
  1335. .driver_info = (unsigned long) &ax88772_info,
  1336. }, {
  1337. // DLink DUB-E100 H/W Ver B1
  1338. USB_DEVICE (0x07d1, 0x3c05),
  1339. .driver_info = (unsigned long) &ax88772_info,
  1340. }, {
  1341. // DLink DUB-E100 H/W Ver B1 Alternate
  1342. USB_DEVICE (0x2001, 0x3c05),
  1343. .driver_info = (unsigned long) &ax88772_info,
  1344. }, {
  1345. // Linksys USB1000
  1346. USB_DEVICE (0x1737, 0x0039),
  1347. .driver_info = (unsigned long) &ax88178_info,
  1348. }, {
  1349. // IO-DATA ETG-US2
  1350. USB_DEVICE (0x04bb, 0x0930),
  1351. .driver_info = (unsigned long) &ax88178_info,
  1352. }, {
  1353. // Belkin F5D5055
  1354. USB_DEVICE(0x050d, 0x5055),
  1355. .driver_info = (unsigned long) &ax88178_info,
  1356. }, {
  1357. // Apple USB Ethernet Adapter
  1358. USB_DEVICE(0x05ac, 0x1402),
  1359. .driver_info = (unsigned long) &ax88772_info,
  1360. }, {
  1361. // Cables-to-Go USB Ethernet Adapter
  1362. USB_DEVICE(0x0b95, 0x772a),
  1363. .driver_info = (unsigned long) &ax88772_info,
  1364. }, {
  1365. // ABOCOM for pci
  1366. USB_DEVICE(0x14ea, 0xab11),
  1367. .driver_info = (unsigned long) &ax88178_info,
  1368. }, {
  1369. // ASIX 88772a
  1370. USB_DEVICE(0x0db0, 0xa877),
  1371. .driver_info = (unsigned long) &ax88772_info,
  1372. }, {
  1373. // Asus USB Ethernet Adapter
  1374. USB_DEVICE (0x0b95, 0x7e2b),
  1375. .driver_info = (unsigned long) &ax88772_info,
  1376. },
  1377. { }, // END
  1378. };
  1379. MODULE_DEVICE_TABLE(usb, products);
  1380. static struct usb_driver asix_driver = {
  1381. .name = DRIVER_NAME,
  1382. .id_table = products,
  1383. .probe = usbnet_probe,
  1384. .suspend = usbnet_suspend,
  1385. .resume = usbnet_resume,
  1386. .disconnect = usbnet_disconnect,
  1387. .supports_autosuspend = 1,
  1388. .disable_hub_initiated_lpm = 1,
  1389. };
  1390. module_usb_driver(asix_driver);
  1391. MODULE_AUTHOR("David Hollis");
  1392. MODULE_VERSION(DRIVER_VERSION);
  1393. MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices");
  1394. MODULE_LICENSE("GPL");