rt2800usb.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. Copyright (C) 2010 Willow Garage <http://www.willowgarage.com>
  4. Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
  5. Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de>
  6. Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
  7. Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com>
  8. Copyright (C) 2009 Axel Kollhofer <rain_maker@root-forum.org>
  9. <http://rt2x00.serialmonkey.com>
  10. */
  11. /*
  12. Module: rt2800usb
  13. Abstract: rt2800usb device specific routines.
  14. Supported chipsets: RT2800U.
  15. */
  16. #include <linux/delay.h>
  17. #include <linux/etherdevice.h>
  18. #include <linux/kernel.h>
  19. #include <linux/module.h>
  20. #include <linux/usb.h>
  21. #include "rt2x00.h"
  22. #include "rt2x00usb.h"
  23. #include "rt2800lib.h"
  24. #include "rt2800.h"
  25. #include "rt2800usb.h"
  26. /*
  27. * Allow hardware encryption to be disabled.
  28. */
  29. static bool modparam_nohwcrypt;
  30. module_param_named(nohwcrypt, modparam_nohwcrypt, bool, 0444);
  31. MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
  32. static bool rt2800usb_hwcrypt_disabled(struct rt2x00_dev *rt2x00dev)
  33. {
  34. return modparam_nohwcrypt;
  35. }
  36. /*
  37. * Queue handlers.
  38. */
  39. static void rt2800usb_start_queue(struct data_queue *queue)
  40. {
  41. struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
  42. u32 reg;
  43. switch (queue->qid) {
  44. case QID_RX:
  45. reg = rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL);
  46. rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
  47. rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
  48. break;
  49. case QID_BEACON:
  50. reg = rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG);
  51. rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
  52. rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
  53. rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
  54. rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
  55. break;
  56. default:
  57. break;
  58. }
  59. }
  60. static void rt2800usb_stop_queue(struct data_queue *queue)
  61. {
  62. struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
  63. u32 reg;
  64. switch (queue->qid) {
  65. case QID_RX:
  66. reg = rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL);
  67. rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
  68. rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
  69. break;
  70. case QID_BEACON:
  71. reg = rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG);
  72. rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
  73. rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
  74. rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
  75. rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
  76. break;
  77. default:
  78. break;
  79. }
  80. }
  81. #define TXSTATUS_READ_INTERVAL 1000000
  82. static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
  83. int urb_status, u32 tx_status)
  84. {
  85. bool valid;
  86. if (urb_status) {
  87. rt2x00_warn(rt2x00dev, "TX status read failed %d\n",
  88. urb_status);
  89. goto stop_reading;
  90. }
  91. valid = rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID);
  92. if (valid) {
  93. if (!kfifo_put(&rt2x00dev->txstatus_fifo, tx_status))
  94. rt2x00_warn(rt2x00dev, "TX status FIFO overrun\n");
  95. queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
  96. /* Reschedule urb to read TX status again instantly */
  97. return true;
  98. }
  99. /* Check if there is any entry that timedout waiting on TX status */
  100. if (rt2800_txstatus_timeout(rt2x00dev))
  101. queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
  102. if (rt2800_txstatus_pending(rt2x00dev)) {
  103. /* Read register after 1 ms */
  104. hrtimer_start(&rt2x00dev->txstatus_timer,
  105. TXSTATUS_READ_INTERVAL,
  106. HRTIMER_MODE_REL);
  107. return false;
  108. }
  109. stop_reading:
  110. clear_bit(TX_STATUS_READING, &rt2x00dev->flags);
  111. /*
  112. * There is small race window above, between txstatus pending check and
  113. * clear_bit someone could do rt2x00usb_interrupt_txdone, so recheck
  114. * here again if status reading is needed.
  115. */
  116. if (rt2800_txstatus_pending(rt2x00dev) &&
  117. !test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags))
  118. return true;
  119. else
  120. return false;
  121. }
  122. static void rt2800usb_async_read_tx_status(struct rt2x00_dev *rt2x00dev)
  123. {
  124. if (test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags))
  125. return;
  126. /* Read TX_STA_FIFO register after 2 ms */
  127. hrtimer_start(&rt2x00dev->txstatus_timer,
  128. 2 * TXSTATUS_READ_INTERVAL,
  129. HRTIMER_MODE_REL);
  130. }
  131. static void rt2800usb_tx_dma_done(struct queue_entry *entry)
  132. {
  133. struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
  134. rt2800usb_async_read_tx_status(rt2x00dev);
  135. }
  136. static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *timer)
  137. {
  138. struct rt2x00_dev *rt2x00dev =
  139. container_of(timer, struct rt2x00_dev, txstatus_timer);
  140. rt2x00usb_register_read_async(rt2x00dev, TX_STA_FIFO,
  141. rt2800usb_tx_sta_fifo_read_completed);
  142. return HRTIMER_NORESTART;
  143. }
  144. /*
  145. * Firmware functions
  146. */
  147. static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev)
  148. {
  149. __le32 *reg;
  150. u32 fw_mode;
  151. int ret;
  152. reg = kmalloc_obj(*reg);
  153. if (reg == NULL)
  154. return -ENOMEM;
  155. /* cannot use rt2x00usb_register_read here as it uses different
  156. * mode (MULTI_READ vs. DEVICE_MODE) and does not pass the
  157. * magic value USB_MODE_AUTORUN (0x11) to the device, thus the
  158. * returned value would be invalid.
  159. */
  160. ret = rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
  161. USB_VENDOR_REQUEST_IN, 0,
  162. USB_MODE_AUTORUN, reg, sizeof(*reg),
  163. REGISTER_TIMEOUT_FIRMWARE);
  164. fw_mode = le32_to_cpu(*reg);
  165. kfree(reg);
  166. if (ret < 0)
  167. return ret;
  168. if ((fw_mode & 0x00000003) == 2)
  169. return 1;
  170. return 0;
  171. }
  172. static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
  173. {
  174. return FIRMWARE_RT2870;
  175. }
  176. static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
  177. const u8 *data, const size_t len)
  178. {
  179. int status;
  180. u32 offset;
  181. u32 length;
  182. int retval;
  183. /*
  184. * Check which section of the firmware we need.
  185. */
  186. if (rt2x00_rt(rt2x00dev, RT2860) ||
  187. rt2x00_rt(rt2x00dev, RT2872) ||
  188. rt2x00_rt(rt2x00dev, RT3070)) {
  189. offset = 0;
  190. length = 4096;
  191. } else {
  192. offset = 4096;
  193. length = 4096;
  194. }
  195. /*
  196. * Write firmware to device.
  197. */
  198. retval = rt2800usb_autorun_detect(rt2x00dev);
  199. if (retval < 0)
  200. return retval;
  201. if (retval) {
  202. rt2x00_info(rt2x00dev,
  203. "Firmware loading not required - NIC in AutoRun mode\n");
  204. __clear_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags);
  205. } else {
  206. rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
  207. data + offset, length);
  208. }
  209. rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
  210. rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
  211. /*
  212. * Send firmware request to device to load firmware,
  213. * we need to specify a long timeout time.
  214. */
  215. status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
  216. 0, USB_MODE_FIRMWARE,
  217. REGISTER_TIMEOUT_FIRMWARE);
  218. if (status < 0) {
  219. rt2x00_err(rt2x00dev, "Failed to write Firmware to device\n");
  220. return status;
  221. }
  222. msleep(10);
  223. rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
  224. return 0;
  225. }
  226. /*
  227. * Device state switch handlers.
  228. */
  229. static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
  230. {
  231. u32 reg;
  232. /*
  233. * Wait until BBP and RF are ready.
  234. */
  235. if (rt2800_wait_csr_ready(rt2x00dev))
  236. return -EBUSY;
  237. reg = rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL);
  238. rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
  239. reg = 0;
  240. rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
  241. rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
  242. rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
  243. rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
  244. USB_MODE_RESET, REGISTER_TIMEOUT);
  245. rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
  246. return 0;
  247. }
  248. static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
  249. {
  250. u32 reg = 0;
  251. if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev)))
  252. return -EIO;
  253. rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0);
  254. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN, 0);
  255. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
  256. /*
  257. * Total room for RX frames in kilobytes, PBF might still exceed
  258. * this limit so reduce the number to prevent errors.
  259. */
  260. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_LIMIT,
  261. ((rt2x00dev->rx->limit * DATA_FRAME_SIZE)
  262. / 1024) - 3);
  263. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_EN, 1);
  264. rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1);
  265. rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, reg);
  266. return rt2800_enable_radio(rt2x00dev);
  267. }
  268. static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
  269. {
  270. rt2800_disable_radio(rt2x00dev);
  271. }
  272. static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev,
  273. enum dev_state state)
  274. {
  275. if (state == STATE_AWAKE)
  276. rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 2);
  277. else
  278. rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0xff, 2);
  279. return 0;
  280. }
  281. static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
  282. enum dev_state state)
  283. {
  284. int retval = 0;
  285. switch (state) {
  286. case STATE_RADIO_ON:
  287. /*
  288. * Before the radio can be enabled, the device first has
  289. * to be woken up. After that it needs a bit of time
  290. * to be fully awake and then the radio can be enabled.
  291. */
  292. rt2800usb_set_state(rt2x00dev, STATE_AWAKE);
  293. msleep(1);
  294. retval = rt2800usb_enable_radio(rt2x00dev);
  295. break;
  296. case STATE_RADIO_OFF:
  297. /*
  298. * After the radio has been disabled, the device should
  299. * be put to sleep for powersaving.
  300. */
  301. rt2800usb_disable_radio(rt2x00dev);
  302. rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
  303. break;
  304. case STATE_RADIO_IRQ_ON:
  305. case STATE_RADIO_IRQ_OFF:
  306. /* No support, but no error either */
  307. break;
  308. case STATE_DEEP_SLEEP:
  309. case STATE_SLEEP:
  310. case STATE_STANDBY:
  311. case STATE_AWAKE:
  312. retval = rt2800usb_set_state(rt2x00dev, state);
  313. break;
  314. default:
  315. retval = -ENOTSUPP;
  316. break;
  317. }
  318. if (unlikely(retval))
  319. rt2x00_err(rt2x00dev, "Device failed to enter state %d (%d)\n",
  320. state, retval);
  321. return retval;
  322. }
  323. static unsigned int rt2800usb_get_dma_done(struct data_queue *queue)
  324. {
  325. struct queue_entry *entry;
  326. entry = rt2x00queue_get_entry(queue, Q_INDEX_DMA_DONE);
  327. return entry->entry_idx;
  328. }
  329. /*
  330. * TX descriptor initialization
  331. */
  332. static __le32 *rt2800usb_get_txwi(struct queue_entry *entry)
  333. {
  334. if (entry->queue->qid == QID_BEACON)
  335. return (__le32 *) (entry->skb->data);
  336. else
  337. return (__le32 *) (entry->skb->data + TXINFO_DESC_SIZE);
  338. }
  339. static void rt2800usb_write_tx_desc(struct queue_entry *entry,
  340. struct txentry_desc *txdesc)
  341. {
  342. struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
  343. __le32 *txi = (__le32 *) entry->skb->data;
  344. u32 word;
  345. /*
  346. * Initialize TXINFO descriptor
  347. */
  348. word = rt2x00_desc_read(txi, 0);
  349. /*
  350. * The size of TXINFO_W0_USB_DMA_TX_PKT_LEN is
  351. * TXWI + 802.11 header + L2 pad + payload + pad,
  352. * so need to decrease size of TXINFO.
  353. */
  354. rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN,
  355. roundup(entry->skb->len, 4) - TXINFO_DESC_SIZE);
  356. rt2x00_set_field32(&word, TXINFO_W0_WIV,
  357. !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
  358. rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2);
  359. rt2x00_set_field32(&word, TXINFO_W0_SW_USE_LAST_ROUND, 0);
  360. rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_NEXT_VALID, 0);
  361. rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST,
  362. test_bit(ENTRY_TXD_BURST, &txdesc->flags));
  363. rt2x00_desc_write(txi, 0, word);
  364. /*
  365. * Register descriptor details in skb frame descriptor.
  366. */
  367. skbdesc->flags |= SKBDESC_DESC_IN_SKB;
  368. skbdesc->desc = txi;
  369. skbdesc->desc_len = TXINFO_DESC_SIZE + entry->queue->winfo_size;
  370. }
  371. /*
  372. * TX data initialization
  373. */
  374. static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
  375. {
  376. /*
  377. * pad(1~3 bytes) is needed after each 802.11 payload.
  378. * USB end pad(4 bytes) is needed at each USB bulk out packet end.
  379. * TX frame format is :
  380. * | TXINFO | TXWI | 802.11 header | L2 pad | payload | pad | USB end pad |
  381. * |<------------- tx_pkt_len ------------->|
  382. */
  383. return roundup(entry->skb->len, 4) + 4;
  384. }
  385. /*
  386. * TX control handlers
  387. */
  388. static void rt2800usb_work_txdone(struct work_struct *work)
  389. {
  390. struct rt2x00_dev *rt2x00dev =
  391. container_of(work, struct rt2x00_dev, txdone_work);
  392. while (!kfifo_is_empty(&rt2x00dev->txstatus_fifo) ||
  393. rt2800_txstatus_timeout(rt2x00dev)) {
  394. rt2800_txdone(rt2x00dev, UINT_MAX);
  395. rt2800_txdone_nostatus(rt2x00dev);
  396. /*
  397. * The hw may delay sending the packet after DMA complete
  398. * if the medium is busy, thus the TX_STA_FIFO entry is
  399. * also delayed -> use a timer to retrieve it.
  400. */
  401. if (rt2800_txstatus_pending(rt2x00dev))
  402. rt2800usb_async_read_tx_status(rt2x00dev);
  403. }
  404. }
  405. /*
  406. * RX control handlers
  407. */
  408. static void rt2800usb_fill_rxdone(struct queue_entry *entry,
  409. struct rxdone_entry_desc *rxdesc)
  410. {
  411. struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
  412. __le32 *rxi = (__le32 *)entry->skb->data;
  413. __le32 *rxd;
  414. u32 word;
  415. int rx_pkt_len;
  416. /*
  417. * Copy descriptor to the skbdesc->desc buffer, making it safe from
  418. * moving of frame data in rt2x00usb.
  419. */
  420. memcpy(skbdesc->desc, rxi, skbdesc->desc_len);
  421. /*
  422. * RX frame format is :
  423. * | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad |
  424. * |<------------ rx_pkt_len -------------->|
  425. */
  426. word = rt2x00_desc_read(rxi, 0);
  427. rx_pkt_len = rt2x00_get_field32(word, RXINFO_W0_USB_DMA_RX_PKT_LEN);
  428. /*
  429. * Remove the RXINFO structure from the sbk.
  430. */
  431. skb_pull(entry->skb, RXINFO_DESC_SIZE);
  432. /*
  433. * Check for rx_pkt_len validity. Return if invalid, leaving
  434. * rxdesc->size zeroed out by the upper level.
  435. */
  436. if (unlikely(rx_pkt_len == 0 ||
  437. rx_pkt_len > entry->queue->data_size)) {
  438. rt2x00_err(entry->queue->rt2x00dev,
  439. "Bad frame size %d, forcing to 0\n", rx_pkt_len);
  440. return;
  441. }
  442. rxd = (__le32 *)(entry->skb->data + rx_pkt_len);
  443. /*
  444. * It is now safe to read the descriptor on all architectures.
  445. */
  446. word = rt2x00_desc_read(rxd, 0);
  447. if (rt2x00_get_field32(word, RXD_W0_CRC_ERROR))
  448. rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
  449. rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W0_CIPHER_ERROR);
  450. if (rt2x00_get_field32(word, RXD_W0_DECRYPTED)) {
  451. /*
  452. * Hardware has stripped IV/EIV data from 802.11 frame during
  453. * decryption. Unfortunately the descriptor doesn't contain
  454. * any fields with the EIV/IV data either, so they can't
  455. * be restored by rt2x00lib.
  456. */
  457. rxdesc->flags |= RX_FLAG_IV_STRIPPED;
  458. /*
  459. * The hardware has already checked the Michael Mic and has
  460. * stripped it from the frame. Signal this to mac80211.
  461. */
  462. rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
  463. if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) {
  464. rxdesc->flags |= RX_FLAG_DECRYPTED;
  465. } else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) {
  466. /*
  467. * In order to check the Michael Mic, the packet must have
  468. * been decrypted. Mac80211 doesnt check the MMIC failure
  469. * flag to initiate MMIC countermeasures if the decoded flag
  470. * has not been set.
  471. */
  472. rxdesc->flags |= RX_FLAG_DECRYPTED;
  473. rxdesc->flags |= RX_FLAG_MMIC_ERROR;
  474. }
  475. }
  476. if (rt2x00_get_field32(word, RXD_W0_MY_BSS))
  477. rxdesc->dev_flags |= RXDONE_MY_BSS;
  478. if (rt2x00_get_field32(word, RXD_W0_L2PAD))
  479. rxdesc->dev_flags |= RXDONE_L2PAD;
  480. /*
  481. * Remove RXD descriptor from end of buffer.
  482. */
  483. skb_trim(entry->skb, rx_pkt_len);
  484. /*
  485. * Process the RXWI structure.
  486. */
  487. rt2800_process_rxwi(entry, rxdesc);
  488. }
  489. /*
  490. * Device probe functions.
  491. */
  492. static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev)
  493. {
  494. int retval;
  495. retval = rt2800usb_autorun_detect(rt2x00dev);
  496. if (retval < 0)
  497. return retval;
  498. if (retval)
  499. return 1;
  500. return rt2800_efuse_detect(rt2x00dev);
  501. }
  502. static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev)
  503. {
  504. int retval;
  505. retval = rt2800usb_efuse_detect(rt2x00dev);
  506. if (retval < 0)
  507. return retval;
  508. if (retval)
  509. retval = rt2800_read_eeprom_efuse(rt2x00dev);
  510. else
  511. retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,
  512. EEPROM_SIZE);
  513. return retval;
  514. }
  515. static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
  516. {
  517. int retval;
  518. retval = rt2800_probe_hw(rt2x00dev);
  519. if (retval)
  520. return retval;
  521. /*
  522. * Set txstatus timer function.
  523. */
  524. hrtimer_update_function(&rt2x00dev->txstatus_timer, rt2800usb_tx_sta_fifo_timeout);
  525. /*
  526. * Overwrite TX done handler
  527. */
  528. INIT_WORK(&rt2x00dev->txdone_work, rt2800usb_work_txdone);
  529. return 0;
  530. }
  531. static const struct ieee80211_ops rt2800usb_mac80211_ops = {
  532. .add_chanctx = ieee80211_emulate_add_chanctx,
  533. .remove_chanctx = ieee80211_emulate_remove_chanctx,
  534. .change_chanctx = ieee80211_emulate_change_chanctx,
  535. .switch_vif_chanctx = ieee80211_emulate_switch_vif_chanctx,
  536. .tx = rt2x00mac_tx,
  537. .wake_tx_queue = ieee80211_handle_wake_tx_queue,
  538. .start = rt2x00mac_start,
  539. .stop = rt2x00mac_stop,
  540. .add_interface = rt2x00mac_add_interface,
  541. .remove_interface = rt2x00mac_remove_interface,
  542. .config = rt2x00mac_config,
  543. .configure_filter = rt2x00mac_configure_filter,
  544. .set_tim = rt2x00mac_set_tim,
  545. .set_key = rt2x00mac_set_key,
  546. .sw_scan_start = rt2x00mac_sw_scan_start,
  547. .sw_scan_complete = rt2x00mac_sw_scan_complete,
  548. .get_stats = rt2x00mac_get_stats,
  549. .get_key_seq = rt2800_get_key_seq,
  550. .set_rts_threshold = rt2800_set_rts_threshold,
  551. .sta_add = rt2800_sta_add,
  552. .sta_remove = rt2800_sta_remove,
  553. .bss_info_changed = rt2x00mac_bss_info_changed,
  554. .conf_tx = rt2800_conf_tx,
  555. .get_tsf = rt2800_get_tsf,
  556. .rfkill_poll = rt2x00mac_rfkill_poll,
  557. .ampdu_action = rt2800_ampdu_action,
  558. .flush = rt2x00mac_flush,
  559. .get_survey = rt2800_get_survey,
  560. .get_ringparam = rt2x00mac_get_ringparam,
  561. .tx_frames_pending = rt2x00mac_tx_frames_pending,
  562. .reconfig_complete = rt2x00mac_reconfig_complete,
  563. };
  564. static const struct rt2800_ops rt2800usb_rt2800_ops = {
  565. .register_read = rt2x00usb_register_read,
  566. .register_read_lock = rt2x00usb_register_read_lock,
  567. .register_write = rt2x00usb_register_write,
  568. .register_write_lock = rt2x00usb_register_write_lock,
  569. .register_multiread = rt2x00usb_register_multiread,
  570. .register_multiwrite = rt2x00usb_register_multiwrite,
  571. .regbusy_read = rt2x00usb_regbusy_read,
  572. .read_eeprom = rt2800usb_read_eeprom,
  573. .hwcrypt_disabled = rt2800usb_hwcrypt_disabled,
  574. .drv_write_firmware = rt2800usb_write_firmware,
  575. .drv_init_registers = rt2800usb_init_registers,
  576. .drv_get_txwi = rt2800usb_get_txwi,
  577. .drv_get_dma_done = rt2800usb_get_dma_done,
  578. };
  579. static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
  580. .probe_hw = rt2800usb_probe_hw,
  581. .get_firmware_name = rt2800usb_get_firmware_name,
  582. .check_firmware = rt2800_check_firmware,
  583. .load_firmware = rt2800_load_firmware,
  584. .initialize = rt2x00usb_initialize,
  585. .uninitialize = rt2x00usb_uninitialize,
  586. .clear_entry = rt2x00usb_clear_entry,
  587. .set_device_state = rt2800usb_set_device_state,
  588. .rfkill_poll = rt2800_rfkill_poll,
  589. .link_stats = rt2800_link_stats,
  590. .reset_tuner = rt2800_reset_tuner,
  591. .link_tuner = rt2800_link_tuner,
  592. .gain_calibration = rt2800_gain_calibration,
  593. .vco_calibration = rt2800_vco_calibration,
  594. .watchdog = rt2800_watchdog,
  595. .start_queue = rt2800usb_start_queue,
  596. .kick_queue = rt2x00usb_kick_queue,
  597. .stop_queue = rt2800usb_stop_queue,
  598. .flush_queue = rt2x00usb_flush_queue,
  599. .tx_dma_done = rt2800usb_tx_dma_done,
  600. .write_tx_desc = rt2800usb_write_tx_desc,
  601. .write_tx_data = rt2800_write_tx_data,
  602. .write_beacon = rt2800_write_beacon,
  603. .clear_beacon = rt2800_clear_beacon,
  604. .get_tx_data_len = rt2800usb_get_tx_data_len,
  605. .fill_rxdone = rt2800usb_fill_rxdone,
  606. .config_shared_key = rt2800_config_shared_key,
  607. .config_pairwise_key = rt2800_config_pairwise_key,
  608. .config_filter = rt2800_config_filter,
  609. .config_intf = rt2800_config_intf,
  610. .config_erp = rt2800_config_erp,
  611. .config_ant = rt2800_config_ant,
  612. .config = rt2800_config,
  613. .pre_reset_hw = rt2800_pre_reset_hw,
  614. };
  615. static void rt2800usb_queue_init(struct data_queue *queue)
  616. {
  617. struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
  618. unsigned short txwi_size, rxwi_size;
  619. rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size);
  620. switch (queue->qid) {
  621. case QID_RX:
  622. queue->limit = 128;
  623. queue->data_size = AGGREGATION_SIZE;
  624. queue->desc_size = RXINFO_DESC_SIZE;
  625. queue->winfo_size = rxwi_size;
  626. queue->priv_size = sizeof(struct queue_entry_priv_usb);
  627. break;
  628. case QID_AC_VO:
  629. case QID_AC_VI:
  630. case QID_AC_BE:
  631. case QID_AC_BK:
  632. queue->limit = 16;
  633. queue->data_size = AGGREGATION_SIZE;
  634. queue->desc_size = TXINFO_DESC_SIZE;
  635. queue->winfo_size = txwi_size;
  636. queue->priv_size = sizeof(struct queue_entry_priv_usb);
  637. break;
  638. case QID_BEACON:
  639. queue->limit = 8;
  640. queue->data_size = MGMT_FRAME_SIZE;
  641. queue->desc_size = TXINFO_DESC_SIZE;
  642. queue->winfo_size = txwi_size;
  643. queue->priv_size = sizeof(struct queue_entry_priv_usb);
  644. break;
  645. case QID_ATIM:
  646. default:
  647. BUG();
  648. break;
  649. }
  650. }
  651. static const struct rt2x00_ops rt2800usb_ops = {
  652. .name = KBUILD_MODNAME,
  653. .drv_data_size = sizeof(struct rt2800_drv_data),
  654. .max_ap_intf = 8,
  655. .eeprom_size = EEPROM_SIZE,
  656. .rf_size = RF_SIZE,
  657. .tx_queues = NUM_TX_QUEUES,
  658. .queue_init = rt2800usb_queue_init,
  659. .lib = &rt2800usb_rt2x00_ops,
  660. .drv = &rt2800usb_rt2800_ops,
  661. .hw = &rt2800usb_mac80211_ops,
  662. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  663. .debugfs = &rt2800_rt2x00debug,
  664. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  665. };
  666. /*
  667. * rt2800usb module information.
  668. */
  669. static const struct usb_device_id rt2800usb_device_table[] = {
  670. /* Abocom */
  671. { USB_DEVICE(0x07b8, 0x2870) },
  672. { USB_DEVICE(0x07b8, 0x2770) },
  673. { USB_DEVICE(0x07b8, 0x3070) },
  674. { USB_DEVICE(0x07b8, 0x3071) },
  675. { USB_DEVICE(0x07b8, 0x3072) },
  676. { USB_DEVICE(0x1482, 0x3c09) },
  677. /* AirTies */
  678. { USB_DEVICE(0x1eda, 0x2012) },
  679. { USB_DEVICE(0x1eda, 0x2210) },
  680. { USB_DEVICE(0x1eda, 0x2310) },
  681. /* Allwin */
  682. { USB_DEVICE(0x8516, 0x2070) },
  683. { USB_DEVICE(0x8516, 0x2770) },
  684. { USB_DEVICE(0x8516, 0x2870) },
  685. { USB_DEVICE(0x8516, 0x3070) },
  686. { USB_DEVICE(0x8516, 0x3071) },
  687. { USB_DEVICE(0x8516, 0x3072) },
  688. /* Alpha Networks */
  689. { USB_DEVICE(0x14b2, 0x3c06) },
  690. { USB_DEVICE(0x14b2, 0x3c07) },
  691. { USB_DEVICE(0x14b2, 0x3c09) },
  692. { USB_DEVICE(0x14b2, 0x3c12) },
  693. { USB_DEVICE(0x14b2, 0x3c23) },
  694. { USB_DEVICE(0x14b2, 0x3c25) },
  695. { USB_DEVICE(0x14b2, 0x3c27) },
  696. { USB_DEVICE(0x14b2, 0x3c28) },
  697. { USB_DEVICE(0x14b2, 0x3c2c) },
  698. /* Amit */
  699. { USB_DEVICE(0x15c5, 0x0008) },
  700. /* Askey */
  701. { USB_DEVICE(0x1690, 0x0740) },
  702. /* ASUS */
  703. { USB_DEVICE(0x0b05, 0x1731) },
  704. { USB_DEVICE(0x0b05, 0x1732) },
  705. { USB_DEVICE(0x0b05, 0x1742) },
  706. { USB_DEVICE(0x0b05, 0x1784) },
  707. { USB_DEVICE(0x1761, 0x0b05) },
  708. /* AzureWave */
  709. { USB_DEVICE(0x13d3, 0x3247) },
  710. { USB_DEVICE(0x13d3, 0x3273) },
  711. { USB_DEVICE(0x13d3, 0x3305) },
  712. { USB_DEVICE(0x13d3, 0x3307) },
  713. { USB_DEVICE(0x13d3, 0x3321) },
  714. /* Belkin */
  715. { USB_DEVICE(0x050d, 0x8053) },
  716. { USB_DEVICE(0x050d, 0x805c) },
  717. { USB_DEVICE(0x050d, 0x815c) },
  718. { USB_DEVICE(0x050d, 0x825a) },
  719. { USB_DEVICE(0x050d, 0x825b) },
  720. { USB_DEVICE(0x050d, 0x935a) },
  721. { USB_DEVICE(0x050d, 0x935b) },
  722. /* Buffalo */
  723. { USB_DEVICE(0x0411, 0x00e8) },
  724. { USB_DEVICE(0x0411, 0x0158) },
  725. { USB_DEVICE(0x0411, 0x015d) },
  726. { USB_DEVICE(0x0411, 0x016f) },
  727. { USB_DEVICE(0x0411, 0x01a2) },
  728. { USB_DEVICE(0x0411, 0x01ee) },
  729. { USB_DEVICE(0x0411, 0x01a8) },
  730. { USB_DEVICE(0x0411, 0x01fd) },
  731. /* Corega */
  732. { USB_DEVICE(0x07aa, 0x002f) },
  733. { USB_DEVICE(0x07aa, 0x003c) },
  734. { USB_DEVICE(0x07aa, 0x003f) },
  735. { USB_DEVICE(0x18c5, 0x0012) },
  736. /* D-Link */
  737. { USB_DEVICE(0x07d1, 0x3c09) },
  738. { USB_DEVICE(0x07d1, 0x3c0a) },
  739. { USB_DEVICE(0x07d1, 0x3c0d) },
  740. { USB_DEVICE(0x07d1, 0x3c0e) },
  741. { USB_DEVICE(0x07d1, 0x3c0f) },
  742. { USB_DEVICE(0x07d1, 0x3c11) },
  743. { USB_DEVICE(0x07d1, 0x3c13) },
  744. { USB_DEVICE(0x07d1, 0x3c15) },
  745. { USB_DEVICE(0x07d1, 0x3c16) },
  746. { USB_DEVICE(0x07d1, 0x3c17) },
  747. { USB_DEVICE(0x2001, 0x3317) },
  748. { USB_DEVICE(0x2001, 0x3c1b) },
  749. { USB_DEVICE(0x2001, 0x3c25) },
  750. /* Draytek */
  751. { USB_DEVICE(0x07fa, 0x7712) },
  752. /* DVICO */
  753. { USB_DEVICE(0x0fe9, 0xb307) },
  754. /* Edimax */
  755. { USB_DEVICE(0x7392, 0x4085) },
  756. { USB_DEVICE(0x7392, 0x7711) },
  757. { USB_DEVICE(0x7392, 0x7717) },
  758. { USB_DEVICE(0x7392, 0x7718) },
  759. { USB_DEVICE(0x7392, 0x7722) },
  760. /* Encore */
  761. { USB_DEVICE(0x203d, 0x1480) },
  762. { USB_DEVICE(0x203d, 0x14a9) },
  763. /* EnGenius */
  764. { USB_DEVICE(0x1740, 0x9701) },
  765. { USB_DEVICE(0x1740, 0x9702) },
  766. { USB_DEVICE(0x1740, 0x9703) },
  767. { USB_DEVICE(0x1740, 0x9705) },
  768. { USB_DEVICE(0x1740, 0x9706) },
  769. { USB_DEVICE(0x1740, 0x9707) },
  770. { USB_DEVICE(0x1740, 0x9708) },
  771. { USB_DEVICE(0x1740, 0x9709) },
  772. /* Gemtek */
  773. { USB_DEVICE(0x15a9, 0x0012) },
  774. /* Gigabyte */
  775. { USB_DEVICE(0x1044, 0x800b) },
  776. { USB_DEVICE(0x1044, 0x800d) },
  777. /* Hawking */
  778. { USB_DEVICE(0x0e66, 0x0001) },
  779. { USB_DEVICE(0x0e66, 0x0003) },
  780. { USB_DEVICE(0x0e66, 0x0009) },
  781. { USB_DEVICE(0x0e66, 0x000b) },
  782. { USB_DEVICE(0x0e66, 0x0013) },
  783. { USB_DEVICE(0x0e66, 0x0017) },
  784. { USB_DEVICE(0x0e66, 0x0018) },
  785. /* I-O DATA */
  786. { USB_DEVICE(0x04bb, 0x0945) },
  787. { USB_DEVICE(0x04bb, 0x0947) },
  788. { USB_DEVICE(0x04bb, 0x0948) },
  789. /* Linksys */
  790. { USB_DEVICE(0x13b1, 0x0031) },
  791. { USB_DEVICE(0x1737, 0x0070) },
  792. { USB_DEVICE(0x1737, 0x0071) },
  793. { USB_DEVICE(0x1737, 0x0077) },
  794. { USB_DEVICE(0x1737, 0x0078) },
  795. /* Logitec */
  796. { USB_DEVICE(0x0789, 0x0162) },
  797. { USB_DEVICE(0x0789, 0x0163) },
  798. { USB_DEVICE(0x0789, 0x0164) },
  799. { USB_DEVICE(0x0789, 0x0166) },
  800. /* Motorola */
  801. { USB_DEVICE(0x100d, 0x9031) },
  802. /* MSI */
  803. { USB_DEVICE(0x0db0, 0x3820) },
  804. { USB_DEVICE(0x0db0, 0x3821) },
  805. { USB_DEVICE(0x0db0, 0x3822) },
  806. { USB_DEVICE(0x0db0, 0x3870) },
  807. { USB_DEVICE(0x0db0, 0x3871) },
  808. { USB_DEVICE(0x0db0, 0x6899) },
  809. { USB_DEVICE(0x0db0, 0x821a) },
  810. { USB_DEVICE(0x0db0, 0x822a) },
  811. { USB_DEVICE(0x0db0, 0x822b) },
  812. { USB_DEVICE(0x0db0, 0x822c) },
  813. { USB_DEVICE(0x0db0, 0x870a) },
  814. { USB_DEVICE(0x0db0, 0x871a) },
  815. { USB_DEVICE(0x0db0, 0x871b) },
  816. { USB_DEVICE(0x0db0, 0x871c) },
  817. { USB_DEVICE(0x0db0, 0x899a) },
  818. /* Ovislink */
  819. { USB_DEVICE(0x1b75, 0x3070) },
  820. { USB_DEVICE(0x1b75, 0x3071) },
  821. { USB_DEVICE(0x1b75, 0x3072) },
  822. { USB_DEVICE(0x1b75, 0xa200) },
  823. /* Para */
  824. { USB_DEVICE(0x20b8, 0x8888) },
  825. /* Pegatron */
  826. { USB_DEVICE(0x1d4d, 0x0002) },
  827. { USB_DEVICE(0x1d4d, 0x000c) },
  828. { USB_DEVICE(0x1d4d, 0x000e) },
  829. { USB_DEVICE(0x1d4d, 0x0011) },
  830. /* Philips */
  831. { USB_DEVICE(0x0471, 0x200f) },
  832. /* Planex */
  833. { USB_DEVICE(0x2019, 0x5201) },
  834. { USB_DEVICE(0x2019, 0xab25) },
  835. { USB_DEVICE(0x2019, 0xed06) },
  836. /* Quanta */
  837. { USB_DEVICE(0x1a32, 0x0304) },
  838. /* Ralink */
  839. { USB_DEVICE(0x148f, 0x2070) },
  840. { USB_DEVICE(0x148f, 0x2770) },
  841. { USB_DEVICE(0x148f, 0x2870) },
  842. { USB_DEVICE(0x148f, 0x3070) },
  843. { USB_DEVICE(0x148f, 0x3071) },
  844. { USB_DEVICE(0x148f, 0x3072) },
  845. /* Samsung */
  846. { USB_DEVICE(0x04e8, 0x2018) },
  847. /* Siemens */
  848. { USB_DEVICE(0x129b, 0x1828) },
  849. /* Sitecom */
  850. { USB_DEVICE(0x0df6, 0x0017) },
  851. { USB_DEVICE(0x0df6, 0x002b) },
  852. { USB_DEVICE(0x0df6, 0x002c) },
  853. { USB_DEVICE(0x0df6, 0x002d) },
  854. { USB_DEVICE(0x0df6, 0x0039) },
  855. { USB_DEVICE(0x0df6, 0x003b) },
  856. { USB_DEVICE(0x0df6, 0x003d) },
  857. { USB_DEVICE(0x0df6, 0x003e) },
  858. { USB_DEVICE(0x0df6, 0x003f) },
  859. { USB_DEVICE(0x0df6, 0x0040) },
  860. { USB_DEVICE(0x0df6, 0x0042) },
  861. { USB_DEVICE(0x0df6, 0x0047) },
  862. { USB_DEVICE(0x0df6, 0x0048) },
  863. { USB_DEVICE(0x0df6, 0x0051) },
  864. { USB_DEVICE(0x0df6, 0x005f) },
  865. { USB_DEVICE(0x0df6, 0x0060) },
  866. /* SMC */
  867. { USB_DEVICE(0x083a, 0x6618) },
  868. { USB_DEVICE(0x083a, 0x7511) },
  869. { USB_DEVICE(0x083a, 0x7512) },
  870. { USB_DEVICE(0x083a, 0x7522) },
  871. { USB_DEVICE(0x083a, 0x8522) },
  872. { USB_DEVICE(0x083a, 0xa618) },
  873. { USB_DEVICE(0x083a, 0xa701) },
  874. { USB_DEVICE(0x083a, 0xa702) },
  875. { USB_DEVICE(0x083a, 0xa703) },
  876. { USB_DEVICE(0x083a, 0xb522) },
  877. /* Sparklan */
  878. { USB_DEVICE(0x15a9, 0x0006) },
  879. /* Sweex */
  880. { USB_DEVICE(0x177f, 0x0153) },
  881. { USB_DEVICE(0x177f, 0x0164) },
  882. { USB_DEVICE(0x177f, 0x0302) },
  883. { USB_DEVICE(0x177f, 0x0313) },
  884. { USB_DEVICE(0x177f, 0x0323) },
  885. { USB_DEVICE(0x177f, 0x0324) },
  886. { USB_DEVICE(0x177f, 0x1163) },
  887. /* U-Media */
  888. { USB_DEVICE(0x157e, 0x300e) },
  889. { USB_DEVICE(0x157e, 0x3013) },
  890. /* ZCOM */
  891. { USB_DEVICE(0x0cde, 0x0022) },
  892. { USB_DEVICE(0x0cde, 0x0025) },
  893. /* Zinwell */
  894. { USB_DEVICE(0x5a57, 0x0280) },
  895. { USB_DEVICE(0x5a57, 0x0282) },
  896. { USB_DEVICE(0x5a57, 0x0283) },
  897. { USB_DEVICE(0x5a57, 0x5257) },
  898. /* Zyxel */
  899. { USB_DEVICE(0x0586, 0x3416) },
  900. { USB_DEVICE(0x0586, 0x3418) },
  901. { USB_DEVICE(0x0586, 0x341a) },
  902. { USB_DEVICE(0x0586, 0x341e) },
  903. { USB_DEVICE(0x0586, 0x343e) },
  904. #ifdef CONFIG_RT2800USB_RT33XX
  905. /* Belkin */
  906. { USB_DEVICE(0x050d, 0x945b) },
  907. /* D-Link */
  908. { USB_DEVICE(0x2001, 0x3c17) },
  909. /* Panasonic */
  910. { USB_DEVICE(0x083a, 0xb511) },
  911. /* Accton/Arcadyan/Epson */
  912. { USB_DEVICE(0x083a, 0xb512) },
  913. /* Philips */
  914. { USB_DEVICE(0x0471, 0x20dd) },
  915. /* Ralink */
  916. { USB_DEVICE(0x148f, 0x3370) },
  917. { USB_DEVICE(0x148f, 0x8070) },
  918. /* Sitecom */
  919. { USB_DEVICE(0x0df6, 0x0050) },
  920. /* Sweex */
  921. { USB_DEVICE(0x177f, 0x0163) },
  922. { USB_DEVICE(0x177f, 0x0165) },
  923. #endif
  924. #ifdef CONFIG_RT2800USB_RT35XX
  925. /* Allwin */
  926. { USB_DEVICE(0x8516, 0x3572) },
  927. /* Askey */
  928. { USB_DEVICE(0x1690, 0x0744) },
  929. { USB_DEVICE(0x1690, 0x0761) },
  930. { USB_DEVICE(0x1690, 0x0764) },
  931. /* ASUS */
  932. { USB_DEVICE(0x0b05, 0x179d) },
  933. /* Cisco */
  934. { USB_DEVICE(0x167b, 0x4001) },
  935. /* EnGenius */
  936. { USB_DEVICE(0x1740, 0x9801) },
  937. /* I-O DATA */
  938. { USB_DEVICE(0x04bb, 0x0944) },
  939. /* Linksys */
  940. { USB_DEVICE(0x13b1, 0x002f) },
  941. { USB_DEVICE(0x1737, 0x0079) },
  942. /* Logitec */
  943. { USB_DEVICE(0x0789, 0x0170) },
  944. /* Ralink */
  945. { USB_DEVICE(0x148f, 0x3572) },
  946. /* Sitecom */
  947. { USB_DEVICE(0x0df6, 0x0041) },
  948. { USB_DEVICE(0x0df6, 0x0062) },
  949. { USB_DEVICE(0x0df6, 0x0065) },
  950. { USB_DEVICE(0x0df6, 0x0066) },
  951. { USB_DEVICE(0x0df6, 0x0068) },
  952. /* Toshiba */
  953. { USB_DEVICE(0x0930, 0x0a07) },
  954. /* Zinwell */
  955. { USB_DEVICE(0x5a57, 0x0284) },
  956. #endif
  957. #ifdef CONFIG_RT2800USB_RT3573
  958. /* AirLive */
  959. { USB_DEVICE(0x1b75, 0x7733) },
  960. /* ASUS */
  961. { USB_DEVICE(0x0b05, 0x17bc) },
  962. { USB_DEVICE(0x0b05, 0x17ad) },
  963. /* Belkin */
  964. { USB_DEVICE(0x050d, 0x1103) },
  965. /* Cameo */
  966. { USB_DEVICE(0x148f, 0xf301) },
  967. /* D-Link */
  968. { USB_DEVICE(0x2001, 0x3c1f) },
  969. /* Edimax */
  970. { USB_DEVICE(0x7392, 0x7733) },
  971. /* Hawking */
  972. { USB_DEVICE(0x0e66, 0x0020) },
  973. { USB_DEVICE(0x0e66, 0x0021) },
  974. /* I-O DATA */
  975. { USB_DEVICE(0x04bb, 0x094e) },
  976. /* Linksys */
  977. { USB_DEVICE(0x13b1, 0x003b) },
  978. /* Logitec */
  979. { USB_DEVICE(0x0789, 0x016b) },
  980. /* NETGEAR */
  981. { USB_DEVICE(0x0846, 0x9012) },
  982. { USB_DEVICE(0x0846, 0x9013) },
  983. { USB_DEVICE(0x0846, 0x9019) },
  984. /* Planex */
  985. { USB_DEVICE(0x2019, 0xed14) },
  986. { USB_DEVICE(0x2019, 0xed19) },
  987. /* Ralink */
  988. { USB_DEVICE(0x148f, 0x3573) },
  989. /* Sitecom */
  990. { USB_DEVICE(0x0df6, 0x0067) },
  991. { USB_DEVICE(0x0df6, 0x006a) },
  992. { USB_DEVICE(0x0df6, 0x006e) },
  993. /* ZyXEL */
  994. { USB_DEVICE(0x0586, 0x3421) },
  995. #endif
  996. #ifdef CONFIG_RT2800USB_RT53XX
  997. /* Arcadyan */
  998. { USB_DEVICE(0x043e, 0x7a12) },
  999. /* ASUS */
  1000. { USB_DEVICE(0x0b05, 0x17e8) },
  1001. /* Azurewave */
  1002. { USB_DEVICE(0x13d3, 0x3329) },
  1003. { USB_DEVICE(0x13d3, 0x3365) },
  1004. /* D-Link */
  1005. { USB_DEVICE(0x2001, 0x3c15) },
  1006. { USB_DEVICE(0x2001, 0x3c19) },
  1007. { USB_DEVICE(0x2001, 0x3c1c) },
  1008. { USB_DEVICE(0x2001, 0x3c1d) },
  1009. { USB_DEVICE(0x2001, 0x3c1e) },
  1010. { USB_DEVICE(0x2001, 0x3c20) },
  1011. { USB_DEVICE(0x2001, 0x3c22) },
  1012. { USB_DEVICE(0x2001, 0x3c23) },
  1013. /* LG innotek */
  1014. { USB_DEVICE(0x043e, 0x7a22) },
  1015. { USB_DEVICE(0x043e, 0x7a42) },
  1016. /* Panasonic */
  1017. { USB_DEVICE(0x04da, 0x1801) },
  1018. { USB_DEVICE(0x04da, 0x1800) },
  1019. { USB_DEVICE(0x04da, 0x23f6) },
  1020. /* Philips */
  1021. { USB_DEVICE(0x0471, 0x2104) },
  1022. { USB_DEVICE(0x0471, 0x2126) },
  1023. { USB_DEVICE(0x0471, 0x2180) },
  1024. { USB_DEVICE(0x0471, 0x2181) },
  1025. { USB_DEVICE(0x0471, 0x2182) },
  1026. /* Ralink */
  1027. { USB_DEVICE(0x148f, 0x5370) },
  1028. { USB_DEVICE(0x148f, 0x5372) },
  1029. #endif
  1030. #ifdef CONFIG_RT2800USB_RT55XX
  1031. /* Arcadyan */
  1032. { USB_DEVICE(0x043e, 0x7a32) },
  1033. /* AVM GmbH */
  1034. { USB_DEVICE(0x057c, 0x8501) },
  1035. /* Buffalo */
  1036. { USB_DEVICE(0x0411, 0x0241) },
  1037. { USB_DEVICE(0x0411, 0x0253) },
  1038. /* D-Link */
  1039. { USB_DEVICE(0x2001, 0x3c1a) },
  1040. { USB_DEVICE(0x2001, 0x3c21) },
  1041. /* Proware */
  1042. { USB_DEVICE(0x043e, 0x7a13) },
  1043. /* Ralink */
  1044. { USB_DEVICE(0x148f, 0x5572) },
  1045. /* TRENDnet */
  1046. { USB_DEVICE(0x20f4, 0x724a) },
  1047. #endif
  1048. #ifdef CONFIG_RT2800USB_UNKNOWN
  1049. /*
  1050. * Unclear what kind of devices these are (they aren't supported by the
  1051. * vendor linux driver).
  1052. */
  1053. /* Abocom */
  1054. { USB_DEVICE(0x07b8, 0x3073) },
  1055. { USB_DEVICE(0x07b8, 0x3074) },
  1056. /* Alpha Networks */
  1057. { USB_DEVICE(0x14b2, 0x3c08) },
  1058. { USB_DEVICE(0x14b2, 0x3c11) },
  1059. /* Amigo */
  1060. { USB_DEVICE(0x0e0b, 0x9031) },
  1061. { USB_DEVICE(0x0e0b, 0x9041) },
  1062. /* ASUS */
  1063. { USB_DEVICE(0x0b05, 0x166a) },
  1064. { USB_DEVICE(0x0b05, 0x1760) },
  1065. { USB_DEVICE(0x0b05, 0x1761) },
  1066. { USB_DEVICE(0x0b05, 0x1790) },
  1067. { USB_DEVICE(0x0b05, 0x17a7) },
  1068. /* AzureWave */
  1069. { USB_DEVICE(0x13d3, 0x3262) },
  1070. { USB_DEVICE(0x13d3, 0x3284) },
  1071. { USB_DEVICE(0x13d3, 0x3322) },
  1072. { USB_DEVICE(0x13d3, 0x3340) },
  1073. { USB_DEVICE(0x13d3, 0x3399) },
  1074. { USB_DEVICE(0x13d3, 0x3400) },
  1075. { USB_DEVICE(0x13d3, 0x3401) },
  1076. /* Belkin */
  1077. { USB_DEVICE(0x050d, 0x1003) },
  1078. /* Buffalo */
  1079. { USB_DEVICE(0x0411, 0x012e) },
  1080. { USB_DEVICE(0x0411, 0x0148) },
  1081. { USB_DEVICE(0x0411, 0x0150) },
  1082. /* Corega */
  1083. { USB_DEVICE(0x07aa, 0x0041) },
  1084. { USB_DEVICE(0x07aa, 0x0042) },
  1085. { USB_DEVICE(0x18c5, 0x0008) },
  1086. /* D-Link */
  1087. { USB_DEVICE(0x07d1, 0x3c0b) },
  1088. /* Encore */
  1089. { USB_DEVICE(0x203d, 0x14a1) },
  1090. /* EnGenius */
  1091. { USB_DEVICE(0x1740, 0x0600) },
  1092. { USB_DEVICE(0x1740, 0x0602) },
  1093. /* Gemtek */
  1094. { USB_DEVICE(0x15a9, 0x0010) },
  1095. /* Gigabyte */
  1096. { USB_DEVICE(0x1044, 0x800c) },
  1097. /* Hercules */
  1098. { USB_DEVICE(0x06f8, 0xe036) },
  1099. /* Huawei */
  1100. { USB_DEVICE(0x148f, 0xf101) },
  1101. /* I-O DATA */
  1102. { USB_DEVICE(0x04bb, 0x094b) },
  1103. /* LevelOne */
  1104. { USB_DEVICE(0x1740, 0x0605) },
  1105. { USB_DEVICE(0x1740, 0x0615) },
  1106. /* Logitec */
  1107. { USB_DEVICE(0x0789, 0x0168) },
  1108. { USB_DEVICE(0x0789, 0x0169) },
  1109. /* Motorola */
  1110. { USB_DEVICE(0x100d, 0x9032) },
  1111. /* Pegatron */
  1112. { USB_DEVICE(0x05a6, 0x0101) },
  1113. { USB_DEVICE(0x1d4d, 0x0010) },
  1114. /* Planex */
  1115. { USB_DEVICE(0x2019, 0xab24) },
  1116. { USB_DEVICE(0x2019, 0xab29) },
  1117. /* Qcom */
  1118. { USB_DEVICE(0x18e8, 0x6259) },
  1119. /* RadioShack */
  1120. { USB_DEVICE(0x08b9, 0x1197) },
  1121. /* Sitecom */
  1122. { USB_DEVICE(0x0df6, 0x003c) },
  1123. { USB_DEVICE(0x0df6, 0x004a) },
  1124. { USB_DEVICE(0x0df6, 0x004d) },
  1125. { USB_DEVICE(0x0df6, 0x0053) },
  1126. { USB_DEVICE(0x0df6, 0x0069) },
  1127. { USB_DEVICE(0x0df6, 0x006f) },
  1128. { USB_DEVICE(0x0df6, 0x0078) },
  1129. /* SMC */
  1130. { USB_DEVICE(0x083a, 0xa512) },
  1131. { USB_DEVICE(0x083a, 0xc522) },
  1132. { USB_DEVICE(0x083a, 0xd522) },
  1133. { USB_DEVICE(0x083a, 0xf511) },
  1134. /* Sweex */
  1135. { USB_DEVICE(0x177f, 0x0254) },
  1136. /* TP-LINK */
  1137. { USB_DEVICE(0xf201, 0x5370) },
  1138. #endif
  1139. { 0, }
  1140. };
  1141. MODULE_AUTHOR(DRV_PROJECT);
  1142. MODULE_VERSION(DRV_VERSION);
  1143. MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
  1144. MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
  1145. MODULE_FIRMWARE(FIRMWARE_RT2870);
  1146. MODULE_LICENSE("GPL");
  1147. static int rt2800usb_probe(struct usb_interface *usb_intf,
  1148. const struct usb_device_id *id)
  1149. {
  1150. return rt2x00usb_probe(usb_intf, &rt2800usb_ops);
  1151. }
  1152. static struct usb_driver rt2800usb_driver = {
  1153. .name = KBUILD_MODNAME,
  1154. .id_table = rt2800usb_device_table,
  1155. .probe = rt2800usb_probe,
  1156. .disconnect = rt2x00usb_disconnect,
  1157. .suspend = rt2x00usb_suspend,
  1158. .resume = rt2x00usb_resume,
  1159. .reset_resume = rt2x00usb_resume,
  1160. .disable_hub_initiated_lpm = 1,
  1161. };
  1162. module_usb_driver(rt2800usb_driver);