rt2800usb.c 38 KB

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