rt2800usb.c 38 KB

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