rt2800usb.c 39 KB

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