rt2800usb.c 38 KB

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