rt2800usb.c 37 KB

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