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