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