rt2800usb.c 34 KB

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