Commit | Line | Data |
---|---|---|
d53d9e67 | 1 | /* |
9c9a0d14 GW |
2 | Copyright (C) 2009 Ivo van Doorn <IvDoorn@gmail.com> |
3 | Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de> | |
4 | Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org> | |
5 | Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com> | |
6 | Copyright (C) 2009 Axel Kollhofer <rain_maker@root-forum.org> | |
d53d9e67 ID |
7 | <http://rt2x00.serialmonkey.com> |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the | |
21 | Free Software Foundation, Inc., | |
22 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
23 | */ | |
24 | ||
25 | /* | |
26 | Module: rt2800usb | |
27 | Abstract: rt2800usb device specific routines. | |
28 | Supported chipsets: RT2800U. | |
29 | */ | |
30 | ||
31 | #include <linux/crc-ccitt.h> | |
32 | #include <linux/delay.h> | |
33 | #include <linux/etherdevice.h> | |
34 | #include <linux/init.h> | |
35 | #include <linux/kernel.h> | |
36 | #include <linux/module.h> | |
37 | #include <linux/usb.h> | |
38 | ||
39 | #include "rt2x00.h" | |
40 | #include "rt2x00usb.h" | |
7ef5cc92 | 41 | #include "rt2800lib.h" |
b54f78a8 | 42 | #include "rt2800.h" |
d53d9e67 ID |
43 | #include "rt2800usb.h" |
44 | ||
45 | /* | |
46 | * Allow hardware encryption to be disabled. | |
47 | */ | |
48 | static int modparam_nohwcrypt = 1; | |
49 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | |
50 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | |
51 | ||
d53d9e67 ID |
52 | /* |
53 | * Firmware functions | |
54 | */ | |
55 | static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) | |
56 | { | |
57 | return FIRMWARE_RT2870; | |
58 | } | |
59 | ||
60 | static bool rt2800usb_check_crc(const u8 *data, const size_t len) | |
61 | { | |
62 | u16 fw_crc; | |
63 | u16 crc; | |
64 | ||
65 | /* | |
66 | * The last 2 bytes in the firmware array are the crc checksum itself, | |
67 | * this means that we should never pass those 2 bytes to the crc | |
68 | * algorithm. | |
69 | */ | |
70 | fw_crc = (data[len - 2] << 8 | data[len - 1]); | |
71 | ||
72 | /* | |
73 | * Use the crc ccitt algorithm. | |
74 | * This will return the same value as the legacy driver which | |
75 | * used bit ordering reversion on the both the firmware bytes | |
76 | * before input input as well as on the final output. | |
77 | * Obviously using crc ccitt directly is much more efficient. | |
78 | */ | |
79 | crc = crc_ccitt(~0, data, len - 2); | |
80 | ||
81 | /* | |
82 | * There is a small difference between the crc-itu-t + bitrev and | |
83 | * the crc-ccitt crc calculation. In the latter method the 2 bytes | |
84 | * will be swapped, use swab16 to convert the crc to the correct | |
85 | * value. | |
86 | */ | |
87 | crc = swab16(crc); | |
88 | ||
89 | return fw_crc == crc; | |
90 | } | |
91 | ||
92 | static int rt2800usb_check_firmware(struct rt2x00_dev *rt2x00dev, | |
93 | const u8 *data, const size_t len) | |
94 | { | |
d53d9e67 ID |
95 | size_t offset = 0; |
96 | ||
97 | /* | |
98 | * Firmware files: | |
99 | * There are 2 variations of the rt2870 firmware. | |
100 | * a) size: 4kb | |
101 | * b) size: 8kb | |
3ad2f3fb | 102 | * Note that (b) contains 2 separate firmware blobs of 4k |
d53d9e67 ID |
103 | * within the file. The first blob is the same firmware as (a), |
104 | * but the second blob is for the additional chipsets. | |
105 | */ | |
106 | if (len != 4096 && len != 8192) | |
107 | return FW_BAD_LENGTH; | |
108 | ||
109 | /* | |
110 | * Check if we need the upper 4kb firmware data or not. | |
111 | */ | |
112 | if ((len == 4096) && | |
49e721ec GW |
113 | !rt2x00_rt(rt2x00dev, RT2860) && |
114 | !rt2x00_rt(rt2x00dev, RT2872) && | |
115 | !rt2x00_rt(rt2x00dev, RT3070)) | |
d53d9e67 ID |
116 | return FW_BAD_VERSION; |
117 | ||
118 | /* | |
119 | * 8kb firmware files must be checked as if it were | |
3ad2f3fb | 120 | * 2 separate firmware files. |
d53d9e67 ID |
121 | */ |
122 | while (offset < len) { | |
123 | if (!rt2800usb_check_crc(data + offset, 4096)) | |
124 | return FW_BAD_CRC; | |
125 | ||
126 | offset += 4096; | |
127 | } | |
128 | ||
129 | return FW_OK; | |
130 | } | |
131 | ||
132 | static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev, | |
133 | const u8 *data, const size_t len) | |
134 | { | |
135 | unsigned int i; | |
136 | int status; | |
137 | u32 reg; | |
138 | u32 offset; | |
139 | u32 length; | |
d53d9e67 ID |
140 | |
141 | /* | |
142 | * Check which section of the firmware we need. | |
143 | */ | |
49e721ec GW |
144 | if (rt2x00_rt(rt2x00dev, RT2860) || |
145 | rt2x00_rt(rt2x00dev, RT2872) || | |
146 | rt2x00_rt(rt2x00dev, RT3070)) { | |
d53d9e67 ID |
147 | offset = 0; |
148 | length = 4096; | |
149 | } else { | |
150 | offset = 4096; | |
151 | length = 4096; | |
152 | } | |
153 | ||
154 | /* | |
155 | * Wait for stable hardware. | |
156 | */ | |
157 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | |
abbb505d | 158 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); |
d53d9e67 ID |
159 | if (reg && reg != ~0) |
160 | break; | |
161 | msleep(1); | |
162 | } | |
163 | ||
164 | if (i == REGISTER_BUSY_COUNT) { | |
165 | ERROR(rt2x00dev, "Unstable hardware.\n"); | |
166 | return -EBUSY; | |
167 | } | |
168 | ||
169 | /* | |
170 | * Write firmware to device. | |
171 | */ | |
96b61baf GW |
172 | rt2800_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE, |
173 | data + offset, length); | |
d53d9e67 | 174 | |
abbb505d BZ |
175 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0); |
176 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0); | |
d53d9e67 ID |
177 | |
178 | /* | |
179 | * Send firmware request to device to load firmware, | |
180 | * we need to specify a long timeout time. | |
181 | */ | |
182 | status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, | |
183 | 0, USB_MODE_FIRMWARE, | |
184 | REGISTER_TIMEOUT_FIRMWARE); | |
185 | if (status < 0) { | |
186 | ERROR(rt2x00dev, "Failed to write Firmware to device.\n"); | |
187 | return status; | |
188 | } | |
189 | ||
15e46928 | 190 | msleep(10); |
abbb505d | 191 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); |
15e46928 ID |
192 | |
193 | /* | |
194 | * Send signal to firmware during boot time. | |
195 | */ | |
4f2c5326 | 196 | rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0xff, 0, 0); |
15e46928 | 197 | |
49e721ec GW |
198 | if (rt2x00_rt(rt2x00dev, RT3070) || |
199 | rt2x00_rt(rt2x00dev, RT3071) || | |
200 | rt2x00_rt(rt2x00dev, RT3572)) { | |
15e46928 | 201 | udelay(200); |
4f2c5326 | 202 | rt2800_mcu_request(rt2x00dev, MCU_CURRENT, 0, 0, 0); |
15e46928 ID |
203 | udelay(10); |
204 | } | |
205 | ||
d53d9e67 ID |
206 | /* |
207 | * Wait for device to stabilize. | |
208 | */ | |
209 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | |
abbb505d | 210 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); |
d53d9e67 ID |
211 | if (rt2x00_get_field32(reg, PBF_SYS_CTRL_READY)) |
212 | break; | |
213 | msleep(1); | |
214 | } | |
215 | ||
216 | if (i == REGISTER_BUSY_COUNT) { | |
217 | ERROR(rt2x00dev, "PBF system register not ready.\n"); | |
218 | return -EBUSY; | |
219 | } | |
220 | ||
221 | /* | |
222 | * Initialize firmware. | |
223 | */ | |
abbb505d BZ |
224 | rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); |
225 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); | |
d53d9e67 ID |
226 | msleep(1); |
227 | ||
228 | return 0; | |
229 | } | |
230 | ||
d53d9e67 ID |
231 | /* |
232 | * Device state switch handlers. | |
233 | */ | |
234 | static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev, | |
235 | enum dev_state state) | |
236 | { | |
237 | u32 reg; | |
238 | ||
abbb505d | 239 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
d53d9e67 ID |
240 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, |
241 | (state == STATE_RADIO_RX_ON) || | |
242 | (state == STATE_RADIO_RX_ON_LINK)); | |
abbb505d | 243 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
d53d9e67 ID |
244 | } |
245 | ||
d53d9e67 ID |
246 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) |
247 | { | |
248 | u32 reg; | |
249 | u16 word; | |
250 | ||
251 | /* | |
252 | * Initialize all registers. | |
253 | */ | |
67a4c1e2 | 254 | if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) || |
fcf51541 BZ |
255 | rt2800_init_registers(rt2x00dev) || |
256 | rt2800_init_bbp(rt2x00dev) || | |
257 | rt2800_init_rfcsr(rt2x00dev))) | |
d53d9e67 ID |
258 | return -EIO; |
259 | ||
abbb505d | 260 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
d53d9e67 | 261 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1); |
abbb505d | 262 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
d53d9e67 ID |
263 | |
264 | udelay(50); | |
265 | ||
abbb505d | 266 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
d53d9e67 ID |
267 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1); |
268 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1); | |
269 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 1); | |
abbb505d | 270 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); |
d53d9e67 ID |
271 | |
272 | ||
abbb505d | 273 | rt2800_register_read(rt2x00dev, USB_DMA_CFG, ®); |
d53d9e67 | 274 | rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0); |
9c8427d9 | 275 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN, 0); |
d53d9e67 | 276 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128); |
15e46928 ID |
277 | /* |
278 | * Total room for RX frames in kilobytes, PBF might still exceed | |
279 | * this limit so reduce the number to prevent errors. | |
280 | */ | |
281 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_LIMIT, | |
282 | ((RX_ENTRIES * DATA_FRAME_SIZE) / 1024) - 3); | |
d53d9e67 ID |
283 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_EN, 1); |
284 | rt2x00_set_field32(®, USB_DMA_CFG_TX_BULK_EN, 1); | |
abbb505d | 285 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg); |
d53d9e67 | 286 | |
abbb505d | 287 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
d53d9e67 ID |
288 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1); |
289 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, 1); | |
abbb505d | 290 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
d53d9e67 | 291 | |
d53d9e67 ID |
292 | /* |
293 | * Initialize LED control | |
294 | */ | |
295 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word); | |
4f2c5326 | 296 | rt2800_mcu_request(rt2x00dev, MCU_LED_1, 0xff, |
d53d9e67 ID |
297 | word & 0xff, (word >> 8) & 0xff); |
298 | ||
299 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word); | |
4f2c5326 | 300 | rt2800_mcu_request(rt2x00dev, MCU_LED_2, 0xff, |
d53d9e67 ID |
301 | word & 0xff, (word >> 8) & 0xff); |
302 | ||
303 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word); | |
4f2c5326 | 304 | rt2800_mcu_request(rt2x00dev, MCU_LED_3, 0xff, |
d53d9e67 ID |
305 | word & 0xff, (word >> 8) & 0xff); |
306 | ||
307 | return 0; | |
308 | } | |
309 | ||
310 | static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev) | |
311 | { | |
312 | u32 reg; | |
313 | ||
abbb505d | 314 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
d53d9e67 ID |
315 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); |
316 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0); | |
abbb505d | 317 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); |
d53d9e67 | 318 | |
abbb505d BZ |
319 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0); |
320 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0); | |
321 | rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0); | |
d53d9e67 ID |
322 | |
323 | /* Wait for DMA, ignore error */ | |
67a4c1e2 | 324 | rt2800_wait_wpdma_ready(rt2x00dev); |
d53d9e67 ID |
325 | |
326 | rt2x00usb_disable_radio(rt2x00dev); | |
327 | } | |
328 | ||
329 | static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev, | |
330 | enum dev_state state) | |
331 | { | |
d53d9e67 | 332 | if (state == STATE_AWAKE) |
4f2c5326 | 333 | rt2800_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0); |
d53d9e67 | 334 | else |
4f2c5326 | 335 | rt2800_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2); |
d53d9e67 ID |
336 | |
337 | return 0; | |
338 | } | |
339 | ||
340 | static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev, | |
341 | enum dev_state state) | |
342 | { | |
343 | int retval = 0; | |
344 | ||
345 | switch (state) { | |
346 | case STATE_RADIO_ON: | |
347 | /* | |
348 | * Before the radio can be enabled, the device first has | |
349 | * to be woken up. After that it needs a bit of time | |
49513481 | 350 | * to be fully awake and then the radio can be enabled. |
d53d9e67 ID |
351 | */ |
352 | rt2800usb_set_state(rt2x00dev, STATE_AWAKE); | |
353 | msleep(1); | |
354 | retval = rt2800usb_enable_radio(rt2x00dev); | |
355 | break; | |
356 | case STATE_RADIO_OFF: | |
357 | /* | |
49513481 | 358 | * After the radio has been disabled, the device should |
d53d9e67 ID |
359 | * be put to sleep for powersaving. |
360 | */ | |
361 | rt2800usb_disable_radio(rt2x00dev); | |
362 | rt2800usb_set_state(rt2x00dev, STATE_SLEEP); | |
363 | break; | |
364 | case STATE_RADIO_RX_ON: | |
365 | case STATE_RADIO_RX_ON_LINK: | |
366 | case STATE_RADIO_RX_OFF: | |
367 | case STATE_RADIO_RX_OFF_LINK: | |
368 | rt2800usb_toggle_rx(rt2x00dev, state); | |
369 | break; | |
370 | case STATE_RADIO_IRQ_ON: | |
371 | case STATE_RADIO_IRQ_OFF: | |
372 | /* No support, but no error either */ | |
373 | break; | |
374 | case STATE_DEEP_SLEEP: | |
375 | case STATE_SLEEP: | |
376 | case STATE_STANDBY: | |
377 | case STATE_AWAKE: | |
378 | retval = rt2800usb_set_state(rt2x00dev, state); | |
379 | break; | |
380 | default: | |
381 | retval = -ENOTSUPP; | |
382 | break; | |
383 | } | |
384 | ||
385 | if (unlikely(retval)) | |
386 | ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n", | |
387 | state, retval); | |
388 | ||
389 | return retval; | |
390 | } | |
391 | ||
392 | /* | |
393 | * TX descriptor initialization | |
394 | */ | |
395 | static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |
396 | struct sk_buff *skb, | |
397 | struct txentry_desc *txdesc) | |
398 | { | |
399 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | |
0b8004aa GW |
400 | __le32 *txi = (__le32 *) skb->data; |
401 | __le32 *txwi = (__le32 *) (skb->data + TXINFO_DESC_SIZE); | |
d53d9e67 ID |
402 | u32 word; |
403 | ||
404 | /* | |
59679b91 | 405 | * Initialize TXWI descriptor |
d53d9e67 | 406 | */ |
0b8004aa | 407 | rt2800_write_txwi(txwi, txdesc); |
d53d9e67 ID |
408 | |
409 | /* | |
59679b91 | 410 | * Initialize TXINFO descriptor |
d53d9e67 ID |
411 | */ |
412 | rt2x00_desc_read(txi, 0, &word); | |
413 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN, | |
a903ae00 | 414 | skb->len - TXINFO_DESC_SIZE); |
d53d9e67 ID |
415 | rt2x00_set_field32(&word, TXINFO_W0_WIV, |
416 | !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); | |
417 | rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2); | |
418 | rt2x00_set_field32(&word, TXINFO_W0_SW_USE_LAST_ROUND, 0); | |
419 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_NEXT_VALID, 0); | |
420 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST, | |
421 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); | |
422 | rt2x00_desc_write(txi, 0, word); | |
85b7a8b3 GW |
423 | |
424 | /* | |
425 | * Register descriptor details in skb frame descriptor. | |
426 | */ | |
0b8004aa | 427 | skbdesc->flags |= SKBDESC_DESC_IN_SKB; |
85b7a8b3 GW |
428 | skbdesc->desc = txi; |
429 | skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE; | |
d53d9e67 ID |
430 | } |
431 | ||
432 | /* | |
433 | * TX data initialization | |
434 | */ | |
f224f4ef GW |
435 | static void rt2800usb_write_beacon(struct queue_entry *entry, |
436 | struct txentry_desc *txdesc) | |
d53d9e67 ID |
437 | { |
438 | struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; | |
5c3b685c | 439 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
d53d9e67 ID |
440 | unsigned int beacon_base; |
441 | u32 reg; | |
442 | ||
d53d9e67 ID |
443 | /* |
444 | * Disable beaconing while we are reloading the beacon data, | |
445 | * otherwise we might be sending out invalid data. | |
446 | */ | |
abbb505d | 447 | rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®); |
d53d9e67 | 448 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0); |
abbb505d | 449 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
d53d9e67 | 450 | |
0b8004aa GW |
451 | /* |
452 | * Add space for the TXWI in front of the skb. | |
453 | */ | |
454 | skb_push(entry->skb, TXWI_DESC_SIZE); | |
455 | memset(entry->skb, 0, TXWI_DESC_SIZE); | |
456 | ||
5c3b685c GW |
457 | /* |
458 | * Register descriptor details in skb frame descriptor. | |
459 | */ | |
0b8004aa GW |
460 | skbdesc->flags |= SKBDESC_DESC_IN_SKB; |
461 | skbdesc->desc = entry->skb->data; | |
5c3b685c GW |
462 | skbdesc->desc_len = TXWI_DESC_SIZE; |
463 | ||
3b9f0ed7 GW |
464 | /* |
465 | * Add the TXWI for the beacon to the skb. | |
466 | */ | |
0b8004aa | 467 | rt2800_write_txwi((__le32 *) entry->skb->data, txdesc); |
5c3b685c GW |
468 | |
469 | /* | |
470 | * Dump beacon to userspace through debugfs. | |
471 | */ | |
472 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); | |
473 | ||
d53d9e67 ID |
474 | /* |
475 | * Write entire beacon with descriptor to register. | |
476 | */ | |
477 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); | |
96b61baf GW |
478 | rt2800_register_multiwrite(rt2x00dev, beacon_base, |
479 | entry->skb->data, entry->skb->len); | |
d53d9e67 | 480 | |
d61cb266 GW |
481 | /* |
482 | * Enable beaconing again. | |
483 | */ | |
484 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1); | |
485 | rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1); | |
486 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 1); | |
487 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); | |
488 | ||
d53d9e67 ID |
489 | /* |
490 | * Clean up the beacon skb. | |
491 | */ | |
492 | dev_kfree_skb(entry->skb); | |
493 | entry->skb = NULL; | |
494 | } | |
495 | ||
496 | static int rt2800usb_get_tx_data_len(struct queue_entry *entry) | |
497 | { | |
498 | int length; | |
499 | ||
500 | /* | |
501 | * The length _must_ include 4 bytes padding, | |
502 | * it should always be multiple of 4, | |
503 | * but it must _not_ be a multiple of the USB packet size. | |
504 | */ | |
505 | length = roundup(entry->skb->len + 4, 4); | |
506 | length += (4 * !(length % entry->queue->usb_maxpacket)); | |
507 | ||
508 | return length; | |
509 | } | |
510 | ||
d53d9e67 ID |
511 | /* |
512 | * RX control handlers | |
513 | */ | |
514 | static void rt2800usb_fill_rxdone(struct queue_entry *entry, | |
515 | struct rxdone_entry_desc *rxdesc) | |
516 | { | |
d53d9e67 | 517 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
5de42f9e | 518 | __le32 *rxi = (__le32 *)entry->skb->data; |
5de42f9e | 519 | __le32 *rxd; |
2de64dd2 | 520 | u32 word; |
5de42f9e BP |
521 | int rx_pkt_len; |
522 | ||
2de64dd2 GW |
523 | /* |
524 | * Copy descriptor to the skbdesc->desc buffer, making it safe from | |
525 | * moving of frame data in rt2x00usb. | |
526 | */ | |
527 | memcpy(skbdesc->desc, rxi, skbdesc->desc_len); | |
528 | ||
5de42f9e BP |
529 | /* |
530 | * RX frame format is : | |
531 | * | RXINFO | RXWI | header | L2 pad | payload | pad | RXD | USB pad | | |
532 | * |<------------ rx_pkt_len -------------->| | |
533 | */ | |
2de64dd2 GW |
534 | rt2x00_desc_read(rxi, 0, &word); |
535 | rx_pkt_len = rt2x00_get_field32(word, RXINFO_W0_USB_DMA_RX_PKT_LEN); | |
5de42f9e BP |
536 | |
537 | /* | |
2de64dd2 | 538 | * Remove the RXINFO structure from the sbk. |
5de42f9e | 539 | */ |
2de64dd2 | 540 | skb_pull(entry->skb, RXINFO_DESC_SIZE); |
d53d9e67 ID |
541 | |
542 | /* | |
2de64dd2 | 543 | * FIXME: we need to check for rx_pkt_len validity |
d53d9e67 | 544 | */ |
2de64dd2 | 545 | rxd = (__le32 *)(entry->skb->data + rx_pkt_len); |
d53d9e67 ID |
546 | |
547 | /* | |
548 | * It is now safe to read the descriptor on all architectures. | |
549 | */ | |
2de64dd2 | 550 | rt2x00_desc_read(rxd, 0, &word); |
d53d9e67 | 551 | |
2de64dd2 | 552 | if (rt2x00_get_field32(word, RXD_W0_CRC_ERROR)) |
d53d9e67 ID |
553 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
554 | ||
2de64dd2 | 555 | rxdesc->cipher_status = rt2x00_get_field32(word, RXD_W0_CIPHER_ERROR); |
d53d9e67 | 556 | |
2de64dd2 | 557 | if (rt2x00_get_field32(word, RXD_W0_DECRYPTED)) { |
d53d9e67 ID |
558 | /* |
559 | * Hardware has stripped IV/EIV data from 802.11 frame during | |
560 | * decryption. Unfortunately the descriptor doesn't contain | |
561 | * any fields with the EIV/IV data either, so they can't | |
562 | * be restored by rt2x00lib. | |
563 | */ | |
564 | rxdesc->flags |= RX_FLAG_IV_STRIPPED; | |
565 | ||
566 | if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) | |
567 | rxdesc->flags |= RX_FLAG_DECRYPTED; | |
568 | else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) | |
569 | rxdesc->flags |= RX_FLAG_MMIC_ERROR; | |
570 | } | |
571 | ||
2de64dd2 | 572 | if (rt2x00_get_field32(word, RXD_W0_MY_BSS)) |
d53d9e67 ID |
573 | rxdesc->dev_flags |= RXDONE_MY_BSS; |
574 | ||
2de64dd2 | 575 | if (rt2x00_get_field32(word, RXD_W0_L2PAD)) |
d53d9e67 ID |
576 | rxdesc->dev_flags |= RXDONE_L2PAD; |
577 | ||
d53d9e67 | 578 | /* |
2de64dd2 | 579 | * Remove RXD descriptor from end of buffer. |
d53d9e67 | 580 | */ |
2de64dd2 | 581 | skb_trim(entry->skb, rx_pkt_len); |
d53d9e67 ID |
582 | |
583 | /* | |
2de64dd2 | 584 | * Process the RXWI structure. |
d53d9e67 | 585 | */ |
2de64dd2 | 586 | rt2800_process_rxwi(entry->skb, rxdesc); |
d53d9e67 ID |
587 | } |
588 | ||
589 | /* | |
590 | * Device probe functions. | |
591 | */ | |
7ab71325 BZ |
592 | static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev) |
593 | { | |
40beee5c BZ |
594 | if (rt2800_efuse_detect(rt2x00dev)) |
595 | rt2800_read_eeprom_efuse(rt2x00dev); | |
596 | else | |
597 | rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, | |
598 | EEPROM_SIZE); | |
7ab71325 BZ |
599 | |
600 | return rt2800_validate_eeprom(rt2x00dev); | |
601 | } | |
602 | ||
7a345d3d BZ |
603 | static const struct rt2800_ops rt2800usb_rt2800_ops = { |
604 | .register_read = rt2x00usb_register_read, | |
31a4cf1f | 605 | .register_read_lock = rt2x00usb_register_read_lock, |
7a345d3d BZ |
606 | .register_write = rt2x00usb_register_write, |
607 | .register_write_lock = rt2x00usb_register_write_lock, | |
608 | ||
609 | .register_multiread = rt2x00usb_register_multiread, | |
610 | .register_multiwrite = rt2x00usb_register_multiwrite, | |
611 | ||
612 | .regbusy_read = rt2x00usb_regbusy_read, | |
613 | }; | |
614 | ||
d53d9e67 ID |
615 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) |
616 | { | |
617 | int retval; | |
618 | ||
7a345d3d BZ |
619 | rt2x00dev->priv = (void *)&rt2800usb_rt2800_ops; |
620 | ||
d53d9e67 ID |
621 | /* |
622 | * Allocate eeprom data. | |
623 | */ | |
624 | retval = rt2800usb_validate_eeprom(rt2x00dev); | |
625 | if (retval) | |
626 | return retval; | |
627 | ||
38bd7b8a | 628 | retval = rt2800_init_eeprom(rt2x00dev); |
d53d9e67 ID |
629 | if (retval) |
630 | return retval; | |
631 | ||
632 | /* | |
633 | * Initialize hw specifications. | |
634 | */ | |
4da2933f | 635 | retval = rt2800_probe_hw_mode(rt2x00dev); |
d53d9e67 ID |
636 | if (retval) |
637 | return retval; | |
638 | ||
1afcfd54 IP |
639 | /* |
640 | * This device has multiple filters for control frames | |
641 | * and has a separate filter for PS Poll frames. | |
642 | */ | |
643 | __set_bit(DRIVER_SUPPORT_CONTROL_FILTERS, &rt2x00dev->flags); | |
644 | __set_bit(DRIVER_SUPPORT_CONTROL_FILTER_PSPOLL, &rt2x00dev->flags); | |
645 | ||
d53d9e67 ID |
646 | /* |
647 | * This device requires firmware. | |
648 | */ | |
649 | __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags); | |
d53d9e67 ID |
650 | __set_bit(DRIVER_REQUIRE_L2PAD, &rt2x00dev->flags); |
651 | if (!modparam_nohwcrypt) | |
652 | __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags); | |
653 | ||
654 | /* | |
655 | * Set the rssi offset. | |
656 | */ | |
657 | rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; | |
658 | ||
659 | return 0; | |
660 | } | |
661 | ||
d53d9e67 ID |
662 | static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = { |
663 | .probe_hw = rt2800usb_probe_hw, | |
664 | .get_firmware_name = rt2800usb_get_firmware_name, | |
665 | .check_firmware = rt2800usb_check_firmware, | |
666 | .load_firmware = rt2800usb_load_firmware, | |
667 | .initialize = rt2x00usb_initialize, | |
668 | .uninitialize = rt2x00usb_uninitialize, | |
669 | .clear_entry = rt2x00usb_clear_entry, | |
670 | .set_device_state = rt2800usb_set_device_state, | |
f4450616 BZ |
671 | .rfkill_poll = rt2800_rfkill_poll, |
672 | .link_stats = rt2800_link_stats, | |
673 | .reset_tuner = rt2800_reset_tuner, | |
674 | .link_tuner = rt2800_link_tuner, | |
d53d9e67 ID |
675 | .write_tx_desc = rt2800usb_write_tx_desc, |
676 | .write_tx_data = rt2x00usb_write_tx_data, | |
677 | .write_beacon = rt2800usb_write_beacon, | |
678 | .get_tx_data_len = rt2800usb_get_tx_data_len, | |
d61cb266 | 679 | .kick_tx_queue = rt2x00usb_kick_tx_queue, |
d53d9e67 ID |
680 | .kill_tx_queue = rt2x00usb_kill_tx_queue, |
681 | .fill_rxdone = rt2800usb_fill_rxdone, | |
f4450616 BZ |
682 | .config_shared_key = rt2800_config_shared_key, |
683 | .config_pairwise_key = rt2800_config_pairwise_key, | |
684 | .config_filter = rt2800_config_filter, | |
685 | .config_intf = rt2800_config_intf, | |
686 | .config_erp = rt2800_config_erp, | |
687 | .config_ant = rt2800_config_ant, | |
688 | .config = rt2800_config, | |
d53d9e67 ID |
689 | }; |
690 | ||
691 | static const struct data_queue_desc rt2800usb_queue_rx = { | |
692 | .entry_num = RX_ENTRIES, | |
693 | .data_size = AGGREGATION_SIZE, | |
d42c8d86 | 694 | .desc_size = RXINFO_DESC_SIZE + RXWI_DESC_SIZE, |
d53d9e67 ID |
695 | .priv_size = sizeof(struct queue_entry_priv_usb), |
696 | }; | |
697 | ||
698 | static const struct data_queue_desc rt2800usb_queue_tx = { | |
699 | .entry_num = TX_ENTRIES, | |
700 | .data_size = AGGREGATION_SIZE, | |
701 | .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, | |
702 | .priv_size = sizeof(struct queue_entry_priv_usb), | |
703 | }; | |
704 | ||
705 | static const struct data_queue_desc rt2800usb_queue_bcn = { | |
706 | .entry_num = 8 * BEACON_ENTRIES, | |
707 | .data_size = MGMT_FRAME_SIZE, | |
708 | .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, | |
709 | .priv_size = sizeof(struct queue_entry_priv_usb), | |
710 | }; | |
711 | ||
712 | static const struct rt2x00_ops rt2800usb_ops = { | |
04d0362e GW |
713 | .name = KBUILD_MODNAME, |
714 | .max_sta_intf = 1, | |
715 | .max_ap_intf = 8, | |
716 | .eeprom_size = EEPROM_SIZE, | |
717 | .rf_size = RF_SIZE, | |
718 | .tx_queues = NUM_TX_QUEUES, | |
e6218cc4 | 719 | .extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE, |
04d0362e GW |
720 | .rx = &rt2800usb_queue_rx, |
721 | .tx = &rt2800usb_queue_tx, | |
722 | .bcn = &rt2800usb_queue_bcn, | |
723 | .lib = &rt2800usb_rt2x00_ops, | |
724 | .hw = &rt2800_mac80211_ops, | |
d53d9e67 | 725 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
04d0362e | 726 | .debugfs = &rt2800_rt2x00debug, |
d53d9e67 ID |
727 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
728 | }; | |
729 | ||
730 | /* | |
731 | * rt2800usb module information. | |
732 | */ | |
733 | static struct usb_device_id rt2800usb_device_table[] = { | |
d53d9e67 ID |
734 | /* Abocom */ |
735 | { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
736 | { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 | 737 | { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, |
e8958330 XVP |
738 | /* Allwin */ |
739 | { USB_DEVICE(0x8516, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
740 | { USB_DEVICE(0x8516, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
741 | { USB_DEVICE(0x8516, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
742 | /* Amit */ |
743 | { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
2edcb7ff XVP |
744 | /* Askey */ |
745 | { USB_DEVICE(0x1690, 0x0740), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
746 | /* ASUS */ |
747 | { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
748 | { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
749 | { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
750 | /* AzureWave */ |
751 | { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
752 | /* Belkin */ |
753 | { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
754 | { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
755 | { USB_DEVICE(0x050d, 0x815c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
756 | /* Buffalo */ | |
757 | { USB_DEVICE(0x0411, 0x00e8), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
758 | /* Conceptronic */ |
759 | { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
760 | { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 | 761 | { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 ID |
762 | { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) }, |
763 | { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
764 | { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
765 | { USB_DEVICE(0x14b2, 0x3c28), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
766 | /* Corega */ | |
767 | { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
768 | { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
769 | { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
770 | /* D-Link */ |
771 | { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
772 | { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) }, |
773 | /* Edimax */ | |
774 | { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
775 | { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
776 | /* EnGenius */ | |
a6bc03a0 | 777 | { USB_DEVICE(0x1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce GW |
778 | { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) }, |
779 | /* Gigabyte */ | |
780 | { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
781 | /* Hawking */ | |
782 | { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
783 | { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
2fddd880 XVP |
784 | { USB_DEVICE(0x0e66, 0x0009), USB_DEVICE_DATA(&rt2800usb_ops) }, |
785 | { USB_DEVICE(0x0e66, 0x000b), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
786 | { USB_DEVICE(0x0e66, 0x0013), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
787 | { USB_DEVICE(0x0e66, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
788 | { USB_DEVICE(0x0e66, 0x0018), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
789 | /* Linksys */ |
790 | { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
791 | { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
792 | /* Logitec */ | |
793 | { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
794 | { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
795 | { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
796 | /* Motorola */ | |
797 | { USB_DEVICE(0x100d, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
798 | /* MSI */ | |
799 | { USB_DEVICE(0x0db0, 0x6899), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
800 | /* Philips */ | |
801 | { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
802 | /* Planex */ | |
803 | { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
804 | /* Ralink */ | |
805 | { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
806 | { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
807 | /* Samsung */ | |
808 | { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
809 | /* Siemens */ | |
810 | { USB_DEVICE(0x129b, 0x1828), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
811 | /* Sitecom */ | |
812 | { USB_DEVICE(0x0df6, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
813 | { USB_DEVICE(0x0df6, 0x002b), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
814 | { USB_DEVICE(0x0df6, 0x002c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
815 | { USB_DEVICE(0x0df6, 0x002d), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
816 | { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
a5e944f1 XVP |
817 | { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
818 | { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
819 | { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) }, |
820 | /* SMC */ | |
821 | { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
822 | { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
823 | { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
824 | { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
825 | { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
826 | { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
827 | /* Sparklan */ | |
828 | { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
829 | /* Sweex */ | |
830 | { USB_DEVICE(0x177f, 0x0302), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
831 | /* U-Media*/ | |
832 | { USB_DEVICE(0x157e, 0x300e), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
833 | /* ZCOM */ | |
834 | { USB_DEVICE(0x0cde, 0x0022), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
835 | { USB_DEVICE(0x0cde, 0x0025), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
836 | /* Zinwell */ | |
837 | { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
838 | { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
839 | /* Zyxel */ | |
840 | { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
841 | #ifdef CONFIG_RT2800USB_RT30XX | |
842 | /* Abocom */ | |
843 | { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
844 | { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
845 | { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
846 | /* AirTies */ | |
847 | { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
e8958330 XVP |
848 | /* Allwin */ |
849 | { USB_DEVICE(0x8516, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
850 | { USB_DEVICE(0x8516, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
851 | { USB_DEVICE(0x8516, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
852 | /* ASUS */ |
853 | { USB_DEVICE(0x0b05, 0x1784), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
854 | /* AzureWave */ |
855 | { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 | 856 | { USB_DEVICE(0x13d3, 0x3305), USB_DEVICE_DATA(&rt2800usb_ops) }, |
f01a0229 XVP |
857 | { USB_DEVICE(0x13d3, 0x3307), USB_DEVICE_DATA(&rt2800usb_ops) }, |
858 | { USB_DEVICE(0x13d3, 0x3321), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
859 | /* Conceptronic */ |
860 | { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
861 | /* Corega */ | |
862 | { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
863 | /* D-Link */ | |
d53d9e67 | 864 | { USB_DEVICE(0x07d1, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
ce2ebc9b ID |
865 | { USB_DEVICE(0x07d1, 0x3c0d), USB_DEVICE_DATA(&rt2800usb_ops) }, |
866 | { USB_DEVICE(0x07d1, 0x3c0e), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
867 | { USB_DEVICE(0x07d1, 0x3c0f), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 | 868 | { USB_DEVICE(0x07d1, 0x3c16), USB_DEVICE_DATA(&rt2800usb_ops) }, |
f01a0229 XVP |
869 | /* Draytek */ |
870 | { USB_DEVICE(0x07fa, 0x7712), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
871 | /* Edimax */ |
872 | { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
ce2ebc9b ID |
873 | /* Encore */ |
874 | { USB_DEVICE(0x203d, 0x1480), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 | 875 | { USB_DEVICE(0x203d, 0x14a9), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 | 876 | /* EnGenius */ |
d53d9e67 ID |
877 | { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) }, |
878 | { USB_DEVICE(0x1740, 0x9705), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
879 | { USB_DEVICE(0x1740, 0x9706), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
880 | { USB_DEVICE(0x1740, 0x9707), USB_DEVICE_DATA(&rt2800usb_ops) }, |
881 | { USB_DEVICE(0x1740, 0x9708), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
882 | { USB_DEVICE(0x1740, 0x9709), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
883 | /* Gigabyte */ |
884 | { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
885 | /* I-O DATA */ | |
886 | { USB_DEVICE(0x04bb, 0x0945), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
887 | { USB_DEVICE(0x04bb, 0x0947), USB_DEVICE_DATA(&rt2800usb_ops) }, |
888 | { USB_DEVICE(0x04bb, 0x0948), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
f01a0229 XVP |
889 | /* Logitec */ |
890 | { USB_DEVICE(0x0789, 0x0166), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
891 | /* MSI */ |
892 | { USB_DEVICE(0x0db0, 0x3820), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
893 | { USB_DEVICE(0x0db0, 0x3821), USB_DEVICE_DATA(&rt2800usb_ops) }, |
894 | { USB_DEVICE(0x0db0, 0x3822), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
895 | { USB_DEVICE(0x0db0, 0x3870), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
896 | { USB_DEVICE(0x0db0, 0x3871), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
897 | { USB_DEVICE(0x0db0, 0x821a), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
898 | { USB_DEVICE(0x0db0, 0x822a), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
f01a0229 XVP |
899 | { USB_DEVICE(0x0db0, 0x822b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
900 | { USB_DEVICE(0x0db0, 0x822c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
901 | { USB_DEVICE(0x0db0, 0x870a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
902 | { USB_DEVICE(0x0db0, 0x871a), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
f01a0229 XVP |
903 | { USB_DEVICE(0x0db0, 0x871b), USB_DEVICE_DATA(&rt2800usb_ops) }, |
904 | { USB_DEVICE(0x0db0, 0x871c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
905 | { USB_DEVICE(0x0db0, 0x899a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
906 | /* Para */ | |
907 | { USB_DEVICE(0x20b8, 0x8888), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
908 | /* Pegatron */ |
909 | { USB_DEVICE(0x1d4d, 0x000c), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
910 | { USB_DEVICE(0x1d4d, 0x000e), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
911 | /* Planex */ | |
912 | { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
913 | /* Quanta */ | |
914 | { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
915 | /* Ralink */ | |
916 | { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
917 | { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
918 | { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
919 | { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
920 | /* Sitecom */ | |
921 | { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
a5e944f1 | 922 | { USB_DEVICE(0x0df6, 0x0040), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce | 923 | { USB_DEVICE(0x0df6, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) }, |
fc3f1487 XVP |
924 | { USB_DEVICE(0x0df6, 0x0047), USB_DEVICE_DATA(&rt2800usb_ops) }, |
925 | { USB_DEVICE(0x0df6, 0x0048), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
926 | /* SMC */ |
927 | { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
fc3f1487 XVP |
928 | { USB_DEVICE(0x083a, 0xa701), USB_DEVICE_DATA(&rt2800usb_ops) }, |
929 | { USB_DEVICE(0x083a, 0xa702), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
f01a0229 | 930 | { USB_DEVICE(0x083a, 0xa703), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce GW |
931 | /* Zinwell */ |
932 | { USB_DEVICE(0x5a57, 0x0283), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
933 | { USB_DEVICE(0x5a57, 0x5257), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
934 | #endif | |
935 | #ifdef CONFIG_RT2800USB_RT35XX | |
e8958330 XVP |
936 | /* Allwin */ |
937 | { USB_DEVICE(0x8516, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
938 | /* Askey */ |
939 | { USB_DEVICE(0x1690, 0x0744), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
940 | /* Cisco */ | |
941 | { USB_DEVICE(0x167b, 0x4001), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
942 | /* EnGenius */ | |
943 | { USB_DEVICE(0x1740, 0x9801), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
944 | /* I-O DATA */ | |
945 | { USB_DEVICE(0x04bb, 0x0944), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
946 | /* Ralink */ | |
947 | { USB_DEVICE(0x148f, 0x3370), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
948 | { USB_DEVICE(0x148f, 0x3572), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
949 | { USB_DEVICE(0x148f, 0x8070), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
950 | /* Sitecom */ | |
951 | { USB_DEVICE(0x0df6, 0x0041), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
a5e944f1 | 952 | { USB_DEVICE(0x0df6, 0x0050), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce GW |
953 | /* Zinwell */ |
954 | { USB_DEVICE(0x5a57, 0x0284), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
955 | #endif | |
956 | #ifdef CONFIG_RT2800USB_UNKNOWN | |
957 | /* | |
958 | * Unclear what kind of devices these are (they aren't supported by the | |
12ef116b | 959 | * vendor linux driver). |
de1ebdce | 960 | */ |
de1ebdce GW |
961 | /* Amigo */ |
962 | { USB_DEVICE(0x0e0b, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
963 | { USB_DEVICE(0x0e0b, 0x9041), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
964 | /* ASUS */ |
965 | { USB_DEVICE(0x0b05, 0x1760), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
966 | { USB_DEVICE(0x0b05, 0x1761), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
de1ebdce GW |
967 | { USB_DEVICE(0x0b05, 0x1790), USB_DEVICE_DATA(&rt2800usb_ops) }, |
968 | { USB_DEVICE(0x1761, 0x0b05), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
969 | /* AzureWave */ | |
970 | { USB_DEVICE(0x13d3, 0x3262), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
971 | { USB_DEVICE(0x13d3, 0x3284), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
12ef116b | 972 | { USB_DEVICE(0x13d3, 0x3322), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce GW |
973 | /* Belkin */ |
974 | { USB_DEVICE(0x050d, 0x825a), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
975 | /* Buffalo */ | |
976 | { USB_DEVICE(0x0411, 0x012e), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
977 | { USB_DEVICE(0x0411, 0x0148), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
978 | { USB_DEVICE(0x0411, 0x0150), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
979 | { USB_DEVICE(0x0411, 0x015d), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
980 | /* Conceptronic */ | |
981 | { USB_DEVICE(0x14b2, 0x3c08), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
982 | { USB_DEVICE(0x14b2, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
983 | /* Corega */ | |
984 | { USB_DEVICE(0x07aa, 0x0041), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
985 | { USB_DEVICE(0x07aa, 0x0042), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
986 | { USB_DEVICE(0x18c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
987 | /* D-Link */ | |
988 | { USB_DEVICE(0x07d1, 0x3c0b), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
989 | { USB_DEVICE(0x07d1, 0x3c13), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
990 | { USB_DEVICE(0x07d1, 0x3c15), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
12ef116b | 991 | { USB_DEVICE(0x07d1, 0x3c17), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce GW |
992 | /* Encore */ |
993 | { USB_DEVICE(0x203d, 0x14a1), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 ID |
994 | /* Gemtek */ |
995 | { USB_DEVICE(0x15a9, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
996 | /* Gigabyte */ | |
d53d9e67 | 997 | { USB_DEVICE(0x1044, 0x800c), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 ID |
998 | /* LevelOne */ |
999 | { USB_DEVICE(0x1740, 0x0605), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
1000 | { USB_DEVICE(0x1740, 0x0615), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
1001 | /* Linksys */ | |
e430d607 | 1002 | { USB_DEVICE(0x1737, 0x0077), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce | 1003 | { USB_DEVICE(0x1737, 0x0078), USB_DEVICE_DATA(&rt2800usb_ops) }, |
5e312589 | 1004 | { USB_DEVICE(0x1737, 0x0079), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 | 1005 | /* Motorola */ |
d53d9e67 ID |
1006 | { USB_DEVICE(0x100d, 0x9032), USB_DEVICE_DATA(&rt2800usb_ops) }, |
1007 | /* Ovislink */ | |
12ef116b | 1008 | { USB_DEVICE(0x1b75, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 ID |
1009 | { USB_DEVICE(0x1b75, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) }, |
1010 | /* Pegatron */ | |
de1ebdce | 1011 | { USB_DEVICE(0x05a6, 0x0101), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 | 1012 | { USB_DEVICE(0x1d4d, 0x0002), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce | 1013 | { USB_DEVICE(0x1d4d, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) }, |
12ef116b | 1014 | { USB_DEVICE(0x1d4d, 0x0011), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 | 1015 | /* Planex */ |
d53d9e67 | 1016 | { USB_DEVICE(0x2019, 0xab24), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 ID |
1017 | /* Qcom */ |
1018 | { USB_DEVICE(0x18e8, 0x6259), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
d53d9e67 | 1019 | /* SMC */ |
d53d9e67 | 1020 | { USB_DEVICE(0x083a, 0xa512), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 | 1021 | { USB_DEVICE(0x083a, 0xc522), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce | 1022 | { USB_DEVICE(0x083a, 0xd522), USB_DEVICE_DATA(&rt2800usb_ops) }, |
12ef116b | 1023 | { USB_DEVICE(0x083a, 0xf511), USB_DEVICE_DATA(&rt2800usb_ops) }, |
3b91c360 ID |
1024 | /* Sweex */ |
1025 | { USB_DEVICE(0x177f, 0x0153), USB_DEVICE_DATA(&rt2800usb_ops) }, | |
3b91c360 | 1026 | { USB_DEVICE(0x177f, 0x0313), USB_DEVICE_DATA(&rt2800usb_ops) }, |
d53d9e67 | 1027 | /* Zyxel */ |
d53d9e67 | 1028 | { USB_DEVICE(0x0586, 0x341a), USB_DEVICE_DATA(&rt2800usb_ops) }, |
de1ebdce | 1029 | #endif |
d53d9e67 ID |
1030 | { 0, } |
1031 | }; | |
1032 | ||
1033 | MODULE_AUTHOR(DRV_PROJECT); | |
1034 | MODULE_VERSION(DRV_VERSION); | |
1035 | MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver."); | |
1036 | MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards"); | |
1037 | MODULE_DEVICE_TABLE(usb, rt2800usb_device_table); | |
1038 | MODULE_FIRMWARE(FIRMWARE_RT2870); | |
1039 | MODULE_LICENSE("GPL"); | |
1040 | ||
1041 | static struct usb_driver rt2800usb_driver = { | |
1042 | .name = KBUILD_MODNAME, | |
1043 | .id_table = rt2800usb_device_table, | |
1044 | .probe = rt2x00usb_probe, | |
1045 | .disconnect = rt2x00usb_disconnect, | |
1046 | .suspend = rt2x00usb_suspend, | |
1047 | .resume = rt2x00usb_resume, | |
1048 | }; | |
1049 | ||
1050 | static int __init rt2800usb_init(void) | |
1051 | { | |
1052 | return usb_register(&rt2800usb_driver); | |
1053 | } | |
1054 | ||
1055 | static void __exit rt2800usb_exit(void) | |
1056 | { | |
1057 | usb_deregister(&rt2800usb_driver); | |
1058 | } | |
1059 | ||
1060 | module_init(rt2800usb_init); | |
1061 | module_exit(rt2800usb_exit); |