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