rt2800usb.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  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 int 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. rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
  54. rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
  55. rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
  56. break;
  57. case QID_BEACON:
  58. rt2800_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. rt2800_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. rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
  75. rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
  76. rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
  77. break;
  78. case QID_BEACON:
  79. rt2800_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. rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
  84. break;
  85. default:
  86. break;
  87. }
  88. }
  89. static void rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
  90. int urb_status, u32 tx_status)
  91. {
  92. if (urb_status) {
  93. WARNING(rt2x00dev, "rt2x00usb_register_read_async failed: %d\n", urb_status);
  94. return;
  95. }
  96. /* try to read all TX_STA_FIFO entries before scheduling txdone_work */
  97. if (rt2x00_get_field32(tx_status, TX_STA_FIFO_VALID)) {
  98. if (!kfifo_put(&rt2x00dev->txstatus_fifo, &tx_status)) {
  99. WARNING(rt2x00dev, "TX status FIFO overrun, "
  100. "drop tx status report.\n");
  101. queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
  102. } else
  103. rt2x00usb_register_read_async(rt2x00dev, TX_STA_FIFO,
  104. rt2800usb_tx_sta_fifo_read_completed);
  105. } else if (!kfifo_is_empty(&rt2x00dev->txstatus_fifo))
  106. queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
  107. }
  108. static void rt2800usb_tx_dma_done(struct queue_entry *entry)
  109. {
  110. struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
  111. rt2x00usb_register_read_async(rt2x00dev, TX_STA_FIFO,
  112. rt2800usb_tx_sta_fifo_read_completed);
  113. }
  114. /*
  115. * Firmware functions
  116. */
  117. static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
  118. {
  119. return FIRMWARE_RT2870;
  120. }
  121. static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
  122. const u8 *data, const size_t len)
  123. {
  124. int status;
  125. u32 offset;
  126. u32 length;
  127. /*
  128. * Check which section of the firmware we need.
  129. */
  130. if (rt2x00_rt(rt2x00dev, RT2860) ||
  131. rt2x00_rt(rt2x00dev, RT2872) ||
  132. rt2x00_rt(rt2x00dev, RT3070)) {
  133. offset = 0;
  134. length = 4096;
  135. } else {
  136. offset = 4096;
  137. length = 4096;
  138. }
  139. /*
  140. * Write firmware to device.
  141. */
  142. rt2800_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
  143. data + offset, length);
  144. rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
  145. rt2800_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
  146. /*
  147. * Send firmware request to device to load firmware,
  148. * we need to specify a long timeout time.
  149. */
  150. status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
  151. 0, USB_MODE_FIRMWARE,
  152. REGISTER_TIMEOUT_FIRMWARE);
  153. if (status < 0) {
  154. ERROR(rt2x00dev, "Failed to write Firmware to device.\n");
  155. return status;
  156. }
  157. msleep(10);
  158. rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
  159. return 0;
  160. }
  161. /*
  162. * Device state switch handlers.
  163. */
  164. static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
  165. {
  166. u32 reg;
  167. /*
  168. * Wait until BBP and RF are ready.
  169. */
  170. if (rt2800_wait_csr_ready(rt2x00dev))
  171. return -EBUSY;
  172. rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, &reg);
  173. rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
  174. rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
  175. rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
  176. rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
  177. rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
  178. rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
  179. rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
  180. rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
  181. USB_MODE_RESET, REGISTER_TIMEOUT);
  182. rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
  183. return 0;
  184. }
  185. static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
  186. {
  187. u32 reg;
  188. if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev)))
  189. return -EIO;
  190. rt2800_register_read(rt2x00dev, USB_DMA_CFG, &reg);
  191. rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0);
  192. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN, 0);
  193. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
  194. /*
  195. * Total room for RX frames in kilobytes, PBF might still exceed
  196. * this limit so reduce the number to prevent errors.
  197. */
  198. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_LIMIT,
  199. ((rt2x00dev->ops->rx->entry_num * DATA_FRAME_SIZE)
  200. / 1024) - 3);
  201. rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_EN, 1);
  202. rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1);
  203. rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg);
  204. return rt2800_enable_radio(rt2x00dev);
  205. }
  206. static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
  207. {
  208. rt2800_disable_radio(rt2x00dev);
  209. rt2x00usb_disable_radio(rt2x00dev);
  210. }
  211. static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev,
  212. enum dev_state state)
  213. {
  214. if (state == STATE_AWAKE)
  215. rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 2);
  216. else
  217. rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0xff, 2);
  218. return 0;
  219. }
  220. static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
  221. enum dev_state state)
  222. {
  223. int retval = 0;
  224. switch (state) {
  225. case STATE_RADIO_ON:
  226. /*
  227. * Before the radio can be enabled, the device first has
  228. * to be woken up. After that it needs a bit of time
  229. * to be fully awake and then the radio can be enabled.
  230. */
  231. rt2800usb_set_state(rt2x00dev, STATE_AWAKE);
  232. msleep(1);
  233. retval = rt2800usb_enable_radio(rt2x00dev);
  234. break;
  235. case STATE_RADIO_OFF:
  236. /*
  237. * After the radio has been disabled, the device should
  238. * be put to sleep for powersaving.
  239. */
  240. rt2800usb_disable_radio(rt2x00dev);
  241. rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
  242. break;
  243. case STATE_RADIO_IRQ_ON:
  244. case STATE_RADIO_IRQ_OFF:
  245. /* No support, but no error either */
  246. break;
  247. case STATE_DEEP_SLEEP:
  248. case STATE_SLEEP:
  249. case STATE_STANDBY:
  250. case STATE_AWAKE:
  251. retval = rt2800usb_set_state(rt2x00dev, state);
  252. break;
  253. default:
  254. retval = -ENOTSUPP;
  255. break;
  256. }
  257. if (unlikely(retval))
  258. ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
  259. state, retval);
  260. return retval;
  261. }
  262. /*
  263. * Watchdog handlers
  264. */
  265. static void rt2800usb_watchdog(struct rt2x00_dev *rt2x00dev)
  266. {
  267. unsigned int i;
  268. u32 reg;
  269. rt2800_register_read(rt2x00dev, TXRXQ_PCNT, &reg);
  270. if (rt2x00_get_field32(reg, TXRXQ_PCNT_TX0Q)) {
  271. WARNING(rt2x00dev, "TX HW queue 0 timed out,"
  272. " invoke forced kick\n");
  273. rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40012);
  274. for (i = 0; i < 10; i++) {
  275. udelay(10);
  276. if (!rt2x00_get_field32(reg, TXRXQ_PCNT_TX0Q))
  277. break;
  278. }
  279. rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006);
  280. }
  281. rt2800_register_read(rt2x00dev, TXRXQ_PCNT, &reg);
  282. if (rt2x00_get_field32(reg, TXRXQ_PCNT_TX1Q)) {
  283. WARNING(rt2x00dev, "TX HW queue 1 timed out,"
  284. " invoke forced kick\n");
  285. rt2800_register_write(rt2x00dev, PBF_CFG, 0xf4000a);
  286. for (i = 0; i < 10; i++) {
  287. udelay(10);
  288. if (!rt2x00_get_field32(reg, TXRXQ_PCNT_TX1Q))
  289. break;
  290. }
  291. rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006);
  292. }
  293. rt2x00usb_watchdog(rt2x00dev);
  294. }
  295. /*
  296. * TX descriptor initialization
  297. */
  298. static __le32 *rt2800usb_get_txwi(struct queue_entry *entry)
  299. {
  300. if (entry->queue->qid == QID_BEACON)
  301. return (__le32 *) (entry->skb->data);
  302. else
  303. return (__le32 *) (entry->skb->data + TXINFO_DESC_SIZE);
  304. }
  305. static void rt2800usb_write_tx_desc(struct queue_entry *entry,
  306. struct txentry_desc *txdesc)
  307. {
  308. struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
  309. __le32 *txi = (__le32 *) entry->skb->data;
  310. u32 word;
  311. /*
  312. * Initialize TXINFO descriptor
  313. */
  314. rt2x00_desc_read(txi, 0, &word);
  315. /*
  316. * The size of TXINFO_W0_USB_DMA_TX_PKT_LEN is
  317. * TXWI + 802.11 header + L2 pad + payload + pad,
  318. * so need to decrease size of TXINFO and USB end pad.
  319. */
  320. rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN,
  321. entry->skb->len - TXINFO_DESC_SIZE - 4);
  322. rt2x00_set_field32(&word, TXINFO_W0_WIV,
  323. !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
  324. rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2);
  325. rt2x00_set_field32(&word, TXINFO_W0_SW_USE_LAST_ROUND, 0);
  326. rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_NEXT_VALID, 0);
  327. rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST,
  328. test_bit(ENTRY_TXD_BURST, &txdesc->flags));
  329. rt2x00_desc_write(txi, 0, word);
  330. /*
  331. * Register descriptor details in skb frame descriptor.
  332. */
  333. skbdesc->flags |= SKBDESC_DESC_IN_SKB;
  334. skbdesc->desc = txi;
  335. skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
  336. }
  337. static void rt2800usb_write_tx_data(struct queue_entry *entry,
  338. struct txentry_desc *txdesc)
  339. {
  340. unsigned int len;
  341. int err;
  342. rt2800_write_tx_data(entry, txdesc);
  343. /*
  344. * pad(1~3 bytes) is added after each 802.11 payload.
  345. * USB end pad(4 bytes) is added at each USB bulk out packet end.
  346. * TX frame format is :
  347. * | TXINFO | TXWI | 802.11 header | L2 pad | payload | pad | USB end pad |
  348. * |<------------- tx_pkt_len ------------->|
  349. */
  350. len = roundup(entry->skb->len, 4) + 4;
  351. err = skb_padto(entry->skb, len);
  352. if (unlikely(err)) {
  353. WARNING(entry->queue->rt2x00dev, "TX SKB padding error, out of memory\n");
  354. return;
  355. }
  356. entry->skb->len = len;
  357. }
  358. /*
  359. * TX data initialization
  360. */
  361. static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
  362. {
  363. return entry->skb->len;
  364. }
  365. /*
  366. * TX control handlers
  367. */
  368. static void rt2800usb_work_txdone(struct work_struct *work)
  369. {
  370. struct rt2x00_dev *rt2x00dev =
  371. container_of(work, struct rt2x00_dev, txdone_work);
  372. struct data_queue *queue;
  373. struct queue_entry *entry;
  374. rt2800_txdone(rt2x00dev);
  375. /*
  376. * Process any trailing TX status reports for IO failures,
  377. * we loop until we find the first non-IO error entry. This
  378. * can either be a frame which is free, is being uploaded,
  379. * or has completed the upload but didn't have an entry
  380. * in the TX_STAT_FIFO register yet.
  381. */
  382. tx_queue_for_each(rt2x00dev, queue) {
  383. while (!rt2x00queue_empty(queue)) {
  384. entry = rt2x00queue_get_entry(queue, Q_INDEX_DONE);
  385. if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
  386. break;
  387. if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags))
  388. rt2x00lib_txdone_noinfo(entry, TXDONE_FAILURE);
  389. else if (rt2x00queue_status_timeout(entry))
  390. rt2x00lib_txdone_noinfo(entry, TXDONE_UNKNOWN);
  391. else
  392. break;
  393. }
  394. }
  395. }
  396. /*
  397. * RX control handlers
  398. */
  399. static void rt2800usb_fill_rxdone(struct queue_entry *entry,
  400. struct rxdone_entry_desc *rxdesc)
  401. {
  402. struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
  403. __le32 *rxi = (__le32 *)entry->skb->data;
  404. __le32 *rxd;
  405. u32 word;
  406. int rx_pkt_len;
  407. /*
  408. * Copy descriptor to the skbdesc->desc buffer, making it safe from
  409. * moving of frame data in rt2x00usb.
  410. */
  411. memcpy(skbdesc->desc, rxi, skbdesc->desc_len);
  412. /*
  413. * RX frame format is :
  414. * | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad |
  415. * |<------------ rx_pkt_len -------------->|
  416. */
  417. rt2x00_desc_read(rxi, 0, &word);
  418. rx_pkt_len = rt2x00_get_field32(word, RXINFO_W0_USB_DMA_RX_PKT_LEN);
  419. /*
  420. * Remove the RXINFO structure from the sbk.
  421. */
  422. skb_pull(entry->skb, RXINFO_DESC_SIZE);
  423. /*
  424. * FIXME: we need to check for rx_pkt_len validity
  425. */
  426. rxd = (__le32 *)(entry->skb->data + rx_pkt_len);
  427. /*
  428. * It is now safe to read the descriptor on all architectures.
  429. */
  430. rt2x00_desc_read(rxd, 0, &word);
  431. if (rt2x00_get_field32(word, RXD_W0_CRC_ERROR))
  432. rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
  433. rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W0_CIPHER_ERROR);
  434. if (rt2x00_get_field32(word, RXD_W0_DECRYPTED)) {
  435. /*
  436. * Hardware has stripped IV/EIV data from 802.11 frame during
  437. * decryption. Unfortunately the descriptor doesn't contain
  438. * any fields with the EIV/IV data either, so they can't
  439. * be restored by rt2x00lib.
  440. */
  441. rxdesc->flags |= RX_FLAG_IV_STRIPPED;
  442. /*
  443. * The hardware has already checked the Michael Mic and has
  444. * stripped it from the frame. Signal this to mac80211.
  445. */
  446. rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
  447. if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
  448. rxdesc->flags |= RX_FLAG_DECRYPTED;
  449. else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
  450. rxdesc->flags |= RX_FLAG_MMIC_ERROR;
  451. }
  452. if (rt2x00_get_field32(word, RXD_W0_MY_BSS))
  453. rxdesc->dev_flags |= RXDONE_MY_BSS;
  454. if (rt2x00_get_field32(word, RXD_W0_L2PAD))
  455. rxdesc->dev_flags |= RXDONE_L2PAD;
  456. /*
  457. * Remove RXD descriptor from end of buffer.
  458. */
  459. skb_trim(entry->skb, rx_pkt_len);
  460. /*
  461. * Process the RXWI structure.
  462. */
  463. rt2800_process_rxwi(entry, rxdesc);
  464. }
  465. /*
  466. * Device probe functions.
  467. */
  468. static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
  469. {
  470. if (rt2800_efuse_detect(rt2x00dev))
  471. rt2800_read_eeprom_efuse(rt2x00dev);
  472. else
  473. rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,
  474. EEPROM_SIZE);
  475. return rt2800_validate_eeprom(rt2x00dev);
  476. }
  477. static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
  478. {
  479. int retval;
  480. /*
  481. * Allocate eeprom data.
  482. */
  483. retval = rt2800usb_validate_eeprom(rt2x00dev);
  484. if (retval)
  485. return retval;
  486. retval = rt2800_init_eeprom(rt2x00dev);
  487. if (retval)
  488. return retval;
  489. /*
  490. * Initialize hw specifications.
  491. */
  492. retval = rt2800_probe_hw_mode(rt2x00dev);
  493. if (retval)
  494. return retval;
  495. /*
  496. * This device has multiple filters for control frames
  497. * and has a separate filter for PS Poll frames.
  498. */
  499. __set_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags);
  500. __set_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags);
  501. /*
  502. * This device requires firmware.
  503. */
  504. __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags);
  505. __set_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags);
  506. if (!modparam_nohwcrypt)
  507. __set_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags);
  508. __set_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags);
  509. __set_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags);
  510. __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags);
  511. /*
  512. * Set the rssi offset.
  513. */
  514. rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
  515. /*
  516. * Overwrite TX done handler
  517. */
  518. PREPARE_WORK(&rt2x00dev->txdone_work, rt2800usb_work_txdone);
  519. return 0;
  520. }
  521. static const struct ieee80211_ops rt2800usb_mac80211_ops = {
  522. .tx = rt2x00mac_tx,
  523. .start = rt2x00mac_start,
  524. .stop = rt2x00mac_stop,
  525. .add_interface = rt2x00mac_add_interface,
  526. .remove_interface = rt2x00mac_remove_interface,
  527. .config = rt2x00mac_config,
  528. .configure_filter = rt2x00mac_configure_filter,
  529. .set_tim = rt2x00mac_set_tim,
  530. .set_key = rt2x00mac_set_key,
  531. .sw_scan_start = rt2x00mac_sw_scan_start,
  532. .sw_scan_complete = rt2x00mac_sw_scan_complete,
  533. .get_stats = rt2x00mac_get_stats,
  534. .get_tkip_seq = rt2800_get_tkip_seq,
  535. .set_rts_threshold = rt2800_set_rts_threshold,
  536. .bss_info_changed = rt2x00mac_bss_info_changed,
  537. .conf_tx = rt2800_conf_tx,
  538. .get_tsf = rt2800_get_tsf,
  539. .rfkill_poll = rt2x00mac_rfkill_poll,
  540. .ampdu_action = rt2800_ampdu_action,
  541. .flush = rt2x00mac_flush,
  542. .get_survey = rt2800_get_survey,
  543. };
  544. static const struct rt2800_ops rt2800usb_rt2800_ops = {
  545. .register_read = rt2x00usb_register_read,
  546. .register_read_lock = rt2x00usb_register_read_lock,
  547. .register_write = rt2x00usb_register_write,
  548. .register_write_lock = rt2x00usb_register_write_lock,
  549. .register_multiread = rt2x00usb_register_multiread,
  550. .register_multiwrite = rt2x00usb_register_multiwrite,
  551. .regbusy_read = rt2x00usb_regbusy_read,
  552. .drv_write_firmware = rt2800usb_write_firmware,
  553. .drv_init_registers = rt2800usb_init_registers,
  554. .drv_get_txwi = rt2800usb_get_txwi,
  555. };
  556. static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
  557. .probe_hw = rt2800usb_probe_hw,
  558. .get_firmware_name = rt2800usb_get_firmware_name,
  559. .check_firmware = rt2800_check_firmware,
  560. .load_firmware = rt2800_load_firmware,
  561. .initialize = rt2x00usb_initialize,
  562. .uninitialize = rt2x00usb_uninitialize,
  563. .clear_entry = rt2x00usb_clear_entry,
  564. .set_device_state = rt2800usb_set_device_state,
  565. .rfkill_poll = rt2800_rfkill_poll,
  566. .link_stats = rt2800_link_stats,
  567. .reset_tuner = rt2800_reset_tuner,
  568. .link_tuner = rt2800_link_tuner,
  569. .gain_calibration = rt2800_gain_calibration,
  570. .watchdog = rt2800usb_watchdog,
  571. .start_queue = rt2800usb_start_queue,
  572. .kick_queue = rt2x00usb_kick_queue,
  573. .stop_queue = rt2800usb_stop_queue,
  574. .flush_queue = rt2x00usb_flush_queue,
  575. .tx_dma_done = rt2800usb_tx_dma_done,
  576. .write_tx_desc = rt2800usb_write_tx_desc,
  577. .write_tx_data = rt2800usb_write_tx_data,
  578. .write_beacon = rt2800_write_beacon,
  579. .clear_beacon = rt2800_clear_beacon,
  580. .get_tx_data_len = rt2800usb_get_tx_data_len,
  581. .fill_rxdone = rt2800usb_fill_rxdone,
  582. .config_shared_key = rt2800_config_shared_key,
  583. .config_pairwise_key = rt2800_config_pairwise_key,
  584. .config_filter = rt2800_config_filter,
  585. .config_intf = rt2800_config_intf,
  586. .config_erp = rt2800_config_erp,
  587. .config_ant = rt2800_config_ant,
  588. .config = rt2800_config,
  589. };
  590. static const struct data_queue_desc rt2800usb_queue_rx = {
  591. .entry_num = 128,
  592. .data_size = AGGREGATION_SIZE,
  593. .desc_size = RXINFO_DESC_SIZE + RXWI_DESC_SIZE,
  594. .priv_size = sizeof(struct queue_entry_priv_usb),
  595. };
  596. static const struct data_queue_desc rt2800usb_queue_tx = {
  597. .entry_num = 64,
  598. .data_size = AGGREGATION_SIZE,
  599. .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
  600. .priv_size = sizeof(struct queue_entry_priv_usb),
  601. };
  602. static const struct data_queue_desc rt2800usb_queue_bcn = {
  603. .entry_num = 8,
  604. .data_size = MGMT_FRAME_SIZE,
  605. .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
  606. .priv_size = sizeof(struct queue_entry_priv_usb),
  607. };
  608. static const struct rt2x00_ops rt2800usb_ops = {
  609. .name = KBUILD_MODNAME,
  610. .max_sta_intf = 1,
  611. .max_ap_intf = 8,
  612. .eeprom_size = EEPROM_SIZE,
  613. .rf_size = RF_SIZE,
  614. .tx_queues = NUM_TX_QUEUES,
  615. .extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
  616. .rx = &rt2800usb_queue_rx,
  617. .tx = &rt2800usb_queue_tx,
  618. .bcn = &rt2800usb_queue_bcn,
  619. .lib = &rt2800usb_rt2x00_ops,
  620. .drv = &rt2800usb_rt2800_ops,
  621. .hw = &rt2800usb_mac80211_ops,
  622. #ifdef CONFIG_RT2X00_LIB_DEBUGFS
  623. .debugfs = &rt2800_rt2x00debug,
  624. #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
  625. };
  626. /*
  627. * rt2800usb module information.
  628. */
  629. static struct usb_device_id rt2800usb_device_table[] = {
  630. /* Abocom */
  631. { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
  632. { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
  633. { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
  634. { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
  635. { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
  636. { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
  637. /* AirTies */
  638. { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) },
  639. /* Allwin */
  640. { USB_DEVICE(0x8516, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) },
  641. { USB_DEVICE(0x8516, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
  642. { USB_DEVICE(0x8516, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
  643. { USB_DEVICE(0x8516, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
  644. { USB_DEVICE(0x8516, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
  645. { USB_DEVICE(0x8516, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
  646. /* Alpha Networks */
  647. { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) },
  648. { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) },
  649. { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
  650. { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) },
  651. { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) },
  652. { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) },
  653. { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) },
  654. { USB_DEVICE(0x14b2, 0x3c28), USB_DEVICE_DATA(&rt2800usb_ops) },
  655. { USB_DEVICE(0x14b2, 0x3c2c), USB_DEVICE_DATA(&rt2800usb_ops) },
  656. /* Amit */
  657. { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
  658. /* Askey */
  659. { USB_DEVICE(0x1690, 0x0740), USB_DEVICE_DATA(&rt2800usb_ops) },
  660. /* ASUS */
  661. { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) },
  662. { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) },
  663. { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) },
  664. { USB_DEVICE(0x0b05, 0x1784), USB_DEVICE_DATA(&rt2800usb_ops) },
  665. { USB_DEVICE(0x1761, 0x0b05), USB_DEVICE_DATA(&rt2800usb_ops) },
  666. /* AzureWave */
  667. { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) },
  668. { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) },
  669. { USB_DEVICE(0x13d3, 0x3305), USB_DEVICE_DATA(&rt2800usb_ops) },
  670. { USB_DEVICE(0x13d3, 0x3307), USB_DEVICE_DATA(&rt2800usb_ops) },
  671. { USB_DEVICE(0x13d3, 0x3321), USB_DEVICE_DATA(&rt2800usb_ops) },
  672. /* Belkin */
  673. { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) },
  674. { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) },
  675. { USB_DEVICE(0x050d, 0x815c), USB_DEVICE_DATA(&rt2800usb_ops) },
  676. { USB_DEVICE(0x050d, 0x825b), USB_DEVICE_DATA(&rt2800usb_ops) },
  677. { USB_DEVICE(0x050d, 0x935a), USB_DEVICE_DATA(&rt2800usb_ops) },
  678. { USB_DEVICE(0x050d, 0x935b), USB_DEVICE_DATA(&rt2800usb_ops) },
  679. /* Buffalo */
  680. { USB_DEVICE(0x0411, 0x00e8), USB_DEVICE_DATA(&rt2800usb_ops) },
  681. { USB_DEVICE(0x0411, 0x016f), USB_DEVICE_DATA(&rt2800usb_ops) },
  682. { USB_DEVICE(0x0411, 0x01a2), USB_DEVICE_DATA(&rt2800usb_ops) },
  683. /* Corega */
  684. { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) },
  685. { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
  686. { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
  687. { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) },
  688. /* D-Link */
  689. { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
  690. { USB_DEVICE(0x07d1, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) },
  691. { USB_DEVICE(0x07d1, 0x3c0d), USB_DEVICE_DATA(&rt2800usb_ops) },
  692. { USB_DEVICE(0x07d1, 0x3c0e), USB_DEVICE_DATA(&rt2800usb_ops) },
  693. { USB_DEVICE(0x07d1, 0x3c0f), USB_DEVICE_DATA(&rt2800usb_ops) },
  694. { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
  695. { USB_DEVICE(0x07d1, 0x3c16), USB_DEVICE_DATA(&rt2800usb_ops) },
  696. /* Draytek */
  697. { USB_DEVICE(0x07fa, 0x7712), USB_DEVICE_DATA(&rt2800usb_ops) },
  698. /* Edimax */
  699. { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) },
  700. { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) },
  701. { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) },
  702. /* Encore */
  703. { USB_DEVICE(0x203d, 0x1480), USB_DEVICE_DATA(&rt2800usb_ops) },
  704. { USB_DEVICE(0x203d, 0x14a9), USB_DEVICE_DATA(&rt2800usb_ops) },
  705. /* EnGenius */
  706. { USB_DEVICE(0x1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) },
  707. { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) },
  708. { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) },
  709. { USB_DEVICE(0x1740, 0x9705), USB_DEVICE_DATA(&rt2800usb_ops) },
  710. { USB_DEVICE(0x1740, 0x9706), USB_DEVICE_DATA(&rt2800usb_ops) },
  711. { USB_DEVICE(0x1740, 0x9707), USB_DEVICE_DATA(&rt2800usb_ops) },
  712. { USB_DEVICE(0x1740, 0x9708), USB_DEVICE_DATA(&rt2800usb_ops) },
  713. { USB_DEVICE(0x1740, 0x9709), USB_DEVICE_DATA(&rt2800usb_ops) },
  714. /* Gemtek */
  715. { USB_DEVICE(0x15a9, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) },
  716. /* Gigabyte */
  717. { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) },
  718. { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) },
  719. /* Hawking */
  720. { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) },
  721. { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) },
  722. { USB_DEVICE(0x0e66, 0x0009), USB_DEVICE_DATA(&rt2800usb_ops) },
  723. { USB_DEVICE(0x0e66, 0x000b), USB_DEVICE_DATA(&rt2800usb_ops) },
  724. { USB_DEVICE(0x0e66, 0x0013), USB_DEVICE_DATA(&rt2800usb_ops) },
  725. { USB_DEVICE(0x0e66, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) },
  726. { USB_DEVICE(0x0e66, 0x0018), USB_DEVICE_DATA(&rt2800usb_ops) },
  727. /* I-O DATA */
  728. { USB_DEVICE(0x04bb, 0x0945), USB_DEVICE_DATA(&rt2800usb_ops) },
  729. { USB_DEVICE(0x04bb, 0x0947), USB_DEVICE_DATA(&rt2800usb_ops) },
  730. { USB_DEVICE(0x04bb, 0x0948), USB_DEVICE_DATA(&rt2800usb_ops) },
  731. /* Linksys */
  732. { USB_DEVICE(0x13b1, 0x0031), USB_DEVICE_DATA(&rt2800usb_ops) },
  733. { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) },
  734. { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) },
  735. /* Logitec */
  736. { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) },
  737. { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) },
  738. { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) },
  739. { USB_DEVICE(0x0789, 0x0166), USB_DEVICE_DATA(&rt2800usb_ops) },
  740. /* Motorola */
  741. { USB_DEVICE(0x100d, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) },
  742. /* MSI */
  743. { USB_DEVICE(0x0db0, 0x3820), USB_DEVICE_DATA(&rt2800usb_ops) },
  744. { USB_DEVICE(0x0db0, 0x3821), USB_DEVICE_DATA(&rt2800usb_ops) },
  745. { USB_DEVICE(0x0db0, 0x3822), USB_DEVICE_DATA(&rt2800usb_ops) },
  746. { USB_DEVICE(0x0db0, 0x3870), USB_DEVICE_DATA(&rt2800usb_ops) },
  747. { USB_DEVICE(0x0db0, 0x3871), USB_DEVICE_DATA(&rt2800usb_ops) },
  748. { USB_DEVICE(0x0db0, 0x6899), USB_DEVICE_DATA(&rt2800usb_ops) },
  749. { USB_DEVICE(0x0db0, 0x821a), USB_DEVICE_DATA(&rt2800usb_ops) },
  750. { USB_DEVICE(0x0db0, 0x822a), USB_DEVICE_DATA(&rt2800usb_ops) },
  751. { USB_DEVICE(0x0db0, 0x822b), USB_DEVICE_DATA(&rt2800usb_ops) },
  752. { USB_DEVICE(0x0db0, 0x822c), USB_DEVICE_DATA(&rt2800usb_ops) },
  753. { USB_DEVICE(0x0db0, 0x870a), USB_DEVICE_DATA(&rt2800usb_ops) },
  754. { USB_DEVICE(0x0db0, 0x871a), USB_DEVICE_DATA(&rt2800usb_ops) },
  755. { USB_DEVICE(0x0db0, 0x871b), USB_DEVICE_DATA(&rt2800usb_ops) },
  756. { USB_DEVICE(0x0db0, 0x871c), USB_DEVICE_DATA(&rt2800usb_ops) },
  757. { USB_DEVICE(0x0db0, 0x899a), USB_DEVICE_DATA(&rt2800usb_ops) },
  758. /* Para */
  759. { USB_DEVICE(0x20b8, 0x8888), USB_DEVICE_DATA(&rt2800usb_ops) },
  760. /* Pegatron */
  761. { USB_DEVICE(0x1d4d, 0x000c), USB_DEVICE_DATA(&rt2800usb_ops) },
  762. { USB_DEVICE(0x1d4d, 0x000e), USB_DEVICE_DATA(&rt2800usb_ops) },
  763. { USB_DEVICE(0x1d4d, 0x0011), USB_DEVICE_DATA(&rt2800usb_ops) },
  764. /* Philips */
  765. { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) },
  766. /* Planex */
  767. { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) },
  768. { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) },
  769. /* Quanta */
  770. { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) },
  771. /* Ralink */
  772. { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) },
  773. { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
  774. { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
  775. { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
  776. { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
  777. { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
  778. /* Samsung */
  779. { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) },
  780. /* Siemens */
  781. { USB_DEVICE(0x129b, 0x1828), USB_DEVICE_DATA(&rt2800usb_ops) },
  782. /* Sitecom */
  783. { USB_DEVICE(0x0df6, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) },
  784. { USB_DEVICE(0x0df6, 0x002b), USB_DEVICE_DATA(&rt2800usb_ops) },
  785. { USB_DEVICE(0x0df6, 0x002c), USB_DEVICE_DATA(&rt2800usb_ops) },
  786. { USB_DEVICE(0x0df6, 0x002d), USB_DEVICE_DATA(&rt2800usb_ops) },
  787. { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) },
  788. { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) },
  789. { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) },
  790. { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) },
  791. { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
  792. { USB_DEVICE(0x0df6, 0x0040), USB_DEVICE_DATA(&rt2800usb_ops) },
  793. { USB_DEVICE(0x0df6, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) },
  794. { USB_DEVICE(0x0df6, 0x0047), USB_DEVICE_DATA(&rt2800usb_ops) },
  795. { USB_DEVICE(0x0df6, 0x0048), USB_DEVICE_DATA(&rt2800usb_ops) },
  796. /* SMC */
  797. { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) },
  798. { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) },
  799. { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) },
  800. { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) },
  801. { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) },
  802. { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) },
  803. { USB_DEVICE(0x083a, 0xa701), USB_DEVICE_DATA(&rt2800usb_ops) },
  804. { USB_DEVICE(0x083a, 0xa702), USB_DEVICE_DATA(&rt2800usb_ops) },
  805. { USB_DEVICE(0x083a, 0xa703), USB_DEVICE_DATA(&rt2800usb_ops) },
  806. { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) },
  807. /* Sparklan */
  808. { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) },
  809. /* Sweex */
  810. { USB_DEVICE(0x177f, 0x0302), USB_DEVICE_DATA(&rt2800usb_ops) },
  811. /* U-Media */
  812. { USB_DEVICE(0x157e, 0x300e), USB_DEVICE_DATA(&rt2800usb_ops) },
  813. { USB_DEVICE(0x157e, 0x3013), USB_DEVICE_DATA(&rt2800usb_ops) },
  814. /* ZCOM */
  815. { USB_DEVICE(0x0cde, 0x0022), USB_DEVICE_DATA(&rt2800usb_ops) },
  816. { USB_DEVICE(0x0cde, 0x0025), USB_DEVICE_DATA(&rt2800usb_ops) },
  817. /* Zinwell */
  818. { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) },
  819. { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) },
  820. { USB_DEVICE(0x5a57, 0x0283), USB_DEVICE_DATA(&rt2800usb_ops) },
  821. { USB_DEVICE(0x5a57, 0x5257), USB_DEVICE_DATA(&rt2800usb_ops) },
  822. /* Zyxel */
  823. { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) },
  824. { USB_DEVICE(0x0586, 0x3418), USB_DEVICE_DATA(&rt2800usb_ops) },
  825. { USB_DEVICE(0x0586, 0x341e), USB_DEVICE_DATA(&rt2800usb_ops) },
  826. #ifdef CONFIG_RT2800USB_RT33XX
  827. /* Ralink */
  828. { USB_DEVICE(0x148f, 0x3370), USB_DEVICE_DATA(&rt2800usb_ops) },
  829. { USB_DEVICE(0x148f, 0x8070), USB_DEVICE_DATA(&rt2800usb_ops) },
  830. /* Sitecom */
  831. { USB_DEVICE(0x0df6, 0x0050), USB_DEVICE_DATA(&rt2800usb_ops) },
  832. #endif
  833. #ifdef CONFIG_RT2800USB_RT35XX
  834. /* Allwin */
  835. { USB_DEVICE(0x8516, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) },
  836. /* Askey */
  837. { USB_DEVICE(0x1690, 0x0744), USB_DEVICE_DATA(&rt2800usb_ops) },
  838. /* Cisco */
  839. { USB_DEVICE(0x167b, 0x4001), USB_DEVICE_DATA(&rt2800usb_ops) },
  840. /* EnGenius */
  841. { USB_DEVICE(0x1740, 0x9801), USB_DEVICE_DATA(&rt2800usb_ops) },
  842. /* I-O DATA */
  843. { USB_DEVICE(0x04bb, 0x0944), USB_DEVICE_DATA(&rt2800usb_ops) },
  844. /* Linksys */
  845. { USB_DEVICE(0x13b1, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) },
  846. /* Ralink */
  847. { USB_DEVICE(0x148f, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) },
  848. /* Sitecom */
  849. { USB_DEVICE(0x0df6, 0x0041), USB_DEVICE_DATA(&rt2800usb_ops) },
  850. /* Toshiba */
  851. { USB_DEVICE(0x0930, 0x0a07), USB_DEVICE_DATA(&rt2800usb_ops) },
  852. /* Zinwell */
  853. { USB_DEVICE(0x5a57, 0x0284), USB_DEVICE_DATA(&rt2800usb_ops) },
  854. #endif
  855. #ifdef CONFIG_RT2800USB_UNKNOWN
  856. /*
  857. * Unclear what kind of devices these are (they aren't supported by the
  858. * vendor linux driver).
  859. */
  860. /* Alpha Networks */
  861. { USB_DEVICE(0x14b2, 0x3c08), USB_DEVICE_DATA(&rt2800usb_ops) },
  862. { USB_DEVICE(0x14b2, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
  863. /* Amigo */
  864. { USB_DEVICE(0x0e0b, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) },
  865. { USB_DEVICE(0x0e0b, 0x9041), USB_DEVICE_DATA(&rt2800usb_ops) },
  866. /* ASUS */
  867. { USB_DEVICE(0x0b05, 0x1760), USB_DEVICE_DATA(&rt2800usb_ops) },
  868. { USB_DEVICE(0x0b05, 0x1761), USB_DEVICE_DATA(&rt2800usb_ops) },
  869. { USB_DEVICE(0x0b05, 0x1790), USB_DEVICE_DATA(&rt2800usb_ops) },
  870. /* AzureWave */
  871. { USB_DEVICE(0x13d3, 0x3262), USB_DEVICE_DATA(&rt2800usb_ops) },
  872. { USB_DEVICE(0x13d3, 0x3284), USB_DEVICE_DATA(&rt2800usb_ops) },
  873. { USB_DEVICE(0x13d3, 0x3322), USB_DEVICE_DATA(&rt2800usb_ops) },
  874. /* Belkin */
  875. { USB_DEVICE(0x050d, 0x825a), USB_DEVICE_DATA(&rt2800usb_ops) },
  876. /* Buffalo */
  877. { USB_DEVICE(0x0411, 0x012e), USB_DEVICE_DATA(&rt2800usb_ops) },
  878. { USB_DEVICE(0x0411, 0x0148), USB_DEVICE_DATA(&rt2800usb_ops) },
  879. { USB_DEVICE(0x0411, 0x0150), USB_DEVICE_DATA(&rt2800usb_ops) },
  880. { USB_DEVICE(0x0411, 0x015d), USB_DEVICE_DATA(&rt2800usb_ops) },
  881. /* Corega */
  882. { USB_DEVICE(0x07aa, 0x0041), USB_DEVICE_DATA(&rt2800usb_ops) },
  883. { USB_DEVICE(0x07aa, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) },
  884. { USB_DEVICE(0x18c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
  885. /* D-Link */
  886. { USB_DEVICE(0x07d1, 0x3c0b), USB_DEVICE_DATA(&rt2800usb_ops) },
  887. { USB_DEVICE(0x07d1, 0x3c13), USB_DEVICE_DATA(&rt2800usb_ops) },
  888. { USB_DEVICE(0x07d1, 0x3c15), USB_DEVICE_DATA(&rt2800usb_ops) },
  889. { USB_DEVICE(0x07d1, 0x3c17), USB_DEVICE_DATA(&rt2800usb_ops) },
  890. /* Edimax */
  891. { USB_DEVICE(0x7392, 0x4085), USB_DEVICE_DATA(&rt2800usb_ops) },
  892. /* Encore */
  893. { USB_DEVICE(0x203d, 0x14a1), USB_DEVICE_DATA(&rt2800usb_ops) },
  894. /* Gemtek */
  895. { USB_DEVICE(0x15a9, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) },
  896. /* Gigabyte */
  897. { USB_DEVICE(0x1044, 0x800c), USB_DEVICE_DATA(&rt2800usb_ops) },
  898. /* LevelOne */
  899. { USB_DEVICE(0x1740, 0x0605), USB_DEVICE_DATA(&rt2800usb_ops) },
  900. { USB_DEVICE(0x1740, 0x0615), USB_DEVICE_DATA(&rt2800usb_ops) },
  901. /* Linksys */
  902. { USB_DEVICE(0x1737, 0x0077), USB_DEVICE_DATA(&rt2800usb_ops) },
  903. { USB_DEVICE(0x1737, 0x0078), USB_DEVICE_DATA(&rt2800usb_ops) },
  904. { USB_DEVICE(0x1737, 0x0079), USB_DEVICE_DATA(&rt2800usb_ops) },
  905. /* Motorola */
  906. { USB_DEVICE(0x100d, 0x9032), USB_DEVICE_DATA(&rt2800usb_ops) },
  907. /* Ovislink */
  908. { USB_DEVICE(0x1b75, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
  909. { USB_DEVICE(0x1b75, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
  910. /* Pegatron */
  911. { USB_DEVICE(0x05a6, 0x0101), USB_DEVICE_DATA(&rt2800usb_ops) },
  912. { USB_DEVICE(0x1d4d, 0x0002), USB_DEVICE_DATA(&rt2800usb_ops) },
  913. { USB_DEVICE(0x1d4d, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) },
  914. /* Planex */
  915. { USB_DEVICE(0x2019, 0x5201), USB_DEVICE_DATA(&rt2800usb_ops) },
  916. { USB_DEVICE(0x2019, 0xab24), USB_DEVICE_DATA(&rt2800usb_ops) },
  917. /* Qcom */
  918. { USB_DEVICE(0x18e8, 0x6259), USB_DEVICE_DATA(&rt2800usb_ops) },
  919. /* SMC */
  920. { USB_DEVICE(0x083a, 0xa512), USB_DEVICE_DATA(&rt2800usb_ops) },
  921. { USB_DEVICE(0x083a, 0xc522), USB_DEVICE_DATA(&rt2800usb_ops) },
  922. { USB_DEVICE(0x083a, 0xd522), USB_DEVICE_DATA(&rt2800usb_ops) },
  923. { USB_DEVICE(0x083a, 0xf511), USB_DEVICE_DATA(&rt2800usb_ops) },
  924. /* Sweex */
  925. { USB_DEVICE(0x177f, 0x0153), USB_DEVICE_DATA(&rt2800usb_ops) },
  926. { USB_DEVICE(0x177f, 0x0313), USB_DEVICE_DATA(&rt2800usb_ops) },
  927. /* Zyxel */
  928. { USB_DEVICE(0x0586, 0x341a), USB_DEVICE_DATA(&rt2800usb_ops) },
  929. #endif
  930. { 0, }
  931. };
  932. MODULE_AUTHOR(DRV_PROJECT);
  933. MODULE_VERSION(DRV_VERSION);
  934. MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
  935. MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards");
  936. MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
  937. MODULE_FIRMWARE(FIRMWARE_RT2870);
  938. MODULE_LICENSE("GPL");
  939. static struct usb_driver rt2800usb_driver = {
  940. .name = KBUILD_MODNAME,
  941. .id_table = rt2800usb_device_table,
  942. .probe = rt2x00usb_probe,
  943. .disconnect = rt2x00usb_disconnect,
  944. .suspend = rt2x00usb_suspend,
  945. .resume = rt2x00usb_resume,
  946. };
  947. static int __init rt2800usb_init(void)
  948. {
  949. return usb_register(&rt2800usb_driver);
  950. }
  951. static void __exit rt2800usb_exit(void)
  952. {
  953. usb_deregister(&rt2800usb_driver);
  954. }
  955. module_init(rt2800usb_init);
  956. module_exit(rt2800usb_exit);