rt2800usb.c 39 KB

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