rt2800usb.c 36 KB

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