mcs7830.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * MOSCHIP MCS7830 based (7730/7830/7832) USB 2.0 Ethernet Devices
  4. *
  5. * based on usbnet.c, asix.c and the vendor provided mcs7830 driver
  6. *
  7. * Copyright (C) 2010 Andreas Mohr <andi@lisas.de>
  8. * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>
  9. * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
  10. * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
  11. * Copyright (c) 2002-2003 TiVo Inc.
  12. *
  13. * Definitions gathered from MOSCHIP, Data Sheet_7830DA.pdf (thanks!).
  14. *
  15. * 2010-12-19: add 7832 USB PID ("functionality same as MCS7830"),
  16. * per active notification by manufacturer
  17. *
  18. * TODO:
  19. * - support HIF_REG_CONFIG_SLEEPMODE/HIF_REG_CONFIG_TXENABLE (via autopm?)
  20. * - implement ethtool_ops get_pauseparam/set_pauseparam
  21. * via HIF_REG_PAUSE_THRESHOLD (>= revision C only!)
  22. * - implement get_eeprom/[set_eeprom]
  23. * - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII)
  24. * - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs,
  25. * can access only ~ 24, remaining user buffer is uninitialized garbage
  26. * - anything else?
  27. */
  28. #include <linux/crc32.h>
  29. #include <linux/etherdevice.h>
  30. #include <linux/ethtool.h>
  31. #include <linux/mii.h>
  32. #include <linux/module.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/slab.h>
  35. #include <linux/usb.h>
  36. #include <linux/usb/usbnet.h>
  37. /* requests */
  38. #define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \
  39. USB_RECIP_DEVICE)
  40. #define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \
  41. USB_RECIP_DEVICE)
  42. #define MCS7830_RD_BREQ 0x0E
  43. #define MCS7830_WR_BREQ 0x0D
  44. #define MCS7830_CTRL_TIMEOUT 1000
  45. #define MCS7830_MAX_MCAST 64
  46. #define MCS7830_VENDOR_ID 0x9710
  47. #define MCS7832_PRODUCT_ID 0x7832
  48. #define MCS7830_PRODUCT_ID 0x7830
  49. #define MCS7730_PRODUCT_ID 0x7730
  50. #define SITECOM_VENDOR_ID 0x0DF6
  51. #define LN_030_PRODUCT_ID 0x0021
  52. #define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \
  53. ADVERTISE_100HALF | ADVERTISE_10FULL | \
  54. ADVERTISE_10HALF | ADVERTISE_CSMA)
  55. /* HIF_REG_XX corresponding index value */
  56. enum {
  57. HIF_REG_MULTICAST_HASH = 0x00,
  58. HIF_REG_PACKET_GAP1 = 0x08,
  59. HIF_REG_PACKET_GAP2 = 0x09,
  60. HIF_REG_PHY_DATA = 0x0a,
  61. HIF_REG_PHY_CMD1 = 0x0c,
  62. HIF_REG_PHY_CMD1_READ = 0x40,
  63. HIF_REG_PHY_CMD1_WRITE = 0x20,
  64. HIF_REG_PHY_CMD1_PHYADDR = 0x01,
  65. HIF_REG_PHY_CMD2 = 0x0d,
  66. HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80,
  67. HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40,
  68. HIF_REG_CONFIG = 0x0e,
  69. /* hmm, spec sez: "R/W", "Except bit 3" (likely TXENABLE). */
  70. HIF_REG_CONFIG_CFG = 0x80,
  71. HIF_REG_CONFIG_SPEED100 = 0x40,
  72. HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20,
  73. HIF_REG_CONFIG_RXENABLE = 0x10,
  74. HIF_REG_CONFIG_TXENABLE = 0x08,
  75. HIF_REG_CONFIG_SLEEPMODE = 0x04,
  76. HIF_REG_CONFIG_ALLMULTICAST = 0x02,
  77. HIF_REG_CONFIG_PROMISCUOUS = 0x01,
  78. HIF_REG_ETHERNET_ADDR = 0x0f,
  79. HIF_REG_FRAME_DROP_COUNTER = 0x15, /* 0..ff; reset: 0 */
  80. HIF_REG_PAUSE_THRESHOLD = 0x16,
  81. HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0,
  82. };
  83. /* Trailing status byte in Ethernet Rx frame */
  84. enum {
  85. MCS7830_RX_SHORT_FRAME = 0x01, /* < 64 bytes */
  86. MCS7830_RX_LENGTH_ERROR = 0x02, /* framelen != Ethernet length field */
  87. MCS7830_RX_ALIGNMENT_ERROR = 0x04, /* non-even number of nibbles */
  88. MCS7830_RX_CRC_ERROR = 0x08,
  89. MCS7830_RX_LARGE_FRAME = 0x10, /* > 1518 bytes */
  90. MCS7830_RX_FRAME_CORRECT = 0x20, /* frame is correct */
  91. /* [7:6] reserved */
  92. };
  93. struct mcs7830_data {
  94. u8 multi_filter[8];
  95. u8 config;
  96. };
  97. static const char driver_name[] = "MOSCHIP usb-ethernet driver";
  98. static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
  99. {
  100. return usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ,
  101. 0x0000, index, data, size);
  102. }
  103. static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data)
  104. {
  105. return usbnet_write_cmd(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ,
  106. 0x0000, index, data, size);
  107. }
  108. static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
  109. {
  110. usbnet_write_cmd_async(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ,
  111. 0x0000, index, data, size);
  112. }
  113. static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr)
  114. {
  115. int ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr);
  116. if (ret < 0)
  117. return ret;
  118. return 0;
  119. }
  120. static int mcs7830_hif_set_mac_address(struct usbnet *dev, unsigned char *addr)
  121. {
  122. int ret = mcs7830_set_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr);
  123. if (ret < 0)
  124. return ret;
  125. return 0;
  126. }
  127. static int mcs7830_set_mac_address(struct net_device *netdev, void *p)
  128. {
  129. int ret;
  130. struct usbnet *dev = netdev_priv(netdev);
  131. struct sockaddr *addr = p;
  132. if (netif_running(netdev))
  133. return -EBUSY;
  134. if (!is_valid_ether_addr(addr->sa_data))
  135. return -EADDRNOTAVAIL;
  136. ret = mcs7830_hif_set_mac_address(dev, addr->sa_data);
  137. if (ret < 0)
  138. return ret;
  139. /* it worked --> adopt it on netdev side */
  140. memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
  141. return 0;
  142. }
  143. static int mcs7830_read_phy(struct usbnet *dev, u8 index)
  144. {
  145. int ret;
  146. int i;
  147. __le16 val;
  148. u8 cmd[2] = {
  149. HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR,
  150. HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index,
  151. };
  152. mutex_lock(&dev->phy_mutex);
  153. /* write the MII command */
  154. ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
  155. if (ret < 0)
  156. goto out;
  157. /* wait for the data to become valid, should be within < 1ms */
  158. for (i = 0; i < 10; i++) {
  159. ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
  160. if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
  161. break;
  162. ret = -EIO;
  163. msleep(1);
  164. }
  165. if (ret < 0)
  166. goto out;
  167. /* read actual register contents */
  168. ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val);
  169. if (ret < 0)
  170. goto out;
  171. ret = le16_to_cpu(val);
  172. dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n",
  173. index, val, i);
  174. out:
  175. mutex_unlock(&dev->phy_mutex);
  176. return ret;
  177. }
  178. static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
  179. {
  180. int ret;
  181. int i;
  182. __le16 le_val;
  183. u8 cmd[2] = {
  184. HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR,
  185. HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F),
  186. };
  187. mutex_lock(&dev->phy_mutex);
  188. /* write the new register contents */
  189. le_val = cpu_to_le16(val);
  190. ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val);
  191. if (ret < 0)
  192. goto out;
  193. /* write the MII command */
  194. ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
  195. if (ret < 0)
  196. goto out;
  197. /* wait for the command to be accepted by the PHY */
  198. for (i = 0; i < 10; i++) {
  199. ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
  200. if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
  201. break;
  202. ret = -EIO;
  203. msleep(1);
  204. }
  205. if (ret < 0)
  206. goto out;
  207. ret = 0;
  208. dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n",
  209. index, val, i);
  210. out:
  211. mutex_unlock(&dev->phy_mutex);
  212. return ret;
  213. }
  214. /*
  215. * This algorithm comes from the original mcs7830 version 1.4 driver,
  216. * not sure if it is needed.
  217. */
  218. static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
  219. {
  220. int ret;
  221. /* Enable all media types */
  222. ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
  223. /* First reset BMCR */
  224. if (!ret)
  225. ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
  226. /* Enable Auto Neg */
  227. if (!ret)
  228. ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
  229. /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */
  230. if (!ret)
  231. ret = mcs7830_write_phy(dev, MII_BMCR,
  232. BMCR_ANENABLE | BMCR_ANRESTART );
  233. return ret;
  234. }
  235. /*
  236. * if we can read register 22, the chip revision is C or higher
  237. */
  238. static int mcs7830_get_rev(struct usbnet *dev)
  239. {
  240. u8 dummy[2];
  241. int ret;
  242. ret = mcs7830_get_reg(dev, HIF_REG_FRAME_DROP_COUNTER, 2, dummy);
  243. if (ret > 0)
  244. return 2; /* Rev C or later */
  245. return 1; /* earlier revision */
  246. }
  247. /*
  248. * On rev. C we need to set the pause threshold
  249. */
  250. static void mcs7830_rev_C_fixup(struct usbnet *dev)
  251. {
  252. u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT;
  253. int retry;
  254. for (retry = 0; retry < 2; retry++) {
  255. if (mcs7830_get_rev(dev) == 2) {
  256. dev_info(&dev->udev->dev, "applying rev.C fixup\n");
  257. mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD,
  258. 1, &pause_threshold);
  259. }
  260. msleep(1);
  261. }
  262. }
  263. static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
  264. int location)
  265. {
  266. struct usbnet *dev = netdev_priv(netdev);
  267. return mcs7830_read_phy(dev, location);
  268. }
  269. static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
  270. int location, int val)
  271. {
  272. struct usbnet *dev = netdev_priv(netdev);
  273. mcs7830_write_phy(dev, location, val);
  274. }
  275. static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
  276. {
  277. struct usbnet *dev = netdev_priv(net);
  278. return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
  279. }
  280. static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev)
  281. {
  282. return (struct mcs7830_data *)&dev->data;
  283. }
  284. static void mcs7830_hif_update_multicast_hash(struct usbnet *dev)
  285. {
  286. struct mcs7830_data *data = mcs7830_get_data(dev);
  287. mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH,
  288. sizeof data->multi_filter,
  289. data->multi_filter);
  290. }
  291. static void mcs7830_hif_update_config(struct usbnet *dev)
  292. {
  293. /* implementation specific to data->config
  294. (argument needs to be heap-based anyway - USB DMA!) */
  295. struct mcs7830_data *data = mcs7830_get_data(dev);
  296. mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config);
  297. }
  298. static void mcs7830_data_set_multicast(struct net_device *net)
  299. {
  300. struct usbnet *dev = netdev_priv(net);
  301. struct mcs7830_data *data = mcs7830_get_data(dev);
  302. memset(data->multi_filter, 0, sizeof data->multi_filter);
  303. data->config = HIF_REG_CONFIG_TXENABLE;
  304. /* this should not be needed, but it doesn't work otherwise */
  305. data->config |= HIF_REG_CONFIG_ALLMULTICAST;
  306. if (net->flags & IFF_PROMISC) {
  307. data->config |= HIF_REG_CONFIG_PROMISCUOUS;
  308. } else if (net->flags & IFF_ALLMULTI ||
  309. netdev_mc_count(net) > MCS7830_MAX_MCAST) {
  310. data->config |= HIF_REG_CONFIG_ALLMULTICAST;
  311. } else if (netdev_mc_empty(net)) {
  312. /* just broadcast and directed */
  313. } else {
  314. /* We use the 20 byte dev->data
  315. * for our 8 byte filter buffer
  316. * to avoid allocating memory that
  317. * is tricky to free later */
  318. struct netdev_hw_addr *ha;
  319. u32 crc_bits;
  320. /* Build the multicast hash filter. */
  321. netdev_for_each_mc_addr(ha, net) {
  322. crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
  323. data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
  324. }
  325. }
  326. }
  327. static int mcs7830_apply_base_config(struct usbnet *dev)
  328. {
  329. int ret;
  330. /* re-configure known MAC (suspend case etc.) */
  331. ret = mcs7830_hif_set_mac_address(dev, dev->net->dev_addr);
  332. if (ret) {
  333. dev_info(&dev->udev->dev, "Cannot set MAC address\n");
  334. goto out;
  335. }
  336. /* Set up PHY */
  337. ret = mcs7830_set_autoneg(dev, 0);
  338. if (ret) {
  339. dev_info(&dev->udev->dev, "Cannot set autoneg\n");
  340. goto out;
  341. }
  342. mcs7830_hif_update_multicast_hash(dev);
  343. mcs7830_hif_update_config(dev);
  344. mcs7830_rev_C_fixup(dev);
  345. ret = 0;
  346. out:
  347. return ret;
  348. }
  349. /* credits go to asix_set_multicast */
  350. static void mcs7830_set_multicast(struct net_device *net)
  351. {
  352. struct usbnet *dev = netdev_priv(net);
  353. mcs7830_data_set_multicast(net);
  354. mcs7830_hif_update_multicast_hash(dev);
  355. mcs7830_hif_update_config(dev);
  356. }
  357. static int mcs7830_get_regs_len(struct net_device *net)
  358. {
  359. struct usbnet *dev = netdev_priv(net);
  360. switch (mcs7830_get_rev(dev)) {
  361. case 1:
  362. return 21;
  363. case 2:
  364. return 32;
  365. }
  366. return 0;
  367. }
  368. static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo)
  369. {
  370. usbnet_get_drvinfo(net, drvinfo);
  371. }
  372. static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
  373. {
  374. struct usbnet *dev = netdev_priv(net);
  375. regs->version = mcs7830_get_rev(dev);
  376. mcs7830_get_reg(dev, 0, regs->len, data);
  377. }
  378. static const struct ethtool_ops mcs7830_ethtool_ops = {
  379. .get_drvinfo = mcs7830_get_drvinfo,
  380. .get_regs_len = mcs7830_get_regs_len,
  381. .get_regs = mcs7830_get_regs,
  382. /* common usbnet calls */
  383. .get_link = usbnet_get_link,
  384. .get_msglevel = usbnet_get_msglevel,
  385. .set_msglevel = usbnet_set_msglevel,
  386. .nway_reset = usbnet_nway_reset,
  387. .get_link_ksettings = usbnet_get_link_ksettings,
  388. .set_link_ksettings = usbnet_set_link_ksettings,
  389. };
  390. static const struct net_device_ops mcs7830_netdev_ops = {
  391. .ndo_open = usbnet_open,
  392. .ndo_stop = usbnet_stop,
  393. .ndo_start_xmit = usbnet_start_xmit,
  394. .ndo_tx_timeout = usbnet_tx_timeout,
  395. .ndo_change_mtu = usbnet_change_mtu,
  396. .ndo_get_stats64 = usbnet_get_stats64,
  397. .ndo_validate_addr = eth_validate_addr,
  398. .ndo_do_ioctl = mcs7830_ioctl,
  399. .ndo_set_rx_mode = mcs7830_set_multicast,
  400. .ndo_set_mac_address = mcs7830_set_mac_address,
  401. };
  402. static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
  403. {
  404. struct net_device *net = dev->net;
  405. int ret;
  406. int retry;
  407. /* Initial startup: Gather MAC address setting from EEPROM */
  408. ret = -EINVAL;
  409. for (retry = 0; retry < 5 && ret; retry++)
  410. ret = mcs7830_hif_get_mac_address(dev, net->dev_addr);
  411. if (ret) {
  412. dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
  413. goto out;
  414. }
  415. mcs7830_data_set_multicast(net);
  416. ret = mcs7830_apply_base_config(dev);
  417. if (ret)
  418. goto out;
  419. net->ethtool_ops = &mcs7830_ethtool_ops;
  420. net->netdev_ops = &mcs7830_netdev_ops;
  421. /* reserve space for the status byte on rx */
  422. dev->rx_urb_size = ETH_FRAME_LEN + 1;
  423. dev->mii.mdio_read = mcs7830_mdio_read;
  424. dev->mii.mdio_write = mcs7830_mdio_write;
  425. dev->mii.dev = net;
  426. dev->mii.phy_id_mask = 0x3f;
  427. dev->mii.reg_num_mask = 0x1f;
  428. dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
  429. ret = usbnet_get_endpoints(dev, udev);
  430. out:
  431. return ret;
  432. }
  433. /* The chip always appends a status byte that we need to strip */
  434. static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
  435. {
  436. u8 status;
  437. /* This check is no longer done by usbnet */
  438. if (skb->len < dev->net->hard_header_len) {
  439. dev_err(&dev->udev->dev, "unexpected tiny rx frame\n");
  440. return 0;
  441. }
  442. skb_trim(skb, skb->len - 1);
  443. status = skb->data[skb->len];
  444. if (status != MCS7830_RX_FRAME_CORRECT) {
  445. dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status);
  446. /* hmm, perhaps usbnet.c already sees a globally visible
  447. frame error and increments rx_errors on its own already? */
  448. dev->net->stats.rx_errors++;
  449. if (status & (MCS7830_RX_SHORT_FRAME
  450. |MCS7830_RX_LENGTH_ERROR
  451. |MCS7830_RX_LARGE_FRAME))
  452. dev->net->stats.rx_length_errors++;
  453. if (status & MCS7830_RX_ALIGNMENT_ERROR)
  454. dev->net->stats.rx_frame_errors++;
  455. if (status & MCS7830_RX_CRC_ERROR)
  456. dev->net->stats.rx_crc_errors++;
  457. }
  458. return skb->len > 0;
  459. }
  460. static void mcs7830_status(struct usbnet *dev, struct urb *urb)
  461. {
  462. u8 *buf = urb->transfer_buffer;
  463. bool link, link_changed;
  464. if (urb->actual_length < 16)
  465. return;
  466. link = !(buf[1] == 0x20);
  467. link_changed = netif_carrier_ok(dev->net) != link;
  468. if (link_changed) {
  469. usbnet_link_change(dev, link, 0);
  470. netdev_dbg(dev->net, "Link Status is: %d\n", link);
  471. }
  472. }
  473. static const struct driver_info moschip_info = {
  474. .description = "MOSCHIP 7830/7832/7730 usb-NET adapter",
  475. .bind = mcs7830_bind,
  476. .rx_fixup = mcs7830_rx_fixup,
  477. .flags = FLAG_ETHER | FLAG_LINK_INTR,
  478. .status = mcs7830_status,
  479. .in = 1,
  480. .out = 2,
  481. };
  482. static const struct driver_info sitecom_info = {
  483. .description = "Sitecom LN-30 usb-NET adapter",
  484. .bind = mcs7830_bind,
  485. .rx_fixup = mcs7830_rx_fixup,
  486. .flags = FLAG_ETHER | FLAG_LINK_INTR,
  487. .status = mcs7830_status,
  488. .in = 1,
  489. .out = 2,
  490. };
  491. static const struct usb_device_id products[] = {
  492. {
  493. USB_DEVICE(MCS7830_VENDOR_ID, MCS7832_PRODUCT_ID),
  494. .driver_info = (unsigned long) &moschip_info,
  495. },
  496. {
  497. USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID),
  498. .driver_info = (unsigned long) &moschip_info,
  499. },
  500. {
  501. USB_DEVICE(MCS7830_VENDOR_ID, MCS7730_PRODUCT_ID),
  502. .driver_info = (unsigned long) &moschip_info,
  503. },
  504. {
  505. USB_DEVICE(SITECOM_VENDOR_ID, LN_030_PRODUCT_ID),
  506. .driver_info = (unsigned long) &sitecom_info,
  507. },
  508. {},
  509. };
  510. MODULE_DEVICE_TABLE(usb, products);
  511. static int mcs7830_reset_resume (struct usb_interface *intf)
  512. {
  513. /* YES, this function is successful enough that ethtool -d
  514. does show same output pre-/post-suspend */
  515. struct usbnet *dev = usb_get_intfdata(intf);
  516. mcs7830_apply_base_config(dev);
  517. usbnet_resume(intf);
  518. return 0;
  519. }
  520. static struct usb_driver mcs7830_driver = {
  521. .name = driver_name,
  522. .id_table = products,
  523. .probe = usbnet_probe,
  524. .disconnect = usbnet_disconnect,
  525. .suspend = usbnet_suspend,
  526. .resume = usbnet_resume,
  527. .reset_resume = mcs7830_reset_resume,
  528. .disable_hub_initiated_lpm = 1,
  529. };
  530. module_usb_driver(mcs7830_driver);
  531. MODULE_DESCRIPTION("USB to network adapter MCS7830)");
  532. MODULE_LICENSE("GPL");