rt2500usb: fallback to SW encryption for TKIP+AES
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / wireless / rt2x00 / rt2500usb.c
blob99d6fd7327a24fe646fef373b9eacc26e271e5c7
1 /*
2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 Module: rt2500usb
23 Abstract: rt2500usb device specific routines.
24 Supported chipsets: RT2570.
27 #include <linux/delay.h>
28 #include <linux/etherdevice.h>
29 #include <linux/init.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/usb.h>
34 #include "rt2x00.h"
35 #include "rt2x00usb.h"
36 #include "rt2500usb.h"
39 * Allow hardware encryption to be disabled.
41 static int modparam_nohwcrypt = 0;
42 module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
43 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
46 * Register access.
47 * All access to the CSR registers will go through the methods
48 * rt2500usb_register_read and rt2500usb_register_write.
49 * BBP and RF register require indirect register access,
50 * and use the CSR registers BBPCSR and RFCSR to achieve this.
51 * These indirect registers work with busy bits,
52 * and we will try maximal REGISTER_BUSY_COUNT times to access
53 * the register while taking a REGISTER_BUSY_DELAY us delay
54 * between each attampt. When the busy bit is still set at that time,
55 * the access attempt is considered to have failed,
56 * and we will print an error.
57 * If the csr_mutex is already held then the _lock variants must
58 * be used instead.
60 static inline void rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
61 const unsigned int offset,
62 u16 *value)
64 __le16 reg;
65 rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
66 USB_VENDOR_REQUEST_IN, offset,
67 &reg, sizeof(reg), REGISTER_TIMEOUT);
68 *value = le16_to_cpu(reg);
71 static inline void rt2500usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
72 const unsigned int offset,
73 u16 *value)
75 __le16 reg;
76 rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_READ,
77 USB_VENDOR_REQUEST_IN, offset,
78 &reg, sizeof(reg), REGISTER_TIMEOUT);
79 *value = le16_to_cpu(reg);
82 static inline void rt2500usb_register_multiread(struct rt2x00_dev *rt2x00dev,
83 const unsigned int offset,
84 void *value, const u16 length)
86 rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
87 USB_VENDOR_REQUEST_IN, offset,
88 value, length,
89 REGISTER_TIMEOUT16(length));
92 static inline void rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
93 const unsigned int offset,
94 u16 value)
96 __le16 reg = cpu_to_le16(value);
97 rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
98 USB_VENDOR_REQUEST_OUT, offset,
99 &reg, sizeof(reg), REGISTER_TIMEOUT);
102 static inline void rt2500usb_register_write_lock(struct rt2x00_dev *rt2x00dev,
103 const unsigned int offset,
104 u16 value)
106 __le16 reg = cpu_to_le16(value);
107 rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_WRITE,
108 USB_VENDOR_REQUEST_OUT, offset,
109 &reg, sizeof(reg), REGISTER_TIMEOUT);
112 static inline void rt2500usb_register_multiwrite(struct rt2x00_dev *rt2x00dev,
113 const unsigned int offset,
114 void *value, const u16 length)
116 rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_WRITE,
117 USB_VENDOR_REQUEST_OUT, offset,
118 value, length,
119 REGISTER_TIMEOUT16(length));
122 static int rt2500usb_regbusy_read(struct rt2x00_dev *rt2x00dev,
123 const unsigned int offset,
124 struct rt2x00_field16 field,
125 u16 *reg)
127 unsigned int i;
129 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
130 rt2500usb_register_read_lock(rt2x00dev, offset, reg);
131 if (!rt2x00_get_field16(*reg, field))
132 return 1;
133 udelay(REGISTER_BUSY_DELAY);
136 ERROR(rt2x00dev, "Indirect register access failed: "
137 "offset=0x%.08x, value=0x%.08x\n", offset, *reg);
138 *reg = ~0;
140 return 0;
143 #define WAIT_FOR_BBP(__dev, __reg) \
144 rt2500usb_regbusy_read((__dev), PHY_CSR8, PHY_CSR8_BUSY, (__reg))
145 #define WAIT_FOR_RF(__dev, __reg) \
146 rt2500usb_regbusy_read((__dev), PHY_CSR10, PHY_CSR10_RF_BUSY, (__reg))
148 static void rt2500usb_bbp_write(struct rt2x00_dev *rt2x00dev,
149 const unsigned int word, const u8 value)
151 u16 reg;
153 mutex_lock(&rt2x00dev->csr_mutex);
156 * Wait until the BBP becomes available, afterwards we
157 * can safely write the new data into the register.
159 if (WAIT_FOR_BBP(rt2x00dev, &reg)) {
160 reg = 0;
161 rt2x00_set_field16(&reg, PHY_CSR7_DATA, value);
162 rt2x00_set_field16(&reg, PHY_CSR7_REG_ID, word);
163 rt2x00_set_field16(&reg, PHY_CSR7_READ_CONTROL, 0);
165 rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg);
168 mutex_unlock(&rt2x00dev->csr_mutex);
171 static void rt2500usb_bbp_read(struct rt2x00_dev *rt2x00dev,
172 const unsigned int word, u8 *value)
174 u16 reg;
176 mutex_lock(&rt2x00dev->csr_mutex);
179 * Wait until the BBP becomes available, afterwards we
180 * can safely write the read request into the register.
181 * After the data has been written, we wait until hardware
182 * returns the correct value, if at any time the register
183 * doesn't become available in time, reg will be 0xffffffff
184 * which means we return 0xff to the caller.
186 if (WAIT_FOR_BBP(rt2x00dev, &reg)) {
187 reg = 0;
188 rt2x00_set_field16(&reg, PHY_CSR7_REG_ID, word);
189 rt2x00_set_field16(&reg, PHY_CSR7_READ_CONTROL, 1);
191 rt2500usb_register_write_lock(rt2x00dev, PHY_CSR7, reg);
193 if (WAIT_FOR_BBP(rt2x00dev, &reg))
194 rt2500usb_register_read_lock(rt2x00dev, PHY_CSR7, &reg);
197 *value = rt2x00_get_field16(reg, PHY_CSR7_DATA);
199 mutex_unlock(&rt2x00dev->csr_mutex);
202 static void rt2500usb_rf_write(struct rt2x00_dev *rt2x00dev,
203 const unsigned int word, const u32 value)
205 u16 reg;
207 mutex_lock(&rt2x00dev->csr_mutex);
210 * Wait until the RF becomes available, afterwards we
211 * can safely write the new data into the register.
213 if (WAIT_FOR_RF(rt2x00dev, &reg)) {
214 reg = 0;
215 rt2x00_set_field16(&reg, PHY_CSR9_RF_VALUE, value);
216 rt2500usb_register_write_lock(rt2x00dev, PHY_CSR9, reg);
218 reg = 0;
219 rt2x00_set_field16(&reg, PHY_CSR10_RF_VALUE, value >> 16);
220 rt2x00_set_field16(&reg, PHY_CSR10_RF_NUMBER_OF_BITS, 20);
221 rt2x00_set_field16(&reg, PHY_CSR10_RF_IF_SELECT, 0);
222 rt2x00_set_field16(&reg, PHY_CSR10_RF_BUSY, 1);
224 rt2500usb_register_write_lock(rt2x00dev, PHY_CSR10, reg);
225 rt2x00_rf_write(rt2x00dev, word, value);
228 mutex_unlock(&rt2x00dev->csr_mutex);
231 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
232 static void _rt2500usb_register_read(struct rt2x00_dev *rt2x00dev,
233 const unsigned int offset,
234 u32 *value)
236 rt2500usb_register_read(rt2x00dev, offset, (u16 *)value);
239 static void _rt2500usb_register_write(struct rt2x00_dev *rt2x00dev,
240 const unsigned int offset,
241 u32 value)
243 rt2500usb_register_write(rt2x00dev, offset, value);
246 static const struct rt2x00debug rt2500usb_rt2x00debug = {
247 .owner = THIS_MODULE,
248 .csr = {
249 .read = _rt2500usb_register_read,
250 .write = _rt2500usb_register_write,
251 .flags = RT2X00DEBUGFS_OFFSET,
252 .word_base = CSR_REG_BASE,
253 .word_size = sizeof(u16),
254 .word_count = CSR_REG_SIZE / sizeof(u16),
256 .eeprom = {
257 .read = rt2x00_eeprom_read,
258 .write = rt2x00_eeprom_write,
259 .word_base = EEPROM_BASE,
260 .word_size = sizeof(u16),
261 .word_count = EEPROM_SIZE / sizeof(u16),
263 .bbp = {
264 .read = rt2500usb_bbp_read,
265 .write = rt2500usb_bbp_write,
266 .word_base = BBP_BASE,
267 .word_size = sizeof(u8),
268 .word_count = BBP_SIZE / sizeof(u8),
270 .rf = {
271 .read = rt2x00_rf_read,
272 .write = rt2500usb_rf_write,
273 .word_base = RF_BASE,
274 .word_size = sizeof(u32),
275 .word_count = RF_SIZE / sizeof(u32),
278 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
280 static int rt2500usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)
282 u16 reg;
284 rt2500usb_register_read(rt2x00dev, MAC_CSR19, &reg);
285 return rt2x00_get_field32(reg, MAC_CSR19_BIT7);
288 #ifdef CONFIG_RT2X00_LIB_LEDS
289 static void rt2500usb_brightness_set(struct led_classdev *led_cdev,
290 enum led_brightness brightness)
292 struct rt2x00_led *led =
293 container_of(led_cdev, struct rt2x00_led, led_dev);
294 unsigned int enabled = brightness != LED_OFF;
295 u16 reg;
297 rt2500usb_register_read(led->rt2x00dev, MAC_CSR20, &reg);
299 if (led->type == LED_TYPE_RADIO || led->type == LED_TYPE_ASSOC)
300 rt2x00_set_field16(&reg, MAC_CSR20_LINK, enabled);
301 else if (led->type == LED_TYPE_ACTIVITY)
302 rt2x00_set_field16(&reg, MAC_CSR20_ACTIVITY, enabled);
304 rt2500usb_register_write(led->rt2x00dev, MAC_CSR20, reg);
307 static int rt2500usb_blink_set(struct led_classdev *led_cdev,
308 unsigned long *delay_on,
309 unsigned long *delay_off)
311 struct rt2x00_led *led =
312 container_of(led_cdev, struct rt2x00_led, led_dev);
313 u16 reg;
315 rt2500usb_register_read(led->rt2x00dev, MAC_CSR21, &reg);
316 rt2x00_set_field16(&reg, MAC_CSR21_ON_PERIOD, *delay_on);
317 rt2x00_set_field16(&reg, MAC_CSR21_OFF_PERIOD, *delay_off);
318 rt2500usb_register_write(led->rt2x00dev, MAC_CSR21, reg);
320 return 0;
323 static void rt2500usb_init_led(struct rt2x00_dev *rt2x00dev,
324 struct rt2x00_led *led,
325 enum led_type type)
327 led->rt2x00dev = rt2x00dev;
328 led->type = type;
329 led->led_dev.brightness_set = rt2500usb_brightness_set;
330 led->led_dev.blink_set = rt2500usb_blink_set;
331 led->flags = LED_INITIALIZED;
333 #endif /* CONFIG_RT2X00_LIB_LEDS */
336 * Configuration handlers.
340 * rt2500usb does not differentiate between shared and pairwise
341 * keys, so we should use the same function for both key types.
343 static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
344 struct rt2x00lib_crypto *crypto,
345 struct ieee80211_key_conf *key)
347 int timeout;
348 u32 mask;
349 u16 reg;
350 enum cipher curr_cipher;
352 if (crypto->cmd == SET_KEY) {
354 * Pairwise key will always be entry 0, but this
355 * could collide with a shared key on the same
356 * position...
358 mask = TXRX_CSR0_KEY_ID.bit_mask;
360 rt2500usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
361 curr_cipher = rt2x00_get_field16(reg, TXRX_CSR0_ALGORITHM);
362 reg &= mask;
364 if (reg && reg == mask)
365 return -ENOSPC;
367 reg = rt2x00_get_field16(reg, TXRX_CSR0_KEY_ID);
369 key->hw_key_idx += reg ? ffz(reg) : 0;
371 * Hardware requires that all keys use the same cipher
372 * (e.g. TKIP-only, AES-only, but not TKIP+AES).
373 * If this is not the first key, compare the cipher with the
374 * first one and fall back to SW crypto if not the same.
376 if (key->hw_key_idx > 0 && crypto->cipher != curr_cipher)
377 return -EOPNOTSUPP;
380 * The encryption key doesn't fit within the CSR cache,
381 * this means we should allocate it seperately and use
382 * rt2x00usb_vendor_request() to send the key to the hardware.
384 reg = KEY_ENTRY(key->hw_key_idx);
385 timeout = REGISTER_TIMEOUT32(sizeof(crypto->key));
386 rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
387 USB_VENDOR_REQUEST_OUT, reg,
388 crypto->key,
389 sizeof(crypto->key),
390 timeout);
393 * The driver does not support the IV/EIV generation
394 * in hardware. However it demands the data to be provided
395 * both seperately as well as inside the frame.
396 * We already provided the CONFIG_CRYPTO_COPY_IV to rt2x00lib
397 * to ensure rt2x00lib will not strip the data from the
398 * frame after the copy, now we must tell mac80211
399 * to generate the IV/EIV data.
401 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
402 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
406 * TXRX_CSR0_KEY_ID contains only single-bit fields to indicate
407 * a particular key is valid.
409 rt2500usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
410 rt2x00_set_field16(&reg, TXRX_CSR0_ALGORITHM, crypto->cipher);
411 rt2x00_set_field16(&reg, TXRX_CSR0_IV_OFFSET, IEEE80211_HEADER);
413 mask = rt2x00_get_field16(reg, TXRX_CSR0_KEY_ID);
414 if (crypto->cmd == SET_KEY)
415 mask |= 1 << key->hw_key_idx;
416 else if (crypto->cmd == DISABLE_KEY)
417 mask &= ~(1 << key->hw_key_idx);
418 rt2x00_set_field16(&reg, TXRX_CSR0_KEY_ID, mask);
419 rt2500usb_register_write(rt2x00dev, TXRX_CSR0, reg);
421 return 0;
424 static void rt2500usb_config_filter(struct rt2x00_dev *rt2x00dev,
425 const unsigned int filter_flags)
427 u16 reg;
430 * Start configuration steps.
431 * Note that the version error will always be dropped
432 * and broadcast frames will always be accepted since
433 * there is no filter for it at this time.
435 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
436 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CRC,
437 !(filter_flags & FIF_FCSFAIL));
438 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_PHYSICAL,
439 !(filter_flags & FIF_PLCPFAIL));
440 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_CONTROL,
441 !(filter_flags & FIF_CONTROL));
442 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_NOT_TO_ME,
443 !(filter_flags & FIF_PROMISC_IN_BSS));
444 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_TODS,
445 !(filter_flags & FIF_PROMISC_IN_BSS) &&
446 !rt2x00dev->intf_ap_count);
447 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_VERSION_ERROR, 1);
448 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_MULTICAST,
449 !(filter_flags & FIF_ALLMULTI));
450 rt2x00_set_field16(&reg, TXRX_CSR2_DROP_BROADCAST, 0);
451 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
454 static void rt2500usb_config_intf(struct rt2x00_dev *rt2x00dev,
455 struct rt2x00_intf *intf,
456 struct rt2x00intf_conf *conf,
457 const unsigned int flags)
459 unsigned int bcn_preload;
460 u16 reg;
462 if (flags & CONFIG_UPDATE_TYPE) {
464 * Enable beacon config
466 bcn_preload = PREAMBLE + GET_DURATION(IEEE80211_HEADER, 20);
467 rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg);
468 rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET, bcn_preload >> 6);
469 rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW,
470 2 * (conf->type != NL80211_IFTYPE_STATION));
471 rt2500usb_register_write(rt2x00dev, TXRX_CSR20, reg);
474 * Enable synchronisation.
476 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
477 rt2x00_set_field16(&reg, TXRX_CSR18_OFFSET, 0);
478 rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg);
480 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
481 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
482 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, conf->sync);
483 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
484 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
487 if (flags & CONFIG_UPDATE_MAC)
488 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR2, conf->mac,
489 (3 * sizeof(__le16)));
491 if (flags & CONFIG_UPDATE_BSSID)
492 rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, conf->bssid,
493 (3 * sizeof(__le16)));
496 static void rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
497 struct rt2x00lib_erp *erp)
499 u16 reg;
501 rt2500usb_register_read(rt2x00dev, TXRX_CSR10, &reg);
502 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
503 !!erp->short_preamble);
504 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
506 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, erp->basic_rates);
508 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
509 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL, erp->beacon_int * 4);
510 rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg);
512 rt2500usb_register_write(rt2x00dev, MAC_CSR10, erp->slot_time);
513 rt2500usb_register_write(rt2x00dev, MAC_CSR11, erp->sifs);
514 rt2500usb_register_write(rt2x00dev, MAC_CSR12, erp->eifs);
517 static void rt2500usb_config_ant(struct rt2x00_dev *rt2x00dev,
518 struct antenna_setup *ant)
520 u8 r2;
521 u8 r14;
522 u16 csr5;
523 u16 csr6;
526 * We should never come here because rt2x00lib is supposed
527 * to catch this and send us the correct antenna explicitely.
529 BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
530 ant->tx == ANTENNA_SW_DIVERSITY);
532 rt2500usb_bbp_read(rt2x00dev, 2, &r2);
533 rt2500usb_bbp_read(rt2x00dev, 14, &r14);
534 rt2500usb_register_read(rt2x00dev, PHY_CSR5, &csr5);
535 rt2500usb_register_read(rt2x00dev, PHY_CSR6, &csr6);
538 * Configure the TX antenna.
540 switch (ant->tx) {
541 case ANTENNA_HW_DIVERSITY:
542 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 1);
543 rt2x00_set_field16(&csr5, PHY_CSR5_CCK, 1);
544 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM, 1);
545 break;
546 case ANTENNA_A:
547 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 0);
548 rt2x00_set_field16(&csr5, PHY_CSR5_CCK, 0);
549 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM, 0);
550 break;
551 case ANTENNA_B:
552 default:
553 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2);
554 rt2x00_set_field16(&csr5, PHY_CSR5_CCK, 2);
555 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM, 2);
556 break;
560 * Configure the RX antenna.
562 switch (ant->rx) {
563 case ANTENNA_HW_DIVERSITY:
564 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 1);
565 break;
566 case ANTENNA_A:
567 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 0);
568 break;
569 case ANTENNA_B:
570 default:
571 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2);
572 break;
576 * RT2525E and RT5222 need to flip TX I/Q
578 if (rt2x00_rf(&rt2x00dev->chip, RF2525E) ||
579 rt2x00_rf(&rt2x00dev->chip, RF5222)) {
580 rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1);
581 rt2x00_set_field16(&csr5, PHY_CSR5_CCK_FLIP, 1);
582 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM_FLIP, 1);
585 * RT2525E does not need RX I/Q Flip.
587 if (rt2x00_rf(&rt2x00dev->chip, RF2525E))
588 rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0);
589 } else {
590 rt2x00_set_field16(&csr5, PHY_CSR5_CCK_FLIP, 0);
591 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM_FLIP, 0);
594 rt2500usb_bbp_write(rt2x00dev, 2, r2);
595 rt2500usb_bbp_write(rt2x00dev, 14, r14);
596 rt2500usb_register_write(rt2x00dev, PHY_CSR5, csr5);
597 rt2500usb_register_write(rt2x00dev, PHY_CSR6, csr6);
600 static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
601 struct rf_channel *rf, const int txpower)
604 * Set TXpower.
606 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
609 * For RT2525E we should first set the channel to half band higher.
611 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {
612 static const u32 vals[] = {
613 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
614 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
615 0x000008ba, 0x000008be, 0x000008b7, 0x00000902,
616 0x00000902, 0x00000906
619 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->channel - 1]);
620 if (rf->rf4)
621 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
624 rt2500usb_rf_write(rt2x00dev, 1, rf->rf1);
625 rt2500usb_rf_write(rt2x00dev, 2, rf->rf2);
626 rt2500usb_rf_write(rt2x00dev, 3, rf->rf3);
627 if (rf->rf4)
628 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
631 static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
632 const int txpower)
634 u32 rf3;
636 rt2x00_rf_read(rt2x00dev, 3, &rf3);
637 rt2x00_set_field32(&rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
638 rt2500usb_rf_write(rt2x00dev, 3, rf3);
641 static void rt2500usb_config_ps(struct rt2x00_dev *rt2x00dev,
642 struct rt2x00lib_conf *libconf)
644 enum dev_state state =
645 (libconf->conf->flags & IEEE80211_CONF_PS) ?
646 STATE_SLEEP : STATE_AWAKE;
647 u16 reg;
649 if (state == STATE_SLEEP) {
650 rt2500usb_register_read(rt2x00dev, MAC_CSR18, &reg);
651 rt2x00_set_field16(&reg, MAC_CSR18_DELAY_AFTER_BEACON,
652 rt2x00dev->beacon_int - 20);
653 rt2x00_set_field16(&reg, MAC_CSR18_BEACONS_BEFORE_WAKEUP,
654 libconf->conf->listen_interval - 1);
656 /* We must first disable autowake before it can be enabled */
657 rt2x00_set_field16(&reg, MAC_CSR18_AUTO_WAKE, 0);
658 rt2500usb_register_write(rt2x00dev, MAC_CSR18, reg);
660 rt2x00_set_field16(&reg, MAC_CSR18_AUTO_WAKE, 1);
661 rt2500usb_register_write(rt2x00dev, MAC_CSR18, reg);
664 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state);
667 static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
668 struct rt2x00lib_conf *libconf,
669 const unsigned int flags)
671 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
672 rt2500usb_config_channel(rt2x00dev, &libconf->rf,
673 libconf->conf->power_level);
674 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
675 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
676 rt2500usb_config_txpower(rt2x00dev,
677 libconf->conf->power_level);
678 if (flags & IEEE80211_CONF_CHANGE_PS)
679 rt2500usb_config_ps(rt2x00dev, libconf);
683 * Link tuning
685 static void rt2500usb_link_stats(struct rt2x00_dev *rt2x00dev,
686 struct link_qual *qual)
688 u16 reg;
691 * Update FCS error count from register.
693 rt2500usb_register_read(rt2x00dev, STA_CSR0, &reg);
694 qual->rx_failed = rt2x00_get_field16(reg, STA_CSR0_FCS_ERROR);
697 * Update False CCA count from register.
699 rt2500usb_register_read(rt2x00dev, STA_CSR3, &reg);
700 qual->false_cca = rt2x00_get_field16(reg, STA_CSR3_FALSE_CCA_ERROR);
703 static void rt2500usb_reset_tuner(struct rt2x00_dev *rt2x00dev,
704 struct link_qual *qual)
706 u16 eeprom;
707 u16 value;
709 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R24, &eeprom);
710 value = rt2x00_get_field16(eeprom, EEPROM_BBPTUNE_R24_LOW);
711 rt2500usb_bbp_write(rt2x00dev, 24, value);
713 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R25, &eeprom);
714 value = rt2x00_get_field16(eeprom, EEPROM_BBPTUNE_R25_LOW);
715 rt2500usb_bbp_write(rt2x00dev, 25, value);
717 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R61, &eeprom);
718 value = rt2x00_get_field16(eeprom, EEPROM_BBPTUNE_R61_LOW);
719 rt2500usb_bbp_write(rt2x00dev, 61, value);
721 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_VGC, &eeprom);
722 value = rt2x00_get_field16(eeprom, EEPROM_BBPTUNE_VGCUPPER);
723 rt2500usb_bbp_write(rt2x00dev, 17, value);
725 qual->vgc_level = value;
729 * NOTE: This function is directly ported from legacy driver, but
730 * despite it being declared it was never called. Although link tuning
731 * sounds like a good idea, and usually works well for the other drivers,
732 * it does _not_ work with rt2500usb. Enabling this function will result
733 * in TX capabilities only until association kicks in. Immediately
734 * after the successful association all TX frames will be kept in the
735 * hardware queue and never transmitted.
737 #if 0
738 static void rt2500usb_link_tuner(struct rt2x00_dev *rt2x00dev)
740 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link);
741 u16 bbp_thresh;
742 u16 vgc_bound;
743 u16 sens;
744 u16 r24;
745 u16 r25;
746 u16 r61;
747 u16 r17_sens;
748 u8 r17;
749 u8 up_bound;
750 u8 low_bound;
753 * Read current r17 value, as well as the sensitivity values
754 * for the r17 register.
756 rt2500usb_bbp_read(rt2x00dev, 17, &r17);
757 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R17, &r17_sens);
759 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_VGC, &vgc_bound);
760 up_bound = rt2x00_get_field16(vgc_bound, EEPROM_BBPTUNE_VGCUPPER);
761 low_bound = rt2x00_get_field16(vgc_bound, EEPROM_BBPTUNE_VGCLOWER);
764 * If we are not associated, we should go straight to the
765 * dynamic CCA tuning.
767 if (!rt2x00dev->intf_associated)
768 goto dynamic_cca_tune;
771 * Determine the BBP tuning threshold and correctly
772 * set BBP 24, 25 and 61.
774 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE, &bbp_thresh);
775 bbp_thresh = rt2x00_get_field16(bbp_thresh, EEPROM_BBPTUNE_THRESHOLD);
777 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R24, &r24);
778 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R25, &r25);
779 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R61, &r61);
781 if ((rssi + bbp_thresh) > 0) {
782 r24 = rt2x00_get_field16(r24, EEPROM_BBPTUNE_R24_HIGH);
783 r25 = rt2x00_get_field16(r25, EEPROM_BBPTUNE_R25_HIGH);
784 r61 = rt2x00_get_field16(r61, EEPROM_BBPTUNE_R61_HIGH);
785 } else {
786 r24 = rt2x00_get_field16(r24, EEPROM_BBPTUNE_R24_LOW);
787 r25 = rt2x00_get_field16(r25, EEPROM_BBPTUNE_R25_LOW);
788 r61 = rt2x00_get_field16(r61, EEPROM_BBPTUNE_R61_LOW);
791 rt2500usb_bbp_write(rt2x00dev, 24, r24);
792 rt2500usb_bbp_write(rt2x00dev, 25, r25);
793 rt2500usb_bbp_write(rt2x00dev, 61, r61);
796 * A too low RSSI will cause too much false CCA which will
797 * then corrupt the R17 tuning. To remidy this the tuning should
798 * be stopped (While making sure the R17 value will not exceed limits)
800 if (rssi >= -40) {
801 if (r17 != 0x60)
802 rt2500usb_bbp_write(rt2x00dev, 17, 0x60);
803 return;
807 * Special big-R17 for short distance
809 if (rssi >= -58) {
810 sens = rt2x00_get_field16(r17_sens, EEPROM_BBPTUNE_R17_LOW);
811 if (r17 != sens)
812 rt2500usb_bbp_write(rt2x00dev, 17, sens);
813 return;
817 * Special mid-R17 for middle distance
819 if (rssi >= -74) {
820 sens = rt2x00_get_field16(r17_sens, EEPROM_BBPTUNE_R17_HIGH);
821 if (r17 != sens)
822 rt2500usb_bbp_write(rt2x00dev, 17, sens);
823 return;
827 * Leave short or middle distance condition, restore r17
828 * to the dynamic tuning range.
830 low_bound = 0x32;
831 if (rssi < -77)
832 up_bound -= (-77 - rssi);
834 if (up_bound < low_bound)
835 up_bound = low_bound;
837 if (r17 > up_bound) {
838 rt2500usb_bbp_write(rt2x00dev, 17, up_bound);
839 rt2x00dev->link.vgc_level = up_bound;
840 return;
843 dynamic_cca_tune:
846 * R17 is inside the dynamic tuning range,
847 * start tuning the link based on the false cca counter.
849 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
850 rt2500usb_bbp_write(rt2x00dev, 17, ++r17);
851 rt2x00dev->link.vgc_level = r17;
852 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
853 rt2500usb_bbp_write(rt2x00dev, 17, --r17);
854 rt2x00dev->link.vgc_level = r17;
857 #else
858 #define rt2500usb_link_tuner NULL
859 #endif
862 * Initialization functions.
864 static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
866 u16 reg;
868 rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0x0001,
869 USB_MODE_TEST, REGISTER_TIMEOUT);
870 rt2x00usb_vendor_request_sw(rt2x00dev, USB_SINGLE_WRITE, 0x0308,
871 0x00f0, REGISTER_TIMEOUT);
873 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
874 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX, 1);
875 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
877 rt2500usb_register_write(rt2x00dev, MAC_CSR13, 0x1111);
878 rt2500usb_register_write(rt2x00dev, MAC_CSR14, 0x1e11);
880 rt2500usb_register_read(rt2x00dev, MAC_CSR1, &reg);
881 rt2x00_set_field16(&reg, MAC_CSR1_SOFT_RESET, 1);
882 rt2x00_set_field16(&reg, MAC_CSR1_BBP_RESET, 1);
883 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 0);
884 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg);
886 rt2500usb_register_read(rt2x00dev, MAC_CSR1, &reg);
887 rt2x00_set_field16(&reg, MAC_CSR1_SOFT_RESET, 0);
888 rt2x00_set_field16(&reg, MAC_CSR1_BBP_RESET, 0);
889 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 0);
890 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg);
892 rt2500usb_register_read(rt2x00dev, TXRX_CSR5, &reg);
893 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID0, 13);
894 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID0_VALID, 1);
895 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID1, 12);
896 rt2x00_set_field16(&reg, TXRX_CSR5_BBP_ID1_VALID, 1);
897 rt2500usb_register_write(rt2x00dev, TXRX_CSR5, reg);
899 rt2500usb_register_read(rt2x00dev, TXRX_CSR6, &reg);
900 rt2x00_set_field16(&reg, TXRX_CSR6_BBP_ID0, 10);
901 rt2x00_set_field16(&reg, TXRX_CSR6_BBP_ID0_VALID, 1);
902 rt2x00_set_field16(&reg, TXRX_CSR6_BBP_ID1, 11);
903 rt2x00_set_field16(&reg, TXRX_CSR6_BBP_ID1_VALID, 1);
904 rt2500usb_register_write(rt2x00dev, TXRX_CSR6, reg);
906 rt2500usb_register_read(rt2x00dev, TXRX_CSR7, &reg);
907 rt2x00_set_field16(&reg, TXRX_CSR7_BBP_ID0, 7);
908 rt2x00_set_field16(&reg, TXRX_CSR7_BBP_ID0_VALID, 1);
909 rt2x00_set_field16(&reg, TXRX_CSR7_BBP_ID1, 6);
910 rt2x00_set_field16(&reg, TXRX_CSR7_BBP_ID1_VALID, 1);
911 rt2500usb_register_write(rt2x00dev, TXRX_CSR7, reg);
913 rt2500usb_register_read(rt2x00dev, TXRX_CSR8, &reg);
914 rt2x00_set_field16(&reg, TXRX_CSR8_BBP_ID0, 5);
915 rt2x00_set_field16(&reg, TXRX_CSR8_BBP_ID0_VALID, 1);
916 rt2x00_set_field16(&reg, TXRX_CSR8_BBP_ID1, 0);
917 rt2x00_set_field16(&reg, TXRX_CSR8_BBP_ID1_VALID, 0);
918 rt2500usb_register_write(rt2x00dev, TXRX_CSR8, reg);
920 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
921 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 0);
922 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 0);
923 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 0);
924 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
925 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
927 rt2500usb_register_write(rt2x00dev, TXRX_CSR21, 0xe78f);
928 rt2500usb_register_write(rt2x00dev, MAC_CSR9, 0xff1d);
930 if (rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE))
931 return -EBUSY;
933 rt2500usb_register_read(rt2x00dev, MAC_CSR1, &reg);
934 rt2x00_set_field16(&reg, MAC_CSR1_SOFT_RESET, 0);
935 rt2x00_set_field16(&reg, MAC_CSR1_BBP_RESET, 0);
936 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 1);
937 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg);
939 if (rt2x00_rev(&rt2x00dev->chip) >= RT2570_VERSION_C) {
940 rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg);
941 rt2x00_set_field16(&reg, PHY_CSR2_LNA, 0);
942 } else {
943 reg = 0;
944 rt2x00_set_field16(&reg, PHY_CSR2_LNA, 1);
945 rt2x00_set_field16(&reg, PHY_CSR2_LNA_MODE, 3);
947 rt2500usb_register_write(rt2x00dev, PHY_CSR2, reg);
949 rt2500usb_register_write(rt2x00dev, MAC_CSR11, 0x0002);
950 rt2500usb_register_write(rt2x00dev, MAC_CSR22, 0x0053);
951 rt2500usb_register_write(rt2x00dev, MAC_CSR15, 0x01ee);
952 rt2500usb_register_write(rt2x00dev, MAC_CSR16, 0x0000);
954 rt2500usb_register_read(rt2x00dev, MAC_CSR8, &reg);
955 rt2x00_set_field16(&reg, MAC_CSR8_MAX_FRAME_UNIT,
956 rt2x00dev->rx->data_size);
957 rt2500usb_register_write(rt2x00dev, MAC_CSR8, reg);
959 rt2500usb_register_read(rt2x00dev, TXRX_CSR0, &reg);
960 rt2x00_set_field16(&reg, TXRX_CSR0_IV_OFFSET, IEEE80211_HEADER);
961 rt2x00_set_field16(&reg, TXRX_CSR0_KEY_ID, 0);
962 rt2500usb_register_write(rt2x00dev, TXRX_CSR0, reg);
964 rt2500usb_register_read(rt2x00dev, MAC_CSR18, &reg);
965 rt2x00_set_field16(&reg, MAC_CSR18_DELAY_AFTER_BEACON, 90);
966 rt2500usb_register_write(rt2x00dev, MAC_CSR18, reg);
968 rt2500usb_register_read(rt2x00dev, PHY_CSR4, &reg);
969 rt2x00_set_field16(&reg, PHY_CSR4_LOW_RF_LE, 1);
970 rt2500usb_register_write(rt2x00dev, PHY_CSR4, reg);
972 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg);
973 rt2x00_set_field16(&reg, TXRX_CSR1_AUTO_SEQUENCE, 1);
974 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg);
976 return 0;
979 static int rt2500usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
981 unsigned int i;
982 u8 value;
984 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
985 rt2500usb_bbp_read(rt2x00dev, 0, &value);
986 if ((value != 0xff) && (value != 0x00))
987 return 0;
988 udelay(REGISTER_BUSY_DELAY);
991 ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
992 return -EACCES;
995 static int rt2500usb_init_bbp(struct rt2x00_dev *rt2x00dev)
997 unsigned int i;
998 u16 eeprom;
999 u8 value;
1000 u8 reg_id;
1002 if (unlikely(rt2500usb_wait_bbp_ready(rt2x00dev)))
1003 return -EACCES;
1005 rt2500usb_bbp_write(rt2x00dev, 3, 0x02);
1006 rt2500usb_bbp_write(rt2x00dev, 4, 0x19);
1007 rt2500usb_bbp_write(rt2x00dev, 14, 0x1c);
1008 rt2500usb_bbp_write(rt2x00dev, 15, 0x30);
1009 rt2500usb_bbp_write(rt2x00dev, 16, 0xac);
1010 rt2500usb_bbp_write(rt2x00dev, 18, 0x18);
1011 rt2500usb_bbp_write(rt2x00dev, 19, 0xff);
1012 rt2500usb_bbp_write(rt2x00dev, 20, 0x1e);
1013 rt2500usb_bbp_write(rt2x00dev, 21, 0x08);
1014 rt2500usb_bbp_write(rt2x00dev, 22, 0x08);
1015 rt2500usb_bbp_write(rt2x00dev, 23, 0x08);
1016 rt2500usb_bbp_write(rt2x00dev, 24, 0x80);
1017 rt2500usb_bbp_write(rt2x00dev, 25, 0x50);
1018 rt2500usb_bbp_write(rt2x00dev, 26, 0x08);
1019 rt2500usb_bbp_write(rt2x00dev, 27, 0x23);
1020 rt2500usb_bbp_write(rt2x00dev, 30, 0x10);
1021 rt2500usb_bbp_write(rt2x00dev, 31, 0x2b);
1022 rt2500usb_bbp_write(rt2x00dev, 32, 0xb9);
1023 rt2500usb_bbp_write(rt2x00dev, 34, 0x12);
1024 rt2500usb_bbp_write(rt2x00dev, 35, 0x50);
1025 rt2500usb_bbp_write(rt2x00dev, 39, 0xc4);
1026 rt2500usb_bbp_write(rt2x00dev, 40, 0x02);
1027 rt2500usb_bbp_write(rt2x00dev, 41, 0x60);
1028 rt2500usb_bbp_write(rt2x00dev, 53, 0x10);
1029 rt2500usb_bbp_write(rt2x00dev, 54, 0x18);
1030 rt2500usb_bbp_write(rt2x00dev, 56, 0x08);
1031 rt2500usb_bbp_write(rt2x00dev, 57, 0x10);
1032 rt2500usb_bbp_write(rt2x00dev, 58, 0x08);
1033 rt2500usb_bbp_write(rt2x00dev, 61, 0x60);
1034 rt2500usb_bbp_write(rt2x00dev, 62, 0x10);
1035 rt2500usb_bbp_write(rt2x00dev, 75, 0xff);
1037 for (i = 0; i < EEPROM_BBP_SIZE; i++) {
1038 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
1040 if (eeprom != 0xffff && eeprom != 0x0000) {
1041 reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
1042 value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
1043 rt2500usb_bbp_write(rt2x00dev, reg_id, value);
1047 return 0;
1051 * Device state switch handlers.
1053 static void rt2500usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
1054 enum dev_state state)
1056 u16 reg;
1058 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
1059 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX,
1060 (state == STATE_RADIO_RX_OFF) ||
1061 (state == STATE_RADIO_RX_OFF_LINK));
1062 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
1065 static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1068 * Initialize all registers.
1070 if (unlikely(rt2500usb_init_registers(rt2x00dev) ||
1071 rt2500usb_init_bbp(rt2x00dev)))
1072 return -EIO;
1074 return 0;
1077 static void rt2500usb_disable_radio(struct rt2x00_dev *rt2x00dev)
1079 rt2500usb_register_write(rt2x00dev, MAC_CSR13, 0x2121);
1080 rt2500usb_register_write(rt2x00dev, MAC_CSR14, 0x2121);
1083 * Disable synchronisation.
1085 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, 0);
1087 rt2x00usb_disable_radio(rt2x00dev);
1090 static int rt2500usb_set_state(struct rt2x00_dev *rt2x00dev,
1091 enum dev_state state)
1093 u16 reg;
1094 u16 reg2;
1095 unsigned int i;
1096 char put_to_sleep;
1097 char bbp_state;
1098 char rf_state;
1100 put_to_sleep = (state != STATE_AWAKE);
1102 reg = 0;
1103 rt2x00_set_field16(&reg, MAC_CSR17_BBP_DESIRE_STATE, state);
1104 rt2x00_set_field16(&reg, MAC_CSR17_RF_DESIRE_STATE, state);
1105 rt2x00_set_field16(&reg, MAC_CSR17_PUT_TO_SLEEP, put_to_sleep);
1106 rt2500usb_register_write(rt2x00dev, MAC_CSR17, reg);
1107 rt2x00_set_field16(&reg, MAC_CSR17_SET_STATE, 1);
1108 rt2500usb_register_write(rt2x00dev, MAC_CSR17, reg);
1111 * Device is not guaranteed to be in the requested state yet.
1112 * We must wait until the register indicates that the
1113 * device has entered the correct state.
1115 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1116 rt2500usb_register_read(rt2x00dev, MAC_CSR17, &reg2);
1117 bbp_state = rt2x00_get_field16(reg2, MAC_CSR17_BBP_CURR_STATE);
1118 rf_state = rt2x00_get_field16(reg2, MAC_CSR17_RF_CURR_STATE);
1119 if (bbp_state == state && rf_state == state)
1120 return 0;
1121 rt2500usb_register_write(rt2x00dev, MAC_CSR17, reg);
1122 msleep(30);
1125 return -EBUSY;
1128 static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1129 enum dev_state state)
1131 int retval = 0;
1133 switch (state) {
1134 case STATE_RADIO_ON:
1135 retval = rt2500usb_enable_radio(rt2x00dev);
1136 break;
1137 case STATE_RADIO_OFF:
1138 rt2500usb_disable_radio(rt2x00dev);
1139 break;
1140 case STATE_RADIO_RX_ON:
1141 case STATE_RADIO_RX_ON_LINK:
1142 case STATE_RADIO_RX_OFF:
1143 case STATE_RADIO_RX_OFF_LINK:
1144 rt2500usb_toggle_rx(rt2x00dev, state);
1145 break;
1146 case STATE_RADIO_IRQ_ON:
1147 case STATE_RADIO_IRQ_OFF:
1148 /* No support, but no error either */
1149 break;
1150 case STATE_DEEP_SLEEP:
1151 case STATE_SLEEP:
1152 case STATE_STANDBY:
1153 case STATE_AWAKE:
1154 retval = rt2500usb_set_state(rt2x00dev, state);
1155 break;
1156 default:
1157 retval = -ENOTSUPP;
1158 break;
1161 if (unlikely(retval))
1162 ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
1163 state, retval);
1165 return retval;
1169 * TX descriptor initialization
1171 static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1172 struct sk_buff *skb,
1173 struct txentry_desc *txdesc)
1175 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1176 __le32 *txd = skbdesc->desc;
1177 u32 word;
1180 * Start writing the descriptor words.
1182 rt2x00_desc_read(txd, 1, &word);
1183 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
1184 rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs);
1185 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min);
1186 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max);
1187 rt2x00_desc_write(txd, 1, word);
1189 rt2x00_desc_read(txd, 2, &word);
1190 rt2x00_set_field32(&word, TXD_W2_PLCP_SIGNAL, txdesc->signal);
1191 rt2x00_set_field32(&word, TXD_W2_PLCP_SERVICE, txdesc->service);
1192 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_LOW, txdesc->length_low);
1193 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_HIGH, txdesc->length_high);
1194 rt2x00_desc_write(txd, 2, word);
1196 if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags)) {
1197 _rt2x00_desc_write(txd, 3, skbdesc->iv[0]);
1198 _rt2x00_desc_write(txd, 4, skbdesc->iv[1]);
1201 rt2x00_desc_read(txd, 0, &word);
1202 rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit);
1203 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
1204 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1205 rt2x00_set_field32(&word, TXD_W0_ACK,
1206 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1207 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1208 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1209 rt2x00_set_field32(&word, TXD_W0_OFDM,
1210 (txdesc->rate_mode == RATE_MODE_OFDM));
1211 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
1212 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1213 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1214 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len);
1215 rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
1216 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
1217 rt2x00_desc_write(txd, 0, word);
1221 * TX data initialization
1223 static void rt2500usb_beacondone(struct urb *urb);
1225 static void rt2500usb_write_beacon(struct queue_entry *entry)
1227 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1228 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
1229 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
1230 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1231 int pipe = usb_sndbulkpipe(usb_dev, entry->queue->usb_endpoint);
1232 int length;
1233 u16 reg;
1236 * Add the descriptor in front of the skb.
1238 skb_push(entry->skb, entry->queue->desc_size);
1239 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1240 skbdesc->desc = entry->skb->data;
1243 * Disable beaconing while we are reloading the beacon data,
1244 * otherwise we might be sending out invalid data.
1246 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
1247 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
1248 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1251 * USB devices cannot blindly pass the skb->len as the
1252 * length of the data to usb_fill_bulk_urb. Pass the skb
1253 * to the driver to determine what the length should be.
1255 length = rt2x00dev->ops->lib->get_tx_data_len(entry);
1257 usb_fill_bulk_urb(bcn_priv->urb, usb_dev, pipe,
1258 entry->skb->data, length, rt2500usb_beacondone,
1259 entry);
1262 * Second we need to create the guardian byte.
1263 * We only need a single byte, so lets recycle
1264 * the 'flags' field we are not using for beacons.
1266 bcn_priv->guardian_data = 0;
1267 usb_fill_bulk_urb(bcn_priv->guardian_urb, usb_dev, pipe,
1268 &bcn_priv->guardian_data, 1, rt2500usb_beacondone,
1269 entry);
1272 * Send out the guardian byte.
1274 usb_submit_urb(bcn_priv->guardian_urb, GFP_ATOMIC);
1277 static int rt2500usb_get_tx_data_len(struct queue_entry *entry)
1279 int length;
1282 * The length _must_ be a multiple of 2,
1283 * but it must _not_ be a multiple of the USB packet size.
1285 length = roundup(entry->skb->len, 2);
1286 length += (2 * !(length % entry->queue->usb_maxpacket));
1288 return length;
1291 static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1292 const enum data_queue_qid queue)
1294 u16 reg, reg0;
1296 if (queue != QID_BEACON) {
1297 rt2x00usb_kick_tx_queue(rt2x00dev, queue);
1298 return;
1301 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
1302 if (!rt2x00_get_field16(reg, TXRX_CSR19_BEACON_GEN)) {
1303 rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
1304 rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
1305 reg0 = reg;
1306 rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 1);
1308 * Beacon generation will fail initially.
1309 * To prevent this we need to change the TXRX_CSR19
1310 * register several times (reg0 is the same as reg
1311 * except for TXRX_CSR19_BEACON_GEN, which is 0 in reg0
1312 * and 1 in reg).
1314 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1315 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg0);
1316 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1317 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg0);
1318 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
1323 * RX control handlers
1325 static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1326 struct rxdone_entry_desc *rxdesc)
1328 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1329 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
1330 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1331 __le32 *rxd =
1332 (__le32 *)(entry->skb->data +
1333 (entry_priv->urb->actual_length -
1334 entry->queue->desc_size));
1335 u32 word0;
1336 u32 word1;
1339 * Copy descriptor to the skbdesc->desc buffer, making it safe from moving of
1340 * frame data in rt2x00usb.
1342 memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
1343 rxd = (__le32 *)skbdesc->desc;
1346 * It is now safe to read the descriptor on all architectures.
1348 rt2x00_desc_read(rxd, 0, &word0);
1349 rt2x00_desc_read(rxd, 1, &word1);
1351 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1352 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
1353 if (rt2x00_get_field32(word0, RXD_W0_PHYSICAL_ERROR))
1354 rxdesc->flags |= RX_FLAG_FAILED_PLCP_CRC;
1356 if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
1357 rxdesc->cipher = rt2x00_get_field32(word0, RXD_W0_CIPHER);
1358 if (rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR))
1359 rxdesc->cipher_status = RX_CRYPTO_FAIL_KEY;
1362 if (rxdesc->cipher != CIPHER_NONE) {
1363 _rt2x00_desc_read(rxd, 2, &rxdesc->iv[0]);
1364 _rt2x00_desc_read(rxd, 3, &rxdesc->iv[1]);
1365 rxdesc->dev_flags |= RXDONE_CRYPTO_IV;
1367 /* ICV is located at the end of frame */
1369 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
1370 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
1371 rxdesc->flags |= RX_FLAG_DECRYPTED;
1372 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
1373 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
1377 * Obtain the status about this packet.
1378 * When frame was received with an OFDM bitrate,
1379 * the signal is the PLCP value. If it was received with
1380 * a CCK bitrate the signal is the rate in 100kbit/s.
1382 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1383 rxdesc->rssi =
1384 rt2x00_get_field32(word1, RXD_W1_RSSI) - rt2x00dev->rssi_offset;
1385 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1387 if (rt2x00_get_field32(word0, RXD_W0_OFDM))
1388 rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
1389 else
1390 rxdesc->dev_flags |= RXDONE_SIGNAL_BITRATE;
1391 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1392 rxdesc->dev_flags |= RXDONE_MY_BSS;
1395 * Adjust the skb memory window to the frame boundaries.
1397 skb_trim(entry->skb, rxdesc->size);
1401 * Interrupt functions.
1403 static void rt2500usb_beacondone(struct urb *urb)
1405 struct queue_entry *entry = (struct queue_entry *)urb->context;
1406 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
1408 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags))
1409 return;
1412 * Check if this was the guardian beacon,
1413 * if that was the case we need to send the real beacon now.
1414 * Otherwise we should free the sk_buffer, the device
1415 * should be doing the rest of the work now.
1417 if (bcn_priv->guardian_urb == urb) {
1418 usb_submit_urb(bcn_priv->urb, GFP_ATOMIC);
1419 } else if (bcn_priv->urb == urb) {
1420 dev_kfree_skb(entry->skb);
1421 entry->skb = NULL;
1426 * Device probe functions.
1428 static int rt2500usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1430 u16 word;
1431 u8 *mac;
1432 u8 bbp;
1434 rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
1437 * Start validation of the data that has been read.
1439 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1440 if (!is_valid_ether_addr(mac)) {
1441 random_ether_addr(mac);
1442 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
1445 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
1446 if (word == 0xffff) {
1447 rt2x00_set_field16(&word, EEPROM_ANTENNA_NUM, 2);
1448 rt2x00_set_field16(&word, EEPROM_ANTENNA_TX_DEFAULT,
1449 ANTENNA_SW_DIVERSITY);
1450 rt2x00_set_field16(&word, EEPROM_ANTENNA_RX_DEFAULT,
1451 ANTENNA_SW_DIVERSITY);
1452 rt2x00_set_field16(&word, EEPROM_ANTENNA_LED_MODE,
1453 LED_MODE_DEFAULT);
1454 rt2x00_set_field16(&word, EEPROM_ANTENNA_DYN_TXAGC, 0);
1455 rt2x00_set_field16(&word, EEPROM_ANTENNA_HARDWARE_RADIO, 0);
1456 rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2522);
1457 rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
1458 EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
1461 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
1462 if (word == 0xffff) {
1463 rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
1464 rt2x00_set_field16(&word, EEPROM_NIC_DYN_BBP_TUNE, 0);
1465 rt2x00_set_field16(&word, EEPROM_NIC_CCK_TX_POWER, 0);
1466 rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
1467 EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
1470 rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &word);
1471 if (word == 0xffff) {
1472 rt2x00_set_field16(&word, EEPROM_CALIBRATE_OFFSET_RSSI,
1473 DEFAULT_RSSI_OFFSET);
1474 rt2x00_eeprom_write(rt2x00dev, EEPROM_CALIBRATE_OFFSET, word);
1475 EEPROM(rt2x00dev, "Calibrate offset: 0x%04x\n", word);
1478 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE, &word);
1479 if (word == 0xffff) {
1480 rt2x00_set_field16(&word, EEPROM_BBPTUNE_THRESHOLD, 45);
1481 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE, word);
1482 EEPROM(rt2x00dev, "BBPtune: 0x%04x\n", word);
1486 * Switch lower vgc bound to current BBP R17 value,
1487 * lower the value a bit for better quality.
1489 rt2500usb_bbp_read(rt2x00dev, 17, &bbp);
1490 bbp -= 6;
1492 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_VGC, &word);
1493 if (word == 0xffff) {
1494 rt2x00_set_field16(&word, EEPROM_BBPTUNE_VGCUPPER, 0x40);
1495 rt2x00_set_field16(&word, EEPROM_BBPTUNE_VGCLOWER, bbp);
1496 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE_VGC, word);
1497 EEPROM(rt2x00dev, "BBPtune vgc: 0x%04x\n", word);
1498 } else {
1499 rt2x00_set_field16(&word, EEPROM_BBPTUNE_VGCLOWER, bbp);
1500 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE_VGC, word);
1503 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R17, &word);
1504 if (word == 0xffff) {
1505 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R17_LOW, 0x48);
1506 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R17_HIGH, 0x41);
1507 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE_R17, word);
1508 EEPROM(rt2x00dev, "BBPtune r17: 0x%04x\n", word);
1511 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R24, &word);
1512 if (word == 0xffff) {
1513 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R24_LOW, 0x40);
1514 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R24_HIGH, 0x80);
1515 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE_R24, word);
1516 EEPROM(rt2x00dev, "BBPtune r24: 0x%04x\n", word);
1519 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R25, &word);
1520 if (word == 0xffff) {
1521 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R25_LOW, 0x40);
1522 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R25_HIGH, 0x50);
1523 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE_R25, word);
1524 EEPROM(rt2x00dev, "BBPtune r25: 0x%04x\n", word);
1527 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R61, &word);
1528 if (word == 0xffff) {
1529 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R61_LOW, 0x60);
1530 rt2x00_set_field16(&word, EEPROM_BBPTUNE_R61_HIGH, 0x6d);
1531 rt2x00_eeprom_write(rt2x00dev, EEPROM_BBPTUNE_R61, word);
1532 EEPROM(rt2x00dev, "BBPtune r61: 0x%04x\n", word);
1535 return 0;
1538 static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1540 u16 reg;
1541 u16 value;
1542 u16 eeprom;
1545 * Read EEPROM word for configuration.
1547 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
1550 * Identify RF chipset.
1552 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
1553 rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
1554 rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
1556 if (!rt2x00_check_rev(&rt2x00dev->chip, 0x000ffff0, 0) ||
1557 rt2x00_check_rev(&rt2x00dev->chip, 0x0000000f, 0)) {
1559 ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
1560 return -ENODEV;
1563 if (!rt2x00_rf(&rt2x00dev->chip, RF2522) &&
1564 !rt2x00_rf(&rt2x00dev->chip, RF2523) &&
1565 !rt2x00_rf(&rt2x00dev->chip, RF2524) &&
1566 !rt2x00_rf(&rt2x00dev->chip, RF2525) &&
1567 !rt2x00_rf(&rt2x00dev->chip, RF2525E) &&
1568 !rt2x00_rf(&rt2x00dev->chip, RF5222)) {
1569 ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
1570 return -ENODEV;
1574 * Identify default antenna configuration.
1576 rt2x00dev->default_ant.tx =
1577 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
1578 rt2x00dev->default_ant.rx =
1579 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
1582 * When the eeprom indicates SW_DIVERSITY use HW_DIVERSITY instead.
1583 * I am not 100% sure about this, but the legacy drivers do not
1584 * indicate antenna swapping in software is required when
1585 * diversity is enabled.
1587 if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
1588 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY;
1589 if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
1590 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY;
1593 * Store led mode, for correct led behaviour.
1595 #ifdef CONFIG_RT2X00_LIB_LEDS
1596 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1598 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1599 if (value == LED_MODE_TXRX_ACTIVITY ||
1600 value == LED_MODE_DEFAULT ||
1601 value == LED_MODE_ASUS)
1602 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1603 LED_TYPE_ACTIVITY);
1604 #endif /* CONFIG_RT2X00_LIB_LEDS */
1607 * Detect if this device has an hardware controlled radio.
1609 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
1610 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
1613 * Check if the BBP tuning should be disabled.
1615 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
1616 if (rt2x00_get_field16(eeprom, EEPROM_NIC_DYN_BBP_TUNE))
1617 __set_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags);
1620 * Read the RSSI <-> dBm offset information.
1622 rt2x00_eeprom_read(rt2x00dev, EEPROM_CALIBRATE_OFFSET, &eeprom);
1623 rt2x00dev->rssi_offset =
1624 rt2x00_get_field16(eeprom, EEPROM_CALIBRATE_OFFSET_RSSI);
1626 return 0;
1630 * RF value list for RF2522
1631 * Supports: 2.4 GHz
1633 static const struct rf_channel rf_vals_bg_2522[] = {
1634 { 1, 0x00002050, 0x000c1fda, 0x00000101, 0 },
1635 { 2, 0x00002050, 0x000c1fee, 0x00000101, 0 },
1636 { 3, 0x00002050, 0x000c2002, 0x00000101, 0 },
1637 { 4, 0x00002050, 0x000c2016, 0x00000101, 0 },
1638 { 5, 0x00002050, 0x000c202a, 0x00000101, 0 },
1639 { 6, 0x00002050, 0x000c203e, 0x00000101, 0 },
1640 { 7, 0x00002050, 0x000c2052, 0x00000101, 0 },
1641 { 8, 0x00002050, 0x000c2066, 0x00000101, 0 },
1642 { 9, 0x00002050, 0x000c207a, 0x00000101, 0 },
1643 { 10, 0x00002050, 0x000c208e, 0x00000101, 0 },
1644 { 11, 0x00002050, 0x000c20a2, 0x00000101, 0 },
1645 { 12, 0x00002050, 0x000c20b6, 0x00000101, 0 },
1646 { 13, 0x00002050, 0x000c20ca, 0x00000101, 0 },
1647 { 14, 0x00002050, 0x000c20fa, 0x00000101, 0 },
1651 * RF value list for RF2523
1652 * Supports: 2.4 GHz
1654 static const struct rf_channel rf_vals_bg_2523[] = {
1655 { 1, 0x00022010, 0x00000c9e, 0x000e0111, 0x00000a1b },
1656 { 2, 0x00022010, 0x00000ca2, 0x000e0111, 0x00000a1b },
1657 { 3, 0x00022010, 0x00000ca6, 0x000e0111, 0x00000a1b },
1658 { 4, 0x00022010, 0x00000caa, 0x000e0111, 0x00000a1b },
1659 { 5, 0x00022010, 0x00000cae, 0x000e0111, 0x00000a1b },
1660 { 6, 0x00022010, 0x00000cb2, 0x000e0111, 0x00000a1b },
1661 { 7, 0x00022010, 0x00000cb6, 0x000e0111, 0x00000a1b },
1662 { 8, 0x00022010, 0x00000cba, 0x000e0111, 0x00000a1b },
1663 { 9, 0x00022010, 0x00000cbe, 0x000e0111, 0x00000a1b },
1664 { 10, 0x00022010, 0x00000d02, 0x000e0111, 0x00000a1b },
1665 { 11, 0x00022010, 0x00000d06, 0x000e0111, 0x00000a1b },
1666 { 12, 0x00022010, 0x00000d0a, 0x000e0111, 0x00000a1b },
1667 { 13, 0x00022010, 0x00000d0e, 0x000e0111, 0x00000a1b },
1668 { 14, 0x00022010, 0x00000d1a, 0x000e0111, 0x00000a03 },
1672 * RF value list for RF2524
1673 * Supports: 2.4 GHz
1675 static const struct rf_channel rf_vals_bg_2524[] = {
1676 { 1, 0x00032020, 0x00000c9e, 0x00000101, 0x00000a1b },
1677 { 2, 0x00032020, 0x00000ca2, 0x00000101, 0x00000a1b },
1678 { 3, 0x00032020, 0x00000ca6, 0x00000101, 0x00000a1b },
1679 { 4, 0x00032020, 0x00000caa, 0x00000101, 0x00000a1b },
1680 { 5, 0x00032020, 0x00000cae, 0x00000101, 0x00000a1b },
1681 { 6, 0x00032020, 0x00000cb2, 0x00000101, 0x00000a1b },
1682 { 7, 0x00032020, 0x00000cb6, 0x00000101, 0x00000a1b },
1683 { 8, 0x00032020, 0x00000cba, 0x00000101, 0x00000a1b },
1684 { 9, 0x00032020, 0x00000cbe, 0x00000101, 0x00000a1b },
1685 { 10, 0x00032020, 0x00000d02, 0x00000101, 0x00000a1b },
1686 { 11, 0x00032020, 0x00000d06, 0x00000101, 0x00000a1b },
1687 { 12, 0x00032020, 0x00000d0a, 0x00000101, 0x00000a1b },
1688 { 13, 0x00032020, 0x00000d0e, 0x00000101, 0x00000a1b },
1689 { 14, 0x00032020, 0x00000d1a, 0x00000101, 0x00000a03 },
1693 * RF value list for RF2525
1694 * Supports: 2.4 GHz
1696 static const struct rf_channel rf_vals_bg_2525[] = {
1697 { 1, 0x00022020, 0x00080c9e, 0x00060111, 0x00000a1b },
1698 { 2, 0x00022020, 0x00080ca2, 0x00060111, 0x00000a1b },
1699 { 3, 0x00022020, 0x00080ca6, 0x00060111, 0x00000a1b },
1700 { 4, 0x00022020, 0x00080caa, 0x00060111, 0x00000a1b },
1701 { 5, 0x00022020, 0x00080cae, 0x00060111, 0x00000a1b },
1702 { 6, 0x00022020, 0x00080cb2, 0x00060111, 0x00000a1b },
1703 { 7, 0x00022020, 0x00080cb6, 0x00060111, 0x00000a1b },
1704 { 8, 0x00022020, 0x00080cba, 0x00060111, 0x00000a1b },
1705 { 9, 0x00022020, 0x00080cbe, 0x00060111, 0x00000a1b },
1706 { 10, 0x00022020, 0x00080d02, 0x00060111, 0x00000a1b },
1707 { 11, 0x00022020, 0x00080d06, 0x00060111, 0x00000a1b },
1708 { 12, 0x00022020, 0x00080d0a, 0x00060111, 0x00000a1b },
1709 { 13, 0x00022020, 0x00080d0e, 0x00060111, 0x00000a1b },
1710 { 14, 0x00022020, 0x00080d1a, 0x00060111, 0x00000a03 },
1714 * RF value list for RF2525e
1715 * Supports: 2.4 GHz
1717 static const struct rf_channel rf_vals_bg_2525e[] = {
1718 { 1, 0x00022010, 0x0000089a, 0x00060111, 0x00000e1b },
1719 { 2, 0x00022010, 0x0000089e, 0x00060111, 0x00000e07 },
1720 { 3, 0x00022010, 0x0000089e, 0x00060111, 0x00000e1b },
1721 { 4, 0x00022010, 0x000008a2, 0x00060111, 0x00000e07 },
1722 { 5, 0x00022010, 0x000008a2, 0x00060111, 0x00000e1b },
1723 { 6, 0x00022010, 0x000008a6, 0x00060111, 0x00000e07 },
1724 { 7, 0x00022010, 0x000008a6, 0x00060111, 0x00000e1b },
1725 { 8, 0x00022010, 0x000008aa, 0x00060111, 0x00000e07 },
1726 { 9, 0x00022010, 0x000008aa, 0x00060111, 0x00000e1b },
1727 { 10, 0x00022010, 0x000008ae, 0x00060111, 0x00000e07 },
1728 { 11, 0x00022010, 0x000008ae, 0x00060111, 0x00000e1b },
1729 { 12, 0x00022010, 0x000008b2, 0x00060111, 0x00000e07 },
1730 { 13, 0x00022010, 0x000008b2, 0x00060111, 0x00000e1b },
1731 { 14, 0x00022010, 0x000008b6, 0x00060111, 0x00000e23 },
1735 * RF value list for RF5222
1736 * Supports: 2.4 GHz & 5.2 GHz
1738 static const struct rf_channel rf_vals_5222[] = {
1739 { 1, 0x00022020, 0x00001136, 0x00000101, 0x00000a0b },
1740 { 2, 0x00022020, 0x0000113a, 0x00000101, 0x00000a0b },
1741 { 3, 0x00022020, 0x0000113e, 0x00000101, 0x00000a0b },
1742 { 4, 0x00022020, 0x00001182, 0x00000101, 0x00000a0b },
1743 { 5, 0x00022020, 0x00001186, 0x00000101, 0x00000a0b },
1744 { 6, 0x00022020, 0x0000118a, 0x00000101, 0x00000a0b },
1745 { 7, 0x00022020, 0x0000118e, 0x00000101, 0x00000a0b },
1746 { 8, 0x00022020, 0x00001192, 0x00000101, 0x00000a0b },
1747 { 9, 0x00022020, 0x00001196, 0x00000101, 0x00000a0b },
1748 { 10, 0x00022020, 0x0000119a, 0x00000101, 0x00000a0b },
1749 { 11, 0x00022020, 0x0000119e, 0x00000101, 0x00000a0b },
1750 { 12, 0x00022020, 0x000011a2, 0x00000101, 0x00000a0b },
1751 { 13, 0x00022020, 0x000011a6, 0x00000101, 0x00000a0b },
1752 { 14, 0x00022020, 0x000011ae, 0x00000101, 0x00000a1b },
1754 /* 802.11 UNI / HyperLan 2 */
1755 { 36, 0x00022010, 0x00018896, 0x00000101, 0x00000a1f },
1756 { 40, 0x00022010, 0x0001889a, 0x00000101, 0x00000a1f },
1757 { 44, 0x00022010, 0x0001889e, 0x00000101, 0x00000a1f },
1758 { 48, 0x00022010, 0x000188a2, 0x00000101, 0x00000a1f },
1759 { 52, 0x00022010, 0x000188a6, 0x00000101, 0x00000a1f },
1760 { 66, 0x00022010, 0x000188aa, 0x00000101, 0x00000a1f },
1761 { 60, 0x00022010, 0x000188ae, 0x00000101, 0x00000a1f },
1762 { 64, 0x00022010, 0x000188b2, 0x00000101, 0x00000a1f },
1764 /* 802.11 HyperLan 2 */
1765 { 100, 0x00022010, 0x00008802, 0x00000101, 0x00000a0f },
1766 { 104, 0x00022010, 0x00008806, 0x00000101, 0x00000a0f },
1767 { 108, 0x00022010, 0x0000880a, 0x00000101, 0x00000a0f },
1768 { 112, 0x00022010, 0x0000880e, 0x00000101, 0x00000a0f },
1769 { 116, 0x00022010, 0x00008812, 0x00000101, 0x00000a0f },
1770 { 120, 0x00022010, 0x00008816, 0x00000101, 0x00000a0f },
1771 { 124, 0x00022010, 0x0000881a, 0x00000101, 0x00000a0f },
1772 { 128, 0x00022010, 0x0000881e, 0x00000101, 0x00000a0f },
1773 { 132, 0x00022010, 0x00008822, 0x00000101, 0x00000a0f },
1774 { 136, 0x00022010, 0x00008826, 0x00000101, 0x00000a0f },
1776 /* 802.11 UNII */
1777 { 140, 0x00022010, 0x0000882a, 0x00000101, 0x00000a0f },
1778 { 149, 0x00022020, 0x000090a6, 0x00000101, 0x00000a07 },
1779 { 153, 0x00022020, 0x000090ae, 0x00000101, 0x00000a07 },
1780 { 157, 0x00022020, 0x000090b6, 0x00000101, 0x00000a07 },
1781 { 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
1784 static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1786 struct hw_mode_spec *spec = &rt2x00dev->spec;
1787 struct channel_info *info;
1788 char *tx_power;
1789 unsigned int i;
1792 * Initialize all hw fields.
1794 rt2x00dev->hw->flags =
1795 IEEE80211_HW_RX_INCLUDES_FCS |
1796 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1797 IEEE80211_HW_SIGNAL_DBM |
1798 IEEE80211_HW_SUPPORTS_PS |
1799 IEEE80211_HW_PS_NULLFUNC_STACK;
1801 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
1802 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
1803 rt2x00_eeprom_addr(rt2x00dev,
1804 EEPROM_MAC_ADDR_0));
1807 * Initialize hw_mode information.
1809 spec->supported_bands = SUPPORT_BAND_2GHZ;
1810 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
1812 if (rt2x00_rf(&rt2x00dev->chip, RF2522)) {
1813 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);
1814 spec->channels = rf_vals_bg_2522;
1815 } else if (rt2x00_rf(&rt2x00dev->chip, RF2523)) {
1816 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2523);
1817 spec->channels = rf_vals_bg_2523;
1818 } else if (rt2x00_rf(&rt2x00dev->chip, RF2524)) {
1819 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2524);
1820 spec->channels = rf_vals_bg_2524;
1821 } else if (rt2x00_rf(&rt2x00dev->chip, RF2525)) {
1822 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525);
1823 spec->channels = rf_vals_bg_2525;
1824 } else if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {
1825 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525e);
1826 spec->channels = rf_vals_bg_2525e;
1827 } else if (rt2x00_rf(&rt2x00dev->chip, RF5222)) {
1828 spec->supported_bands |= SUPPORT_BAND_5GHZ;
1829 spec->num_channels = ARRAY_SIZE(rf_vals_5222);
1830 spec->channels = rf_vals_5222;
1834 * Create channel information array
1836 info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
1837 if (!info)
1838 return -ENOMEM;
1840 spec->channels_info = info;
1842 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_START);
1843 for (i = 0; i < 14; i++)
1844 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);
1846 if (spec->num_channels > 14) {
1847 for (i = 14; i < spec->num_channels; i++)
1848 info[i].tx_power1 = DEFAULT_TXPOWER;
1851 return 0;
1854 static int rt2500usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1856 int retval;
1859 * Allocate eeprom data.
1861 retval = rt2500usb_validate_eeprom(rt2x00dev);
1862 if (retval)
1863 return retval;
1865 retval = rt2500usb_init_eeprom(rt2x00dev);
1866 if (retval)
1867 return retval;
1870 * Initialize hw specifications.
1872 retval = rt2500usb_probe_hw_mode(rt2x00dev);
1873 if (retval)
1874 return retval;
1877 * This device requires the atim queue
1879 __set_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
1880 __set_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags);
1881 if (!modparam_nohwcrypt) {
1882 __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);
1883 __set_bit(DRIVER_REQUIRE_COPY_IV, &rt2x00dev->flags);
1885 __set_bit(CONFIG_DISABLE_LINK_TUNING, &rt2x00dev->flags);
1888 * Set the rssi offset.
1890 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
1892 return 0;
1895 static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1896 .tx = rt2x00mac_tx,
1897 .start = rt2x00mac_start,
1898 .stop = rt2x00mac_stop,
1899 .add_interface = rt2x00mac_add_interface,
1900 .remove_interface = rt2x00mac_remove_interface,
1901 .config = rt2x00mac_config,
1902 .configure_filter = rt2x00mac_configure_filter,
1903 .set_tim = rt2x00mac_set_tim,
1904 .set_key = rt2x00mac_set_key,
1905 .get_stats = rt2x00mac_get_stats,
1906 .bss_info_changed = rt2x00mac_bss_info_changed,
1907 .conf_tx = rt2x00mac_conf_tx,
1908 .get_tx_stats = rt2x00mac_get_tx_stats,
1909 .rfkill_poll = rt2x00mac_rfkill_poll,
1912 static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1913 .probe_hw = rt2500usb_probe_hw,
1914 .initialize = rt2x00usb_initialize,
1915 .uninitialize = rt2x00usb_uninitialize,
1916 .clear_entry = rt2x00usb_clear_entry,
1917 .set_device_state = rt2500usb_set_device_state,
1918 .rfkill_poll = rt2500usb_rfkill_poll,
1919 .link_stats = rt2500usb_link_stats,
1920 .reset_tuner = rt2500usb_reset_tuner,
1921 .link_tuner = rt2500usb_link_tuner,
1922 .write_tx_desc = rt2500usb_write_tx_desc,
1923 .write_tx_data = rt2x00usb_write_tx_data,
1924 .write_beacon = rt2500usb_write_beacon,
1925 .get_tx_data_len = rt2500usb_get_tx_data_len,
1926 .kick_tx_queue = rt2500usb_kick_tx_queue,
1927 .kill_tx_queue = rt2x00usb_kill_tx_queue,
1928 .fill_rxdone = rt2500usb_fill_rxdone,
1929 .config_shared_key = rt2500usb_config_key,
1930 .config_pairwise_key = rt2500usb_config_key,
1931 .config_filter = rt2500usb_config_filter,
1932 .config_intf = rt2500usb_config_intf,
1933 .config_erp = rt2500usb_config_erp,
1934 .config_ant = rt2500usb_config_ant,
1935 .config = rt2500usb_config,
1938 static const struct data_queue_desc rt2500usb_queue_rx = {
1939 .entry_num = RX_ENTRIES,
1940 .data_size = DATA_FRAME_SIZE,
1941 .desc_size = RXD_DESC_SIZE,
1942 .priv_size = sizeof(struct queue_entry_priv_usb),
1945 static const struct data_queue_desc rt2500usb_queue_tx = {
1946 .entry_num = TX_ENTRIES,
1947 .data_size = DATA_FRAME_SIZE,
1948 .desc_size = TXD_DESC_SIZE,
1949 .priv_size = sizeof(struct queue_entry_priv_usb),
1952 static const struct data_queue_desc rt2500usb_queue_bcn = {
1953 .entry_num = BEACON_ENTRIES,
1954 .data_size = MGMT_FRAME_SIZE,
1955 .desc_size = TXD_DESC_SIZE,
1956 .priv_size = sizeof(struct queue_entry_priv_usb_bcn),
1959 static const struct data_queue_desc rt2500usb_queue_atim = {
1960 .entry_num = ATIM_ENTRIES,
1961 .data_size = DATA_FRAME_SIZE,
1962 .desc_size = TXD_DESC_SIZE,
1963 .priv_size = sizeof(struct queue_entry_priv_usb),
1966 static const struct rt2x00_ops rt2500usb_ops = {
1967 .name = KBUILD_MODNAME,
1968 .max_sta_intf = 1,
1969 .max_ap_intf = 1,
1970 .eeprom_size = EEPROM_SIZE,
1971 .rf_size = RF_SIZE,
1972 .tx_queues = NUM_TX_QUEUES,
1973 .extra_tx_headroom = TXD_DESC_SIZE,
1974 .rx = &rt2500usb_queue_rx,
1975 .tx = &rt2500usb_queue_tx,
1976 .bcn = &rt2500usb_queue_bcn,
1977 .atim = &rt2500usb_queue_atim,
1978 .lib = &rt2500usb_rt2x00_ops,
1979 .hw = &rt2500usb_mac80211_ops,
1980 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
1981 .debugfs = &rt2500usb_rt2x00debug,
1982 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
1986 * rt2500usb module information.
1988 static struct usb_device_id rt2500usb_device_table[] = {
1989 /* ASUS */
1990 { USB_DEVICE(0x0b05, 0x1706), USB_DEVICE_DATA(&rt2500usb_ops) },
1991 { USB_DEVICE(0x0b05, 0x1707), USB_DEVICE_DATA(&rt2500usb_ops) },
1992 /* Belkin */
1993 { USB_DEVICE(0x050d, 0x7050), USB_DEVICE_DATA(&rt2500usb_ops) },
1994 { USB_DEVICE(0x050d, 0x7051), USB_DEVICE_DATA(&rt2500usb_ops) },
1995 { USB_DEVICE(0x050d, 0x705a), USB_DEVICE_DATA(&rt2500usb_ops) },
1996 /* Cisco Systems */
1997 { USB_DEVICE(0x13b1, 0x000d), USB_DEVICE_DATA(&rt2500usb_ops) },
1998 { USB_DEVICE(0x13b1, 0x0011), USB_DEVICE_DATA(&rt2500usb_ops) },
1999 { USB_DEVICE(0x13b1, 0x001a), USB_DEVICE_DATA(&rt2500usb_ops) },
2000 /* CNet */
2001 { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt2500usb_ops) },
2002 /* Conceptronic */
2003 { USB_DEVICE(0x14b2, 0x3c02), USB_DEVICE_DATA(&rt2500usb_ops) },
2004 /* D-LINK */
2005 { USB_DEVICE(0x2001, 0x3c00), USB_DEVICE_DATA(&rt2500usb_ops) },
2006 /* Gigabyte */
2007 { USB_DEVICE(0x1044, 0x8001), USB_DEVICE_DATA(&rt2500usb_ops) },
2008 { USB_DEVICE(0x1044, 0x8007), USB_DEVICE_DATA(&rt2500usb_ops) },
2009 /* Hercules */
2010 { USB_DEVICE(0x06f8, 0xe000), USB_DEVICE_DATA(&rt2500usb_ops) },
2011 /* Melco */
2012 { USB_DEVICE(0x0411, 0x005e), USB_DEVICE_DATA(&rt2500usb_ops) },
2013 { USB_DEVICE(0x0411, 0x0066), USB_DEVICE_DATA(&rt2500usb_ops) },
2014 { USB_DEVICE(0x0411, 0x0067), USB_DEVICE_DATA(&rt2500usb_ops) },
2015 { USB_DEVICE(0x0411, 0x008b), USB_DEVICE_DATA(&rt2500usb_ops) },
2016 { USB_DEVICE(0x0411, 0x0097), USB_DEVICE_DATA(&rt2500usb_ops) },
2017 /* MSI */
2018 { USB_DEVICE(0x0db0, 0x6861), USB_DEVICE_DATA(&rt2500usb_ops) },
2019 { USB_DEVICE(0x0db0, 0x6865), USB_DEVICE_DATA(&rt2500usb_ops) },
2020 { USB_DEVICE(0x0db0, 0x6869), USB_DEVICE_DATA(&rt2500usb_ops) },
2021 /* Ralink */
2022 { USB_DEVICE(0x148f, 0x1706), USB_DEVICE_DATA(&rt2500usb_ops) },
2023 { USB_DEVICE(0x148f, 0x2570), USB_DEVICE_DATA(&rt2500usb_ops) },
2024 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt2500usb_ops) },
2025 { USB_DEVICE(0x148f, 0x9020), USB_DEVICE_DATA(&rt2500usb_ops) },
2026 /* Sagem */
2027 { USB_DEVICE(0x079b, 0x004b), USB_DEVICE_DATA(&rt2500usb_ops) },
2028 /* Siemens */
2029 { USB_DEVICE(0x0681, 0x3c06), USB_DEVICE_DATA(&rt2500usb_ops) },
2030 /* SMC */
2031 { USB_DEVICE(0x0707, 0xee13), USB_DEVICE_DATA(&rt2500usb_ops) },
2032 /* Spairon */
2033 { USB_DEVICE(0x114b, 0x0110), USB_DEVICE_DATA(&rt2500usb_ops) },
2034 /* SURECOM */
2035 { USB_DEVICE(0x0769, 0x11f3), USB_DEVICE_DATA(&rt2500usb_ops) },
2036 /* Trust */
2037 { USB_DEVICE(0x0eb0, 0x9020), USB_DEVICE_DATA(&rt2500usb_ops) },
2038 /* VTech */
2039 { USB_DEVICE(0x0f88, 0x3012), USB_DEVICE_DATA(&rt2500usb_ops) },
2040 /* Zinwell */
2041 { USB_DEVICE(0x5a57, 0x0260), USB_DEVICE_DATA(&rt2500usb_ops) },
2042 { 0, }
2045 MODULE_AUTHOR(DRV_PROJECT);
2046 MODULE_VERSION(DRV_VERSION);
2047 MODULE_DESCRIPTION("Ralink RT2500 USB Wireless LAN driver.");
2048 MODULE_SUPPORTED_DEVICE("Ralink RT2570 USB chipset based cards");
2049 MODULE_DEVICE_TABLE(usb, rt2500usb_device_table);
2050 MODULE_LICENSE("GPL");
2052 static struct usb_driver rt2500usb_driver = {
2053 .name = KBUILD_MODNAME,
2054 .id_table = rt2500usb_device_table,
2055 .probe = rt2x00usb_probe,
2056 .disconnect = rt2x00usb_disconnect,
2057 .suspend = rt2x00usb_suspend,
2058 .resume = rt2x00usb_resume,
2061 static int __init rt2500usb_init(void)
2063 return usb_register(&rt2500usb_driver);
2066 static void __exit rt2500usb_exit(void)
2068 usb_deregister(&rt2500usb_driver);
2071 module_init(rt2500usb_init);
2072 module_exit(rt2500usb_exit);