asix.c 43 KB

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