rt2800usb.c 35 KB

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