rt2800usb.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221
  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. .vco_calibration = rt2800_vco_calibration,
  672. .watchdog = rt2800usb_watchdog,
  673. .start_queue = rt2800usb_start_queue,
  674. .kick_queue = rt2x00usb_kick_queue,
  675. .stop_queue = rt2800usb_stop_queue,
  676. .flush_queue = rt2x00usb_flush_queue,
  677. .tx_dma_done = rt2800usb_tx_dma_done,
  678. .write_tx_desc = rt2800usb_write_tx_desc,
  679. .write_tx_data = rt2800_write_tx_data,
  680. .write_beacon = rt2800_write_beacon,
  681. .clear_beacon = rt2800_clear_beacon,
  682. .get_tx_data_len = rt2800usb_get_tx_data_len,
  683. .fill_rxdone = rt2800usb_fill_rxdone,
  684. .config_shared_key = rt2800_config_shared_key,
  685. .config_pairwise_key = rt2800_config_pairwise_key,
  686. .config_filter = rt2800_config_filter,
  687. .config_intf = rt2800_config_intf,
  688. .config_erp = rt2800_config_erp,
  689. .config_ant = rt2800_config_ant,
  690. .config = rt2800_config,
  691. .sta_add = rt2800_sta_add,
  692. .sta_remove = rt2800_sta_remove,
  693. };
  694. static const struct data_queue_desc rt2800usb_queue_rx = {
  695. .entry_num = 128,
  696. .data_size = AGGREGATION_SIZE,
  697. .desc_size = RXINFO_DESC_SIZE + RXWI_DESC_SIZE,
  698. .priv_size = sizeof(struct queue_entry_priv_usb),
  699. };
  700. static const struct data_queue_desc rt2800usb_queue_tx = {
  701. .entry_num = 64,
  702. .data_size = AGGREGATION_SIZE,
  703. .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
  704. .priv_size = sizeof(struct queue_entry_priv_usb),
  705. };
  706. static const struct data_queue_desc rt2800usb_queue_bcn = {
  707. .entry_num = 8,
  708. .data_size = MGMT_FRAME_SIZE,
  709. .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
  710. .priv_size = sizeof(struct queue_entry_priv_usb),
  711. };
  712. static const struct rt2x00_ops rt2800usb_ops = {
  713. .name = KBUILD_MODNAME,
  714. .drv_data_size = sizeof(struct rt2800_drv_data),
  715. .max_sta_intf = 1,
  716. .max_ap_intf = 8,
  717. .eeprom_size = EEPROM_SIZE,
  718. .rf_size = RF_SIZE,
  719. .tx_queues = NUM_TX_QUEUES,
  720. .extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
  721. .rx = &rt2800usb_queue_rx,
  722. .tx = &rt2800usb_queue_tx,
  723. .bcn = &rt2800usb_queue_bcn,
  724. .lib = &rt2800usb_rt2x00_ops,
  725. .drv = &rt2800usb_rt2800_ops,
  726. .hw = &rt2800usb_mac80211_ops,
  727. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  728. .debugfs = &rt2800_rt2x00debug,
  729. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  730. };
  731. /*
  732. * rt2800usb module information.
  733. */
  734. static struct usb_device_id rt2800usb_device_table[] = {
  735. /* Abocom */
  736. { USB_DEVICE(0x07b8, 0x2870) },
  737. { USB_DEVICE(0x07b8, 0x2770) },
  738. { USB_DEVICE(0x07b8, 0x3070) },
  739. { USB_DEVICE(0x07b8, 0x3071) },
  740. { USB_DEVICE(0x07b8, 0x3072) },
  741. { USB_DEVICE(0x1482, 0x3c09) },
  742. /* AirTies */
  743. { USB_DEVICE(0x1eda, 0x2012) },
  744. { USB_DEVICE(0x1eda, 0x2310) },
  745. /* Allwin */
  746. { USB_DEVICE(0x8516, 0x2070) },
  747. { USB_DEVICE(0x8516, 0x2770) },
  748. { USB_DEVICE(0x8516, 0x2870) },
  749. { USB_DEVICE(0x8516, 0x3070) },
  750. { USB_DEVICE(0x8516, 0x3071) },
  751. { USB_DEVICE(0x8516, 0x3072) },
  752. /* Alpha Networks */
  753. { USB_DEVICE(0x14b2, 0x3c06) },
  754. { USB_DEVICE(0x14b2, 0x3c07) },
  755. { USB_DEVICE(0x14b2, 0x3c09) },
  756. { USB_DEVICE(0x14b2, 0x3c12) },
  757. { USB_DEVICE(0x14b2, 0x3c23) },
  758. { USB_DEVICE(0x14b2, 0x3c25) },
  759. { USB_DEVICE(0x14b2, 0x3c27) },
  760. { USB_DEVICE(0x14b2, 0x3c28) },
  761. { USB_DEVICE(0x14b2, 0x3c2c) },
  762. /* Amit */
  763. { USB_DEVICE(0x15c5, 0x0008) },
  764. /* Askey */
  765. { USB_DEVICE(0x1690, 0x0740) },
  766. /* ASUS */
  767. { USB_DEVICE(0x0b05, 0x1731) },
  768. { USB_DEVICE(0x0b05, 0x1732) },
  769. { USB_DEVICE(0x0b05, 0x1742) },
  770. { USB_DEVICE(0x0b05, 0x1784) },
  771. { USB_DEVICE(0x1761, 0x0b05) },
  772. /* AzureWave */
  773. { USB_DEVICE(0x13d3, 0x3247) },
  774. { USB_DEVICE(0x13d3, 0x3273) },
  775. { USB_DEVICE(0x13d3, 0x3305) },
  776. { USB_DEVICE(0x13d3, 0x3307) },
  777. { USB_DEVICE(0x13d3, 0x3321) },
  778. /* Belkin */
  779. { USB_DEVICE(0x050d, 0x8053) },
  780. { USB_DEVICE(0x050d, 0x805c) },
  781. { USB_DEVICE(0x050d, 0x815c) },
  782. { USB_DEVICE(0x050d, 0x825a) },
  783. { USB_DEVICE(0x050d, 0x825b) },
  784. { USB_DEVICE(0x050d, 0x935a) },
  785. { USB_DEVICE(0x050d, 0x935b) },
  786. /* Buffalo */
  787. { USB_DEVICE(0x0411, 0x00e8) },
  788. { USB_DEVICE(0x0411, 0x0158) },
  789. { USB_DEVICE(0x0411, 0x015d) },
  790. { USB_DEVICE(0x0411, 0x016f) },
  791. { USB_DEVICE(0x0411, 0x01a2) },
  792. /* Corega */
  793. { USB_DEVICE(0x07aa, 0x002f) },
  794. { USB_DEVICE(0x07aa, 0x003c) },
  795. { USB_DEVICE(0x07aa, 0x003f) },
  796. { USB_DEVICE(0x18c5, 0x0012) },
  797. /* D-Link */
  798. { USB_DEVICE(0x07d1, 0x3c09) },
  799. { USB_DEVICE(0x07d1, 0x3c0a) },
  800. { USB_DEVICE(0x07d1, 0x3c0d) },
  801. { USB_DEVICE(0x07d1, 0x3c0e) },
  802. { USB_DEVICE(0x07d1, 0x3c0f) },
  803. { USB_DEVICE(0x07d1, 0x3c11) },
  804. { USB_DEVICE(0x07d1, 0x3c13) },
  805. { USB_DEVICE(0x07d1, 0x3c15) },
  806. { USB_DEVICE(0x07d1, 0x3c16) },
  807. { USB_DEVICE(0x2001, 0x3c1b) },
  808. /* Draytek */
  809. { USB_DEVICE(0x07fa, 0x7712) },
  810. /* DVICO */
  811. { USB_DEVICE(0x0fe9, 0xb307) },
  812. /* Edimax */
  813. { USB_DEVICE(0x7392, 0x7711) },
  814. { USB_DEVICE(0x7392, 0x7717) },
  815. { USB_DEVICE(0x7392, 0x7718) },
  816. { USB_DEVICE(0x7392, 0x7722) },
  817. /* Encore */
  818. { USB_DEVICE(0x203d, 0x1480) },
  819. { USB_DEVICE(0x203d, 0x14a9) },
  820. /* EnGenius */
  821. { USB_DEVICE(0x1740, 0x9701) },
  822. { USB_DEVICE(0x1740, 0x9702) },
  823. { USB_DEVICE(0x1740, 0x9703) },
  824. { USB_DEVICE(0x1740, 0x9705) },
  825. { USB_DEVICE(0x1740, 0x9706) },
  826. { USB_DEVICE(0x1740, 0x9707) },
  827. { USB_DEVICE(0x1740, 0x9708) },
  828. { USB_DEVICE(0x1740, 0x9709) },
  829. /* Gemtek */
  830. { USB_DEVICE(0x15a9, 0x0012) },
  831. /* Gigabyte */
  832. { USB_DEVICE(0x1044, 0x800b) },
  833. { USB_DEVICE(0x1044, 0x800d) },
  834. /* Hawking */
  835. { USB_DEVICE(0x0e66, 0x0001) },
  836. { USB_DEVICE(0x0e66, 0x0003) },
  837. { USB_DEVICE(0x0e66, 0x0009) },
  838. { USB_DEVICE(0x0e66, 0x000b) },
  839. { USB_DEVICE(0x0e66, 0x0013) },
  840. { USB_DEVICE(0x0e66, 0x0017) },
  841. { USB_DEVICE(0x0e66, 0x0018) },
  842. /* I-O DATA */
  843. { USB_DEVICE(0x04bb, 0x0945) },
  844. { USB_DEVICE(0x04bb, 0x0947) },
  845. { USB_DEVICE(0x04bb, 0x0948) },
  846. /* Linksys */
  847. { USB_DEVICE(0x13b1, 0x0031) },
  848. { USB_DEVICE(0x1737, 0x0070) },
  849. { USB_DEVICE(0x1737, 0x0071) },
  850. { USB_DEVICE(0x1737, 0x0077) },
  851. { USB_DEVICE(0x1737, 0x0078) },
  852. /* Logitec */
  853. { USB_DEVICE(0x0789, 0x0162) },
  854. { USB_DEVICE(0x0789, 0x0163) },
  855. { USB_DEVICE(0x0789, 0x0164) },
  856. { USB_DEVICE(0x0789, 0x0166) },
  857. /* Motorola */
  858. { USB_DEVICE(0x100d, 0x9031) },
  859. /* MSI */
  860. { USB_DEVICE(0x0db0, 0x3820) },
  861. { USB_DEVICE(0x0db0, 0x3821) },
  862. { USB_DEVICE(0x0db0, 0x3822) },
  863. { USB_DEVICE(0x0db0, 0x3870) },
  864. { USB_DEVICE(0x0db0, 0x3871) },
  865. { USB_DEVICE(0x0db0, 0x6899) },
  866. { USB_DEVICE(0x0db0, 0x821a) },
  867. { USB_DEVICE(0x0db0, 0x822a) },
  868. { USB_DEVICE(0x0db0, 0x822b) },
  869. { USB_DEVICE(0x0db0, 0x822c) },
  870. { USB_DEVICE(0x0db0, 0x870a) },
  871. { USB_DEVICE(0x0db0, 0x871a) },
  872. { USB_DEVICE(0x0db0, 0x871b) },
  873. { USB_DEVICE(0x0db0, 0x871c) },
  874. { USB_DEVICE(0x0db0, 0x899a) },
  875. /* Ovislink */
  876. { USB_DEVICE(0x1b75, 0x3071) },
  877. { USB_DEVICE(0x1b75, 0x3072) },
  878. /* Para */
  879. { USB_DEVICE(0x20b8, 0x8888) },
  880. /* Pegatron */
  881. { USB_DEVICE(0x1d4d, 0x0002) },
  882. { USB_DEVICE(0x1d4d, 0x000c) },
  883. { USB_DEVICE(0x1d4d, 0x000e) },
  884. { USB_DEVICE(0x1d4d, 0x0011) },
  885. /* Philips */
  886. { USB_DEVICE(0x0471, 0x200f) },
  887. /* Planex */
  888. { USB_DEVICE(0x2019, 0xab25) },
  889. { USB_DEVICE(0x2019, 0xed06) },
  890. /* Quanta */
  891. { USB_DEVICE(0x1a32, 0x0304) },
  892. /* Ralink */
  893. { USB_DEVICE(0x148f, 0x2070) },
  894. { USB_DEVICE(0x148f, 0x2770) },
  895. { USB_DEVICE(0x148f, 0x2870) },
  896. { USB_DEVICE(0x148f, 0x3070) },
  897. { USB_DEVICE(0x148f, 0x3071) },
  898. { USB_DEVICE(0x148f, 0x3072) },
  899. /* Samsung */
  900. { USB_DEVICE(0x04e8, 0x2018) },
  901. /* Siemens */
  902. { USB_DEVICE(0x129b, 0x1828) },
  903. /* Sitecom */
  904. { USB_DEVICE(0x0df6, 0x0017) },
  905. { USB_DEVICE(0x0df6, 0x002b) },
  906. { USB_DEVICE(0x0df6, 0x002c) },
  907. { USB_DEVICE(0x0df6, 0x002d) },
  908. { USB_DEVICE(0x0df6, 0x0039) },
  909. { USB_DEVICE(0x0df6, 0x003b) },
  910. { USB_DEVICE(0x0df6, 0x003d) },
  911. { USB_DEVICE(0x0df6, 0x003e) },
  912. { USB_DEVICE(0x0df6, 0x003f) },
  913. { USB_DEVICE(0x0df6, 0x0040) },
  914. { USB_DEVICE(0x0df6, 0x0042) },
  915. { USB_DEVICE(0x0df6, 0x0047) },
  916. { USB_DEVICE(0x0df6, 0x0048) },
  917. { USB_DEVICE(0x0df6, 0x0051) },
  918. { USB_DEVICE(0x0df6, 0x005f) },
  919. { USB_DEVICE(0x0df6, 0x0060) },
  920. /* SMC */
  921. { USB_DEVICE(0x083a, 0x6618) },
  922. { USB_DEVICE(0x083a, 0x7511) },
  923. { USB_DEVICE(0x083a, 0x7512) },
  924. { USB_DEVICE(0x083a, 0x7522) },
  925. { USB_DEVICE(0x083a, 0x8522) },
  926. { USB_DEVICE(0x083a, 0xa618) },
  927. { USB_DEVICE(0x083a, 0xa701) },
  928. { USB_DEVICE(0x083a, 0xa702) },
  929. { USB_DEVICE(0x083a, 0xa703) },
  930. { USB_DEVICE(0x083a, 0xb522) },
  931. /* Sparklan */
  932. { USB_DEVICE(0x15a9, 0x0006) },
  933. /* Sweex */
  934. { USB_DEVICE(0x177f, 0x0153) },
  935. { USB_DEVICE(0x177f, 0x0302) },
  936. { USB_DEVICE(0x177f, 0x0313) },
  937. /* U-Media */
  938. { USB_DEVICE(0x157e, 0x300e) },
  939. { USB_DEVICE(0x157e, 0x3013) },
  940. /* ZCOM */
  941. { USB_DEVICE(0x0cde, 0x0022) },
  942. { USB_DEVICE(0x0cde, 0x0025) },
  943. /* Zinwell */
  944. { USB_DEVICE(0x5a57, 0x0280) },
  945. { USB_DEVICE(0x5a57, 0x0282) },
  946. { USB_DEVICE(0x5a57, 0x0283) },
  947. { USB_DEVICE(0x5a57, 0x5257) },
  948. /* Zyxel */
  949. { USB_DEVICE(0x0586, 0x3416) },
  950. { USB_DEVICE(0x0586, 0x3418) },
  951. { USB_DEVICE(0x0586, 0x341e) },
  952. { USB_DEVICE(0x0586, 0x343e) },
  953. #ifdef CONFIG_RT2800USB_RT33XX
  954. /* Belkin */
  955. { USB_DEVICE(0x050d, 0x945b) },
  956. /* Ralink */
  957. { USB_DEVICE(0x148f, 0x3370) },
  958. { USB_DEVICE(0x148f, 0x8070) },
  959. /* Sitecom */
  960. { USB_DEVICE(0x0df6, 0x0050) },
  961. #endif
  962. #ifdef CONFIG_RT2800USB_RT35XX
  963. /* Allwin */
  964. { USB_DEVICE(0x8516, 0x3572) },
  965. /* Askey */
  966. { USB_DEVICE(0x1690, 0x0744) },
  967. /* Cisco */
  968. { USB_DEVICE(0x167b, 0x4001) },
  969. /* EnGenius */
  970. { USB_DEVICE(0x1740, 0x9801) },
  971. /* I-O DATA */
  972. { USB_DEVICE(0x04bb, 0x0944) },
  973. /* Linksys */
  974. { USB_DEVICE(0x13b1, 0x002f) },
  975. { USB_DEVICE(0x1737, 0x0079) },
  976. /* Ralink */
  977. { USB_DEVICE(0x148f, 0x3572) },
  978. /* Sitecom */
  979. { USB_DEVICE(0x0df6, 0x0041) },
  980. { USB_DEVICE(0x0df6, 0x0062) },
  981. /* Toshiba */
  982. { USB_DEVICE(0x0930, 0x0a07) },
  983. /* Zinwell */
  984. { USB_DEVICE(0x5a57, 0x0284) },
  985. #endif
  986. #ifdef CONFIG_RT2800USB_RT53XX
  987. /* Azurewave */
  988. { USB_DEVICE(0x13d3, 0x3329) },
  989. { USB_DEVICE(0x13d3, 0x3365) },
  990. /* Ralink */
  991. { USB_DEVICE(0x148f, 0x5370) },
  992. { USB_DEVICE(0x148f, 0x5372) },
  993. #endif
  994. #ifdef CONFIG_RT2800USB_UNKNOWN
  995. /*
  996. * Unclear what kind of devices these are (they aren't supported by the
  997. * vendor linux driver).
  998. */
  999. /* Abocom */
  1000. { USB_DEVICE(0x07b8, 0x3073) },
  1001. { USB_DEVICE(0x07b8, 0x3074) },
  1002. /* Alpha Networks */
  1003. { USB_DEVICE(0x14b2, 0x3c08) },
  1004. { USB_DEVICE(0x14b2, 0x3c11) },
  1005. /* Amigo */
  1006. { USB_DEVICE(0x0e0b, 0x9031) },
  1007. { USB_DEVICE(0x0e0b, 0x9041) },
  1008. /* ASUS */
  1009. { USB_DEVICE(0x0b05, 0x166a) },
  1010. { USB_DEVICE(0x0b05, 0x1760) },
  1011. { USB_DEVICE(0x0b05, 0x1761) },
  1012. { USB_DEVICE(0x0b05, 0x1790) },
  1013. { USB_DEVICE(0x0b05, 0x179d) },
  1014. /* AzureWave */
  1015. { USB_DEVICE(0x13d3, 0x3262) },
  1016. { USB_DEVICE(0x13d3, 0x3284) },
  1017. { USB_DEVICE(0x13d3, 0x3322) },
  1018. /* Belkin */
  1019. { USB_DEVICE(0x050d, 0x1003) },
  1020. /* Buffalo */
  1021. { USB_DEVICE(0x0411, 0x012e) },
  1022. { USB_DEVICE(0x0411, 0x0148) },
  1023. { USB_DEVICE(0x0411, 0x0150) },
  1024. /* Corega */
  1025. { USB_DEVICE(0x07aa, 0x0041) },
  1026. { USB_DEVICE(0x07aa, 0x0042) },
  1027. { USB_DEVICE(0x18c5, 0x0008) },
  1028. /* D-Link */
  1029. { USB_DEVICE(0x07d1, 0x3c0b) },
  1030. { USB_DEVICE(0x07d1, 0x3c17) },
  1031. { USB_DEVICE(0x2001, 0x3c17) },
  1032. /* Edimax */
  1033. { USB_DEVICE(0x7392, 0x4085) },
  1034. /* Encore */
  1035. { USB_DEVICE(0x203d, 0x14a1) },
  1036. /* Fujitsu Stylistic 550 */
  1037. { USB_DEVICE(0x1690, 0x0761) },
  1038. /* Gemtek */
  1039. { USB_DEVICE(0x15a9, 0x0010) },
  1040. /* Gigabyte */
  1041. { USB_DEVICE(0x1044, 0x800c) },
  1042. /* Huawei */
  1043. { USB_DEVICE(0x148f, 0xf101) },
  1044. /* I-O DATA */
  1045. { USB_DEVICE(0x04bb, 0x094b) },
  1046. /* LevelOne */
  1047. { USB_DEVICE(0x1740, 0x0605) },
  1048. { USB_DEVICE(0x1740, 0x0615) },
  1049. /* Logitec */
  1050. { USB_DEVICE(0x0789, 0x0168) },
  1051. { USB_DEVICE(0x0789, 0x0169) },
  1052. /* Motorola */
  1053. { USB_DEVICE(0x100d, 0x9032) },
  1054. /* Pegatron */
  1055. { USB_DEVICE(0x05a6, 0x0101) },
  1056. { USB_DEVICE(0x1d4d, 0x0010) },
  1057. /* Planex */
  1058. { USB_DEVICE(0x2019, 0x5201) },
  1059. { USB_DEVICE(0x2019, 0xab24) },
  1060. /* Qcom */
  1061. { USB_DEVICE(0x18e8, 0x6259) },
  1062. /* RadioShack */
  1063. { USB_DEVICE(0x08b9, 0x1197) },
  1064. /* Sitecom */
  1065. { USB_DEVICE(0x0df6, 0x003c) },
  1066. { USB_DEVICE(0x0df6, 0x004a) },
  1067. { USB_DEVICE(0x0df6, 0x004d) },
  1068. { USB_DEVICE(0x0df6, 0x0053) },
  1069. /* SMC */
  1070. { USB_DEVICE(0x083a, 0xa512) },
  1071. { USB_DEVICE(0x083a, 0xc522) },
  1072. { USB_DEVICE(0x083a, 0xd522) },
  1073. { USB_DEVICE(0x083a, 0xf511) },
  1074. /* Zyxel */
  1075. { USB_DEVICE(0x0586, 0x341a) },
  1076. #endif
  1077. { 0, }
  1078. };
  1079. MODULE_AUTHOR(DRV_PROJECT);
  1080. MODULE_VERSION(DRV_VERSION);
  1081. MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
  1082. MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards");
  1083. MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
  1084. MODULE_FIRMWARE(FIRMWARE_RT2870);
  1085. MODULE_LICENSE("GPL");
  1086. static int rt2800usb_probe(struct usb_interface *usb_intf,
  1087. const struct usb_device_id *id)
  1088. {
  1089. return rt2x00usb_probe(usb_intf, &rt2800usb_ops);
  1090. }
  1091. static struct usb_driver rt2800usb_driver = {
  1092. .name = KBUILD_MODNAME,
  1093. .id_table = rt2800usb_device_table,
  1094. .probe = rt2800usb_probe,
  1095. .disconnect = rt2x00usb_disconnect,
  1096. .suspend = rt2x00usb_suspend,
  1097. .resume = rt2x00usb_resume,
  1098. };
  1099. module_usb_driver(rt2800usb_driver);