2 Copyright (C) 2004 - 2008 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.
23 Abstract: rt73usb device specific routines.
24 Supported chipsets: rt2571W & rt2671.
27 #include <linux/crc-itu-t.h>
28 #include <linux/delay.h>
29 #include <linux/etherdevice.h>
30 #include <linux/init.h>
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/usb.h>
36 #include "rt2x00usb.h"
40 * Allow hardware encryption to be disabled.
42 static int modparam_nohwcrypt = 0;
43 module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
44 MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
48 * All access to the CSR registers will go through the methods
49 * rt2x00usb_register_read and rt2x00usb_register_write.
50 * BBP and RF register require indirect register access,
51 * and use the CSR registers BBPCSR and RFCSR to achieve this.
52 * These indirect registers work with busy bits,
53 * and we will try maximal REGISTER_BUSY_COUNT times to access
54 * the register while taking a REGISTER_BUSY_DELAY us delay
55 * between each attampt. When the busy bit is still set at that time,
56 * the access attempt is considered to have failed,
57 * and we will print an error.
58 * The _lock versions must be used if you already hold the csr_mutex
60 #define WAIT_FOR_BBP(__dev, __reg) \
61 rt2x00usb_regbusy_read((__dev), PHY_CSR3, PHY_CSR3_BUSY, (__reg))
62 #define WAIT_FOR_RF(__dev, __reg) \
63 rt2x00usb_regbusy_read((__dev), PHY_CSR4, PHY_CSR4_BUSY, (__reg))
65 static void rt73usb_bbp_write(struct rt2x00_dev *rt2x00dev,
66 const unsigned int word, const u8 value)
70 mutex_lock(&rt2x00dev->csr_mutex);
73 * Wait until the BBP becomes available, afterwards we
74 * can safely write the new data into the register.
76 if (WAIT_FOR_BBP(rt2x00dev, ®)) {
78 rt2x00_set_field32(®, PHY_CSR3_VALUE, value);
79 rt2x00_set_field32(®, PHY_CSR3_REGNUM, word);
80 rt2x00_set_field32(®, PHY_CSR3_BUSY, 1);
81 rt2x00_set_field32(®, PHY_CSR3_READ_CONTROL, 0);
83 rt2x00usb_register_write_lock(rt2x00dev, PHY_CSR3, reg);
86 mutex_unlock(&rt2x00dev->csr_mutex);
89 static void rt73usb_bbp_read(struct rt2x00_dev *rt2x00dev,
90 const unsigned int word, u8 *value)
94 mutex_lock(&rt2x00dev->csr_mutex);
97 * Wait until the BBP becomes available, afterwards we
98 * can safely write the read request into the register.
99 * After the data has been written, we wait until hardware
100 * returns the correct value, if at any time the register
101 * doesn't become available in time, reg will be 0xffffffff
102 * which means we return 0xff to the caller.
104 if (WAIT_FOR_BBP(rt2x00dev, ®)) {
106 rt2x00_set_field32(®, PHY_CSR3_REGNUM, word);
107 rt2x00_set_field32(®, PHY_CSR3_BUSY, 1);
108 rt2x00_set_field32(®, PHY_CSR3_READ_CONTROL, 1);
110 rt2x00usb_register_write_lock(rt2x00dev, PHY_CSR3, reg);
112 WAIT_FOR_BBP(rt2x00dev, ®);
115 *value = rt2x00_get_field32(reg, PHY_CSR3_VALUE);
117 mutex_unlock(&rt2x00dev->csr_mutex);
120 static void rt73usb_rf_write(struct rt2x00_dev *rt2x00dev,
121 const unsigned int word, const u32 value)
128 mutex_lock(&rt2x00dev->csr_mutex);
131 * Wait until the RF becomes available, afterwards we
132 * can safely write the new data into the register.
134 if (WAIT_FOR_RF(rt2x00dev, ®)) {
136 rt2x00_set_field32(®, PHY_CSR4_VALUE, value);
138 * RF5225 and RF2527 contain 21 bits per RF register value,
139 * all others contain 20 bits.
141 rt2x00_set_field32(®, PHY_CSR4_NUMBER_OF_BITS,
142 20 + (rt2x00_rf(&rt2x00dev->chip, RF5225) ||
143 rt2x00_rf(&rt2x00dev->chip, RF2527)));
144 rt2x00_set_field32(®, PHY_CSR4_IF_SELECT, 0);
145 rt2x00_set_field32(®, PHY_CSR4_BUSY, 1);
147 rt2x00usb_register_write_lock(rt2x00dev, PHY_CSR4, reg);
148 rt2x00_rf_write(rt2x00dev, word, value);
151 mutex_unlock(&rt2x00dev->csr_mutex);
154 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
155 static const struct rt2x00debug rt73usb_rt2x00debug = {
156 .owner = THIS_MODULE,
158 .read = rt2x00usb_register_read,
159 .write = rt2x00usb_register_write,
160 .flags = RT2X00DEBUGFS_OFFSET,
161 .word_base = CSR_REG_BASE,
162 .word_size = sizeof(u32),
163 .word_count = CSR_REG_SIZE / sizeof(u32),
166 .read = rt2x00_eeprom_read,
167 .write = rt2x00_eeprom_write,
168 .word_base = EEPROM_BASE,
169 .word_size = sizeof(u16),
170 .word_count = EEPROM_SIZE / sizeof(u16),
173 .read = rt73usb_bbp_read,
174 .write = rt73usb_bbp_write,
175 .word_base = BBP_BASE,
176 .word_size = sizeof(u8),
177 .word_count = BBP_SIZE / sizeof(u8),
180 .read = rt2x00_rf_read,
181 .write = rt73usb_rf_write,
182 .word_base = RF_BASE,
183 .word_size = sizeof(u32),
184 .word_count = RF_SIZE / sizeof(u32),
187 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
189 #ifdef CONFIG_RT2X00_LIB_LEDS
190 static void rt73usb_brightness_set(struct led_classdev *led_cdev,
191 enum led_brightness brightness)
193 struct rt2x00_led *led =
194 container_of(led_cdev, struct rt2x00_led, led_dev);
195 unsigned int enabled = brightness != LED_OFF;
196 unsigned int a_mode =
197 (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_5GHZ);
198 unsigned int bg_mode =
199 (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
201 if (led->type == LED_TYPE_RADIO) {
202 rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
203 MCU_LEDCS_RADIO_STATUS, enabled);
205 rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
206 0, led->rt2x00dev->led_mcu_reg,
208 } else if (led->type == LED_TYPE_ASSOC) {
209 rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
210 MCU_LEDCS_LINK_BG_STATUS, bg_mode);
211 rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
212 MCU_LEDCS_LINK_A_STATUS, a_mode);
214 rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
215 0, led->rt2x00dev->led_mcu_reg,
217 } else if (led->type == LED_TYPE_QUALITY) {
219 * The brightness is divided into 6 levels (0 - 5),
220 * this means we need to convert the brightness
221 * argument into the matching level within that range.
223 rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
224 brightness / (LED_FULL / 6),
225 led->rt2x00dev->led_mcu_reg,
230 static int rt73usb_blink_set(struct led_classdev *led_cdev,
231 unsigned long *delay_on,
232 unsigned long *delay_off)
234 struct rt2x00_led *led =
235 container_of(led_cdev, struct rt2x00_led, led_dev);
238 rt2x00usb_register_read(led->rt2x00dev, MAC_CSR14, ®);
239 rt2x00_set_field32(®, MAC_CSR14_ON_PERIOD, *delay_on);
240 rt2x00_set_field32(®, MAC_CSR14_OFF_PERIOD, *delay_off);
241 rt2x00usb_register_write(led->rt2x00dev, MAC_CSR14, reg);
246 static void rt73usb_init_led(struct rt2x00_dev *rt2x00dev,
247 struct rt2x00_led *led,
250 led->rt2x00dev = rt2x00dev;
252 led->led_dev.brightness_set = rt73usb_brightness_set;
253 led->led_dev.blink_set = rt73usb_blink_set;
254 led->flags = LED_INITIALIZED;
256 #endif /* CONFIG_RT2X00_LIB_LEDS */
259 * Configuration handlers.
261 static int rt73usb_config_shared_key(struct rt2x00_dev *rt2x00dev,
262 struct rt2x00lib_crypto *crypto,
263 struct ieee80211_key_conf *key)
265 struct hw_key_entry key_entry;
266 struct rt2x00_field32 field;
271 if (crypto->cmd == SET_KEY) {
273 * rt2x00lib can't determine the correct free
274 * key_idx for shared keys. We have 1 register
275 * with key valid bits. The goal is simple, read
276 * the register, if that is full we have no slots
278 * Note that each BSS is allowed to have up to 4
279 * shared keys, so put a mask over the allowed
282 mask = (0xf << crypto->bssidx);
284 rt2x00usb_register_read(rt2x00dev, SEC_CSR0, ®);
287 if (reg && reg == mask)
290 key->hw_key_idx += reg ? ffz(reg) : 0;
293 * Upload key to hardware
295 memcpy(key_entry.key, crypto->key,
296 sizeof(key_entry.key));
297 memcpy(key_entry.tx_mic, crypto->tx_mic,
298 sizeof(key_entry.tx_mic));
299 memcpy(key_entry.rx_mic, crypto->rx_mic,
300 sizeof(key_entry.rx_mic));
302 reg = SHARED_KEY_ENTRY(key->hw_key_idx);
303 timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
304 rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
305 USB_VENDOR_REQUEST_OUT, reg,
311 * The cipher types are stored over 2 registers.
312 * bssidx 0 and 1 keys are stored in SEC_CSR1 and
313 * bssidx 1 and 2 keys are stored in SEC_CSR5.
314 * Using the correct defines correctly will cause overhead,
315 * so just calculate the correct offset.
317 if (key->hw_key_idx < 8) {
318 field.bit_offset = (3 * key->hw_key_idx);
319 field.bit_mask = 0x7 << field.bit_offset;
321 rt2x00usb_register_read(rt2x00dev, SEC_CSR1, ®);
322 rt2x00_set_field32(®, field, crypto->cipher);
323 rt2x00usb_register_write(rt2x00dev, SEC_CSR1, reg);
325 field.bit_offset = (3 * (key->hw_key_idx - 8));
326 field.bit_mask = 0x7 << field.bit_offset;
328 rt2x00usb_register_read(rt2x00dev, SEC_CSR5, ®);
329 rt2x00_set_field32(®, field, crypto->cipher);
330 rt2x00usb_register_write(rt2x00dev, SEC_CSR5, reg);
334 * The driver does not support the IV/EIV generation
335 * in hardware. However it doesn't support the IV/EIV
336 * inside the ieee80211 frame either, but requires it
337 * to be provided seperately for the descriptor.
338 * rt2x00lib will cut the IV/EIV data out of all frames
339 * given to us by mac80211, but we must tell mac80211
340 * to generate the IV/EIV data.
342 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
346 * SEC_CSR0 contains only single-bit fields to indicate
347 * a particular key is valid. Because using the FIELD32()
348 * defines directly will cause a lot of overhead we use
349 * a calculation to determine the correct bit directly.
351 mask = 1 << key->hw_key_idx;
353 rt2x00usb_register_read(rt2x00dev, SEC_CSR0, ®);
354 if (crypto->cmd == SET_KEY)
356 else if (crypto->cmd == DISABLE_KEY)
358 rt2x00usb_register_write(rt2x00dev, SEC_CSR0, reg);
363 static int rt73usb_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
364 struct rt2x00lib_crypto *crypto,
365 struct ieee80211_key_conf *key)
367 struct hw_pairwise_ta_entry addr_entry;
368 struct hw_key_entry key_entry;
373 if (crypto->cmd == SET_KEY) {
375 * rt2x00lib can't determine the correct free
376 * key_idx for pairwise keys. We have 2 registers
377 * with key valid bits. The goal is simple, read
378 * the first register, if that is full move to
380 * When both registers are full, we drop the key,
381 * otherwise we use the first invalid entry.
383 rt2x00usb_register_read(rt2x00dev, SEC_CSR2, ®);
384 if (reg && reg == ~0) {
385 key->hw_key_idx = 32;
386 rt2x00usb_register_read(rt2x00dev, SEC_CSR3, ®);
387 if (reg && reg == ~0)
391 key->hw_key_idx += reg ? ffz(reg) : 0;
394 * Upload key to hardware
396 memcpy(key_entry.key, crypto->key,
397 sizeof(key_entry.key));
398 memcpy(key_entry.tx_mic, crypto->tx_mic,
399 sizeof(key_entry.tx_mic));
400 memcpy(key_entry.rx_mic, crypto->rx_mic,
401 sizeof(key_entry.rx_mic));
403 reg = PAIRWISE_KEY_ENTRY(key->hw_key_idx);
404 timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
405 rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
406 USB_VENDOR_REQUEST_OUT, reg,
412 * Send the address and cipher type to the hardware register.
413 * This data fits within the CSR cache size, so we can use
414 * rt2x00usb_register_multiwrite() directly.
416 memset(&addr_entry, 0, sizeof(addr_entry));
417 memcpy(&addr_entry, crypto->address, ETH_ALEN);
418 addr_entry.cipher = crypto->cipher;
420 reg = PAIRWISE_TA_ENTRY(key->hw_key_idx);
421 rt2x00usb_register_multiwrite(rt2x00dev, reg,
422 &addr_entry, sizeof(addr_entry));
425 * Enable pairwise lookup table for given BSS idx,
426 * without this received frames will not be decrypted
429 rt2x00usb_register_read(rt2x00dev, SEC_CSR4, ®);
430 reg |= (1 << crypto->bssidx);
431 rt2x00usb_register_write(rt2x00dev, SEC_CSR4, reg);
434 * The driver does not support the IV/EIV generation
435 * in hardware. However it doesn't support the IV/EIV
436 * inside the ieee80211 frame either, but requires it
437 * to be provided seperately for the descriptor.
438 * rt2x00lib will cut the IV/EIV data out of all frames
439 * given to us by mac80211, but we must tell mac80211
440 * to generate the IV/EIV data.
442 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
446 * SEC_CSR2 and SEC_CSR3 contain only single-bit fields to indicate
447 * a particular key is valid. Because using the FIELD32()
448 * defines directly will cause a lot of overhead we use
449 * a calculation to determine the correct bit directly.
451 if (key->hw_key_idx < 32) {
452 mask = 1 << key->hw_key_idx;
454 rt2x00usb_register_read(rt2x00dev, SEC_CSR2, ®);
455 if (crypto->cmd == SET_KEY)
457 else if (crypto->cmd == DISABLE_KEY)
459 rt2x00usb_register_write(rt2x00dev, SEC_CSR2, reg);
461 mask = 1 << (key->hw_key_idx - 32);
463 rt2x00usb_register_read(rt2x00dev, SEC_CSR3, ®);
464 if (crypto->cmd == SET_KEY)
466 else if (crypto->cmd == DISABLE_KEY)
468 rt2x00usb_register_write(rt2x00dev, SEC_CSR3, reg);
474 static void rt73usb_config_filter(struct rt2x00_dev *rt2x00dev,
475 const unsigned int filter_flags)
480 * Start configuration steps.
481 * Note that the version error will always be dropped
482 * and broadcast frames will always be accepted since
483 * there is no filter for it at this time.
485 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, ®);
486 rt2x00_set_field32(®, TXRX_CSR0_DROP_CRC,
487 !(filter_flags & FIF_FCSFAIL));
488 rt2x00_set_field32(®, TXRX_CSR0_DROP_PHYSICAL,
489 !(filter_flags & FIF_PLCPFAIL));
490 rt2x00_set_field32(®, TXRX_CSR0_DROP_CONTROL,
491 !(filter_flags & FIF_CONTROL));
492 rt2x00_set_field32(®, TXRX_CSR0_DROP_NOT_TO_ME,
493 !(filter_flags & FIF_PROMISC_IN_BSS));
494 rt2x00_set_field32(®, TXRX_CSR0_DROP_TO_DS,
495 !(filter_flags & FIF_PROMISC_IN_BSS) &&
496 !rt2x00dev->intf_ap_count);
497 rt2x00_set_field32(®, TXRX_CSR0_DROP_VERSION_ERROR, 1);
498 rt2x00_set_field32(®, TXRX_CSR0_DROP_MULTICAST,
499 !(filter_flags & FIF_ALLMULTI));
500 rt2x00_set_field32(®, TXRX_CSR0_DROP_BROADCAST, 0);
501 rt2x00_set_field32(®, TXRX_CSR0_DROP_ACK_CTS,
502 !(filter_flags & FIF_CONTROL));
503 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
506 static void rt73usb_config_intf(struct rt2x00_dev *rt2x00dev,
507 struct rt2x00_intf *intf,
508 struct rt2x00intf_conf *conf,
509 const unsigned int flags)
511 unsigned int beacon_base;
514 if (flags & CONFIG_UPDATE_TYPE) {
516 * Clear current synchronisation setup.
517 * For the Beacon base registers we only need to clear
518 * the first byte since that byte contains the VALID and OWNER
519 * bits which (when set to 0) will invalidate the entire beacon.
521 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
522 rt2x00usb_register_write(rt2x00dev, beacon_base, 0);
525 * Enable synchronisation.
527 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, ®);
528 rt2x00_set_field32(®, TXRX_CSR9_TSF_TICKING, 1);
529 rt2x00_set_field32(®, TXRX_CSR9_TSF_SYNC, conf->sync);
530 rt2x00_set_field32(®, TXRX_CSR9_TBTT_ENABLE, 1);
531 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
534 if (flags & CONFIG_UPDATE_MAC) {
535 reg = le32_to_cpu(conf->mac[1]);
536 rt2x00_set_field32(®, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff);
537 conf->mac[1] = cpu_to_le32(reg);
539 rt2x00usb_register_multiwrite(rt2x00dev, MAC_CSR2,
540 conf->mac, sizeof(conf->mac));
543 if (flags & CONFIG_UPDATE_BSSID) {
544 reg = le32_to_cpu(conf->bssid[1]);
545 rt2x00_set_field32(®, MAC_CSR5_BSS_ID_MASK, 3);
546 conf->bssid[1] = cpu_to_le32(reg);
548 rt2x00usb_register_multiwrite(rt2x00dev, MAC_CSR4,
549 conf->bssid, sizeof(conf->bssid));
553 static void rt73usb_config_erp(struct rt2x00_dev *rt2x00dev,
554 struct rt2x00lib_erp *erp)
558 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, ®);
559 rt2x00_set_field32(®, TXRX_CSR0_RX_ACK_TIMEOUT, erp->ack_timeout);
560 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
562 rt2x00usb_register_read(rt2x00dev, TXRX_CSR4, ®);
563 rt2x00_set_field32(®, TXRX_CSR4_AUTORESPOND_PREAMBLE,
564 !!erp->short_preamble);
565 rt2x00usb_register_write(rt2x00dev, TXRX_CSR4, reg);
567 rt2x00usb_register_write(rt2x00dev, TXRX_CSR5, erp->basic_rates);
569 rt2x00usb_register_read(rt2x00dev, MAC_CSR9, ®);
570 rt2x00_set_field32(®, MAC_CSR9_SLOT_TIME, erp->slot_time);
571 rt2x00usb_register_write(rt2x00dev, MAC_CSR9, reg);
573 rt2x00usb_register_read(rt2x00dev, MAC_CSR8, ®);
574 rt2x00_set_field32(®, MAC_CSR8_SIFS, erp->sifs);
575 rt2x00_set_field32(®, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3);
576 rt2x00_set_field32(®, MAC_CSR8_EIFS, erp->eifs);
577 rt2x00usb_register_write(rt2x00dev, MAC_CSR8, reg);
580 static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
581 struct antenna_setup *ant)
588 rt73usb_bbp_read(rt2x00dev, 3, &r3);
589 rt73usb_bbp_read(rt2x00dev, 4, &r4);
590 rt73usb_bbp_read(rt2x00dev, 77, &r77);
592 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0);
595 * Configure the RX antenna.
598 case ANTENNA_HW_DIVERSITY:
599 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2);
600 temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags)
601 && (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ);
602 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp);
605 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
606 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
607 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)
608 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
610 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
614 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
615 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
616 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)
617 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
619 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
623 rt73usb_bbp_write(rt2x00dev, 77, r77);
624 rt73usb_bbp_write(rt2x00dev, 3, r3);
625 rt73usb_bbp_write(rt2x00dev, 4, r4);
628 static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
629 struct antenna_setup *ant)
635 rt73usb_bbp_read(rt2x00dev, 3, &r3);
636 rt73usb_bbp_read(rt2x00dev, 4, &r4);
637 rt73usb_bbp_read(rt2x00dev, 77, &r77);
639 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0);
640 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
641 !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags));
644 * Configure the RX antenna.
647 case ANTENNA_HW_DIVERSITY:
648 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2);
651 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
652 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
656 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
657 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
661 rt73usb_bbp_write(rt2x00dev, 77, r77);
662 rt73usb_bbp_write(rt2x00dev, 3, r3);
663 rt73usb_bbp_write(rt2x00dev, 4, r4);
669 * value[0] -> non-LNA
675 static const struct antenna_sel antenna_sel_a[] = {
676 { 96, { 0x58, 0x78 } },
677 { 104, { 0x38, 0x48 } },
678 { 75, { 0xfe, 0x80 } },
679 { 86, { 0xfe, 0x80 } },
680 { 88, { 0xfe, 0x80 } },
681 { 35, { 0x60, 0x60 } },
682 { 97, { 0x58, 0x58 } },
683 { 98, { 0x58, 0x58 } },
686 static const struct antenna_sel antenna_sel_bg[] = {
687 { 96, { 0x48, 0x68 } },
688 { 104, { 0x2c, 0x3c } },
689 { 75, { 0xfe, 0x80 } },
690 { 86, { 0xfe, 0x80 } },
691 { 88, { 0xfe, 0x80 } },
692 { 35, { 0x50, 0x50 } },
693 { 97, { 0x48, 0x48 } },
694 { 98, { 0x48, 0x48 } },
697 static void rt73usb_config_ant(struct rt2x00_dev *rt2x00dev,
698 struct antenna_setup *ant)
700 const struct antenna_sel *sel;
706 * We should never come here because rt2x00lib is supposed
707 * to catch this and send us the correct antenna explicitely.
709 BUG_ON(ant->rx == ANTENNA_SW_DIVERSITY ||
710 ant->tx == ANTENNA_SW_DIVERSITY);
712 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) {
714 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
716 sel = antenna_sel_bg;
717 lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
720 for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++)
721 rt73usb_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]);
723 rt2x00usb_register_read(rt2x00dev, PHY_CSR0, ®);
725 rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG,
726 (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ));
727 rt2x00_set_field32(®, PHY_CSR0_PA_PE_A,
728 (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ));
730 rt2x00usb_register_write(rt2x00dev, PHY_CSR0, reg);
732 if (rt2x00_rf(&rt2x00dev->chip, RF5226) ||
733 rt2x00_rf(&rt2x00dev->chip, RF5225))
734 rt73usb_config_antenna_5x(rt2x00dev, ant);
735 else if (rt2x00_rf(&rt2x00dev->chip, RF2528) ||
736 rt2x00_rf(&rt2x00dev->chip, RF2527))
737 rt73usb_config_antenna_2x(rt2x00dev, ant);
740 static void rt73usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
741 struct rt2x00lib_conf *libconf)
746 if (libconf->conf->channel->band == IEEE80211_BAND_2GHZ) {
747 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
750 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &eeprom);
751 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_BG_1);
753 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &eeprom);
754 lna_gain -= rt2x00_get_field16(eeprom, EEPROM_RSSI_OFFSET_A_1);
757 rt2x00dev->lna_gain = lna_gain;
760 static void rt73usb_config_channel(struct rt2x00_dev *rt2x00dev,
761 struct rf_channel *rf, const int txpower)
767 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
768 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
770 smart = !(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
771 rt2x00_rf(&rt2x00dev->chip, RF2527));
773 rt73usb_bbp_read(rt2x00dev, 3, &r3);
774 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, smart);
775 rt73usb_bbp_write(rt2x00dev, 3, r3);
778 if (txpower > MAX_TXPOWER && txpower <= (MAX_TXPOWER + r94))
779 r94 += txpower - MAX_TXPOWER;
780 else if (txpower < MIN_TXPOWER && txpower >= (MIN_TXPOWER - r94))
782 rt73usb_bbp_write(rt2x00dev, 94, r94);
784 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
785 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
786 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
787 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
789 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
790 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
791 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
792 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
794 rt73usb_rf_write(rt2x00dev, 1, rf->rf1);
795 rt73usb_rf_write(rt2x00dev, 2, rf->rf2);
796 rt73usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
797 rt73usb_rf_write(rt2x00dev, 4, rf->rf4);
802 static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev,
805 struct rf_channel rf;
807 rt2x00_rf_read(rt2x00dev, 1, &rf.rf1);
808 rt2x00_rf_read(rt2x00dev, 2, &rf.rf2);
809 rt2x00_rf_read(rt2x00dev, 3, &rf.rf3);
810 rt2x00_rf_read(rt2x00dev, 4, &rf.rf4);
812 rt73usb_config_channel(rt2x00dev, &rf, txpower);
815 static void rt73usb_config_retry_limit(struct rt2x00_dev *rt2x00dev,
816 struct rt2x00lib_conf *libconf)
820 rt2x00usb_register_read(rt2x00dev, TXRX_CSR4, ®);
821 rt2x00_set_field32(®, TXRX_CSR4_LONG_RETRY_LIMIT,
822 libconf->conf->long_frame_max_tx_count);
823 rt2x00_set_field32(®, TXRX_CSR4_SHORT_RETRY_LIMIT,
824 libconf->conf->short_frame_max_tx_count);
825 rt2x00usb_register_write(rt2x00dev, TXRX_CSR4, reg);
828 static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
829 struct rt2x00lib_conf *libconf)
833 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, ®);
834 rt2x00_set_field32(®, TXRX_CSR0_TSF_OFFSET, IEEE80211_HEADER);
835 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
837 rt2x00usb_register_read(rt2x00dev, TXRX_CSR4, ®);
838 rt2x00_set_field32(®, TXRX_CSR4_AUTORESPOND_ENABLE, 1);
839 rt2x00usb_register_write(rt2x00dev, TXRX_CSR4, reg);
841 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, ®);
842 rt2x00_set_field32(®, TXRX_CSR9_BEACON_INTERVAL,
843 libconf->conf->beacon_int * 16);
844 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
847 static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
848 struct rt2x00lib_conf *libconf,
849 const unsigned int flags)
851 /* Always recalculate LNA gain before changing configuration */
852 rt73usb_config_lna_gain(rt2x00dev, libconf);
854 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
855 rt73usb_config_channel(rt2x00dev, &libconf->rf,
856 libconf->conf->power_level);
857 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
858 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
859 rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level);
860 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
861 rt73usb_config_retry_limit(rt2x00dev, libconf);
862 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
863 rt73usb_config_duration(rt2x00dev, libconf);
869 static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev,
870 struct link_qual *qual)
875 * Update FCS error count from register.
877 rt2x00usb_register_read(rt2x00dev, STA_CSR0, ®);
878 qual->rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR);
881 * Update False CCA count from register.
883 rt2x00usb_register_read(rt2x00dev, STA_CSR1, ®);
884 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
887 static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev)
889 rt73usb_bbp_write(rt2x00dev, 17, 0x20);
890 rt2x00dev->link.vgc_level = 0x20;
893 static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
895 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link);
900 rt73usb_bbp_read(rt2x00dev, 17, &r17);
903 * Determine r17 bounds.
905 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) {
909 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) {
917 } else if (rssi > -84) {
925 if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags)) {
932 * If we are not associated, we should go straight to the
933 * dynamic CCA tuning.
935 if (!rt2x00dev->intf_associated)
936 goto dynamic_cca_tune;
939 * Special big-R17 for very short distance
943 rt73usb_bbp_write(rt2x00dev, 17, 0x60);
948 * Special big-R17 for short distance
952 rt73usb_bbp_write(rt2x00dev, 17, up_bound);
957 * Special big-R17 for middle-short distance
961 if (r17 != low_bound)
962 rt73usb_bbp_write(rt2x00dev, 17, low_bound);
967 * Special mid-R17 for middle distance
970 if (r17 != (low_bound + 0x10))
971 rt73usb_bbp_write(rt2x00dev, 17, low_bound + 0x08);
976 * Special case: Change up_bound based on the rssi.
977 * Lower up_bound when rssi is weaker then -74 dBm.
979 up_bound -= 2 * (-74 - rssi);
980 if (low_bound > up_bound)
981 up_bound = low_bound;
983 if (r17 > up_bound) {
984 rt73usb_bbp_write(rt2x00dev, 17, up_bound);
991 * r17 does not yet exceed upper limit, continue and base
992 * the r17 tuning on the false CCA count.
994 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
998 rt73usb_bbp_write(rt2x00dev, 17, r17);
999 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
1001 if (r17 < low_bound)
1003 rt73usb_bbp_write(rt2x00dev, 17, r17);
1008 * Firmware functions
1010 static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
1012 return FIRMWARE_RT2571;
1015 static u16 rt73usb_get_firmware_crc(const void *data, const size_t len)
1020 * Use the crc itu-t algorithm.
1021 * The last 2 bytes in the firmware array are the crc checksum itself,
1022 * this means that we should never pass those 2 bytes to the crc
1025 crc = crc_itu_t(0, data, len - 2);
1026 crc = crc_itu_t_byte(crc, 0);
1027 crc = crc_itu_t_byte(crc, 0);
1032 static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, const void *data,
1040 * Wait for stable hardware.
1042 for (i = 0; i < 100; i++) {
1043 rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
1050 ERROR(rt2x00dev, "Unstable hardware.\n");
1055 * Write firmware to device.
1057 rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
1058 USB_VENDOR_REQUEST_OUT,
1059 FIRMWARE_IMAGE_BASE,
1061 REGISTER_TIMEOUT32(len));
1064 * Send firmware request to device to load firmware,
1065 * we need to specify a long timeout time.
1067 status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
1068 0, USB_MODE_FIRMWARE,
1069 REGISTER_TIMEOUT_FIRMWARE);
1071 ERROR(rt2x00dev, "Failed to write Firmware to device.\n");
1079 * Initialization functions.
1081 static int rt73usb_init_registers(struct rt2x00_dev *rt2x00dev)
1085 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, ®);
1086 rt2x00_set_field32(®, TXRX_CSR0_AUTO_TX_SEQ, 1);
1087 rt2x00_set_field32(®, TXRX_CSR0_DISABLE_RX, 0);
1088 rt2x00_set_field32(®, TXRX_CSR0_TX_WITHOUT_WAITING, 0);
1089 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1091 rt2x00usb_register_read(rt2x00dev, TXRX_CSR1, ®);
1092 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID0, 47); /* CCK Signal */
1093 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID0_VALID, 1);
1094 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID1, 30); /* Rssi */
1095 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID1_VALID, 1);
1096 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID2, 42); /* OFDM Rate */
1097 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID2_VALID, 1);
1098 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID3, 30); /* Rssi */
1099 rt2x00_set_field32(®, TXRX_CSR1_BBP_ID3_VALID, 1);
1100 rt2x00usb_register_write(rt2x00dev, TXRX_CSR1, reg);
1103 * CCK TXD BBP registers
1105 rt2x00usb_register_read(rt2x00dev, TXRX_CSR2, ®);
1106 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID0, 13);
1107 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID0_VALID, 1);
1108 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID1, 12);
1109 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID1_VALID, 1);
1110 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID2, 11);
1111 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID2_VALID, 1);
1112 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID3, 10);
1113 rt2x00_set_field32(®, TXRX_CSR2_BBP_ID3_VALID, 1);
1114 rt2x00usb_register_write(rt2x00dev, TXRX_CSR2, reg);
1117 * OFDM TXD BBP registers
1119 rt2x00usb_register_read(rt2x00dev, TXRX_CSR3, ®);
1120 rt2x00_set_field32(®, TXRX_CSR3_BBP_ID0, 7);
1121 rt2x00_set_field32(®, TXRX_CSR3_BBP_ID0_VALID, 1);
1122 rt2x00_set_field32(®, TXRX_CSR3_BBP_ID1, 6);
1123 rt2x00_set_field32(®, TXRX_CSR3_BBP_ID1_VALID, 1);
1124 rt2x00_set_field32(®, TXRX_CSR3_BBP_ID2, 5);
1125 rt2x00_set_field32(®, TXRX_CSR3_BBP_ID2_VALID, 1);
1126 rt2x00usb_register_write(rt2x00dev, TXRX_CSR3, reg);
1128 rt2x00usb_register_read(rt2x00dev, TXRX_CSR7, ®);
1129 rt2x00_set_field32(®, TXRX_CSR7_ACK_CTS_6MBS, 59);
1130 rt2x00_set_field32(®, TXRX_CSR7_ACK_CTS_9MBS, 53);
1131 rt2x00_set_field32(®, TXRX_CSR7_ACK_CTS_12MBS, 49);
1132 rt2x00_set_field32(®, TXRX_CSR7_ACK_CTS_18MBS, 46);
1133 rt2x00usb_register_write(rt2x00dev, TXRX_CSR7, reg);
1135 rt2x00usb_register_read(rt2x00dev, TXRX_CSR8, ®);
1136 rt2x00_set_field32(®, TXRX_CSR8_ACK_CTS_24MBS, 44);
1137 rt2x00_set_field32(®, TXRX_CSR8_ACK_CTS_36MBS, 42);
1138 rt2x00_set_field32(®, TXRX_CSR8_ACK_CTS_48MBS, 42);
1139 rt2x00_set_field32(®, TXRX_CSR8_ACK_CTS_54MBS, 42);
1140 rt2x00usb_register_write(rt2x00dev, TXRX_CSR8, reg);
1142 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, ®);
1143 rt2x00_set_field32(®, TXRX_CSR9_BEACON_INTERVAL, 0);
1144 rt2x00_set_field32(®, TXRX_CSR9_TSF_TICKING, 0);
1145 rt2x00_set_field32(®, TXRX_CSR9_TSF_SYNC, 0);
1146 rt2x00_set_field32(®, TXRX_CSR9_TBTT_ENABLE, 0);
1147 rt2x00_set_field32(®, TXRX_CSR9_BEACON_GEN, 0);
1148 rt2x00_set_field32(®, TXRX_CSR9_TIMESTAMP_COMPENSATE, 0);
1149 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1151 rt2x00usb_register_write(rt2x00dev, TXRX_CSR15, 0x0000000f);
1153 rt2x00usb_register_read(rt2x00dev, MAC_CSR6, ®);
1154 rt2x00_set_field32(®, MAC_CSR6_MAX_FRAME_UNIT, 0xfff);
1155 rt2x00usb_register_write(rt2x00dev, MAC_CSR6, reg);
1157 rt2x00usb_register_write(rt2x00dev, MAC_CSR10, 0x00000718);
1159 if (rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_AWAKE))
1162 rt2x00usb_register_write(rt2x00dev, MAC_CSR13, 0x00007f00);
1165 * Invalidate all Shared Keys (SEC_CSR0),
1166 * and clear the Shared key Cipher algorithms (SEC_CSR1 & SEC_CSR5)
1168 rt2x00usb_register_write(rt2x00dev, SEC_CSR0, 0x00000000);
1169 rt2x00usb_register_write(rt2x00dev, SEC_CSR1, 0x00000000);
1170 rt2x00usb_register_write(rt2x00dev, SEC_CSR5, 0x00000000);
1173 if (rt2x00_rf(&rt2x00dev->chip, RF5225) ||
1174 rt2x00_rf(&rt2x00dev->chip, RF2527))
1175 rt2x00_set_field32(®, PHY_CSR1_RF_RPI, 1);
1176 rt2x00usb_register_write(rt2x00dev, PHY_CSR1, reg);
1178 rt2x00usb_register_write(rt2x00dev, PHY_CSR5, 0x00040a06);
1179 rt2x00usb_register_write(rt2x00dev, PHY_CSR6, 0x00080606);
1180 rt2x00usb_register_write(rt2x00dev, PHY_CSR7, 0x00000408);
1182 rt2x00usb_register_read(rt2x00dev, MAC_CSR9, ®);
1183 rt2x00_set_field32(®, MAC_CSR9_CW_SELECT, 0);
1184 rt2x00usb_register_write(rt2x00dev, MAC_CSR9, reg);
1188 * For the Beacon base registers we only need to clear
1189 * the first byte since that byte contains the VALID and OWNER
1190 * bits which (when set to 0) will invalidate the entire beacon.
1192 rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE0, 0);
1193 rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE1, 0);
1194 rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE2, 0);
1195 rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE3, 0);
1198 * We must clear the error counters.
1199 * These registers are cleared on read,
1200 * so we may pass a useless variable to store the value.
1202 rt2x00usb_register_read(rt2x00dev, STA_CSR0, ®);
1203 rt2x00usb_register_read(rt2x00dev, STA_CSR1, ®);
1204 rt2x00usb_register_read(rt2x00dev, STA_CSR2, ®);
1207 * Reset MAC and BBP registers.
1209 rt2x00usb_register_read(rt2x00dev, MAC_CSR1, ®);
1210 rt2x00_set_field32(®, MAC_CSR1_SOFT_RESET, 1);
1211 rt2x00_set_field32(®, MAC_CSR1_BBP_RESET, 1);
1212 rt2x00usb_register_write(rt2x00dev, MAC_CSR1, reg);
1214 rt2x00usb_register_read(rt2x00dev, MAC_CSR1, ®);
1215 rt2x00_set_field32(®, MAC_CSR1_SOFT_RESET, 0);
1216 rt2x00_set_field32(®, MAC_CSR1_BBP_RESET, 0);
1217 rt2x00usb_register_write(rt2x00dev, MAC_CSR1, reg);
1219 rt2x00usb_register_read(rt2x00dev, MAC_CSR1, ®);
1220 rt2x00_set_field32(®, MAC_CSR1_HOST_READY, 1);
1221 rt2x00usb_register_write(rt2x00dev, MAC_CSR1, reg);
1226 static int rt73usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
1231 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1232 rt73usb_bbp_read(rt2x00dev, 0, &value);
1233 if ((value != 0xff) && (value != 0x00))
1235 udelay(REGISTER_BUSY_DELAY);
1238 ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
1242 static int rt73usb_init_bbp(struct rt2x00_dev *rt2x00dev)
1249 if (unlikely(rt73usb_wait_bbp_ready(rt2x00dev)))
1252 rt73usb_bbp_write(rt2x00dev, 3, 0x80);
1253 rt73usb_bbp_write(rt2x00dev, 15, 0x30);
1254 rt73usb_bbp_write(rt2x00dev, 21, 0xc8);
1255 rt73usb_bbp_write(rt2x00dev, 22, 0x38);
1256 rt73usb_bbp_write(rt2x00dev, 23, 0x06);
1257 rt73usb_bbp_write(rt2x00dev, 24, 0xfe);
1258 rt73usb_bbp_write(rt2x00dev, 25, 0x0a);
1259 rt73usb_bbp_write(rt2x00dev, 26, 0x0d);
1260 rt73usb_bbp_write(rt2x00dev, 32, 0x0b);
1261 rt73usb_bbp_write(rt2x00dev, 34, 0x12);
1262 rt73usb_bbp_write(rt2x00dev, 37, 0x07);
1263 rt73usb_bbp_write(rt2x00dev, 39, 0xf8);
1264 rt73usb_bbp_write(rt2x00dev, 41, 0x60);
1265 rt73usb_bbp_write(rt2x00dev, 53, 0x10);
1266 rt73usb_bbp_write(rt2x00dev, 54, 0x18);
1267 rt73usb_bbp_write(rt2x00dev, 60, 0x10);
1268 rt73usb_bbp_write(rt2x00dev, 61, 0x04);
1269 rt73usb_bbp_write(rt2x00dev, 62, 0x04);
1270 rt73usb_bbp_write(rt2x00dev, 75, 0xfe);
1271 rt73usb_bbp_write(rt2x00dev, 86, 0xfe);
1272 rt73usb_bbp_write(rt2x00dev, 88, 0xfe);
1273 rt73usb_bbp_write(rt2x00dev, 90, 0x0f);
1274 rt73usb_bbp_write(rt2x00dev, 99, 0x00);
1275 rt73usb_bbp_write(rt2x00dev, 102, 0x16);
1276 rt73usb_bbp_write(rt2x00dev, 107, 0x04);
1278 for (i = 0; i < EEPROM_BBP_SIZE; i++) {
1279 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
1281 if (eeprom != 0xffff && eeprom != 0x0000) {
1282 reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
1283 value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
1284 rt73usb_bbp_write(rt2x00dev, reg_id, value);
1292 * Device state switch handlers.
1294 static void rt73usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
1295 enum dev_state state)
1299 rt2x00usb_register_read(rt2x00dev, TXRX_CSR0, ®);
1300 rt2x00_set_field32(®, TXRX_CSR0_DISABLE_RX,
1301 (state == STATE_RADIO_RX_OFF) ||
1302 (state == STATE_RADIO_RX_OFF_LINK));
1303 rt2x00usb_register_write(rt2x00dev, TXRX_CSR0, reg);
1306 static int rt73usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1309 * Initialize all registers.
1311 if (unlikely(rt73usb_init_registers(rt2x00dev) ||
1312 rt73usb_init_bbp(rt2x00dev)))
1318 static void rt73usb_disable_radio(struct rt2x00_dev *rt2x00dev)
1320 rt2x00usb_register_write(rt2x00dev, MAC_CSR10, 0x00001818);
1323 * Disable synchronisation.
1325 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, 0);
1327 rt2x00usb_disable_radio(rt2x00dev);
1330 static int rt73usb_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
1336 put_to_sleep = (state != STATE_AWAKE);
1338 rt2x00usb_register_read(rt2x00dev, MAC_CSR12, ®);
1339 rt2x00_set_field32(®, MAC_CSR12_FORCE_WAKEUP, !put_to_sleep);
1340 rt2x00_set_field32(®, MAC_CSR12_PUT_TO_SLEEP, put_to_sleep);
1341 rt2x00usb_register_write(rt2x00dev, MAC_CSR12, reg);
1344 * Device is not guaranteed to be in the requested state yet.
1345 * We must wait until the register indicates that the
1346 * device has entered the correct state.
1348 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1349 rt2x00usb_register_read(rt2x00dev, MAC_CSR12, ®);
1350 state = rt2x00_get_field32(reg, MAC_CSR12_BBP_CURRENT_STATE);
1351 if (state == !put_to_sleep)
1359 static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1360 enum dev_state state)
1365 case STATE_RADIO_ON:
1366 retval = rt73usb_enable_radio(rt2x00dev);
1368 case STATE_RADIO_OFF:
1369 rt73usb_disable_radio(rt2x00dev);
1371 case STATE_RADIO_RX_ON:
1372 case STATE_RADIO_RX_ON_LINK:
1373 case STATE_RADIO_RX_OFF:
1374 case STATE_RADIO_RX_OFF_LINK:
1375 rt73usb_toggle_rx(rt2x00dev, state);
1377 case STATE_RADIO_IRQ_ON:
1378 case STATE_RADIO_IRQ_OFF:
1379 /* No support, but no error either */
1381 case STATE_DEEP_SLEEP:
1385 retval = rt73usb_set_state(rt2x00dev, state);
1392 if (unlikely(retval))
1393 ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
1400 * TX descriptor initialization
1402 static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1403 struct sk_buff *skb,
1404 struct txentry_desc *txdesc)
1406 struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1407 __le32 *txd = skbdesc->desc;
1411 * Start writing the descriptor words.
1413 rt2x00_desc_read(txd, 1, &word);
1414 rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->queue);
1415 rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs);
1416 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min);
1417 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max);
1418 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset);
1419 rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE,
1420 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags));
1421 rt2x00_desc_write(txd, 1, word);
1423 rt2x00_desc_read(txd, 2, &word);
1424 rt2x00_set_field32(&word, TXD_W2_PLCP_SIGNAL, txdesc->signal);
1425 rt2x00_set_field32(&word, TXD_W2_PLCP_SERVICE, txdesc->service);
1426 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_LOW, txdesc->length_low);
1427 rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_HIGH, txdesc->length_high);
1428 rt2x00_desc_write(txd, 2, word);
1430 if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags)) {
1431 _rt2x00_desc_write(txd, 3, skbdesc->iv);
1432 _rt2x00_desc_write(txd, 4, skbdesc->eiv);
1435 rt2x00_desc_read(txd, 5, &word);
1436 rt2x00_set_field32(&word, TXD_W5_TX_POWER,
1437 TXPOWER_TO_DEV(rt2x00dev->tx_power));
1438 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
1439 rt2x00_desc_write(txd, 5, word);
1441 rt2x00_desc_read(txd, 0, &word);
1442 rt2x00_set_field32(&word, TXD_W0_BURST,
1443 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1444 rt2x00_set_field32(&word, TXD_W0_VALID, 1);
1445 rt2x00_set_field32(&word, TXD_W0_MORE_FRAG,
1446 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1447 rt2x00_set_field32(&word, TXD_W0_ACK,
1448 test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1449 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1450 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1451 rt2x00_set_field32(&word, TXD_W0_OFDM,
1452 test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags));
1453 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1454 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
1455 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
1456 rt2x00_set_field32(&word, TXD_W0_TKIP_MIC,
1457 test_bit(ENTRY_TXD_ENCRYPT_MMIC, &txdesc->flags));
1458 rt2x00_set_field32(&word, TXD_W0_KEY_TABLE,
1459 test_bit(ENTRY_TXD_ENCRYPT_PAIRWISE, &txdesc->flags));
1460 rt2x00_set_field32(&word, TXD_W0_KEY_INDEX, txdesc->key_idx);
1461 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len);
1462 rt2x00_set_field32(&word, TXD_W0_BURST2,
1463 test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1464 rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher);
1465 rt2x00_desc_write(txd, 0, word);
1469 * TX data initialization
1471 static void rt73usb_write_beacon(struct queue_entry *entry)
1473 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1474 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1475 unsigned int beacon_base;
1479 * Add the descriptor in front of the skb.
1481 skb_push(entry->skb, entry->queue->desc_size);
1482 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1483 skbdesc->desc = entry->skb->data;
1486 * Disable beaconing while we are reloading the beacon data,
1487 * otherwise we might be sending out invalid data.
1489 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, ®);
1490 rt2x00_set_field32(®, TXRX_CSR9_TSF_TICKING, 0);
1491 rt2x00_set_field32(®, TXRX_CSR9_TBTT_ENABLE, 0);
1492 rt2x00_set_field32(®, TXRX_CSR9_BEACON_GEN, 0);
1493 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1496 * Write entire beacon with descriptor to register.
1498 beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1499 rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
1500 USB_VENDOR_REQUEST_OUT, beacon_base,
1501 entry->skb->data, entry->skb->len,
1502 REGISTER_TIMEOUT32(entry->skb->len));
1505 * Clean up the beacon skb.
1507 dev_kfree_skb(entry->skb);
1511 static int rt73usb_get_tx_data_len(struct queue_entry *entry)
1516 * The length _must_ be a multiple of 4,
1517 * but it must _not_ be a multiple of the USB packet size.
1519 length = roundup(entry->skb->len, 4);
1520 length += (4 * !(length % entry->queue->usb_maxpacket));
1525 static void rt73usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1526 const enum data_queue_qid queue)
1530 if (queue != QID_BEACON) {
1531 rt2x00usb_kick_tx_queue(rt2x00dev, queue);
1536 * For Wi-Fi faily generated beacons between participating stations.
1537 * Set TBTT phase adaptive adjustment step to 8us (default 16us)
1539 rt2x00usb_register_write(rt2x00dev, TXRX_CSR10, 0x00001008);
1541 rt2x00usb_register_read(rt2x00dev, TXRX_CSR9, ®);
1542 if (!rt2x00_get_field32(reg, TXRX_CSR9_BEACON_GEN)) {
1543 rt2x00_set_field32(®, TXRX_CSR9_TSF_TICKING, 1);
1544 rt2x00_set_field32(®, TXRX_CSR9_TBTT_ENABLE, 1);
1545 rt2x00_set_field32(®, TXRX_CSR9_BEACON_GEN, 1);
1546 rt2x00usb_register_write(rt2x00dev, TXRX_CSR9, reg);
1551 * RX control handlers
1553 static int rt73usb_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1555 u8 offset = rt2x00dev->lna_gain;
1558 lna = rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_LNA);
1573 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) {
1574 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) {
1575 if (lna == 3 || lna == 2)
1585 return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset;
1588 static void rt73usb_fill_rxdone(struct queue_entry *entry,
1589 struct rxdone_entry_desc *rxdesc)
1591 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1592 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1593 __le32 *rxd = (__le32 *)entry->skb->data;
1598 * Copy descriptor to the skbdesc->desc buffer, making it safe from moving of
1599 * frame data in rt2x00usb.
1601 memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
1602 rxd = (__le32 *)skbdesc->desc;
1605 * It is now safe to read the descriptor on all architectures.
1607 rt2x00_desc_read(rxd, 0, &word0);
1608 rt2x00_desc_read(rxd, 1, &word1);
1610 if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR))
1611 rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
1613 if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
1615 rt2x00_get_field32(word0, RXD_W0_CIPHER_ALG);
1616 rxdesc->cipher_status =
1617 rt2x00_get_field32(word0, RXD_W0_CIPHER_ERROR);
1620 if (rxdesc->cipher != CIPHER_NONE) {
1621 _rt2x00_desc_read(rxd, 2, &rxdesc->iv);
1622 _rt2x00_desc_read(rxd, 3, &rxdesc->eiv);
1623 _rt2x00_desc_read(rxd, 4, &rxdesc->icv);
1626 * Hardware has stripped IV/EIV data from 802.11 frame during
1627 * decryption. It has provided the data seperately but rt2x00lib
1628 * should decide if it should be reinserted.
1630 rxdesc->flags |= RX_FLAG_IV_STRIPPED;
1633 * FIXME: Legacy driver indicates that the frame does
1634 * contain the Michael Mic. Unfortunately, in rt2x00
1635 * the MIC seems to be missing completely...
1637 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
1639 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
1640 rxdesc->flags |= RX_FLAG_DECRYPTED;
1641 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
1642 rxdesc->flags |= RX_FLAG_MMIC_ERROR;
1646 * Obtain the status about this packet.
1647 * When frame was received with an OFDM bitrate,
1648 * the signal is the PLCP value. If it was received with
1649 * a CCK bitrate the signal is the rate in 100kbit/s.
1651 rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL);
1652 rxdesc->rssi = rt73usb_agc_to_rssi(rt2x00dev, word1);
1653 rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT);
1655 if (rt2x00_get_field32(word0, RXD_W0_OFDM))
1656 rxdesc->dev_flags |= RXDONE_SIGNAL_PLCP;
1658 rxdesc->dev_flags |= RXDONE_SIGNAL_BITRATE;
1659 if (rt2x00_get_field32(word0, RXD_W0_MY_BSS))
1660 rxdesc->dev_flags |= RXDONE_MY_BSS;
1663 * Set skb pointers, and update frame information.
1665 skb_pull(entry->skb, entry->queue->desc_size);
1666 skb_trim(entry->skb, rxdesc->size);
1670 * Device probe functions.
1672 static int rt73usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1678 rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
1681 * Start validation of the data that has been read.
1683 mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1684 if (!is_valid_ether_addr(mac)) {
1685 random_ether_addr(mac);
1686 EEPROM(rt2x00dev, "MAC: %pM\n", mac);
1689 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
1690 if (word == 0xffff) {
1691 rt2x00_set_field16(&word, EEPROM_ANTENNA_NUM, 2);
1692 rt2x00_set_field16(&word, EEPROM_ANTENNA_TX_DEFAULT,
1694 rt2x00_set_field16(&word, EEPROM_ANTENNA_RX_DEFAULT,
1696 rt2x00_set_field16(&word, EEPROM_ANTENNA_FRAME_TYPE, 0);
1697 rt2x00_set_field16(&word, EEPROM_ANTENNA_DYN_TXAGC, 0);
1698 rt2x00_set_field16(&word, EEPROM_ANTENNA_HARDWARE_RADIO, 0);
1699 rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF5226);
1700 rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
1701 EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
1704 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
1705 if (word == 0xffff) {
1706 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA, 0);
1707 rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
1708 EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
1711 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &word);
1712 if (word == 0xffff) {
1713 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_RDY_G, 0);
1714 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_RDY_A, 0);
1715 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_ACT, 0);
1716 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_GPIO_0, 0);
1717 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_GPIO_1, 0);
1718 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_GPIO_2, 0);
1719 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_GPIO_3, 0);
1720 rt2x00_set_field16(&word, EEPROM_LED_POLARITY_GPIO_4, 0);
1721 rt2x00_set_field16(&word, EEPROM_LED_LED_MODE,
1723 rt2x00_eeprom_write(rt2x00dev, EEPROM_LED, word);
1724 EEPROM(rt2x00dev, "Led: 0x%04x\n", word);
1727 rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
1728 if (word == 0xffff) {
1729 rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
1730 rt2x00_set_field16(&word, EEPROM_FREQ_SEQ, 0);
1731 rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
1732 EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
1735 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_BG, &word);
1736 if (word == 0xffff) {
1737 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_BG_1, 0);
1738 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_BG_2, 0);
1739 rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_OFFSET_BG, word);
1740 EEPROM(rt2x00dev, "RSSI OFFSET BG: 0x%04x\n", word);
1742 value = rt2x00_get_field16(word, EEPROM_RSSI_OFFSET_BG_1);
1743 if (value < -10 || value > 10)
1744 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_BG_1, 0);
1745 value = rt2x00_get_field16(word, EEPROM_RSSI_OFFSET_BG_2);
1746 if (value < -10 || value > 10)
1747 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_BG_2, 0);
1748 rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_OFFSET_BG, word);
1751 rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_OFFSET_A, &word);
1752 if (word == 0xffff) {
1753 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_A_1, 0);
1754 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_A_2, 0);
1755 rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_OFFSET_A, word);
1756 EEPROM(rt2x00dev, "RSSI OFFSET A: 0x%04x\n", word);
1758 value = rt2x00_get_field16(word, EEPROM_RSSI_OFFSET_A_1);
1759 if (value < -10 || value > 10)
1760 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_A_1, 0);
1761 value = rt2x00_get_field16(word, EEPROM_RSSI_OFFSET_A_2);
1762 if (value < -10 || value > 10)
1763 rt2x00_set_field16(&word, EEPROM_RSSI_OFFSET_A_2, 0);
1764 rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_OFFSET_A, word);
1770 static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1777 * Read EEPROM word for configuration.
1779 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
1782 * Identify RF chipset.
1784 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
1785 rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
1786 rt2x00_set_chip(rt2x00dev, RT2571, value, reg);
1788 if (!rt2x00_check_rev(&rt2x00dev->chip, 0x25730)) {
1789 ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
1793 if (!rt2x00_rf(&rt2x00dev->chip, RF5226) &&
1794 !rt2x00_rf(&rt2x00dev->chip, RF2528) &&
1795 !rt2x00_rf(&rt2x00dev->chip, RF5225) &&
1796 !rt2x00_rf(&rt2x00dev->chip, RF2527)) {
1797 ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
1802 * Identify default antenna configuration.
1804 rt2x00dev->default_ant.tx =
1805 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
1806 rt2x00dev->default_ant.rx =
1807 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
1810 * Read the Frame type.
1812 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_FRAME_TYPE))
1813 __set_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags);
1816 * Read frequency offset.
1818 rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
1819 rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
1822 * Read external LNA informations.
1824 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
1826 if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA)) {
1827 __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
1828 __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
1832 * Store led settings, for correct led behaviour.
1834 #ifdef CONFIG_RT2X00_LIB_LEDS
1835 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
1837 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1838 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
1839 if (value == LED_MODE_SIGNAL_STRENGTH)
1840 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1843 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value);
1844 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0,
1845 rt2x00_get_field16(eeprom,
1846 EEPROM_LED_POLARITY_GPIO_0));
1847 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_1,
1848 rt2x00_get_field16(eeprom,
1849 EEPROM_LED_POLARITY_GPIO_1));
1850 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_2,
1851 rt2x00_get_field16(eeprom,
1852 EEPROM_LED_POLARITY_GPIO_2));
1853 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_3,
1854 rt2x00_get_field16(eeprom,
1855 EEPROM_LED_POLARITY_GPIO_3));
1856 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_4,
1857 rt2x00_get_field16(eeprom,
1858 EEPROM_LED_POLARITY_GPIO_4));
1859 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_ACT,
1860 rt2x00_get_field16(eeprom, EEPROM_LED_POLARITY_ACT));
1861 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_BG,
1862 rt2x00_get_field16(eeprom,
1863 EEPROM_LED_POLARITY_RDY_G));
1864 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_A,
1865 rt2x00_get_field16(eeprom,
1866 EEPROM_LED_POLARITY_RDY_A));
1867 #endif /* CONFIG_RT2X00_LIB_LEDS */
1873 * RF value list for RF2528
1876 static const struct rf_channel rf_vals_bg_2528[] = {
1877 { 1, 0x00002c0c, 0x00000786, 0x00068255, 0x000fea0b },
1878 { 2, 0x00002c0c, 0x00000786, 0x00068255, 0x000fea1f },
1879 { 3, 0x00002c0c, 0x0000078a, 0x00068255, 0x000fea0b },
1880 { 4, 0x00002c0c, 0x0000078a, 0x00068255, 0x000fea1f },
1881 { 5, 0x00002c0c, 0x0000078e, 0x00068255, 0x000fea0b },
1882 { 6, 0x00002c0c, 0x0000078e, 0x00068255, 0x000fea1f },
1883 { 7, 0x00002c0c, 0x00000792, 0x00068255, 0x000fea0b },
1884 { 8, 0x00002c0c, 0x00000792, 0x00068255, 0x000fea1f },
1885 { 9, 0x00002c0c, 0x00000796, 0x00068255, 0x000fea0b },
1886 { 10, 0x00002c0c, 0x00000796, 0x00068255, 0x000fea1f },
1887 { 11, 0x00002c0c, 0x0000079a, 0x00068255, 0x000fea0b },
1888 { 12, 0x00002c0c, 0x0000079a, 0x00068255, 0x000fea1f },
1889 { 13, 0x00002c0c, 0x0000079e, 0x00068255, 0x000fea0b },
1890 { 14, 0x00002c0c, 0x000007a2, 0x00068255, 0x000fea13 },
1894 * RF value list for RF5226
1895 * Supports: 2.4 GHz & 5.2 GHz
1897 static const struct rf_channel rf_vals_5226[] = {
1898 { 1, 0x00002c0c, 0x00000786, 0x00068255, 0x000fea0b },
1899 { 2, 0x00002c0c, 0x00000786, 0x00068255, 0x000fea1f },
1900 { 3, 0x00002c0c, 0x0000078a, 0x00068255, 0x000fea0b },
1901 { 4, 0x00002c0c, 0x0000078a, 0x00068255, 0x000fea1f },
1902 { 5, 0x00002c0c, 0x0000078e, 0x00068255, 0x000fea0b },
1903 { 6, 0x00002c0c, 0x0000078e, 0x00068255, 0x000fea1f },
1904 { 7, 0x00002c0c, 0x00000792, 0x00068255, 0x000fea0b },
1905 { 8, 0x00002c0c, 0x00000792, 0x00068255, 0x000fea1f },
1906 { 9, 0x00002c0c, 0x00000796, 0x00068255, 0x000fea0b },
1907 { 10, 0x00002c0c, 0x00000796, 0x00068255, 0x000fea1f },
1908 { 11, 0x00002c0c, 0x0000079a, 0x00068255, 0x000fea0b },
1909 { 12, 0x00002c0c, 0x0000079a, 0x00068255, 0x000fea1f },
1910 { 13, 0x00002c0c, 0x0000079e, 0x00068255, 0x000fea0b },
1911 { 14, 0x00002c0c, 0x000007a2, 0x00068255, 0x000fea13 },
1913 /* 802.11 UNI / HyperLan 2 */
1914 { 36, 0x00002c0c, 0x0000099a, 0x00098255, 0x000fea23 },
1915 { 40, 0x00002c0c, 0x000009a2, 0x00098255, 0x000fea03 },
1916 { 44, 0x00002c0c, 0x000009a6, 0x00098255, 0x000fea0b },
1917 { 48, 0x00002c0c, 0x000009aa, 0x00098255, 0x000fea13 },
1918 { 52, 0x00002c0c, 0x000009ae, 0x00098255, 0x000fea1b },
1919 { 56, 0x00002c0c, 0x000009b2, 0x00098255, 0x000fea23 },
1920 { 60, 0x00002c0c, 0x000009ba, 0x00098255, 0x000fea03 },
1921 { 64, 0x00002c0c, 0x000009be, 0x00098255, 0x000fea0b },
1923 /* 802.11 HyperLan 2 */
1924 { 100, 0x00002c0c, 0x00000a2a, 0x000b8255, 0x000fea03 },
1925 { 104, 0x00002c0c, 0x00000a2e, 0x000b8255, 0x000fea0b },
1926 { 108, 0x00002c0c, 0x00000a32, 0x000b8255, 0x000fea13 },
1927 { 112, 0x00002c0c, 0x00000a36, 0x000b8255, 0x000fea1b },
1928 { 116, 0x00002c0c, 0x00000a3a, 0x000b8255, 0x000fea23 },
1929 { 120, 0x00002c0c, 0x00000a82, 0x000b8255, 0x000fea03 },
1930 { 124, 0x00002c0c, 0x00000a86, 0x000b8255, 0x000fea0b },
1931 { 128, 0x00002c0c, 0x00000a8a, 0x000b8255, 0x000fea13 },
1932 { 132, 0x00002c0c, 0x00000a8e, 0x000b8255, 0x000fea1b },
1933 { 136, 0x00002c0c, 0x00000a92, 0x000b8255, 0x000fea23 },
1936 { 140, 0x00002c0c, 0x00000a9a, 0x000b8255, 0x000fea03 },
1937 { 149, 0x00002c0c, 0x00000aa2, 0x000b8255, 0x000fea1f },
1938 { 153, 0x00002c0c, 0x00000aa6, 0x000b8255, 0x000fea27 },
1939 { 157, 0x00002c0c, 0x00000aae, 0x000b8255, 0x000fea07 },
1940 { 161, 0x00002c0c, 0x00000ab2, 0x000b8255, 0x000fea0f },
1941 { 165, 0x00002c0c, 0x00000ab6, 0x000b8255, 0x000fea17 },
1943 /* MMAC(Japan)J52 ch 34,38,42,46 */
1944 { 34, 0x00002c0c, 0x0008099a, 0x000da255, 0x000d3a0b },
1945 { 38, 0x00002c0c, 0x0008099e, 0x000da255, 0x000d3a13 },
1946 { 42, 0x00002c0c, 0x000809a2, 0x000da255, 0x000d3a1b },
1947 { 46, 0x00002c0c, 0x000809a6, 0x000da255, 0x000d3a23 },
1951 * RF value list for RF5225 & RF2527
1952 * Supports: 2.4 GHz & 5.2 GHz
1954 static const struct rf_channel rf_vals_5225_2527[] = {
1955 { 1, 0x00002ccc, 0x00004786, 0x00068455, 0x000ffa0b },
1956 { 2, 0x00002ccc, 0x00004786, 0x00068455, 0x000ffa1f },
1957 { 3, 0x00002ccc, 0x0000478a, 0x00068455, 0x000ffa0b },
1958 { 4, 0x00002ccc, 0x0000478a, 0x00068455, 0x000ffa1f },
1959 { 5, 0x00002ccc, 0x0000478e, 0x00068455, 0x000ffa0b },
1960 { 6, 0x00002ccc, 0x0000478e, 0x00068455, 0x000ffa1f },
1961 { 7, 0x00002ccc, 0x00004792, 0x00068455, 0x000ffa0b },
1962 { 8, 0x00002ccc, 0x00004792, 0x00068455, 0x000ffa1f },
1963 { 9, 0x00002ccc, 0x00004796, 0x00068455, 0x000ffa0b },
1964 { 10, 0x00002ccc, 0x00004796, 0x00068455, 0x000ffa1f },
1965 { 11, 0x00002ccc, 0x0000479a, 0x00068455, 0x000ffa0b },
1966 { 12, 0x00002ccc, 0x0000479a, 0x00068455, 0x000ffa1f },
1967 { 13, 0x00002ccc, 0x0000479e, 0x00068455, 0x000ffa0b },
1968 { 14, 0x00002ccc, 0x000047a2, 0x00068455, 0x000ffa13 },
1970 /* 802.11 UNI / HyperLan 2 */
1971 { 36, 0x00002ccc, 0x0000499a, 0x0009be55, 0x000ffa23 },
1972 { 40, 0x00002ccc, 0x000049a2, 0x0009be55, 0x000ffa03 },
1973 { 44, 0x00002ccc, 0x000049a6, 0x0009be55, 0x000ffa0b },
1974 { 48, 0x00002ccc, 0x000049aa, 0x0009be55, 0x000ffa13 },
1975 { 52, 0x00002ccc, 0x000049ae, 0x0009ae55, 0x000ffa1b },
1976 { 56, 0x00002ccc, 0x000049b2, 0x0009ae55, 0x000ffa23 },
1977 { 60, 0x00002ccc, 0x000049ba, 0x0009ae55, 0x000ffa03 },
1978 { 64, 0x00002ccc, 0x000049be, 0x0009ae55, 0x000ffa0b },
1980 /* 802.11 HyperLan 2 */
1981 { 100, 0x00002ccc, 0x00004a2a, 0x000bae55, 0x000ffa03 },
1982 { 104, 0x00002ccc, 0x00004a2e, 0x000bae55, 0x000ffa0b },
1983 { 108, 0x00002ccc, 0x00004a32, 0x000bae55, 0x000ffa13 },
1984 { 112, 0x00002ccc, 0x00004a36, 0x000bae55, 0x000ffa1b },
1985 { 116, 0x00002ccc, 0x00004a3a, 0x000bbe55, 0x000ffa23 },
1986 { 120, 0x00002ccc, 0x00004a82, 0x000bbe55, 0x000ffa03 },
1987 { 124, 0x00002ccc, 0x00004a86, 0x000bbe55, 0x000ffa0b },
1988 { 128, 0x00002ccc, 0x00004a8a, 0x000bbe55, 0x000ffa13 },
1989 { 132, 0x00002ccc, 0x00004a8e, 0x000bbe55, 0x000ffa1b },
1990 { 136, 0x00002ccc, 0x00004a92, 0x000bbe55, 0x000ffa23 },
1993 { 140, 0x00002ccc, 0x00004a9a, 0x000bbe55, 0x000ffa03 },
1994 { 149, 0x00002ccc, 0x00004aa2, 0x000bbe55, 0x000ffa1f },
1995 { 153, 0x00002ccc, 0x00004aa6, 0x000bbe55, 0x000ffa27 },
1996 { 157, 0x00002ccc, 0x00004aae, 0x000bbe55, 0x000ffa07 },
1997 { 161, 0x00002ccc, 0x00004ab2, 0x000bbe55, 0x000ffa0f },
1998 { 165, 0x00002ccc, 0x00004ab6, 0x000bbe55, 0x000ffa17 },
2000 /* MMAC(Japan)J52 ch 34,38,42,46 */
2001 { 34, 0x00002ccc, 0x0000499a, 0x0009be55, 0x000ffa0b },
2002 { 38, 0x00002ccc, 0x0000499e, 0x0009be55, 0x000ffa13 },
2003 { 42, 0x00002ccc, 0x000049a2, 0x0009be55, 0x000ffa1b },
2004 { 46, 0x00002ccc, 0x000049a6, 0x0009be55, 0x000ffa23 },
2008 static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2010 struct hw_mode_spec *spec = &rt2x00dev->spec;
2011 struct channel_info *info;
2016 * Initialize all hw fields.
2018 rt2x00dev->hw->flags =
2019 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
2020 IEEE80211_HW_SIGNAL_DBM;
2021 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
2023 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
2024 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
2025 rt2x00_eeprom_addr(rt2x00dev,
2026 EEPROM_MAC_ADDR_0));
2029 * Initialize hw_mode information.
2031 spec->supported_bands = SUPPORT_BAND_2GHZ;
2032 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
2034 if (rt2x00_rf(&rt2x00dev->chip, RF2528)) {
2035 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2528);
2036 spec->channels = rf_vals_bg_2528;
2037 } else if (rt2x00_rf(&rt2x00dev->chip, RF5226)) {
2038 spec->supported_bands |= SUPPORT_BAND_5GHZ;
2039 spec->num_channels = ARRAY_SIZE(rf_vals_5226);
2040 spec->channels = rf_vals_5226;
2041 } else if (rt2x00_rf(&rt2x00dev->chip, RF2527)) {
2042 spec->num_channels = 14;
2043 spec->channels = rf_vals_5225_2527;
2044 } else if (rt2x00_rf(&rt2x00dev->chip, RF5225)) {
2045 spec->supported_bands |= SUPPORT_BAND_5GHZ;
2046 spec->num_channels = ARRAY_SIZE(rf_vals_5225_2527);
2047 spec->channels = rf_vals_5225_2527;
2051 * Create channel information array
2053 info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
2057 spec->channels_info = info;
2059 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_G_START);
2060 for (i = 0; i < 14; i++)
2061 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);
2063 if (spec->num_channels > 14) {
2064 tx_power = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A_START);
2065 for (i = 14; i < spec->num_channels; i++)
2066 info[i].tx_power1 = TXPOWER_FROM_DEV(tx_power[i]);
2072 static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
2077 * Allocate eeprom data.
2079 retval = rt73usb_validate_eeprom(rt2x00dev);
2083 retval = rt73usb_init_eeprom(rt2x00dev);
2088 * Initialize hw specifications.
2090 retval = rt73usb_probe_hw_mode(rt2x00dev);
2095 * This device requires firmware.
2097 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
2098 __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
2099 if (!modparam_nohwcrypt)
2100 __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);
2103 * Set the rssi offset.
2105 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
2111 * IEEE80211 stack callback functions.
2113 static int rt73usb_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2114 const struct ieee80211_tx_queue_params *params)
2116 struct rt2x00_dev *rt2x00dev = hw->priv;
2117 struct data_queue *queue;
2118 struct rt2x00_field32 field;
2123 * First pass the configuration through rt2x00lib, that will
2124 * update the queue settings and validate the input. After that
2125 * we are free to update the registers based on the value
2126 * in the queue parameter.
2128 retval = rt2x00mac_conf_tx(hw, queue_idx, params);
2132 queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
2134 /* Update WMM TXOP register */
2135 if (queue_idx < 2) {
2136 field.bit_offset = queue_idx * 16;
2137 field.bit_mask = 0xffff << field.bit_offset;
2139 rt2x00usb_register_read(rt2x00dev, AC_TXOP_CSR0, ®);
2140 rt2x00_set_field32(®, field, queue->txop);
2141 rt2x00usb_register_write(rt2x00dev, AC_TXOP_CSR0, reg);
2142 } else if (queue_idx < 4) {
2143 field.bit_offset = (queue_idx - 2) * 16;
2144 field.bit_mask = 0xffff << field.bit_offset;
2146 rt2x00usb_register_read(rt2x00dev, AC_TXOP_CSR1, ®);
2147 rt2x00_set_field32(®, field, queue->txop);
2148 rt2x00usb_register_write(rt2x00dev, AC_TXOP_CSR1, reg);
2151 /* Update WMM registers */
2152 field.bit_offset = queue_idx * 4;
2153 field.bit_mask = 0xf << field.bit_offset;
2155 rt2x00usb_register_read(rt2x00dev, AIFSN_CSR, ®);
2156 rt2x00_set_field32(®, field, queue->aifs);
2157 rt2x00usb_register_write(rt2x00dev, AIFSN_CSR, reg);
2159 rt2x00usb_register_read(rt2x00dev, CWMIN_CSR, ®);
2160 rt2x00_set_field32(®, field, queue->cw_min);
2161 rt2x00usb_register_write(rt2x00dev, CWMIN_CSR, reg);
2163 rt2x00usb_register_read(rt2x00dev, CWMAX_CSR, ®);
2164 rt2x00_set_field32(®, field, queue->cw_max);
2165 rt2x00usb_register_write(rt2x00dev, CWMAX_CSR, reg);
2172 * Mac80211 demands get_tsf must be atomic.
2173 * This is not possible for rt73usb since all register access
2174 * functions require sleeping. Untill mac80211 no longer needs
2175 * get_tsf to be atomic, this function should be disabled.
2177 static u64 rt73usb_get_tsf(struct ieee80211_hw *hw)
2179 struct rt2x00_dev *rt2x00dev = hw->priv;
2183 rt2x00usb_register_read(rt2x00dev, TXRX_CSR13, ®);
2184 tsf = (u64) rt2x00_get_field32(reg, TXRX_CSR13_HIGH_TSFTIMER) << 32;
2185 rt2x00usb_register_read(rt2x00dev, TXRX_CSR12, ®);
2186 tsf |= rt2x00_get_field32(reg, TXRX_CSR12_LOW_TSFTIMER);
2191 #define rt73usb_get_tsf NULL
2194 static const struct ieee80211_ops rt73usb_mac80211_ops = {
2196 .start = rt2x00mac_start,
2197 .stop = rt2x00mac_stop,
2198 .add_interface = rt2x00mac_add_interface,
2199 .remove_interface = rt2x00mac_remove_interface,
2200 .config = rt2x00mac_config,
2201 .config_interface = rt2x00mac_config_interface,
2202 .configure_filter = rt2x00mac_configure_filter,
2203 .set_key = rt2x00mac_set_key,
2204 .get_stats = rt2x00mac_get_stats,
2205 .bss_info_changed = rt2x00mac_bss_info_changed,
2206 .conf_tx = rt73usb_conf_tx,
2207 .get_tx_stats = rt2x00mac_get_tx_stats,
2208 .get_tsf = rt73usb_get_tsf,
2211 static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2212 .probe_hw = rt73usb_probe_hw,
2213 .get_firmware_name = rt73usb_get_firmware_name,
2214 .get_firmware_crc = rt73usb_get_firmware_crc,
2215 .load_firmware = rt73usb_load_firmware,
2216 .initialize = rt2x00usb_initialize,
2217 .uninitialize = rt2x00usb_uninitialize,
2218 .clear_entry = rt2x00usb_clear_entry,
2219 .set_device_state = rt73usb_set_device_state,
2220 .link_stats = rt73usb_link_stats,
2221 .reset_tuner = rt73usb_reset_tuner,
2222 .link_tuner = rt73usb_link_tuner,
2223 .write_tx_desc = rt73usb_write_tx_desc,
2224 .write_tx_data = rt2x00usb_write_tx_data,
2225 .write_beacon = rt73usb_write_beacon,
2226 .get_tx_data_len = rt73usb_get_tx_data_len,
2227 .kick_tx_queue = rt73usb_kick_tx_queue,
2228 .fill_rxdone = rt73usb_fill_rxdone,
2229 .config_shared_key = rt73usb_config_shared_key,
2230 .config_pairwise_key = rt73usb_config_pairwise_key,
2231 .config_filter = rt73usb_config_filter,
2232 .config_intf = rt73usb_config_intf,
2233 .config_erp = rt73usb_config_erp,
2234 .config_ant = rt73usb_config_ant,
2235 .config = rt73usb_config,
2238 static const struct data_queue_desc rt73usb_queue_rx = {
2239 .entry_num = RX_ENTRIES,
2240 .data_size = DATA_FRAME_SIZE,
2241 .desc_size = RXD_DESC_SIZE,
2242 .priv_size = sizeof(struct queue_entry_priv_usb),
2245 static const struct data_queue_desc rt73usb_queue_tx = {
2246 .entry_num = TX_ENTRIES,
2247 .data_size = DATA_FRAME_SIZE,
2248 .desc_size = TXD_DESC_SIZE,
2249 .priv_size = sizeof(struct queue_entry_priv_usb),
2252 static const struct data_queue_desc rt73usb_queue_bcn = {
2253 .entry_num = 4 * BEACON_ENTRIES,
2254 .data_size = MGMT_FRAME_SIZE,
2255 .desc_size = TXINFO_SIZE,
2256 .priv_size = sizeof(struct queue_entry_priv_usb),
2259 static const struct rt2x00_ops rt73usb_ops = {
2260 .name = KBUILD_MODNAME,
2263 .eeprom_size = EEPROM_SIZE,
2265 .tx_queues = NUM_TX_QUEUES,
2266 .rx = &rt73usb_queue_rx,
2267 .tx = &rt73usb_queue_tx,
2268 .bcn = &rt73usb_queue_bcn,
2269 .lib = &rt73usb_rt2x00_ops,
2270 .hw = &rt73usb_mac80211_ops,
2271 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
2272 .debugfs = &rt73usb_rt2x00debug,
2273 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
2277 * rt73usb module information.
2279 static struct usb_device_id rt73usb_device_table[] = {
2281 { USB_DEVICE(0x07b8, 0xb21d), USB_DEVICE_DATA(&rt73usb_ops) },
2283 { USB_DEVICE(0x1690, 0x0722), USB_DEVICE_DATA(&rt73usb_ops) },
2285 { USB_DEVICE(0x0b05, 0x1723), USB_DEVICE_DATA(&rt73usb_ops) },
2286 { USB_DEVICE(0x0b05, 0x1724), USB_DEVICE_DATA(&rt73usb_ops) },
2288 { USB_DEVICE(0x050d, 0x7050), USB_DEVICE_DATA(&rt73usb_ops) },
2289 { USB_DEVICE(0x050d, 0x705a), USB_DEVICE_DATA(&rt73usb_ops) },
2290 { USB_DEVICE(0x050d, 0x905b), USB_DEVICE_DATA(&rt73usb_ops) },
2291 { USB_DEVICE(0x050d, 0x905c), USB_DEVICE_DATA(&rt73usb_ops) },
2293 { USB_DEVICE(0x1631, 0xc019), USB_DEVICE_DATA(&rt73usb_ops) },
2295 { USB_DEVICE(0x0411, 0x00f4), USB_DEVICE_DATA(&rt73usb_ops) },
2297 { USB_DEVICE(0x1371, 0x9022), USB_DEVICE_DATA(&rt73usb_ops) },
2298 { USB_DEVICE(0x1371, 0x9032), USB_DEVICE_DATA(&rt73usb_ops) },
2300 { USB_DEVICE(0x14b2, 0x3c22), USB_DEVICE_DATA(&rt73usb_ops) },
2302 { USB_DEVICE(0x07aa, 0x002e), USB_DEVICE_DATA(&rt73usb_ops) },
2304 { USB_DEVICE(0x07d1, 0x3c03), USB_DEVICE_DATA(&rt73usb_ops) },
2305 { USB_DEVICE(0x07d1, 0x3c04), USB_DEVICE_DATA(&rt73usb_ops) },
2306 { USB_DEVICE(0x07d1, 0x3c06), USB_DEVICE_DATA(&rt73usb_ops) },
2307 { USB_DEVICE(0x07d1, 0x3c07), USB_DEVICE_DATA(&rt73usb_ops) },
2309 { USB_DEVICE(0x15a9, 0x0004), USB_DEVICE_DATA(&rt73usb_ops) },
2311 { USB_DEVICE(0x1044, 0x8008), USB_DEVICE_DATA(&rt73usb_ops) },
2312 { USB_DEVICE(0x1044, 0x800a), USB_DEVICE_DATA(&rt73usb_ops) },
2314 { USB_DEVICE(0x1472, 0x0009), USB_DEVICE_DATA(&rt73usb_ops) },
2316 { USB_DEVICE(0x06f8, 0xe010), USB_DEVICE_DATA(&rt73usb_ops) },
2317 { USB_DEVICE(0x06f8, 0xe020), USB_DEVICE_DATA(&rt73usb_ops) },
2319 { USB_DEVICE(0x13b1, 0x0020), USB_DEVICE_DATA(&rt73usb_ops) },
2320 { USB_DEVICE(0x13b1, 0x0023), USB_DEVICE_DATA(&rt73usb_ops) },
2322 { USB_DEVICE(0x0db0, 0x6877), USB_DEVICE_DATA(&rt73usb_ops) },
2323 { USB_DEVICE(0x0db0, 0x6874), USB_DEVICE_DATA(&rt73usb_ops) },
2324 { USB_DEVICE(0x0db0, 0xa861), USB_DEVICE_DATA(&rt73usb_ops) },
2325 { USB_DEVICE(0x0db0, 0xa874), USB_DEVICE_DATA(&rt73usb_ops) },
2327 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) },
2328 { USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) },
2330 { USB_DEVICE(0x18e8, 0x6196), USB_DEVICE_DATA(&rt73usb_ops) },
2331 { USB_DEVICE(0x18e8, 0x6229), USB_DEVICE_DATA(&rt73usb_ops) },
2332 { USB_DEVICE(0x18e8, 0x6238), USB_DEVICE_DATA(&rt73usb_ops) },
2334 { USB_DEVICE(0x1740, 0x7100), USB_DEVICE_DATA(&rt73usb_ops) },
2336 { USB_DEVICE(0x0df6, 0x9712), USB_DEVICE_DATA(&rt73usb_ops) },
2337 { USB_DEVICE(0x0df6, 0x90ac), USB_DEVICE_DATA(&rt73usb_ops) },
2339 { USB_DEVICE(0x0769, 0x31f3), USB_DEVICE_DATA(&rt73usb_ops) },
2341 { USB_DEVICE(0x2019, 0xab01), USB_DEVICE_DATA(&rt73usb_ops) },
2342 { USB_DEVICE(0x2019, 0xab50), USB_DEVICE_DATA(&rt73usb_ops) },
2346 MODULE_AUTHOR(DRV_PROJECT);
2347 MODULE_VERSION(DRV_VERSION);
2348 MODULE_DESCRIPTION("Ralink RT73 USB Wireless LAN driver.");
2349 MODULE_SUPPORTED_DEVICE("Ralink RT2571W & RT2671 USB chipset based cards");
2350 MODULE_DEVICE_TABLE(usb, rt73usb_device_table);
2351 MODULE_FIRMWARE(FIRMWARE_RT2571);
2352 MODULE_LICENSE("GPL");
2354 static struct usb_driver rt73usb_driver = {
2355 .name = KBUILD_MODNAME,
2356 .id_table = rt73usb_device_table,
2357 .probe = rt2x00usb_probe,
2358 .disconnect = rt2x00usb_disconnect,
2359 .suspend = rt2x00usb_suspend,
2360 .resume = rt2x00usb_resume,
2363 static int __init rt73usb_init(void)
2365 return usb_register(&rt73usb_driver);
2368 static void __exit rt73usb_exit(void)
2370 usb_deregister(&rt73usb_driver);
2373 module_init(rt73usb_init);
2374 module_exit(rt73usb_exit);