rt2800usb.c 31 KB

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