rt2800usb.c 34 KB

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