1 From b249bc450f982cd2491448c91faf797ed37b69b8 Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Tue, 3 Mar 2009 19:25:49 +0100
4 Subject: [PATCH] rt2x00: Implement support for rt2800usb
6 Add support for the rt2800usb chipset.
8 Includes various patches from Mattias, Felix, Xose and Axel.
10 Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
11 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
12 Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
13 Signed-off-by: Axel Kollhofer <rain_maker@root-forum.org>
14 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
16 drivers/net/wireless/rt2x00/Kconfig | 14 +
17 drivers/net/wireless/rt2x00/Makefile | 1 +
18 drivers/net/wireless/rt2x00/rt2800usb.c | 3032 +++++++++++++++++++++++++++++++
19 drivers/net/wireless/rt2x00/rt2800usb.h | 1932 ++++++++++++++++++++
20 drivers/net/wireless/rt2x00/rt2x00.h | 7 +
21 5 files changed, 4986 insertions(+), 0 deletions(-)
22 create mode 100644 drivers/net/wireless/rt2x00/rt2800usb.c
23 create mode 100644 drivers/net/wireless/rt2x00/rt2800usb.h
25 --- a/drivers/net/wireless/rt2x00/Makefile
26 +++ b/drivers/net/wireless/rt2x00/Makefile
27 @@ -19,3 +19,4 @@ obj-$(CONFIG_RT61PCI) += rt61pci.o
28 obj-$(CONFIG_RT2800PCI) += rt2800pci.o
29 obj-$(CONFIG_RT2500USB) += rt2500usb.o
30 obj-$(CONFIG_RT73USB) += rt73usb.o
31 +obj-$(CONFIG_RT2800USB) += rt2800usb.o
33 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
36 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
37 + <http://rt2x00.serialmonkey.com>
39 + This program is free software; you can redistribute it and/or modify
40 + it under the terms of the GNU General Public License as published by
41 + the Free Software Foundation; either version 2 of the License, or
42 + (at your option) any later version.
44 + This program is distributed in the hope that it will be useful,
45 + but WITHOUT ANY WARRANTY; without even the implied warranty of
46 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
47 + GNU General Public License for more details.
49 + You should have received a copy of the GNU General Public License
50 + along with this program; if not, write to the
51 + Free Software Foundation, Inc.,
52 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
57 + Abstract: rt2800usb device specific routines.
58 + Supported chipsets: RT2800U.
61 +#include <linux/crc-ccitt.h>
62 +#include <linux/delay.h>
63 +#include <linux/etherdevice.h>
64 +#include <linux/init.h>
65 +#include <linux/kernel.h>
66 +#include <linux/module.h>
67 +#include <linux/usb.h>
70 +#include "rt2x00usb.h"
71 +#include "rt2800usb.h"
74 + * Allow hardware encryption to be disabled.
76 +static int modparam_nohwcrypt = 0;
77 +module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
78 +MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
82 + * All access to the CSR registers will go through the methods
83 + * rt2x00usb_register_read and rt2x00usb_register_write.
84 + * BBP and RF register require indirect register access,
85 + * and use the CSR registers BBPCSR and RFCSR to achieve this.
86 + * These indirect registers work with busy bits,
87 + * and we will try maximal REGISTER_BUSY_COUNT times to access
88 + * the register while taking a REGISTER_BUSY_DELAY us delay
89 + * between each attampt. When the busy bit is still set at that time,
90 + * the access attempt is considered to have failed,
91 + * and we will print an error.
92 + * The _lock versions must be used if you already hold the csr_mutex
94 +#define WAIT_FOR_BBP(__dev, __reg) \
95 + rt2x00usb_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg))
96 +#define WAIT_FOR_RFCSR(__dev, __reg) \
97 + rt2x00usb_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY, (__reg))
98 +#define WAIT_FOR_RF(__dev, __reg) \
99 + rt2x00usb_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg))
100 +#define WAIT_FOR_MCU(__dev, __reg) \
101 + rt2x00usb_regbusy_read((__dev), H2M_MAILBOX_CSR, \
102 + H2M_MAILBOX_CSR_OWNER, (__reg))
104 +static void rt2800usb_bbp_write(struct rt2x00_dev *rt2x00dev,
105 + const unsigned int word, const u8 value)
109 + mutex_lock(&rt2x00dev->csr_mutex);
112 + * Wait until the BBP becomes available, afterwards we
113 + * can safely write the new data into the register.
115 + if (WAIT_FOR_BBP(rt2x00dev, ®)) {
117 + rt2x00_set_field32(®, BBP_CSR_CFG_VALUE, value);
118 + rt2x00_set_field32(®, BBP_CSR_CFG_REGNUM, word);
119 + rt2x00_set_field32(®, BBP_CSR_CFG_BUSY, 1);
120 + rt2x00_set_field32(®, BBP_CSR_CFG_READ_CONTROL, 0);
122 + rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
125 + mutex_unlock(&rt2x00dev->csr_mutex);
128 +static void rt2800usb_bbp_read(struct rt2x00_dev *rt2x00dev,
129 + const unsigned int word, u8 *value)
133 + mutex_lock(&rt2x00dev->csr_mutex);
136 + * Wait until the BBP becomes available, afterwards we
137 + * can safely write the read request into the register.
138 + * After the data has been written, we wait until hardware
139 + * returns the correct value, if at any time the register
140 + * doesn't become available in time, reg will be 0xffffffff
141 + * which means we return 0xff to the caller.
143 + if (WAIT_FOR_BBP(rt2x00dev, ®)) {
145 + rt2x00_set_field32(®, BBP_CSR_CFG_REGNUM, word);
146 + rt2x00_set_field32(®, BBP_CSR_CFG_BUSY, 1);
147 + rt2x00_set_field32(®, BBP_CSR_CFG_READ_CONTROL, 1);
149 + rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
151 + WAIT_FOR_BBP(rt2x00dev, ®);
154 + *value = rt2x00_get_field32(reg, BBP_CSR_CFG_VALUE);
156 + mutex_unlock(&rt2x00dev->csr_mutex);
159 +static void rt2800usb_rfcsr_write(struct rt2x00_dev *rt2x00dev,
160 + const unsigned int word, const u8 value)
164 + mutex_lock(&rt2x00dev->csr_mutex);
167 + * Wait until the RFCSR becomes available, afterwards we
168 + * can safely write the new data into the register.
170 + if (WAIT_FOR_RFCSR(rt2x00dev, ®)) {
172 + rt2x00_set_field32(®, RF_CSR_CFG_DATA, value);
173 + rt2x00_set_field32(®, RF_CSR_CFG_REGNUM, word);
174 + rt2x00_set_field32(®, RF_CSR_CFG_WRITE, 1);
175 + rt2x00_set_field32(®, RF_CSR_CFG_BUSY, 1);
177 + rt2x00usb_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
180 + mutex_unlock(&rt2x00dev->csr_mutex);
183 +static void rt2800usb_rfcsr_read(struct rt2x00_dev *rt2x00dev,
184 + const unsigned int word, u8 *value)
188 + mutex_lock(&rt2x00dev->csr_mutex);
191 + * Wait until the RFCSR becomes available, afterwards we
192 + * can safely write the read request into the register.
193 + * After the data has been written, we wait until hardware
194 + * returns the correct value, if at any time the register
195 + * doesn't become available in time, reg will be 0xffffffff
196 + * which means we return 0xff to the caller.
198 + if (WAIT_FOR_RFCSR(rt2x00dev, ®)) {
200 + rt2x00_set_field32(®, RF_CSR_CFG_REGNUM, word);
201 + rt2x00_set_field32(®, RF_CSR_CFG_WRITE, 0);
202 + rt2x00_set_field32(®, RF_CSR_CFG_BUSY, 1);
204 + rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
206 + WAIT_FOR_RFCSR(rt2x00dev, ®);
209 + *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA);
211 + mutex_unlock(&rt2x00dev->csr_mutex);
214 +static void rt2800usb_rf_write(struct rt2x00_dev *rt2x00dev,
215 + const unsigned int word, const u32 value)
219 + mutex_lock(&rt2x00dev->csr_mutex);
222 + * Wait until the RF becomes available, afterwards we
223 + * can safely write the new data into the register.
225 + if (WAIT_FOR_RF(rt2x00dev, ®)) {
227 + rt2x00_set_field32(®, RF_CSR_CFG0_REG_VALUE_BW, value);
228 + rt2x00_set_field32(®, RF_CSR_CFG0_STANDBYMODE, 0);
229 + rt2x00_set_field32(®, RF_CSR_CFG0_SEL, 0);
230 + rt2x00_set_field32(®, RF_CSR_CFG0_BUSY, 1);
232 + rt2x00usb_register_write_lock(rt2x00dev, RF_CSR_CFG0, reg);
233 + rt2x00_rf_write(rt2x00dev, word, value);
236 + mutex_unlock(&rt2x00dev->csr_mutex);
239 +static void rt2800usb_mcu_request(struct rt2x00_dev *rt2x00dev,
240 + const u8 command, const u8 token,
241 + const u8 arg0, const u8 arg1)
245 + mutex_lock(&rt2x00dev->csr_mutex);
248 + * Wait until the MCU becomes available, afterwards we
249 + * can safely write the new data into the register.
251 + if (WAIT_FOR_MCU(rt2x00dev, ®)) {
252 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_OWNER, 1);
253 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_CMD_TOKEN, token);
254 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_ARG0, arg0);
255 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_ARG1, arg1);
256 + rt2x00usb_register_write_lock(rt2x00dev, H2M_MAILBOX_CSR, reg);
259 + rt2x00_set_field32(®, HOST_CMD_CSR_HOST_COMMAND, command);
260 + rt2x00usb_register_write_lock(rt2x00dev, HOST_CMD_CSR, reg);
263 + mutex_unlock(&rt2x00dev->csr_mutex);
266 +#ifdef CONFIG_RT2X00_LIB_DEBUGFS
267 +static const struct rt2x00debug rt2800usb_rt2x00debug = {
268 + .owner = THIS_MODULE,
270 + .read = rt2x00usb_register_read,
271 + .write = rt2x00usb_register_write,
272 + .flags = RT2X00DEBUGFS_OFFSET,
273 + .word_base = CSR_REG_BASE,
274 + .word_size = sizeof(u32),
275 + .word_count = CSR_REG_SIZE / sizeof(u32),
278 + .read = rt2x00_eeprom_read,
279 + .write = rt2x00_eeprom_write,
280 + .word_base = EEPROM_BASE,
281 + .word_size = sizeof(u16),
282 + .word_count = EEPROM_SIZE / sizeof(u16),
285 + .read = rt2800usb_bbp_read,
286 + .write = rt2800usb_bbp_write,
287 + .word_base = BBP_BASE,
288 + .word_size = sizeof(u8),
289 + .word_count = BBP_SIZE / sizeof(u8),
292 + .read = rt2x00_rf_read,
293 + .write = rt2800usb_rf_write,
294 + .word_base = RF_BASE,
295 + .word_size = sizeof(u32),
296 + .word_count = RF_SIZE / sizeof(u32),
299 +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
301 +#ifdef CONFIG_RT2X00_LIB_RFKILL
302 +static int rt2800usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)
306 + rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, ®);
307 + return rt2x00_get_field32(reg, GPIO_CTRL_CFG_BIT2);
310 +#define rt2800usb_rfkill_poll NULL
311 +#endif /* CONFIG_RT2X00_LIB_RFKILL */
313 +#ifdef CONFIG_RT2X00_LIB_LEDS
314 +static void rt2800usb_brightness_set(struct led_classdev *led_cdev,
315 + enum led_brightness brightness)
317 + struct rt2x00_led *led =
318 + container_of(led_cdev, struct rt2x00_led, led_dev);
319 + unsigned int enabled = brightness != LED_OFF;
320 + unsigned int bg_mode =
321 + (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
322 + unsigned int polarity =
323 + rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
324 + EEPROM_FREQ_LED_POLARITY);
325 + unsigned int ledmode =
326 + rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
327 + EEPROM_FREQ_LED_MODE);
329 + if (led->type == LED_TYPE_RADIO) {
330 + rt2800usb_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
331 + enabled ? 0x20 : 0);
332 + } else if (led->type == LED_TYPE_ASSOC) {
333 + rt2800usb_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
334 + enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
335 + } else if (led->type == LED_TYPE_QUALITY) {
337 + * The brightness is divided into 6 levels (0 - 5),
338 + * The specs tell us the following levels:
339 + * 0, 1 ,3, 7, 15, 31
340 + * to determine the level in a simple way we can simply
341 + * work with bitshifting:
344 + rt2800usb_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
345 + (1 << brightness / (LED_FULL / 6)) - 1,
350 +static int rt2800usb_blink_set(struct led_classdev *led_cdev,
351 + unsigned long *delay_on,
352 + unsigned long *delay_off)
354 + struct rt2x00_led *led =
355 + container_of(led_cdev, struct rt2x00_led, led_dev);
358 + rt2x00usb_register_read(led->rt2x00dev, LED_CFG, ®);
359 + rt2x00_set_field32(®, LED_CFG_ON_PERIOD, *delay_on);
360 + rt2x00_set_field32(®, LED_CFG_OFF_PERIOD, *delay_off);
361 + rt2x00_set_field32(®, LED_CFG_SLOW_BLINK_PERIOD, 3);
362 + rt2x00_set_field32(®, LED_CFG_R_LED_MODE, 3);
363 + rt2x00_set_field32(®, LED_CFG_G_LED_MODE, 12);
364 + rt2x00_set_field32(®, LED_CFG_Y_LED_MODE, 3);
365 + rt2x00_set_field32(®, LED_CFG_LED_POLAR, 1);
366 + rt2x00usb_register_write(led->rt2x00dev, LED_CFG, reg);
371 +static void rt2800usb_init_led(struct rt2x00_dev *rt2x00dev,
372 + struct rt2x00_led *led,
373 + enum led_type type)
375 + led->rt2x00dev = rt2x00dev;
377 + led->led_dev.brightness_set = rt2800usb_brightness_set;
378 + led->led_dev.blink_set = rt2800usb_blink_set;
379 + led->flags = LED_INITIALIZED;
381 +#endif /* CONFIG_RT2X00_LIB_LEDS */
384 + * Configuration handlers.
386 +static void rt2800usb_config_wcid_attr(struct rt2x00_dev *rt2x00dev,
387 + struct rt2x00lib_crypto *crypto,
388 + struct ieee80211_key_conf *key)
390 + struct mac_wcid_entry wcid_entry;
391 + struct mac_iveiv_entry iveiv_entry;
395 + offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx);
397 + rt2x00usb_register_read(rt2x00dev, offset, ®);
398 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_KEYTAB,
399 + !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE));
400 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_CIPHER, crypto->cipher);
401 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_BSS_IDX,
402 + (crypto->cmd == SET_KEY) * crypto->bssidx);
403 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_RX_WIUDF, 0);
404 + rt2x00usb_register_write(rt2x00dev, offset, reg);
406 + offset = MAC_IVEIV_ENTRY(key->hw_key_idx);
408 + memset(&iveiv_entry, 0, sizeof(iveiv_entry));
409 + if ((crypto->cipher == CIPHER_TKIP) ||
410 + (crypto->cipher == CIPHER_TKIP_NO_MIC) ||
411 + (crypto->cipher == CIPHER_AES))
412 + iveiv_entry.iv[3] |= 0x20;
413 + iveiv_entry.iv[3] |= key->keyidx << 6;
414 + rt2x00usb_register_multiwrite(rt2x00dev, offset,
415 + &iveiv_entry, sizeof(iveiv_entry));
417 + offset = MAC_WCID_ENTRY(key->hw_key_idx);
419 + memset(&wcid_entry, 0, sizeof(wcid_entry));
420 + if (crypto->cmd == SET_KEY)
421 + memcpy(&wcid_entry, crypto->address, ETH_ALEN);
422 + rt2x00usb_register_multiwrite(rt2x00dev, offset,
423 + &wcid_entry, sizeof(wcid_entry));
426 +static int rt2800usb_config_shared_key(struct rt2x00_dev *rt2x00dev,
427 + struct rt2x00lib_crypto *crypto,
428 + struct ieee80211_key_conf *key)
430 + struct hw_key_entry key_entry;
431 + struct rt2x00_field32 field;
436 + if (crypto->cmd == SET_KEY) {
437 + key->hw_key_idx = (4 * crypto->bssidx) + key->keyidx;
439 + memcpy(key_entry.key, crypto->key,
440 + sizeof(key_entry.key));
441 + memcpy(key_entry.tx_mic, crypto->tx_mic,
442 + sizeof(key_entry.tx_mic));
443 + memcpy(key_entry.rx_mic, crypto->rx_mic,
444 + sizeof(key_entry.rx_mic));
446 + offset = SHARED_KEY_ENTRY(key->hw_key_idx);
447 + timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
448 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
449 + USB_VENDOR_REQUEST_OUT,
450 + offset, &key_entry,
456 + * The cipher types are stored over multiple registers
457 + * starting with SHARED_KEY_MODE_BASE each word will have
458 + * 32 bits and contains the cipher types for 2 bssidx each.
459 + * Using the correct defines correctly will cause overhead,
460 + * so just calculate the correct offset.
462 + field.bit_offset = (4 * key->keyidx) + (16 * (crypto->bssidx & 1));
463 + field.bit_mask = 0x7 << field.bit_offset;
465 + offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 2);
467 + rt2x00usb_register_read(rt2x00dev, offset, ®);
468 + rt2x00_set_field32(®, field,
469 + (crypto->cmd == SET_KEY) * crypto->cipher);
470 + rt2x00usb_register_write(rt2x00dev, offset, reg);
473 + * Update WCID information
475 + rt2800usb_config_wcid_attr(rt2x00dev, crypto, key);
480 +static int rt2800usb_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
481 + struct rt2x00lib_crypto *crypto,
482 + struct ieee80211_key_conf *key)
484 + struct hw_key_entry key_entry;
488 + if (crypto->cmd == SET_KEY) {
490 + * 1 pairwise key is possible per AID, this means that the AID
491 + * equals our hw_key_idx.
493 + key->hw_key_idx = crypto->aid;
495 + memcpy(key_entry.key, crypto->key,
496 + sizeof(key_entry.key));
497 + memcpy(key_entry.tx_mic, crypto->tx_mic,
498 + sizeof(key_entry.tx_mic));
499 + memcpy(key_entry.rx_mic, crypto->rx_mic,
500 + sizeof(key_entry.rx_mic));
502 + offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx);
503 + timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
504 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
505 + USB_VENDOR_REQUEST_OUT,
506 + offset, &key_entry,
512 + * Update WCID information
514 + rt2800usb_config_wcid_attr(rt2x00dev, crypto, key);
519 +static void rt2800usb_config_filter(struct rt2x00_dev *rt2x00dev,
520 + const unsigned int filter_flags)
525 + * Start configuration steps.
526 + * Note that the version error will always be dropped
527 + * and broadcast frames will always be accepted since
528 + * there is no filter for it at this time.
530 + rt2x00usb_register_read(rt2x00dev, RX_FILTER_CFG, ®);
531 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CRC_ERROR,
532 + !(filter_flags & FIF_FCSFAIL));
533 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_PHY_ERROR,
534 + !(filter_flags & FIF_PLCPFAIL));
535 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_NOT_TO_ME,
536 + !(filter_flags & FIF_PROMISC_IN_BSS));
537 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_NOT_MY_BSSD, 0);
538 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_VER_ERROR, 1);
539 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_MULTICAST,
540 + !(filter_flags & FIF_ALLMULTI));
541 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BROADCAST, 0);
542 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_DUPLICATE, 1);
543 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CF_END_ACK,
544 + !(filter_flags & FIF_CONTROL));
545 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CF_END,
546 + !(filter_flags & FIF_CONTROL));
547 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_ACK,
548 + !(filter_flags & FIF_CONTROL));
549 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CTS,
550 + !(filter_flags & FIF_CONTROL));
551 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_RTS,
552 + !(filter_flags & FIF_CONTROL));
553 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_PSPOLL,
554 + !(filter_flags & FIF_CONTROL));
555 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BA, 1);
556 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BAR, 0);
557 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CNTL,
558 + !(filter_flags & FIF_CONTROL));
559 + rt2x00usb_register_write(rt2x00dev, RX_FILTER_CFG, reg);
562 +static void rt2800usb_config_intf(struct rt2x00_dev *rt2x00dev,
563 + struct rt2x00_intf *intf,
564 + struct rt2x00intf_conf *conf,
565 + const unsigned int flags)
567 + unsigned int beacon_base;
570 + if (flags & CONFIG_UPDATE_TYPE) {
572 + * Clear current synchronisation setup.
573 + * For the Beacon base registers we only need to clear
574 + * the first byte since that byte contains the VALID and OWNER
575 + * bits which (when set to 0) will invalidate the entire beacon.
577 + beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
578 + rt2x00usb_register_write(rt2x00dev, beacon_base, 0);
581 + * Enable synchronisation.
583 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
584 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1);
585 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync);
586 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1);
587 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
590 + if (flags & CONFIG_UPDATE_MAC) {
591 + reg = le32_to_cpu(conf->mac[1]);
592 + rt2x00_set_field32(®, MAC_ADDR_DW1_UNICAST_TO_ME_MASK, 0xff);
593 + conf->mac[1] = cpu_to_le32(reg);
595 + rt2x00usb_register_multiwrite(rt2x00dev, MAC_ADDR_DW0,
596 + conf->mac, sizeof(conf->mac));
599 + if (flags & CONFIG_UPDATE_BSSID) {
600 + reg = le32_to_cpu(conf->bssid[1]);
601 + rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_ID_MASK, 0);
602 + rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_BCN_NUM, 0);
603 + conf->bssid[1] = cpu_to_le32(reg);
605 + rt2x00usb_register_multiwrite(rt2x00dev, MAC_BSSID_DW0,
606 + conf->bssid, sizeof(conf->bssid));
610 +static void rt2800usb_config_erp(struct rt2x00_dev *rt2x00dev,
611 + struct rt2x00lib_erp *erp)
615 + rt2x00usb_register_read(rt2x00dev, TX_TIMEOUT_CFG, ®);
616 + rt2x00_set_field32(®, TX_TIMEOUT_CFG_RX_ACK_TIMEOUT,
617 + DIV_ROUND_UP(erp->ack_timeout, erp->slot_time));
618 + rt2x00usb_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg);
620 + rt2x00usb_register_read(rt2x00dev, AUTO_RSP_CFG, ®);
621 + rt2x00_set_field32(®, AUTO_RSP_CFG_BAC_ACK_POLICY,
622 + !!erp->short_preamble);
623 + rt2x00_set_field32(®, AUTO_RSP_CFG_AR_PREAMBLE,
624 + !!erp->short_preamble);
625 + rt2x00usb_register_write(rt2x00dev, AUTO_RSP_CFG, reg);
627 + rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, ®);
628 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL,
629 + erp->cts_protection ? 2 : 0);
630 + rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
632 + rt2x00usb_register_write(rt2x00dev, LEGACY_BASIC_RATE,
634 + rt2x00usb_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
636 + rt2x00usb_register_read(rt2x00dev, BKOFF_SLOT_CFG, ®);
637 + rt2x00_set_field32(®, BKOFF_SLOT_CFG_SLOT_TIME, erp->slot_time);
638 + rt2x00_set_field32(®, BKOFF_SLOT_CFG_CC_DELAY_TIME, 2);
639 + rt2x00usb_register_write(rt2x00dev, BKOFF_SLOT_CFG, reg);
641 + rt2x00usb_register_read(rt2x00dev, XIFS_TIME_CFG, ®);
642 + rt2x00_set_field32(®, XIFS_TIME_CFG_CCKM_SIFS_TIME, erp->sifs);
643 + rt2x00_set_field32(®, XIFS_TIME_CFG_OFDM_SIFS_TIME, erp->sifs);
644 + rt2x00_set_field32(®, XIFS_TIME_CFG_OFDM_XIFS_TIME, 4);
645 + rt2x00_set_field32(®, XIFS_TIME_CFG_EIFS, erp->eifs);
646 + rt2x00_set_field32(®, XIFS_TIME_CFG_BB_RXEND_ENABLE, 1);
647 + rt2x00usb_register_write(rt2x00dev, XIFS_TIME_CFG, reg);
650 +static void rt2800usb_config_ant(struct rt2x00_dev *rt2x00dev,
651 + struct antenna_setup *ant)
658 + * FIXME: Use requested antenna configuration.
661 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
663 + rt2800usb_bbp_read(rt2x00dev, 1, &r1);
664 + rt2800usb_bbp_read(rt2x00dev, 3, &r3);
667 + * Configure the TX antenna.
669 + switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH)) {
671 + rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 0);
674 + rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2);
682 + * Configure the RX antenna.
684 + switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
686 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
689 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 1);
692 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 2);
696 + rt2800usb_bbp_write(rt2x00dev, 3, r3);
697 + rt2800usb_bbp_write(rt2x00dev, 1, r1);
700 +static void rt2800usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
701 + struct rt2x00lib_conf *libconf)
706 + if (libconf->rf.channel <= 14) {
707 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
708 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG);
709 + } else if (libconf->rf.channel <= 64) {
710 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
711 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
712 + } else if (libconf->rf.channel <= 128) {
713 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
714 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
716 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
717 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
720 + rt2x00dev->lna_gain = lna_gain;
723 +static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
724 + struct ieee80211_conf *conf,
725 + struct rf_channel *rf,
726 + struct channel_info *info)
730 + rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
733 + * Determine antenna settings from EEPROM
735 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
737 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1)
738 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
740 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) {
741 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1);
742 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
743 + } else if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 2)
744 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
746 + if (rf->channel > 14) {
748 + * When TX power is below 0, we should increase it by 7 to
749 + * make it a positive value (Minumum value is -7).
750 + * However this means that values between 0 and 7 have
751 + * double meaning, and we should set a 7DBm boost flag.
753 + rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST,
754 + (info->tx_power1 >= 0));
756 + if (info->tx_power1 < 0)
757 + info->tx_power1 += 7;
759 + rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A,
760 + TXPOWER_A_TO_DEV(info->tx_power1));
762 + rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST,
763 + (info->tx_power2 >= 0));
765 + if (info->tx_power2 < 0)
766 + info->tx_power2 += 7;
768 + rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A,
769 + TXPOWER_A_TO_DEV(info->tx_power2));
771 + rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G,
772 + TXPOWER_G_TO_DEV(info->tx_power1));
773 + rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G,
774 + TXPOWER_G_TO_DEV(info->tx_power2));
777 + rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
779 + rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
780 + rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
781 + rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
782 + rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
786 + rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
787 + rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
788 + rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
789 + rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
793 + rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
794 + rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
795 + rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
796 + rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
799 +static void rt2800usb_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
800 + struct ieee80211_conf *conf,
801 + struct rf_channel *rf,
802 + struct channel_info *info)
806 + rt2800usb_rfcsr_write(rt2x00dev, 2, rf->rf1);
807 + rt2800usb_rfcsr_write(rt2x00dev, 2, rf->rf3);
809 + rt2800usb_rfcsr_read(rt2x00dev, 6, &rfcsr);
810 + rt2x00_set_field8(&rfcsr, RFCSR6_R, rf->rf2);
811 + rt2800usb_rfcsr_write(rt2x00dev, 6, rfcsr);
813 + rt2800usb_rfcsr_read(rt2x00dev, 12, &rfcsr);
814 + rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER,
815 + TXPOWER_G_TO_DEV(info->tx_power1));
816 + rt2800usb_rfcsr_write(rt2x00dev, 12, rfcsr);
818 + rt2800usb_rfcsr_read(rt2x00dev, 23, &rfcsr);
819 + rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset);
820 + rt2800usb_rfcsr_write(rt2x00dev, 23, rfcsr);
822 + if (conf_is_ht40(conf))
823 + rt2800usb_rfcsr_write(rt2x00dev, 24,
824 + rt2x00dev->calibration_bw40);
826 + rt2800usb_rfcsr_write(rt2x00dev, 24,
827 + rt2x00dev->calibration_bw20);
829 + rt2800usb_rfcsr_read(rt2x00dev, 23, &rfcsr);
830 + rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
831 + rt2800usb_rfcsr_write(rt2x00dev, 23, rfcsr);
834 +static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
835 + struct ieee80211_conf *conf,
836 + struct rf_channel *rf,
837 + struct channel_info *info)
840 + unsigned int tx_pin;
845 + * Determine antenna settings from EEPROM
847 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
849 + if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
850 + rt2800usb_config_channel_rt2x(rt2x00dev, conf, rf, info);
852 + rt2800usb_config_channel_rt3x(rt2x00dev, conf, rf, info);
855 + * Change BBP settings
857 + rt2800usb_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
858 + rt2800usb_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
859 + rt2800usb_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
860 + rt2800usb_bbp_write(rt2x00dev, 86, 0);
862 + if (rf->channel <= 14) {
863 + if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags)) {
864 + rt2800usb_bbp_write(rt2x00dev, 82, 0x62);
865 + rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
867 + rt2800usb_bbp_write(rt2x00dev, 82, 0x84);
868 + rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
871 + rt2800usb_bbp_write(rt2x00dev, 82, 0xf2);
873 + if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
874 + rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
876 + rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
879 + rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
880 + rt2x00_set_field32(®, TX_BAND_CFG_HT40_PLUS, conf_is_ht40_plus(conf));
881 + rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14);
882 + rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14);
883 + rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
887 + /* Turn on unused PA or LNA when not using 1T or 1R */
888 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) != 1) {
889 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1);
890 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
893 + /* Turn on unused PA or LNA when not using 1T or 1R */
894 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) != 1) {
895 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
896 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
899 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
900 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
901 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
902 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
903 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, rf->channel <= 14);
904 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
906 + rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
908 + rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
909 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf));
910 + rt2800usb_bbp_write(rt2x00dev, 4, bbp);
912 + rt2800usb_bbp_read(rt2x00dev, 3, &bbp);
913 + rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf));
914 + rt2800usb_bbp_write(rt2x00dev, 3, bbp);
916 + if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) {
917 + if (conf_is_ht40(conf)) {
918 + rt2800usb_bbp_write(rt2x00dev, 69, 0x1a);
919 + rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
920 + rt2800usb_bbp_write(rt2x00dev, 73, 0x16);
922 + rt2800usb_bbp_write(rt2x00dev, 69, 0x16);
923 + rt2800usb_bbp_write(rt2x00dev, 70, 0x08);
924 + rt2800usb_bbp_write(rt2x00dev, 73, 0x11);
931 +static void rt2800usb_config_txpower(struct rt2x00_dev *rt2x00dev,
935 + u32 value = TXPOWER_G_TO_DEV(txpower);
938 + rt2800usb_bbp_read(rt2x00dev, 1, &r1);
939 + rt2x00_set_field8(®, BBP1_TX_POWER, 0);
940 + rt2800usb_bbp_write(rt2x00dev, 1, r1);
942 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_0, ®);
943 + rt2x00_set_field32(®, TX_PWR_CFG_0_1MBS, value);
944 + rt2x00_set_field32(®, TX_PWR_CFG_0_2MBS, value);
945 + rt2x00_set_field32(®, TX_PWR_CFG_0_55MBS, value);
946 + rt2x00_set_field32(®, TX_PWR_CFG_0_11MBS, value);
947 + rt2x00_set_field32(®, TX_PWR_CFG_0_6MBS, value);
948 + rt2x00_set_field32(®, TX_PWR_CFG_0_9MBS, value);
949 + rt2x00_set_field32(®, TX_PWR_CFG_0_12MBS, value);
950 + rt2x00_set_field32(®, TX_PWR_CFG_0_18MBS, value);
951 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_0, reg);
953 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_1, ®);
954 + rt2x00_set_field32(®, TX_PWR_CFG_1_24MBS, value);
955 + rt2x00_set_field32(®, TX_PWR_CFG_1_36MBS, value);
956 + rt2x00_set_field32(®, TX_PWR_CFG_1_48MBS, value);
957 + rt2x00_set_field32(®, TX_PWR_CFG_1_54MBS, value);
958 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS0, value);
959 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS1, value);
960 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS2, value);
961 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS3, value);
962 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_1, reg);
964 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_2, ®);
965 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS4, value);
966 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS5, value);
967 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS6, value);
968 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS7, value);
969 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS8, value);
970 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS9, value);
971 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS10, value);
972 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS11, value);
973 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_2, reg);
975 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_3, ®);
976 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS12, value);
977 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS13, value);
978 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS14, value);
979 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS15, value);
980 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN1, value);
981 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN2, value);
982 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN3, value);
983 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN4, value);
984 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_3, reg);
986 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_4, ®);
987 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN5, value);
988 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN6, value);
989 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN7, value);
990 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN8, value);
991 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_4, reg);
994 +static void rt2800usb_config_retry_limit(struct rt2x00_dev *rt2x00dev,
995 + struct rt2x00lib_conf *libconf)
999 + rt2x00usb_register_read(rt2x00dev, TX_RTY_CFG, ®);
1000 + rt2x00_set_field32(®, TX_RTY_CFG_SHORT_RTY_LIMIT,
1001 + libconf->conf->short_frame_max_tx_count);
1002 + rt2x00_set_field32(®, TX_RTY_CFG_LONG_RTY_LIMIT,
1003 + libconf->conf->long_frame_max_tx_count);
1004 + rt2x00_set_field32(®, TX_RTY_CFG_LONG_RTY_THRE, 2000);
1005 + rt2x00_set_field32(®, TX_RTY_CFG_NON_AGG_RTY_MODE, 0);
1006 + rt2x00_set_field32(®, TX_RTY_CFG_AGG_RTY_MODE, 0);
1007 + rt2x00_set_field32(®, TX_RTY_CFG_TX_AUTO_FB_ENABLE, 1);
1008 + rt2x00usb_register_write(rt2x00dev, TX_RTY_CFG, reg);
1011 +static void rt2800usb_config_duration(struct rt2x00_dev *rt2x00dev,
1012 + struct rt2x00lib_conf *libconf)
1016 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
1017 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL,
1018 + libconf->conf->beacon_int * 16);
1019 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1022 +static void rt2800usb_config_ps(struct rt2x00_dev *rt2x00dev,
1023 + struct rt2x00lib_conf *libconf)
1025 + enum dev_state state =
1026 + (libconf->conf->flags & IEEE80211_CONF_PS) ?
1027 + STATE_SLEEP : STATE_AWAKE;
1030 + if (state == STATE_SLEEP) {
1031 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, 0);
1033 + rt2x00usb_register_read(rt2x00dev, AUTOWAKEUP_CFG, ®);
1034 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 5);
1035 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE,
1036 + libconf->conf->listen_interval - 1);
1037 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTOWAKE, 1);
1038 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
1040 + rt2800usb_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 0);
1042 + rt2800usb_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
1044 + rt2x00usb_register_read(rt2x00dev, AUTOWAKEUP_CFG, ®);
1045 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 0);
1046 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE, 0);
1047 + rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTOWAKE, 0);
1048 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, reg);
1052 +static void rt2800usb_config(struct rt2x00_dev *rt2x00dev,
1053 + struct rt2x00lib_conf *libconf,
1054 + const unsigned int flags)
1056 + /* Always recalculate LNA gain before changing configuration */
1057 + rt2800usb_config_lna_gain(rt2x00dev, libconf);
1059 + if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
1060 + rt2800usb_config_channel(rt2x00dev, libconf->conf,
1061 + &libconf->rf, &libconf->channel);
1062 + if (flags & IEEE80211_CONF_CHANGE_POWER)
1063 + rt2800usb_config_txpower(rt2x00dev, libconf->conf->power_level);
1064 + if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
1065 + rt2800usb_config_retry_limit(rt2x00dev, libconf);
1066 + if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
1067 + rt2800usb_config_duration(rt2x00dev, libconf);
1068 + if (flags & IEEE80211_CONF_CHANGE_PS)
1069 + rt2800usb_config_ps(rt2x00dev, libconf);
1075 +static void rt2800usb_link_stats(struct rt2x00_dev *rt2x00dev,
1076 + struct link_qual *qual)
1081 + * Update FCS error count from register.
1083 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT0, ®);
1084 + qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR);
1087 +static u8 rt2800usb_get_default_vgc(struct rt2x00_dev *rt2x00dev)
1089 + if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
1090 + if (rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION)
1091 + return 0x1c + (2 * rt2x00dev->lna_gain);
1093 + return 0x2e + rt2x00dev->lna_gain;
1096 + if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags))
1097 + return 0x32 + (rt2x00dev->lna_gain * 5) / 3;
1099 + return 0x3a + (rt2x00dev->lna_gain * 5) / 3;
1102 +static inline void rt2800usb_set_vgc(struct rt2x00_dev *rt2x00dev,
1103 + struct link_qual *qual, u8 vgc_level)
1105 + if (qual->vgc_level != vgc_level) {
1106 + rt2800usb_bbp_write(rt2x00dev, 66, vgc_level);
1107 + qual->vgc_level = vgc_level;
1108 + qual->vgc_level_reg = vgc_level;
1112 +static void rt2800usb_reset_tuner(struct rt2x00_dev *rt2x00dev,
1113 + struct link_qual *qual)
1115 + rt2800usb_set_vgc(rt2x00dev, qual,
1116 + rt2800usb_get_default_vgc(rt2x00dev));
1119 +static void rt2800usb_link_tuner(struct rt2x00_dev *rt2x00dev,
1120 + struct link_qual *qual, const u32 count)
1122 + if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION)
1126 + * When RSSI is better then -80 increase VGC level with 0x10
1128 + rt2800usb_set_vgc(rt2x00dev, qual,
1129 + rt2800usb_get_default_vgc(rt2x00dev) +
1130 + ((qual->rssi > -80) * 0x10));
1134 + * Firmware functions
1136 +static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
1138 + return FIRMWARE_RT2870;
1141 +static bool rt2800usb_check_crc(const u8 *data, const size_t len)
1147 + * The last 2 bytes in the firmware array are the crc checksum itself,
1148 + * this means that we should never pass those 2 bytes to the crc
1151 + fw_crc = (data[len - 2] << 8 | data[len - 1]);
1154 + * Use the crc ccitt algorithm.
1155 + * This will return the same value as the legacy driver which
1156 + * used bit ordering reversion on the both the firmware bytes
1157 + * before input input as well as on the final output.
1158 + * Obviously using crc ccitt directly is much more efficient.
1160 + crc = crc_ccitt(~0, data, len - 2);
1163 + * There is a small difference between the crc-itu-t + bitrev and
1164 + * the crc-ccitt crc calculation. In the latter method the 2 bytes
1165 + * will be swapped, use swab16 to convert the crc to the correct
1168 + crc = swab16(crc);
1170 + return fw_crc == crc;
1173 +static int rt2800usb_check_firmware(struct rt2x00_dev *rt2x00dev,
1174 + const u8 *data, const size_t len)
1176 + u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff;
1177 + size_t offset = 0;
1181 + * There are 2 variations of the rt2870 firmware.
1184 + * Note that (b) contains 2 seperate firmware blobs of 4k
1185 + * within the file. The first blob is the same firmware as (a),
1186 + * but the second blob is for the additional chipsets.
1188 + if (len != 4096 && len != 8192)
1189 + return FW_BAD_LENGTH;
1192 + * Check if we need the upper 4kb firmware data or not.
1194 + if ((len == 4096) &&
1195 + (chipset != 0x2860) &&
1196 + (chipset != 0x2872) &&
1197 + (chipset != 0x3070))
1198 + return FW_BAD_VERSION;
1201 + * 8kb firmware files must be checked as if it were
1202 + * 2 seperate firmware files.
1204 + while (offset < len) {
1205 + if (!rt2800usb_check_crc(data + offset, 4096))
1206 + return FW_BAD_CRC;
1214 +static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev,
1215 + const u8 *data, const size_t len)
1222 + u16 chipset = (rt2x00_rev(&rt2x00dev->chip) >> 16) & 0xffff;
1225 + * Check which section of the firmware we need.
1227 + if ((chipset == 0x2860) || (chipset == 0x2872) || (chipset == 0x3070)) {
1236 + * Wait for stable hardware.
1238 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1239 + rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
1240 + if (reg && reg != ~0)
1245 + if (i == REGISTER_BUSY_COUNT) {
1246 + ERROR(rt2x00dev, "Unstable hardware.\n");
1251 + * Write firmware to device.
1253 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
1254 + USB_VENDOR_REQUEST_OUT,
1255 + FIRMWARE_IMAGE_BASE,
1256 + data + offset, length,
1257 + REGISTER_TIMEOUT32(length));
1259 + rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
1260 + rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
1263 + * Send firmware request to device to load firmware,
1264 + * we need to specify a long timeout time.
1266 + status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
1267 + 0, USB_MODE_FIRMWARE,
1268 + REGISTER_TIMEOUT_FIRMWARE);
1270 + ERROR(rt2x00dev, "Failed to write Firmware to device.\n");
1275 + * Wait for device to stabilize.
1277 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1278 + rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, ®);
1279 + if (rt2x00_get_field32(reg, PBF_SYS_CTRL_READY))
1284 + if (i == REGISTER_BUSY_COUNT) {
1285 + ERROR(rt2x00dev, "PBF system register not ready.\n");
1290 + * Initialize firmware.
1292 + rt2x00usb_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
1293 + rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
1300 + * Initialization functions.
1302 +static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
1308 + * Wait untill BBP and RF are ready.
1310 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1311 + rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
1312 + if (reg && reg != ~0)
1317 + if (i == REGISTER_BUSY_COUNT) {
1318 + ERROR(rt2x00dev, "Unstable hardware.\n");
1322 + rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, ®);
1323 + rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
1325 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1326 + rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1);
1327 + rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1);
1328 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1330 + rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
1332 + rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
1333 + USB_MODE_RESET, REGISTER_TIMEOUT);
1335 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
1337 + rt2x00usb_register_read(rt2x00dev, BCN_OFFSET0, ®);
1338 + rt2x00_set_field32(®, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */
1339 + rt2x00_set_field32(®, BCN_OFFSET0_BCN1, 0xe8); /* 0x3a00 */
1340 + rt2x00_set_field32(®, BCN_OFFSET0_BCN2, 0xf0); /* 0x3c00 */
1341 + rt2x00_set_field32(®, BCN_OFFSET0_BCN3, 0xf8); /* 0x3e00 */
1342 + rt2x00usb_register_write(rt2x00dev, BCN_OFFSET0, reg);
1344 + rt2x00usb_register_read(rt2x00dev, BCN_OFFSET1, ®);
1345 + rt2x00_set_field32(®, BCN_OFFSET1_BCN4, 0xc8); /* 0x3200 */
1346 + rt2x00_set_field32(®, BCN_OFFSET1_BCN5, 0xd0); /* 0x3400 */
1347 + rt2x00_set_field32(®, BCN_OFFSET1_BCN6, 0x77); /* 0x1dc0 */
1348 + rt2x00_set_field32(®, BCN_OFFSET1_BCN7, 0x6f); /* 0x1bc0 */
1349 + rt2x00usb_register_write(rt2x00dev, BCN_OFFSET1, reg);
1351 + rt2x00usb_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f);
1352 + rt2x00usb_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
1354 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
1356 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
1357 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL, 0);
1358 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 0);
1359 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, 0);
1360 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 0);
1361 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0);
1362 + rt2x00_set_field32(®, BCN_TIME_CFG_TX_TIME_COMPENSATE, 0);
1363 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1365 + if (rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) {
1366 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400);
1367 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
1368 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
1370 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000);
1371 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
1374 + rt2x00usb_register_read(rt2x00dev, TX_LINK_CFG, ®);
1375 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFB_LIFETIME, 32);
1376 + rt2x00_set_field32(®, TX_LINK_CFG_MFB_ENABLE, 0);
1377 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_UMFS_ENABLE, 0);
1378 + rt2x00_set_field32(®, TX_LINK_CFG_TX_MRQ_EN, 0);
1379 + rt2x00_set_field32(®, TX_LINK_CFG_TX_RDG_EN, 0);
1380 + rt2x00_set_field32(®, TX_LINK_CFG_TX_CF_ACK_EN, 1);
1381 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFB, 0);
1382 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFS, 0);
1383 + rt2x00usb_register_write(rt2x00dev, TX_LINK_CFG, reg);
1385 + rt2x00usb_register_read(rt2x00dev, TX_TIMEOUT_CFG, ®);
1386 + rt2x00_set_field32(®, TX_TIMEOUT_CFG_MPDU_LIFETIME, 9);
1387 + rt2x00_set_field32(®, TX_TIMEOUT_CFG_TX_OP_TIMEOUT, 10);
1388 + rt2x00usb_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg);
1390 + rt2x00usb_register_read(rt2x00dev, MAX_LEN_CFG, ®);
1391 + rt2x00_set_field32(®, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE);
1392 + if (rt2x00_rev(&rt2x00dev->chip) >= RT2880E_VERSION &&
1393 + rt2x00_rev(&rt2x00dev->chip) < RT3070_VERSION)
1394 + rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 2);
1396 + rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 1);
1397 + rt2x00_set_field32(®, MAX_LEN_CFG_MIN_PSDU, 0);
1398 + rt2x00_set_field32(®, MAX_LEN_CFG_MIN_MPDU, 0);
1399 + rt2x00usb_register_write(rt2x00dev, MAX_LEN_CFG, reg);
1401 + rt2x00usb_register_write(rt2x00dev, PBF_MAX_PCNT, 0x1f3fbf9f);
1403 + rt2x00usb_register_read(rt2x00dev, AUTO_RSP_CFG, ®);
1404 + rt2x00_set_field32(®, AUTO_RSP_CFG_AUTORESPONDER, 1);
1405 + rt2x00_set_field32(®, AUTO_RSP_CFG_CTS_40_MMODE, 0);
1406 + rt2x00_set_field32(®, AUTO_RSP_CFG_CTS_40_MREF, 0);
1407 + rt2x00_set_field32(®, AUTO_RSP_CFG_DUAL_CTS_EN, 0);
1408 + rt2x00_set_field32(®, AUTO_RSP_CFG_ACK_CTS_PSM_BIT, 0);
1409 + rt2x00usb_register_write(rt2x00dev, AUTO_RSP_CFG, reg);
1411 + rt2x00usb_register_read(rt2x00dev, CCK_PROT_CFG, ®);
1412 + rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_RATE, 8);
1413 + rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_CTRL, 0);
1414 + rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_NAV, 1);
1415 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1416 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1417 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1418 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM40, 1);
1419 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1420 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1421 + rt2x00usb_register_write(rt2x00dev, CCK_PROT_CFG, reg);
1423 + rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, ®);
1424 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_RATE, 8);
1425 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL, 0);
1426 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_NAV, 1);
1427 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1428 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1429 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1430 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM40, 1);
1431 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1432 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1433 + rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
1435 + rt2x00usb_register_read(rt2x00dev, MM20_PROT_CFG, ®);
1436 + rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_RATE, 0x4004);
1437 + rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_CTRL, 0);
1438 + rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_NAV, 1);
1439 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1440 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1441 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1442 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_MM40, 0);
1443 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1444 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_GF40, 0);
1445 + rt2x00usb_register_write(rt2x00dev, MM20_PROT_CFG, reg);
1447 + rt2x00usb_register_read(rt2x00dev, MM40_PROT_CFG, ®);
1448 + rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_RATE, 0x4084);
1449 + rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_CTRL, 0);
1450 + rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_NAV, 1);
1451 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1452 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1453 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1454 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_MM40, 1);
1455 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1456 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1457 + rt2x00usb_register_write(rt2x00dev, MM40_PROT_CFG, reg);
1459 + rt2x00usb_register_read(rt2x00dev, GF20_PROT_CFG, ®);
1460 + rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_RATE, 0x4004);
1461 + rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_CTRL, 0);
1462 + rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_NAV, 1);
1463 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1464 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1465 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1466 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_MM40, 0);
1467 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1468 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_GF40, 0);
1469 + rt2x00usb_register_write(rt2x00dev, GF20_PROT_CFG, reg);
1471 + rt2x00usb_register_read(rt2x00dev, GF40_PROT_CFG, ®);
1472 + rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_RATE, 0x4084);
1473 + rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_CTRL, 0);
1474 + rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_NAV, 1);
1475 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1476 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1477 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1478 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_MM40, 1);
1479 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1480 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1481 + rt2x00usb_register_write(rt2x00dev, GF40_PROT_CFG, reg);
1483 + rt2x00usb_register_write(rt2x00dev, PBF_CFG, 0xf40006);
1485 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1486 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
1487 + rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_DMA_BUSY, 0);
1488 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
1489 + rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_DMA_BUSY, 0);
1490 + rt2x00_set_field32(®, WPDMA_GLO_CFG_WP_DMA_BURST_SIZE, 3);
1491 + rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 0);
1492 + rt2x00_set_field32(®, WPDMA_GLO_CFG_BIG_ENDIAN, 0);
1493 + rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_HDR_SCATTER, 0);
1494 + rt2x00_set_field32(®, WPDMA_GLO_CFG_HDR_SEG_LEN, 0);
1495 + rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
1497 + rt2x00usb_register_write(rt2x00dev, TXOP_CTRL_CFG, 0x0000583f);
1498 + rt2x00usb_register_write(rt2x00dev, TXOP_HLDR_ET, 0x00000002);
1500 + rt2x00usb_register_read(rt2x00dev, TX_RTS_CFG, ®);
1501 + rt2x00_set_field32(®, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 32);
1502 + rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES,
1503 + IEEE80211_MAX_RTS_THRESHOLD);
1504 + rt2x00_set_field32(®, TX_RTS_CFG_RTS_FBK_EN, 0);
1505 + rt2x00usb_register_write(rt2x00dev, TX_RTS_CFG, reg);
1507 + rt2x00usb_register_write(rt2x00dev, EXP_ACK_TIME, 0x002400ca);
1508 + rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
1511 + * ASIC will keep garbage value after boot, clear encryption keys.
1513 + for (i = 0; i < 256; i++) {
1514 + u32 wcid[2] = { 0xffffffff, 0x00ffffff };
1515 + rt2x00usb_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
1516 + wcid, sizeof(wcid));
1518 + rt2x00usb_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1);
1519 + rt2x00usb_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0);
1522 + for (i = 0; i < 16; i++)
1523 + rt2x00usb_register_write(rt2x00dev,
1524 + SHARED_KEY_MODE_ENTRY(i), 0);
1527 + * Clear all beacons
1528 + * For the Beacon base registers we only need to clear
1529 + * the first byte since that byte contains the VALID and OWNER
1530 + * bits which (when set to 0) will invalidate the entire beacon.
1532 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE0, 0);
1533 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE1, 0);
1534 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE2, 0);
1535 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE3, 0);
1536 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE4, 0);
1537 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE5, 0);
1538 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE6, 0);
1539 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE7, 0);
1541 + rt2x00usb_register_read(rt2x00dev, USB_CYC_CFG, ®);
1542 + rt2x00_set_field32(®, USB_CYC_CFG_CLOCK_CYCLE, 30);
1543 + rt2x00usb_register_write(rt2x00dev, USB_CYC_CFG, reg);
1545 + rt2x00usb_register_read(rt2x00dev, HT_FBK_CFG0, ®);
1546 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS0FBK, 0);
1547 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS1FBK, 0);
1548 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS2FBK, 1);
1549 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS3FBK, 2);
1550 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS4FBK, 3);
1551 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS5FBK, 4);
1552 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS6FBK, 5);
1553 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS7FBK, 6);
1554 + rt2x00usb_register_write(rt2x00dev, HT_FBK_CFG0, reg);
1556 + rt2x00usb_register_read(rt2x00dev, HT_FBK_CFG1, ®);
1557 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS8FBK, 8);
1558 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS9FBK, 8);
1559 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS10FBK, 9);
1560 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS11FBK, 10);
1561 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS12FBK, 11);
1562 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS13FBK, 12);
1563 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS14FBK, 13);
1564 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS15FBK, 14);
1565 + rt2x00usb_register_write(rt2x00dev, HT_FBK_CFG1, reg);
1567 + rt2x00usb_register_read(rt2x00dev, LG_FBK_CFG0, ®);
1568 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS0FBK, 8);
1569 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS1FBK, 8);
1570 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS2FBK, 3);
1571 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS3FBK, 10);
1572 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS4FBK, 11);
1573 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS5FBK, 12);
1574 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS6FBK, 13);
1575 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS7FBK, 14);
1576 + rt2x00usb_register_write(rt2x00dev, LG_FBK_CFG0, reg);
1578 + rt2x00usb_register_read(rt2x00dev, LG_FBK_CFG1, ®);
1579 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS0FBK, 0);
1580 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS1FBK, 0);
1581 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS2FBK, 1);
1582 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS3FBK, 2);
1583 + rt2x00usb_register_write(rt2x00dev, LG_FBK_CFG1, reg);
1586 + * We must clear the error counters.
1587 + * These registers are cleared on read,
1588 + * so we may pass a useless variable to store the value.
1590 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT0, ®);
1591 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT1, ®);
1592 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT2, ®);
1593 + rt2x00usb_register_read(rt2x00dev, TX_STA_CNT0, ®);
1594 + rt2x00usb_register_read(rt2x00dev, TX_STA_CNT1, ®);
1595 + rt2x00usb_register_read(rt2x00dev, TX_STA_CNT2, ®);
1600 +static int rt2800usb_wait_bbp_rf_ready(struct rt2x00_dev *rt2x00dev)
1605 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1606 + rt2x00usb_register_read(rt2x00dev, MAC_STATUS_CFG, ®);
1607 + if (!rt2x00_get_field32(reg, MAC_STATUS_CFG_BBP_RF_BUSY))
1610 + udelay(REGISTER_BUSY_DELAY);
1613 + ERROR(rt2x00dev, "BBP/RF register access failed, aborting.\n");
1617 +static int rt2800usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
1622 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1623 + rt2800usb_bbp_read(rt2x00dev, 0, &value);
1624 + if ((value != 0xff) && (value != 0x00))
1626 + udelay(REGISTER_BUSY_DELAY);
1629 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
1633 +static int rt2800usb_init_bbp(struct rt2x00_dev *rt2x00dev)
1640 + if (unlikely(rt2800usb_wait_bbp_rf_ready(rt2x00dev) ||
1641 + rt2800usb_wait_bbp_ready(rt2x00dev)))
1644 + rt2800usb_bbp_write(rt2x00dev, 65, 0x2c);
1645 + rt2800usb_bbp_write(rt2x00dev, 66, 0x38);
1646 + rt2800usb_bbp_write(rt2x00dev, 69, 0x12);
1647 + rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
1648 + rt2800usb_bbp_write(rt2x00dev, 73, 0x10);
1649 + rt2800usb_bbp_write(rt2x00dev, 81, 0x37);
1650 + rt2800usb_bbp_write(rt2x00dev, 82, 0x62);
1651 + rt2800usb_bbp_write(rt2x00dev, 83, 0x6a);
1652 + rt2800usb_bbp_write(rt2x00dev, 84, 0x99);
1653 + rt2800usb_bbp_write(rt2x00dev, 86, 0x00);
1654 + rt2800usb_bbp_write(rt2x00dev, 91, 0x04);
1655 + rt2800usb_bbp_write(rt2x00dev, 92, 0x00);
1656 + rt2800usb_bbp_write(rt2x00dev, 103, 0x00);
1657 + rt2800usb_bbp_write(rt2x00dev, 105, 0x05);
1659 + if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) {
1660 + rt2800usb_bbp_write(rt2x00dev, 69, 0x16);
1661 + rt2800usb_bbp_write(rt2x00dev, 73, 0x12);
1664 + if (rt2x00_rev(&rt2x00dev->chip) > RT2860D_VERSION) {
1665 + rt2800usb_bbp_write(rt2x00dev, 84, 0x19);
1668 + if (rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) {
1669 + rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
1670 + rt2800usb_bbp_write(rt2x00dev, 84, 0x99);
1671 + rt2800usb_bbp_write(rt2x00dev, 105, 0x05);
1674 + for (i = 0; i < EEPROM_BBP_SIZE; i++) {
1675 + rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
1677 + if (eeprom != 0xffff && eeprom != 0x0000) {
1678 + reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
1679 + value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
1680 + rt2800usb_bbp_write(rt2x00dev, reg_id, value);
1687 +static u8 rt2800usb_init_rx_filter(struct rt2x00_dev *rt2x00dev,
1688 + bool bw40, u8 rfcsr24, u8 filter_target)
1697 + rt2800usb_rfcsr_write(rt2x00dev, 24, rfcsr24);
1699 + rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
1700 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * bw40);
1701 + rt2800usb_bbp_write(rt2x00dev, 4, bbp);
1703 + rt2800usb_rfcsr_read(rt2x00dev, 22, &rfcsr);
1704 + rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 1);
1705 + rt2800usb_rfcsr_write(rt2x00dev, 22, rfcsr);
1708 + * Set power & frequency of passband test tone
1710 + rt2800usb_bbp_write(rt2x00dev, 24, 0);
1712 + for (i = 0; i < 100; i++) {
1713 + rt2800usb_bbp_write(rt2x00dev, 25, 0x90);
1716 + rt2800usb_bbp_read(rt2x00dev, 55, &passband);
1722 + * Set power & frequency of stopband test tone
1724 + rt2800usb_bbp_write(rt2x00dev, 24, 0x06);
1726 + for (i = 0; i < 100; i++) {
1727 + rt2800usb_bbp_write(rt2x00dev, 25, 0x90);
1730 + rt2800usb_bbp_read(rt2x00dev, 55, &stopband);
1732 + if ((passband - stopband) <= filter_target) {
1734 + overtuned += ((passband - stopband) == filter_target);
1738 + rt2800usb_rfcsr_write(rt2x00dev, 24, rfcsr24);
1741 + rfcsr24 -= !!overtuned;
1743 + rt2800usb_rfcsr_write(rt2x00dev, 24, rfcsr24);
1747 +static int rt2800usb_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1752 + if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
1756 + * Init RF calibration.
1758 + rt2800usb_rfcsr_read(rt2x00dev, 30, &rfcsr);
1759 + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
1760 + rt2800usb_rfcsr_write(rt2x00dev, 30, rfcsr);
1762 + rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0);
1763 + rt2800usb_rfcsr_write(rt2x00dev, 30, rfcsr);
1765 + rt2800usb_rfcsr_write(rt2x00dev, 4, 0x40);
1766 + rt2800usb_rfcsr_write(rt2x00dev, 5, 0x03);
1767 + rt2800usb_rfcsr_write(rt2x00dev, 6, 0x02);
1768 + rt2800usb_rfcsr_write(rt2x00dev, 7, 0x70);
1769 + rt2800usb_rfcsr_write(rt2x00dev, 9, 0x0f);
1770 + rt2800usb_rfcsr_write(rt2x00dev, 10, 0x71);
1771 + rt2800usb_rfcsr_write(rt2x00dev, 11, 0x21);
1772 + rt2800usb_rfcsr_write(rt2x00dev, 12, 0x7b);
1773 + rt2800usb_rfcsr_write(rt2x00dev, 14, 0x90);
1774 + rt2800usb_rfcsr_write(rt2x00dev, 15, 0x58);
1775 + rt2800usb_rfcsr_write(rt2x00dev, 16, 0xb3);
1776 + rt2800usb_rfcsr_write(rt2x00dev, 17, 0x92);
1777 + rt2800usb_rfcsr_write(rt2x00dev, 18, 0x2c);
1778 + rt2800usb_rfcsr_write(rt2x00dev, 19, 0x02);
1779 + rt2800usb_rfcsr_write(rt2x00dev, 20, 0xba);
1780 + rt2800usb_rfcsr_write(rt2x00dev, 21, 0xdb);
1781 + rt2800usb_rfcsr_write(rt2x00dev, 24, 0x16);
1782 + rt2800usb_rfcsr_write(rt2x00dev, 25, 0x01);
1783 + rt2800usb_rfcsr_write(rt2x00dev, 27, 0x03);
1784 + rt2800usb_rfcsr_write(rt2x00dev, 29, 0x1f);
1787 + * Set RX Filter calibration for 20MHz and 40MHz
1789 + rt2x00dev->calibration_bw20 =
1790 + rt2800usb_init_rx_filter(rt2x00dev, false, 0x07, 0x16);
1791 + rt2x00dev->calibration_bw40 =
1792 + rt2800usb_init_rx_filter(rt2x00dev, true, 0x27, 0x19);
1795 + * Set back to initial state
1797 + rt2800usb_bbp_write(rt2x00dev, 24, 0);
1799 + rt2800usb_rfcsr_read(rt2x00dev, 22, &rfcsr);
1800 + rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0);
1801 + rt2800usb_rfcsr_write(rt2x00dev, 22, rfcsr);
1804 + * set BBP back to BW20
1806 + rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
1807 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0);
1808 + rt2800usb_bbp_write(rt2x00dev, 4, bbp);
1814 + * Device state switch handlers.
1816 +static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
1817 + enum dev_state state)
1821 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1822 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX,
1823 + (state == STATE_RADIO_RX_ON) ||
1824 + (state == STATE_RADIO_RX_ON_LINK));
1825 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1828 +static int rt2800usb_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev)
1833 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1834 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1835 + if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) &&
1836 + !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY))
1842 + ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n");
1846 +static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1852 + * Initialize all registers.
1854 + if (unlikely(rt2800usb_wait_wpdma_ready(rt2x00dev) ||
1855 + rt2800usb_init_registers(rt2x00dev) ||
1856 + rt2800usb_init_bbp(rt2x00dev) ||
1857 + rt2800usb_init_rfcsr(rt2x00dev)))
1860 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1861 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1);
1862 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1866 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1867 + rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
1868 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1);
1869 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 1);
1870 + rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
1873 + rt2x00usb_register_read(rt2x00dev, USB_DMA_CFG, ®);
1874 + rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0);
1875 + /* Don't use bulk in aggregation when working with USB 1.1 */
1876 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN,
1877 + (rt2x00dev->rx->usb_maxpacket == 512));
1878 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
1879 + /* FIXME: Calculate this value based on Aggregation defines */
1880 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_LIMIT, 21);
1881 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_EN, 1);
1882 + rt2x00_set_field32(®, USB_DMA_CFG_TX_BULK_EN, 1);
1883 + rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, reg);
1885 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1886 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1);
1887 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, 1);
1888 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1891 + * Send signal to firmware during boot time.
1893 + rt2800usb_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0xff, 0, 0);
1896 + * Initialize LED control
1898 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word);
1899 + rt2800usb_mcu_request(rt2x00dev, MCU_LED_1, 0xff,
1900 + word & 0xff, (word >> 8) & 0xff);
1902 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word);
1903 + rt2800usb_mcu_request(rt2x00dev, MCU_LED_2, 0xff,
1904 + word & 0xff, (word >> 8) & 0xff);
1906 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word);
1907 + rt2800usb_mcu_request(rt2x00dev, MCU_LED_3, 0xff,
1908 + word & 0xff, (word >> 8) & 0xff);
1913 +static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
1917 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1918 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
1919 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
1920 + rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
1922 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0);
1923 + rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0);
1924 + rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, 0);
1926 + /* Wait for DMA, ignore error */
1927 + rt2800usb_wait_wpdma_ready(rt2x00dev);
1929 + rt2x00usb_disable_radio(rt2x00dev);
1932 +static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev,
1933 + enum dev_state state)
1935 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, 0);
1937 + if (state == STATE_AWAKE)
1938 + rt2800usb_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
1940 + rt2800usb_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2);
1945 +static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1946 + enum dev_state state)
1951 + case STATE_RADIO_ON:
1953 + * Before the radio can be enabled, the device first has
1954 + * to be woken up. After that it needs a bit of time
1955 + * to be fully awake and the radio can be enabled.
1957 + rt2800usb_set_state(rt2x00dev, STATE_AWAKE);
1959 + retval = rt2800usb_enable_radio(rt2x00dev);
1961 + case STATE_RADIO_OFF:
1963 + * After the radio has been disablee, the device should
1964 + * be put to sleep for powersaving.
1966 + rt2800usb_disable_radio(rt2x00dev);
1967 + rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
1969 + case STATE_RADIO_RX_ON:
1970 + case STATE_RADIO_RX_ON_LINK:
1971 + case STATE_RADIO_RX_OFF:
1972 + case STATE_RADIO_RX_OFF_LINK:
1973 + rt2800usb_toggle_rx(rt2x00dev, state);
1975 + case STATE_RADIO_IRQ_ON:
1976 + case STATE_RADIO_IRQ_OFF:
1977 + /* No support, but no error either */
1979 + case STATE_DEEP_SLEEP:
1981 + case STATE_STANDBY:
1983 + retval = rt2800usb_set_state(rt2x00dev, state);
1986 + retval = -ENOTSUPP;
1990 + if (unlikely(retval))
1991 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
1998 + * TX descriptor initialization
2000 +static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
2001 + struct sk_buff *skb,
2002 + struct txentry_desc *txdesc)
2004 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
2005 + __le32 *txi = skbdesc->desc;
2006 + __le32 *txwi = &txi[TXINFO_DESC_SIZE / sizeof(__le32)];
2010 + * Initialize TX Info descriptor
2012 + rt2x00_desc_read(txwi, 0, &word);
2013 + rt2x00_set_field32(&word, TXWI_W0_FRAG,
2014 + test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
2015 + rt2x00_set_field32(&word, TXWI_W0_MIMO_PS, 0);
2016 + rt2x00_set_field32(&word, TXWI_W0_CF_ACK, 0);
2017 + rt2x00_set_field32(&word, TXWI_W0_TS,
2018 + test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
2019 + rt2x00_set_field32(&word, TXWI_W0_AMPDU,
2020 + test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags));
2021 + rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY, txdesc->mpdu_density);
2022 + rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->ifs);
2023 + rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->mcs);
2024 + rt2x00_set_field32(&word, TXWI_W0_BW,
2025 + test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags));
2026 + rt2x00_set_field32(&word, TXWI_W0_SHORT_GI,
2027 + test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags));
2028 + rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->stbc);
2029 + rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode);
2030 + rt2x00_desc_write(txwi, 0, word);
2032 + rt2x00_desc_read(txwi, 1, &word);
2033 + rt2x00_set_field32(&word, TXWI_W1_ACK,
2034 + test_bit(ENTRY_TXD_ACK, &txdesc->flags));
2035 + rt2x00_set_field32(&word, TXWI_W1_NSEQ,
2036 + test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags));
2037 + rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size);
2038 + rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID,
2039 + test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ?
2040 + txdesc->key_idx : 0xff);
2041 + rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, skb->len);
2042 + rt2x00_set_field32(&word, TXWI_W1_PACKETID,
2043 + skbdesc->entry->entry_idx);
2044 + rt2x00_desc_write(txwi, 1, word);
2047 + * Always write 0 to IV/EIV fields, hardware will insert the IV
2048 + * from the IVEIV register when TXINFO_W0_WIV is set to 0.
2049 + * When TXINFO_W0_WIV is set to 1 it will use the IV data
2050 + * from the descriptor. The TXWI_W1_WIRELESS_CLI_ID indicates which
2051 + * crypto entry in the registers should be used to encrypt the frame.
2053 + _rt2x00_desc_write(txwi, 2, 0 /* skbdesc->iv[0] */);
2054 + _rt2x00_desc_write(txwi, 3, 0 /* skbdesc->iv[1] */);
2057 + * Initialize TX descriptor
2059 + rt2x00_desc_read(txi, 0, &word);
2060 + rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN,
2061 + skb->len + TXWI_DESC_SIZE);
2062 + rt2x00_set_field32(&word, TXINFO_W0_WIV,
2063 + !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags));
2064 + rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2);
2065 + rt2x00_set_field32(&word, TXINFO_W0_SW_USE_LAST_ROUND, 0);
2066 + rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_NEXT_VALID, 0);
2067 + rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_BURST,
2068 + test_bit(ENTRY_TXD_BURST, &txdesc->flags));
2069 + rt2x00_desc_write(txi, 0, word);
2073 + * TX data initialization
2075 +static void rt2800usb_write_beacon(struct queue_entry *entry)
2077 + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
2078 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
2079 + unsigned int beacon_base;
2083 + * Add the descriptor in front of the skb.
2085 + skb_push(entry->skb, entry->queue->desc_size);
2086 + memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
2087 + skbdesc->desc = entry->skb->data;
2090 + * Disable beaconing while we are reloading the beacon data,
2091 + * otherwise we might be sending out invalid data.
2093 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
2094 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 0);
2095 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 0);
2096 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0);
2097 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
2100 + * Write entire beacon with descriptor to register.
2102 + beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
2103 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
2104 + USB_VENDOR_REQUEST_OUT, beacon_base,
2105 + entry->skb->data, entry->skb->len,
2106 + REGISTER_TIMEOUT32(entry->skb->len));
2109 + * Clean up the beacon skb.
2111 + dev_kfree_skb(entry->skb);
2112 + entry->skb = NULL;
2115 +static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
2120 + * The length _must_ include 4 bytes padding,
2121 + * it should always be multiple of 4,
2122 + * but it must _not_ be a multiple of the USB packet size.
2124 + length = roundup(entry->skb->len + 4, 4);
2125 + length += (4 * !(length % entry->queue->usb_maxpacket));
2130 +static void rt2800usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
2131 + const enum data_queue_qid queue)
2135 + if (queue != QID_BEACON) {
2136 + rt2x00usb_kick_tx_queue(rt2x00dev, queue);
2140 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
2141 + if (!rt2x00_get_field32(reg, BCN_TIME_CFG_BEACON_GEN)) {
2142 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1);
2143 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1);
2144 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 1);
2145 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
2150 + * RX control handlers
2152 +static void rt2800usb_fill_rxdone(struct queue_entry *entry,
2153 + struct rxdone_entry_desc *rxdesc)
2155 + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
2156 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
2157 + __le32 *rxd = (__le32 *)entry->skb->data;
2166 + * Copy descriptor to the skbdesc->desc buffer, making it safe from
2167 + * moving of frame data in rt2x00usb.
2169 + memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
2170 + rxd = (__le32 *)skbdesc->desc;
2171 + rxwi = &rxd[RXD_DESC_SIZE / sizeof(__le32)];
2174 + * It is now safe to read the descriptor on all architectures.
2176 + rt2x00_desc_read(rxd, 0, &rxd0);
2177 + rt2x00_desc_read(rxwi, 0, &rxwi0);
2178 + rt2x00_desc_read(rxwi, 1, &rxwi1);
2179 + rt2x00_desc_read(rxwi, 2, &rxwi2);
2180 + rt2x00_desc_read(rxwi, 3, &rxwi3);
2182 + if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR))
2183 + rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
2185 + if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
2187 + * Unfortunately we don't know the cipher type used during
2188 + * decryption. This prevents us from correct providing
2189 + * correct statistics through debugfs.
2191 + rxdesc->cipher = CIPHER_NONE;
2192 + rxdesc->cipher_status =
2193 + rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
2196 + if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) {
2198 + * Hardware has stripped IV/EIV data from 802.11 frame during
2199 + * decryption. Unfortunately the descriptor doesn't contain
2200 + * any fields with the EIV/IV data either, so they can't
2201 + * be restored by rt2x00lib.
2203 + rxdesc->flags |= RX_FLAG_IV_STRIPPED;
2205 + if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
2206 + rxdesc->flags |= RX_FLAG_DECRYPTED;
2207 + else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
2208 + rxdesc->flags |= RX_FLAG_MMIC_ERROR;
2211 + if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
2212 + rxdesc->dev_flags |= RXDONE_MY_BSS;
2214 + if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
2215 + rxdesc->flags |= RX_FLAG_SHORT_GI;
2217 + if (rt2x00_get_field32(rxwi1, RXWI_W1_BW))
2218 + rxdesc->flags |= RX_FLAG_40MHZ;
2221 + * Detect RX rate, always use MCS as signal type.
2223 + rxdesc->dev_flags |= RXDONE_SIGNAL_MCS;
2224 + rxdesc->rate_mode = rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE);
2225 + rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
2228 + * Mask of 0x8 bit to remove the short preamble flag.
2230 + if (rxdesc->dev_flags == RATE_MODE_CCK)
2231 + rxdesc->signal &= ~0x8;
2234 + (rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
2235 + rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1)) / 2;
2238 + (rt2x00_get_field32(rxwi3, RXWI_W3_SNR0) +
2239 + rt2x00_get_field32(rxwi3, RXWI_W3_SNR1)) / 2;
2241 + rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
2244 + * Remove RXWI descriptor from start of buffer.
2246 + skb_pull(entry->skb, skbdesc->desc_len);
2247 + skb_trim(entry->skb, rxdesc->size);
2251 + * Device probe functions.
2253 +static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
2257 + u8 default_lna_gain;
2259 + rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
2262 + * Start validation of the data that has been read.
2264 + mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
2265 + if (!is_valid_ether_addr(mac)) {
2266 + DECLARE_MAC_BUF(macbuf);
2268 + random_ether_addr(mac);
2269 + EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac));
2272 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
2273 + if (word == 0xffff) {
2274 + rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
2275 + rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
2276 + rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
2277 + rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
2278 + EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
2279 + } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) {
2281 + * There is a max of 2 RX streams for RT2860 series
2283 + if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2)
2284 + rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
2285 + rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
2288 + rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
2289 + if (word == 0xffff) {
2290 + rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0);
2291 + rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0);
2292 + rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
2293 + rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
2294 + rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
2295 + rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0);
2296 + rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0);
2297 + rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0);
2298 + rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0);
2299 + rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0);
2300 + rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
2301 + EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
2304 + rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
2305 + if ((word & 0x00ff) == 0x00ff) {
2306 + rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
2307 + rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE,
2308 + LED_MODE_TXRX_ACTIVITY);
2309 + rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
2310 + rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
2311 + rt2x00_eeprom_write(rt2x00dev, EEPROM_LED1, 0x5555);
2312 + rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
2313 + rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
2314 + EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
2318 + * During the LNA validation we are going to use
2319 + * lna0 as correct value. Note that EEPROM_LNA
2320 + * is never validated.
2322 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
2323 + default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
2325 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
2326 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10)
2327 + rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0);
2328 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10)
2329 + rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
2330 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
2332 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
2333 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
2334 + rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
2335 + if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
2336 + rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
2337 + rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
2338 + default_lna_gain);
2339 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
2341 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
2342 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
2343 + rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0);
2344 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10)
2345 + rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0);
2346 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
2348 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
2349 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
2350 + rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
2351 + if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
2352 + rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
2353 + rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
2354 + default_lna_gain);
2355 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
2360 +static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
2367 + * Read EEPROM word for configuration.
2369 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
2372 + * Identify RF chipset.
2374 + value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
2375 + rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
2376 + rt2x00_set_chip(rt2x00dev, RT2870, value, reg);
2379 + * The check for rt2860 is not a typo, some rt2870 hardware
2380 + * identifies itself as rt2860 in the CSR register.
2382 + if ((rt2x00_get_field32(reg, MAC_CSR0_ASIC_VER) != 0x2860) &&
2383 + (rt2x00_get_field32(reg, MAC_CSR0_ASIC_VER) != 0x2870) &&
2384 + (rt2x00_get_field32(reg, MAC_CSR0_ASIC_VER) != 0x3070)) {
2385 + ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
2389 + if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
2390 + !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
2391 + !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
2392 + !rt2x00_rf(&rt2x00dev->chip, RF2750) &&
2393 + !rt2x00_rf(&rt2x00dev->chip, RF3020) &&
2394 + !rt2x00_rf(&rt2x00dev->chip, RF2020)) {
2395 + ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
2400 + * Read frequency offset and RF programming sequence.
2402 + rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
2403 + rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
2406 + * Read external LNA informations.
2408 + rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
2410 + if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
2411 + __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
2412 + if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
2413 + __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
2416 + * Detect if this device has an hardware controlled radio.
2418 +#ifdef CONFIG_RT2X00_LIB_RFKILL
2419 + if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
2420 + __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
2421 +#endif /* CONFIG_RT2X00_LIB_RFKILL */
2424 + * Store led settings, for correct led behaviour.
2426 +#ifdef CONFIG_RT2X00_LIB_LEDS
2427 + rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
2428 + rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
2429 + rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
2431 + rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ,
2432 + &rt2x00dev->led_mcu_reg);
2433 +#endif /* CONFIG_RT2X00_LIB_LEDS */
2439 + * RF value list for rt2870
2440 + * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
2442 +static const struct rf_channel rf_vals[] = {
2443 + { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
2444 + { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
2445 + { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
2446 + { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
2447 + { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
2448 + { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
2449 + { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
2450 + { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
2451 + { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
2452 + { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
2453 + { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
2454 + { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
2455 + { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
2456 + { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
2458 + /* 802.11 UNI / HyperLan 2 */
2459 + { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
2460 + { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
2461 + { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
2462 + { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
2463 + { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
2464 + { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
2465 + { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
2466 + { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
2467 + { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
2468 + { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
2469 + { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
2470 + { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
2472 + /* 802.11 HyperLan 2 */
2473 + { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
2474 + { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
2475 + { 104, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed1a3 },
2476 + { 108, 0x18402ecc, 0x184c0a32, 0x18578a55, 0x180ed193 },
2477 + { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
2478 + { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
2479 + { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
2480 + { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
2481 + { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
2482 + { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
2483 + { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
2484 + { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
2485 + { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
2486 + { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
2487 + { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
2488 + { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
2491 + { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
2492 + { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
2493 + { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
2494 + { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
2495 + { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
2496 + { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
2497 + { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
2499 + /* 802.11 Japan */
2500 + { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
2501 + { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
2502 + { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
2503 + { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
2504 + { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
2505 + { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
2506 + { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
2510 + * RF value list for rt3070
2511 + * Supports: 2.4 GHz
2513 +static const struct rf_channel rf_vals_3070[] = {
2530 +static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2532 + struct hw_mode_spec *spec = &rt2x00dev->spec;
2533 + struct channel_info *info;
2540 + * Initialize all hw fields.
2542 + rt2x00dev->hw->flags =
2543 + IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
2544 + IEEE80211_HW_SIGNAL_DBM |
2545 + IEEE80211_HW_SUPPORTS_PS |
2546 + IEEE80211_HW_PS_NULLFUNC_STACK;
2547 + rt2x00dev->hw->extra_tx_headroom = TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
2549 + SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
2550 + SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
2551 + rt2x00_eeprom_addr(rt2x00dev,
2552 + EEPROM_MAC_ADDR_0));
2554 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
2557 + * Initialize HT information.
2559 + spec->ht.ht_supported = true;
2561 + IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
2562 + IEEE80211_HT_CAP_GRN_FLD |
2563 + IEEE80211_HT_CAP_SGI_20 |
2564 + IEEE80211_HT_CAP_SGI_40 |
2565 + IEEE80211_HT_CAP_TX_STBC |
2566 + IEEE80211_HT_CAP_RX_STBC |
2567 + IEEE80211_HT_CAP_PSMP_SUPPORT;
2568 + spec->ht.ampdu_factor = 3;
2569 + spec->ht.ampdu_density = 4;
2570 + spec->ht.mcs.tx_params =
2571 + IEEE80211_HT_MCS_TX_DEFINED |
2572 + IEEE80211_HT_MCS_TX_RX_DIFF |
2573 + ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
2574 + IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
2576 + switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
2578 + spec->ht.mcs.rx_mask[2] = 0xff;
2580 + spec->ht.mcs.rx_mask[1] = 0xff;
2582 + spec->ht.mcs.rx_mask[0] = 0xff;
2583 + spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
2588 + * Initialize hw_mode information.
2590 + spec->supported_bands = SUPPORT_BAND_2GHZ;
2591 + spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
2593 + if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
2594 + rt2x00_rf(&rt2x00dev->chip, RF2720)) {
2595 + spec->num_channels = 14;
2596 + spec->channels = rf_vals;
2597 + } else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
2598 + rt2x00_rf(&rt2x00dev->chip, RF2750)) {
2599 + spec->supported_bands |= SUPPORT_BAND_5GHZ;
2600 + spec->num_channels = ARRAY_SIZE(rf_vals);
2601 + spec->channels = rf_vals;
2602 + } else if (rt2x00_rf(&rt2x00dev->chip, RF3020) ||
2603 + rt2x00_rf(&rt2x00dev->chip, RF2020)) {
2604 + spec->num_channels = ARRAY_SIZE(rf_vals_3070);
2605 + spec->channels = rf_vals_3070;
2609 + * Create channel information array
2611 + info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
2615 + spec->channels_info = info;
2617 + tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
2618 + tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
2620 + for (i = 0; i < 14; i++) {
2621 + info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
2622 + info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
2625 + if (spec->num_channels > 14) {
2626 + tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
2627 + tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
2629 + for (i = 14; i < spec->num_channels; i++) {
2630 + info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
2631 + info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
2638 +static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
2643 + * Allocate eeprom data.
2645 + retval = rt2800usb_validate_eeprom(rt2x00dev);
2649 + retval = rt2800usb_init_eeprom(rt2x00dev);
2654 + * Initialize hw specifications.
2656 + retval = rt2800usb_probe_hw_mode(rt2x00dev);
2661 + * This device requires firmware.
2663 + __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
2664 + __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
2665 + if (!modparam_nohwcrypt)
2666 + __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);
2669 + * Set the rssi offset.
2671 + rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
2677 + * IEEE80211 stack callback functions.
2679 +static void rt2800usb_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
2680 + u32 *iv32, u16 *iv16)
2682 + struct rt2x00_dev *rt2x00dev = hw->priv;
2683 + struct mac_iveiv_entry iveiv_entry;
2686 + offset = MAC_IVEIV_ENTRY(hw_key_idx);
2687 + rt2x00usb_register_multiread(rt2x00dev, offset,
2688 + &iveiv_entry, sizeof(iveiv_entry));
2690 + memcpy(&iveiv_entry.iv[0], iv16, sizeof(iv16));
2691 + memcpy(&iveiv_entry.iv[4], iv32, sizeof(iv32));
2694 +static int rt2800usb_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
2696 + struct rt2x00_dev *rt2x00dev = hw->priv;
2698 + bool enabled = (value < IEEE80211_MAX_RTS_THRESHOLD);
2700 + rt2x00usb_register_read(rt2x00dev, TX_RTS_CFG, ®);
2701 + rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES, value);
2702 + rt2x00usb_register_write(rt2x00dev, TX_RTS_CFG, reg);
2704 + rt2x00usb_register_read(rt2x00dev, CCK_PROT_CFG, ®);
2705 + rt2x00_set_field32(®, CCK_PROT_CFG_RTS_TH_EN, enabled);
2706 + rt2x00usb_register_write(rt2x00dev, CCK_PROT_CFG, reg);
2708 + rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, ®);
2709 + rt2x00_set_field32(®, OFDM_PROT_CFG_RTS_TH_EN, enabled);
2710 + rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
2712 + rt2x00usb_register_read(rt2x00dev, MM20_PROT_CFG, ®);
2713 + rt2x00_set_field32(®, MM20_PROT_CFG_RTS_TH_EN, enabled);
2714 + rt2x00usb_register_write(rt2x00dev, MM20_PROT_CFG, reg);
2716 + rt2x00usb_register_read(rt2x00dev, MM40_PROT_CFG, ®);
2717 + rt2x00_set_field32(®, MM40_PROT_CFG_RTS_TH_EN, enabled);
2718 + rt2x00usb_register_write(rt2x00dev, MM40_PROT_CFG, reg);
2720 + rt2x00usb_register_read(rt2x00dev, GF20_PROT_CFG, ®);
2721 + rt2x00_set_field32(®, GF20_PROT_CFG_RTS_TH_EN, enabled);
2722 + rt2x00usb_register_write(rt2x00dev, GF20_PROT_CFG, reg);
2724 + rt2x00usb_register_read(rt2x00dev, GF40_PROT_CFG, ®);
2725 + rt2x00_set_field32(®, GF40_PROT_CFG_RTS_TH_EN, enabled);
2726 + rt2x00usb_register_write(rt2x00dev, GF40_PROT_CFG, reg);
2731 +static int rt2800usb_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2732 + const struct ieee80211_tx_queue_params *params)
2734 + struct rt2x00_dev *rt2x00dev = hw->priv;
2735 + struct data_queue *queue;
2736 + struct rt2x00_field32 field;
2742 + * First pass the configuration through rt2x00lib, that will
2743 + * update the queue settings and validate the input. After that
2744 + * we are free to update the registers based on the value
2745 + * in the queue parameter.
2747 + retval = rt2x00mac_conf_tx(hw, queue_idx, params);
2752 + * We only need to perform additional register initialization
2755 + if (queue_idx >= 4)
2758 + queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
2760 + /* Update WMM TXOP register */
2761 + offset = WMM_TXOP0_CFG + (sizeof(u32) * (!!(queue_idx & 2)));
2762 + field.bit_offset = (queue_idx & 1) * 16;
2763 + field.bit_mask = 0xffff << field.bit_offset;
2765 + rt2x00usb_register_read(rt2x00dev, offset, ®);
2766 + rt2x00_set_field32(®, field, queue->txop);
2767 + rt2x00usb_register_write(rt2x00dev, offset, reg);
2769 + /* Update WMM registers */
2770 + field.bit_offset = queue_idx * 4;
2771 + field.bit_mask = 0xf << field.bit_offset;
2773 + rt2x00usb_register_read(rt2x00dev, WMM_AIFSN_CFG, ®);
2774 + rt2x00_set_field32(®, field, queue->aifs);
2775 + rt2x00usb_register_write(rt2x00dev, WMM_AIFSN_CFG, reg);
2777 + rt2x00usb_register_read(rt2x00dev, WMM_CWMIN_CFG, ®);
2778 + rt2x00_set_field32(®, field, queue->cw_min);
2779 + rt2x00usb_register_write(rt2x00dev, WMM_CWMIN_CFG, reg);
2781 + rt2x00usb_register_read(rt2x00dev, WMM_CWMAX_CFG, ®);
2782 + rt2x00_set_field32(®, field, queue->cw_max);
2783 + rt2x00usb_register_write(rt2x00dev, WMM_CWMAX_CFG, reg);
2785 + /* Update EDCA registers */
2786 + offset = EDCA_AC0_CFG + (sizeof(u32) * queue_idx);
2788 + rt2x00usb_register_read(rt2x00dev, offset, ®);
2789 + rt2x00_set_field32(®, EDCA_AC0_CFG_TX_OP, queue->txop);
2790 + rt2x00_set_field32(®, EDCA_AC0_CFG_AIFSN, queue->aifs);
2791 + rt2x00_set_field32(®, EDCA_AC0_CFG_CWMIN, queue->cw_min);
2792 + rt2x00_set_field32(®, EDCA_AC0_CFG_CWMAX, queue->cw_max);
2793 + rt2x00usb_register_write(rt2x00dev, offset, reg);
2798 +static u64 rt2800usb_get_tsf(struct ieee80211_hw *hw)
2800 + struct rt2x00_dev *rt2x00dev = hw->priv;
2804 + rt2x00usb_register_read(rt2x00dev, TSF_TIMER_DW1, ®);
2805 + tsf = (u64) rt2x00_get_field32(reg, TSF_TIMER_DW1_HIGH_WORD) << 32;
2806 + rt2x00usb_register_read(rt2x00dev, TSF_TIMER_DW0, ®);
2807 + tsf |= rt2x00_get_field32(reg, TSF_TIMER_DW0_LOW_WORD);
2812 +static const struct ieee80211_ops rt2800usb_mac80211_ops = {
2813 + .tx = rt2x00mac_tx,
2814 + .start = rt2x00mac_start,
2815 + .stop = rt2x00mac_stop,
2816 + .add_interface = rt2x00mac_add_interface,
2817 + .remove_interface = rt2x00mac_remove_interface,
2818 + .config = rt2x00mac_config,
2819 + .config_interface = rt2x00mac_config_interface,
2820 + .configure_filter = rt2x00mac_configure_filter,
2821 + .set_key = rt2x00mac_set_key,
2822 + .get_stats = rt2x00mac_get_stats,
2823 + .get_tkip_seq = rt2800usb_get_tkip_seq,
2824 + .set_rts_threshold = rt2800usb_set_rts_threshold,
2825 + .bss_info_changed = rt2x00mac_bss_info_changed,
2826 + .conf_tx = rt2800usb_conf_tx,
2827 + .get_tx_stats = rt2x00mac_get_tx_stats,
2828 + .get_tsf = rt2800usb_get_tsf,
2831 +static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
2832 + .probe_hw = rt2800usb_probe_hw,
2833 + .get_firmware_name = rt2800usb_get_firmware_name,
2834 + .check_firmware = rt2800usb_check_firmware,
2835 + .load_firmware = rt2800usb_load_firmware,
2836 + .initialize = rt2x00usb_initialize,
2837 + .uninitialize = rt2x00usb_uninitialize,
2838 + .clear_entry = rt2x00usb_clear_entry,
2839 + .set_device_state = rt2800usb_set_device_state,
2840 + .rfkill_poll = rt2800usb_rfkill_poll,
2841 + .link_stats = rt2800usb_link_stats,
2842 + .reset_tuner = rt2800usb_reset_tuner,
2843 + .link_tuner = rt2800usb_link_tuner,
2844 + .write_tx_desc = rt2800usb_write_tx_desc,
2845 + .write_tx_data = rt2x00usb_write_tx_data,
2846 + .write_beacon = rt2800usb_write_beacon,
2847 + .get_tx_data_len = rt2800usb_get_tx_data_len,
2848 + .kick_tx_queue = rt2800usb_kick_tx_queue,
2849 + .kill_tx_queue = rt2x00usb_kill_tx_queue,
2850 + .fill_rxdone = rt2800usb_fill_rxdone,
2851 + .config_shared_key = rt2800usb_config_shared_key,
2852 + .config_pairwise_key = rt2800usb_config_pairwise_key,
2853 + .config_filter = rt2800usb_config_filter,
2854 + .config_intf = rt2800usb_config_intf,
2855 + .config_erp = rt2800usb_config_erp,
2856 + .config_ant = rt2800usb_config_ant,
2857 + .config = rt2800usb_config,
2860 +static const struct data_queue_desc rt2800usb_queue_rx = {
2861 + .entry_num = RX_ENTRIES,
2862 + .data_size = AGGREGATION_SIZE,
2863 + .desc_size = RXD_DESC_SIZE + RXWI_DESC_SIZE,
2864 + .priv_size = sizeof(struct queue_entry_priv_usb),
2867 +static const struct data_queue_desc rt2800usb_queue_tx = {
2868 + .entry_num = TX_ENTRIES,
2869 + .data_size = AGGREGATION_SIZE,
2870 + .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
2871 + .priv_size = sizeof(struct queue_entry_priv_usb),
2874 +static const struct data_queue_desc rt2800usb_queue_bcn = {
2875 + .entry_num = 8 * BEACON_ENTRIES,
2876 + .data_size = MGMT_FRAME_SIZE,
2877 + .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
2878 + .priv_size = sizeof(struct queue_entry_priv_usb),
2881 +static const struct rt2x00_ops rt2800usb_ops = {
2882 + .name = KBUILD_MODNAME,
2883 + .max_sta_intf = 1,
2885 + .eeprom_size = EEPROM_SIZE,
2886 + .rf_size = RF_SIZE,
2887 + .tx_queues = NUM_TX_QUEUES,
2888 + .rx = &rt2800usb_queue_rx,
2889 + .tx = &rt2800usb_queue_tx,
2890 + .bcn = &rt2800usb_queue_bcn,
2891 + .lib = &rt2800usb_rt2x00_ops,
2892 + .hw = &rt2800usb_mac80211_ops,
2893 +#ifdef CONFIG_RT2X00_LIB_DEBUGFS
2894 + .debugfs = &rt2800usb_rt2x00debug,
2895 +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
2899 + * rt2800usb module information.
2901 +static struct usb_device_id rt2800usb_device_table[] = {
2903 + { USB_DEVICE(0x07b8, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
2904 + { USB_DEVICE(0x07b8, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
2905 + { USB_DEVICE(0x07b8, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
2906 + { USB_DEVICE(0x07b8, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
2907 + { USB_DEVICE(0x07b8, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
2908 + { USB_DEVICE(0x1482, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
2910 + { USB_DEVICE(0x1eda, 0x2310), USB_DEVICE_DATA(&rt2800usb_ops) },
2912 + { USB_DEVICE(0x0e0b, 0x9031), USB_DEVICE_DATA(&rt2800usb_ops) },
2913 + { USB_DEVICE(0x0e0b, 0x9041), USB_DEVICE_DATA(&rt2800usb_ops) },
2915 + { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
2917 + { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) },
2918 + { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) },
2919 + { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) },
2920 + { USB_DEVICE(0x0b05, 0x1760), USB_DEVICE_DATA(&rt2800usb_ops) },
2921 + { USB_DEVICE(0x0b05, 0x1761), USB_DEVICE_DATA(&rt2800usb_ops) },
2923 + { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) },
2924 + { USB_DEVICE(0x13d3, 0x3262), USB_DEVICE_DATA(&rt2800usb_ops) },
2925 + { USB_DEVICE(0x13d3, 0x3273), USB_DEVICE_DATA(&rt2800usb_ops) },
2927 + { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) },
2928 + { USB_DEVICE(0x050d, 0x805c), USB_DEVICE_DATA(&rt2800usb_ops) },
2929 + { USB_DEVICE(0x050d, 0x815c), USB_DEVICE_DATA(&rt2800usb_ops) },
2931 + { USB_DEVICE(0x0411, 0x012e), USB_DEVICE_DATA(&rt2800usb_ops) },
2932 + /* Conceptronic */
2933 + { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) },
2934 + { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) },
2935 + { USB_DEVICE(0x14b2, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
2936 + { USB_DEVICE(0x14b2, 0x3c12), USB_DEVICE_DATA(&rt2800usb_ops) },
2937 + { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) },
2938 + { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) },
2939 + { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) },
2940 + { USB_DEVICE(0x14b2, 0x3c28), USB_DEVICE_DATA(&rt2800usb_ops) },
2942 + { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) },
2943 + { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
2944 + { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
2945 + { USB_DEVICE(0x18c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
2946 + { USB_DEVICE(0x18c5, 0x0012), USB_DEVICE_DATA(&rt2800usb_ops) },
2948 + { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
2949 + { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
2950 + { USB_DEVICE(0x07d1, 0x3c13), USB_DEVICE_DATA(&rt2800usb_ops) },
2951 + { USB_DEVICE(0x2001, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
2952 + { USB_DEVICE(0x2001, 0x3c0a), USB_DEVICE_DATA(&rt2800usb_ops) },
2954 + { USB_DEVICE(0x7392, 0x7711), USB_DEVICE_DATA(&rt2800usb_ops) },
2955 + { USB_DEVICE(0x7392, 0x7717), USB_DEVICE_DATA(&rt2800usb_ops) },
2956 + { USB_DEVICE(0x7392, 0x7718), USB_DEVICE_DATA(&rt2800usb_ops) },
2958 + { USB_DEVICE(0X1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) },
2959 + { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) },
2960 + { USB_DEVICE(0x1740, 0x9703), USB_DEVICE_DATA(&rt2800usb_ops) },
2962 + { USB_DEVICE(0x15a9, 0x0010), USB_DEVICE_DATA(&rt2800usb_ops) },
2964 + { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) },
2965 + { USB_DEVICE(0x1044, 0x800c), USB_DEVICE_DATA(&rt2800usb_ops) },
2966 + { USB_DEVICE(0x1044, 0x800d), USB_DEVICE_DATA(&rt2800usb_ops) },
2968 + { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) },
2969 + { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) },
2970 + { USB_DEVICE(0x0e66, 0x0009), USB_DEVICE_DATA(&rt2800usb_ops) },
2971 + { USB_DEVICE(0x0e66, 0x000b), USB_DEVICE_DATA(&rt2800usb_ops) },
2973 + { USB_DEVICE(0x1740, 0x0605), USB_DEVICE_DATA(&rt2800usb_ops) },
2974 + { USB_DEVICE(0x1740, 0x0615), USB_DEVICE_DATA(&rt2800usb_ops) },
2976 + { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) },
2978 + { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) },
2979 + { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) },
2980 + { USB_DEVICE(0x0789, 0x0164), USB_DEVICE_DATA(&rt2800usb_ops) },
2982 + { USB_DEVICE(0x1d4d, 0x0002), USB_DEVICE_DATA(&rt2800usb_ops) },
2984 + { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) },
2986 + { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) },
2987 + { USB_DEVICE(0x2019, 0xab24), USB_DEVICE_DATA(&rt2800usb_ops) },
2988 + { USB_DEVICE(0x2019, 0xab25), USB_DEVICE_DATA(&rt2800usb_ops) },
2990 + { USB_DEVICE(0x18e8, 0x6259), USB_DEVICE_DATA(&rt2800usb_ops) },
2992 + { USB_DEVICE(0x1a32, 0x0304), USB_DEVICE_DATA(&rt2800usb_ops) },
2994 + { USB_DEVICE(0x148f, 0x2070), USB_DEVICE_DATA(&rt2800usb_ops) },
2995 + { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
2996 + { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
2997 + { USB_DEVICE(0x148f, 0x3070), USB_DEVICE_DATA(&rt2800usb_ops) },
2998 + { USB_DEVICE(0x148f, 0x3071), USB_DEVICE_DATA(&rt2800usb_ops) },
2999 + { USB_DEVICE(0x148f, 0x3072), USB_DEVICE_DATA(&rt2800usb_ops) },
3001 + { USB_DEVICE(0x04e8, 0x2018), USB_DEVICE_DATA(&rt2800usb_ops) },
3003 + { USB_DEVICE(0x129b, 0x1828), USB_DEVICE_DATA(&rt2800usb_ops) },
3005 + { USB_DEVICE(0x0df6, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) },
3006 + { USB_DEVICE(0x0df6, 0x002b), USB_DEVICE_DATA(&rt2800usb_ops) },
3007 + { USB_DEVICE(0x0df6, 0x002c), USB_DEVICE_DATA(&rt2800usb_ops) },
3008 + { USB_DEVICE(0x0df6, 0x002d), USB_DEVICE_DATA(&rt2800usb_ops) },
3009 + { USB_DEVICE(0x0df6, 0x0039), USB_DEVICE_DATA(&rt2800usb_ops) },
3010 + { USB_DEVICE(0x0df6, 0x003b), USB_DEVICE_DATA(&rt2800usb_ops) },
3011 + { USB_DEVICE(0x0df6, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
3012 + { USB_DEVICE(0x0df6, 0x003d), USB_DEVICE_DATA(&rt2800usb_ops) },
3013 + { USB_DEVICE(0x0df6, 0x003e), USB_DEVICE_DATA(&rt2800usb_ops) },
3014 + { USB_DEVICE(0x0df6, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
3016 + { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) },
3017 + { USB_DEVICE(0x083a, 0x7511), USB_DEVICE_DATA(&rt2800usb_ops) },
3018 + { USB_DEVICE(0x083a, 0x7512), USB_DEVICE_DATA(&rt2800usb_ops) },
3019 + { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) },
3020 + { USB_DEVICE(0x083a, 0x8522), USB_DEVICE_DATA(&rt2800usb_ops) },
3021 + { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) },
3022 + { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) },
3024 + { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) },
3026 + { USB_DEVICE(0x157e, 0x300e), USB_DEVICE_DATA(&rt2800usb_ops) },
3028 + { USB_DEVICE(0x0cde, 0x0022), USB_DEVICE_DATA(&rt2800usb_ops) },
3029 + { USB_DEVICE(0x0cde, 0x0025), USB_DEVICE_DATA(&rt2800usb_ops) },
3031 + { USB_DEVICE(0x5a57, 0x0280), USB_DEVICE_DATA(&rt2800usb_ops) },
3032 + { USB_DEVICE(0x5a57, 0x0282), USB_DEVICE_DATA(&rt2800usb_ops) },
3034 + { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) },
3038 +MODULE_AUTHOR(DRV_PROJECT);
3039 +MODULE_VERSION(DRV_VERSION);
3040 +MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
3041 +MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards");
3042 +MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
3043 +MODULE_FIRMWARE(FIRMWARE_RT2870);
3044 +MODULE_LICENSE("GPL");
3046 +static struct usb_driver rt2800usb_driver = {
3047 + .name = KBUILD_MODNAME,
3048 + .id_table = rt2800usb_device_table,
3049 + .probe = rt2x00usb_probe,
3050 + .disconnect = rt2x00usb_disconnect,
3051 + .suspend = rt2x00usb_suspend,
3052 + .resume = rt2x00usb_resume,
3055 +static int __init rt2800usb_init(void)
3057 + return usb_register(&rt2800usb_driver);
3060 +static void __exit rt2800usb_exit(void)
3062 + usb_deregister(&rt2800usb_driver);
3065 +module_init(rt2800usb_init);
3066 +module_exit(rt2800usb_exit);
3068 +++ b/drivers/net/wireless/rt2x00/rt2800usb.h
3071 + Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3072 + <http://rt2x00.serialmonkey.com>
3074 + This program is free software; you can redistribute it and/or modify
3075 + it under the terms of the GNU General Public License as published by
3076 + the Free Software Foundation; either version 2 of the License, or
3077 + (at your option) any later version.
3079 + This program is distributed in the hope that it will be useful,
3080 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3081 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3082 + GNU General Public License for more details.
3084 + You should have received a copy of the GNU General Public License
3085 + along with this program; if not, write to the
3086 + Free Software Foundation, Inc.,
3087 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3092 + Abstract: Data structures and registers for the rt2800usb module.
3093 + Supported chipsets: RT2800U.
3096 +#ifndef RT2800USB_H
3097 +#define RT2800USB_H
3100 + * RF chip defines.
3102 + * RF2820 2.4G 2T3R
3103 + * RF2850 2.4G/5G 2T3R
3104 + * RF2720 2.4G 1T2R
3105 + * RF2750 2.4G/5G 1T2R
3106 + * RF3020 2.4G 1T1R
3109 +#define RF2820 0x0001
3110 +#define RF2850 0x0002
3111 +#define RF2720 0x0003
3112 +#define RF2750 0x0004
3113 +#define RF3020 0x0005
3114 +#define RF2020 0x0006
3119 +#define RT2860C_VERSION 0x28600100
3120 +#define RT2860D_VERSION 0x28600101
3121 +#define RT2880E_VERSION 0x28720200
3122 +#define RT2883_VERSION 0x28830300
3123 +#define RT3070_VERSION 0x30700200
3126 + * Signal information.
3127 + * Defaul offset is required for RSSI <-> dBm conversion.
3129 +#define DEFAULT_RSSI_OFFSET 120 /* FIXME */
3132 + * Register layout information.
3134 +#define CSR_REG_BASE 0x1000
3135 +#define CSR_REG_SIZE 0x0800
3136 +#define EEPROM_BASE 0x0000
3137 +#define EEPROM_SIZE 0x0110
3138 +#define BBP_BASE 0x0000
3139 +#define BBP_SIZE 0x0080
3140 +#define RF_BASE 0x0004
3141 +#define RF_SIZE 0x0010
3144 + * Number of TX queues.
3146 +#define NUM_TX_QUEUES 4
3153 + * HOST-MCU shared memory
3155 +#define HOST_CMD_CSR 0x0404
3156 +#define HOST_CMD_CSR_HOST_COMMAND FIELD32(0x000000ff)
3159 + * INT_SOURCE_CSR: Interrupt source register.
3160 + * Write one to clear corresponding bit.
3161 + * TX_FIFO_STATUS: FIFO Statistics is full, sw should read 0x171c
3163 +#define INT_SOURCE_CSR 0x0200
3164 +#define INT_SOURCE_CSR_RXDELAYINT FIELD32(0x00000001)
3165 +#define INT_SOURCE_CSR_TXDELAYINT FIELD32(0x00000002)
3166 +#define INT_SOURCE_CSR_RX_DONE FIELD32(0x00000004)
3167 +#define INT_SOURCE_CSR_AC0_DMA_DONE FIELD32(0x00000008)
3168 +#define INT_SOURCE_CSR_AC1_DMA_DONE FIELD32(0x00000010)
3169 +#define INT_SOURCE_CSR_AC2_DMA_DONE FIELD32(0x00000020)
3170 +#define INT_SOURCE_CSR_AC3_DMA_DONE FIELD32(0x00000040)
3171 +#define INT_SOURCE_CSR_HCCA_DMA_DONE FIELD32(0x00000080)
3172 +#define INT_SOURCE_CSR_MGMT_DMA_DONE FIELD32(0x00000100)
3173 +#define INT_SOURCE_CSR_MCU_COMMAND FIELD32(0x00000200)
3174 +#define INT_SOURCE_CSR_RXTX_COHERENT FIELD32(0x00000400)
3175 +#define INT_SOURCE_CSR_TBTT FIELD32(0x00000800)
3176 +#define INT_SOURCE_CSR_PRE_TBTT FIELD32(0x00001000)
3177 +#define INT_SOURCE_CSR_TX_FIFO_STATUS FIELD32(0x00002000)
3178 +#define INT_SOURCE_CSR_AUTO_WAKEUP FIELD32(0x00004000)
3179 +#define INT_SOURCE_CSR_GPTIMER FIELD32(0x00008000)
3180 +#define INT_SOURCE_CSR_RX_COHERENT FIELD32(0x00010000)
3181 +#define INT_SOURCE_CSR_TX_COHERENT FIELD32(0x00020000)
3184 + * INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF.
3186 +#define INT_MASK_CSR 0x0204
3187 +#define INT_MASK_CSR_RXDELAYINT FIELD32(0x00000001)
3188 +#define INT_MASK_CSR_TXDELAYINT FIELD32(0x00000002)
3189 +#define INT_MASK_CSR_RX_DONE FIELD32(0x00000004)
3190 +#define INT_MASK_CSR_AC0_DMA_DONE FIELD32(0x00000008)
3191 +#define INT_MASK_CSR_AC1_DMA_DONE FIELD32(0x00000010)
3192 +#define INT_MASK_CSR_AC2_DMA_DONE FIELD32(0x00000020)
3193 +#define INT_MASK_CSR_AC3_DMA_DONE FIELD32(0x00000040)
3194 +#define INT_MASK_CSR_HCCA_DMA_DONE FIELD32(0x00000080)
3195 +#define INT_MASK_CSR_MGMT_DMA_DONE FIELD32(0x00000100)
3196 +#define INT_MASK_CSR_MCU_COMMAND FIELD32(0x00000200)
3197 +#define INT_MASK_CSR_RXTX_COHERENT FIELD32(0x00000400)
3198 +#define INT_MASK_CSR_TBTT FIELD32(0x00000800)
3199 +#define INT_MASK_CSR_PRE_TBTT FIELD32(0x00001000)
3200 +#define INT_MASK_CSR_TX_FIFO_STATUS FIELD32(0x00002000)
3201 +#define INT_MASK_CSR_AUTO_WAKEUP FIELD32(0x00004000)
3202 +#define INT_MASK_CSR_GPTIMER FIELD32(0x00008000)
3203 +#define INT_MASK_CSR_RX_COHERENT FIELD32(0x00010000)
3204 +#define INT_MASK_CSR_TX_COHERENT FIELD32(0x00020000)
3209 +#define WPDMA_GLO_CFG 0x0208
3210 +#define WPDMA_GLO_CFG_ENABLE_TX_DMA FIELD32(0x00000001)
3211 +#define WPDMA_GLO_CFG_TX_DMA_BUSY FIELD32(0x00000002)
3212 +#define WPDMA_GLO_CFG_ENABLE_RX_DMA FIELD32(0x00000004)
3213 +#define WPDMA_GLO_CFG_RX_DMA_BUSY FIELD32(0x00000008)
3214 +#define WPDMA_GLO_CFG_WP_DMA_BURST_SIZE FIELD32(0x00000030)
3215 +#define WPDMA_GLO_CFG_TX_WRITEBACK_DONE FIELD32(0x00000040)
3216 +#define WPDMA_GLO_CFG_BIG_ENDIAN FIELD32(0x00000080)
3217 +#define WPDMA_GLO_CFG_RX_HDR_SCATTER FIELD32(0x0000ff00)
3218 +#define WPDMA_GLO_CFG_HDR_SEG_LEN FIELD32(0xffff0000)
3223 +#define WPDMA_RST_IDX 0x020c
3224 +#define WPDMA_RST_IDX_DTX_IDX0 FIELD32(0x00000001)
3225 +#define WPDMA_RST_IDX_DTX_IDX1 FIELD32(0x00000002)
3226 +#define WPDMA_RST_IDX_DTX_IDX2 FIELD32(0x00000004)
3227 +#define WPDMA_RST_IDX_DTX_IDX3 FIELD32(0x00000008)
3228 +#define WPDMA_RST_IDX_DTX_IDX4 FIELD32(0x00000010)
3229 +#define WPDMA_RST_IDX_DTX_IDX5 FIELD32(0x00000020)
3230 +#define WPDMA_RST_IDX_DRX_IDX0 FIELD32(0x00010000)
3235 +#define DELAY_INT_CFG 0x0210
3236 +#define DELAY_INT_CFG_RXMAX_PTIME FIELD32(0x000000ff)
3237 +#define DELAY_INT_CFG_RXMAX_PINT FIELD32(0x00007f00)
3238 +#define DELAY_INT_CFG_RXDLY_INT_EN FIELD32(0x00008000)
3239 +#define DELAY_INT_CFG_TXMAX_PTIME FIELD32(0x00ff0000)
3240 +#define DELAY_INT_CFG_TXMAX_PINT FIELD32(0x7f000000)
3241 +#define DELAY_INT_CFG_TXDLY_INT_EN FIELD32(0x80000000)
3244 + * WMM_AIFSN_CFG: Aifsn for each EDCA AC
3250 +#define WMM_AIFSN_CFG 0x0214
3251 +#define WMM_AIFSN_CFG_AIFSN0 FIELD32(0x0000000f)
3252 +#define WMM_AIFSN_CFG_AIFSN1 FIELD32(0x000000f0)
3253 +#define WMM_AIFSN_CFG_AIFSN2 FIELD32(0x00000f00)
3254 +#define WMM_AIFSN_CFG_AIFSN3 FIELD32(0x0000f000)
3257 + * WMM_CWMIN_CSR: CWmin for each EDCA AC
3263 +#define WMM_CWMIN_CFG 0x0218
3264 +#define WMM_CWMIN_CFG_CWMIN0 FIELD32(0x0000000f)
3265 +#define WMM_CWMIN_CFG_CWMIN1 FIELD32(0x000000f0)
3266 +#define WMM_CWMIN_CFG_CWMIN2 FIELD32(0x00000f00)
3267 +#define WMM_CWMIN_CFG_CWMIN3 FIELD32(0x0000f000)
3270 + * WMM_CWMAX_CSR: CWmax for each EDCA AC
3276 +#define WMM_CWMAX_CFG 0x021c
3277 +#define WMM_CWMAX_CFG_CWMAX0 FIELD32(0x0000000f)
3278 +#define WMM_CWMAX_CFG_CWMAX1 FIELD32(0x000000f0)
3279 +#define WMM_CWMAX_CFG_CWMAX2 FIELD32(0x00000f00)
3280 +#define WMM_CWMAX_CFG_CWMAX3 FIELD32(0x0000f000)
3283 + * AC_TXOP0: AC_BK/AC_BE TXOP register
3284 + * AC0TXOP: AC_BK in unit of 32us
3285 + * AC1TXOP: AC_BE in unit of 32us
3287 +#define WMM_TXOP0_CFG 0x0220
3288 +#define WMM_TXOP0_CFG_AC0TXOP FIELD32(0x0000ffff)
3289 +#define WMM_TXOP0_CFG_AC1TXOP FIELD32(0xffff0000)
3292 + * AC_TXOP1: AC_VO/AC_VI TXOP register
3293 + * AC2TXOP: AC_VI in unit of 32us
3294 + * AC3TXOP: AC_VO in unit of 32us
3296 +#define WMM_TXOP1_CFG 0x0224
3297 +#define WMM_TXOP1_CFG_AC2TXOP FIELD32(0x0000ffff)
3298 +#define WMM_TXOP1_CFG_AC3TXOP FIELD32(0xffff0000)
3303 +#define GPIO_CTRL_CFG 0x0228
3304 +#define GPIO_CTRL_CFG_BIT0 FIELD32(0x00000001)
3305 +#define GPIO_CTRL_CFG_BIT1 FIELD32(0x00000002)
3306 +#define GPIO_CTRL_CFG_BIT2 FIELD32(0x00000004)
3307 +#define GPIO_CTRL_CFG_BIT3 FIELD32(0x00000008)
3308 +#define GPIO_CTRL_CFG_BIT4 FIELD32(0x00000010)
3309 +#define GPIO_CTRL_CFG_BIT5 FIELD32(0x00000020)
3310 +#define GPIO_CTRL_CFG_BIT6 FIELD32(0x00000040)
3311 +#define GPIO_CTRL_CFG_BIT7 FIELD32(0x00000080)
3312 +#define GPIO_CTRL_CFG_BIT8 FIELD32(0x00000100)
3317 +#define MCU_CMD_CFG 0x022c
3320 + * AC_BK register offsets
3322 +#define TX_BASE_PTR0 0x0230
3323 +#define TX_MAX_CNT0 0x0234
3324 +#define TX_CTX_IDX0 0x0238
3325 +#define TX_DTX_IDX0 0x023c
3328 + * AC_BE register offsets
3330 +#define TX_BASE_PTR1 0x0240
3331 +#define TX_MAX_CNT1 0x0244
3332 +#define TX_CTX_IDX1 0x0248
3333 +#define TX_DTX_IDX1 0x024c
3336 + * AC_VI register offsets
3338 +#define TX_BASE_PTR2 0x0250
3339 +#define TX_MAX_CNT2 0x0254
3340 +#define TX_CTX_IDX2 0x0258
3341 +#define TX_DTX_IDX2 0x025c
3344 + * AC_VO register offsets
3346 +#define TX_BASE_PTR3 0x0260
3347 +#define TX_MAX_CNT3 0x0264
3348 +#define TX_CTX_IDX3 0x0268
3349 +#define TX_DTX_IDX3 0x026c
3352 + * HCCA register offsets
3354 +#define TX_BASE_PTR4 0x0270
3355 +#define TX_MAX_CNT4 0x0274
3356 +#define TX_CTX_IDX4 0x0278
3357 +#define TX_DTX_IDX4 0x027c
3360 + * MGMT register offsets
3362 +#define TX_BASE_PTR5 0x0280
3363 +#define TX_MAX_CNT5 0x0284
3364 +#define TX_CTX_IDX5 0x0288
3365 +#define TX_DTX_IDX5 0x028c
3368 + * RX register offsets
3370 +#define RX_BASE_PTR 0x0290
3371 +#define RX_MAX_CNT 0x0294
3372 +#define RX_CRX_IDX 0x0298
3373 +#define RX_DRX_IDX 0x029c
3377 + * RX_BULK_AGG_TIMEOUT: Rx Bulk Aggregation TimeOut in unit of 33ns.
3378 + * RX_BULK_AGG_LIMIT: Rx Bulk Aggregation Limit in unit of 256 bytes.
3379 + * PHY_CLEAR: phy watch dog enable.
3380 + * TX_CLEAR: Clear USB DMA TX path.
3381 + * TXOP_HALT: Halt TXOP count down when TX buffer is full.
3382 + * RX_BULK_AGG_EN: Enable Rx Bulk Aggregation.
3383 + * RX_BULK_EN: Enable USB DMA Rx.
3384 + * TX_BULK_EN: Enable USB DMA Tx.
3385 + * EP_OUT_VALID: OUT endpoint data valid.
3386 + * RX_BUSY: USB DMA RX FSM busy.
3387 + * TX_BUSY: USB DMA TX FSM busy.
3389 +#define USB_DMA_CFG 0x02a0
3390 +#define USB_DMA_CFG_RX_BULK_AGG_TIMEOUT FIELD32(0x000000ff)
3391 +#define USB_DMA_CFG_RX_BULK_AGG_LIMIT FIELD32(0x0000ff00)
3392 +#define USB_DMA_CFG_PHY_CLEAR FIELD32(0x00010000)
3393 +#define USB_DMA_CFG_TX_CLEAR FIELD32(0x00080000)
3394 +#define USB_DMA_CFG_TXOP_HALT FIELD32(0x00100000)
3395 +#define USB_DMA_CFG_RX_BULK_AGG_EN FIELD32(0x00200000)
3396 +#define USB_DMA_CFG_RX_BULK_EN FIELD32(0x00400000)
3397 +#define USB_DMA_CFG_TX_BULK_EN FIELD32(0x00800000)
3398 +#define USB_DMA_CFG_EP_OUT_VALID FIELD32(0x3f000000)
3399 +#define USB_DMA_CFG_RX_BUSY FIELD32(0x40000000)
3400 +#define USB_DMA_CFG_TX_BUSY FIELD32(0x80000000)
3405 +#define USB_CYC_CFG 0x02a4
3406 +#define USB_CYC_CFG_CLOCK_CYCLE FIELD32(0x000000ff)
3410 + * HOST_RAM_WRITE: enable Host program ram write selection
3412 +#define PBF_SYS_CTRL 0x0400
3413 +#define PBF_SYS_CTRL_READY FIELD32(0x00000080)
3414 +#define PBF_SYS_CTRL_HOST_RAM_WRITE FIELD32(0x00010000)
3418 + * Most are for debug. Driver doesn't touch PBF register.
3420 +#define PBF_CFG 0x0408
3421 +#define PBF_MAX_PCNT 0x040c
3422 +#define PBF_CTRL 0x0410
3423 +#define PBF_INT_STA 0x0414
3424 +#define PBF_INT_ENA 0x0418
3429 +#define BCN_OFFSET0 0x042c
3430 +#define BCN_OFFSET0_BCN0 FIELD32(0x000000ff)
3431 +#define BCN_OFFSET0_BCN1 FIELD32(0x0000ff00)
3432 +#define BCN_OFFSET0_BCN2 FIELD32(0x00ff0000)
3433 +#define BCN_OFFSET0_BCN3 FIELD32(0xff000000)
3438 +#define BCN_OFFSET1 0x0430
3439 +#define BCN_OFFSET1_BCN4 FIELD32(0x000000ff)
3440 +#define BCN_OFFSET1_BCN5 FIELD32(0x0000ff00)
3441 +#define BCN_OFFSET1_BCN6 FIELD32(0x00ff0000)
3442 +#define BCN_OFFSET1_BCN7 FIELD32(0xff000000)
3446 + * Most are for debug. Driver doesn't touch PBF register.
3448 +#define TXRXQ_PCNT 0x0438
3449 +#define PBF_DBG 0x043c
3454 +#define RF_CSR_CFG 0x0500
3455 +#define RF_CSR_CFG_DATA FIELD32(0x000000ff)
3456 +#define RF_CSR_CFG_REGNUM FIELD32(0x00001f00)
3457 +#define RF_CSR_CFG_WRITE FIELD32(0x00010000)
3458 +#define RF_CSR_CFG_BUSY FIELD32(0x00020000)
3461 + * MAC Control/Status Registers(CSR).
3462 + * Some values are set in TU, whereas 1 TU == 1024 us.
3466 + * MAC_CSR0: ASIC revision number.
3470 +#define MAC_CSR0 0x1000
3471 +#define MAC_CSR0_ASIC_REV FIELD32(0x0000ffff)
3472 +#define MAC_CSR0_ASIC_VER FIELD32(0xffff0000)
3477 +#define MAC_SYS_CTRL 0x1004
3478 +#define MAC_SYS_CTRL_RESET_CSR FIELD32(0x00000001)
3479 +#define MAC_SYS_CTRL_RESET_BBP FIELD32(0x00000002)
3480 +#define MAC_SYS_CTRL_ENABLE_TX FIELD32(0x00000004)
3481 +#define MAC_SYS_CTRL_ENABLE_RX FIELD32(0x00000008)
3482 +#define MAC_SYS_CTRL_CONTINUOUS_TX FIELD32(0x00000010)
3483 +#define MAC_SYS_CTRL_LOOPBACK FIELD32(0x00000020)
3484 +#define MAC_SYS_CTRL_WLAN_HALT FIELD32(0x00000040)
3485 +#define MAC_SYS_CTRL_RX_TIMESTAMP FIELD32(0x00000080)
3488 + * MAC_ADDR_DW0: STA MAC register 0
3490 +#define MAC_ADDR_DW0 0x1008
3491 +#define MAC_ADDR_DW0_BYTE0 FIELD32(0x000000ff)
3492 +#define MAC_ADDR_DW0_BYTE1 FIELD32(0x0000ff00)
3493 +#define MAC_ADDR_DW0_BYTE2 FIELD32(0x00ff0000)
3494 +#define MAC_ADDR_DW0_BYTE3 FIELD32(0xff000000)
3497 + * MAC_ADDR_DW1: STA MAC register 1
3498 + * UNICAST_TO_ME_MASK:
3499 + * Used to mask off bits from byte 5 of the MAC address
3500 + * to determine the UNICAST_TO_ME bit for RX frames.
3501 + * The full mask is complemented by BSS_ID_MASK:
3502 + * MASK = BSS_ID_MASK & UNICAST_TO_ME_MASK
3504 +#define MAC_ADDR_DW1 0x100c
3505 +#define MAC_ADDR_DW1_BYTE4 FIELD32(0x000000ff)
3506 +#define MAC_ADDR_DW1_BYTE5 FIELD32(0x0000ff00)
3507 +#define MAC_ADDR_DW1_UNICAST_TO_ME_MASK FIELD32(0x00ff0000)
3510 + * MAC_BSSID_DW0: BSSID register 0
3512 +#define MAC_BSSID_DW0 0x1010
3513 +#define MAC_BSSID_DW0_BYTE0 FIELD32(0x000000ff)
3514 +#define MAC_BSSID_DW0_BYTE1 FIELD32(0x0000ff00)
3515 +#define MAC_BSSID_DW0_BYTE2 FIELD32(0x00ff0000)
3516 +#define MAC_BSSID_DW0_BYTE3 FIELD32(0xff000000)
3519 + * MAC_BSSID_DW1: BSSID register 1
3521 + * 0: 1-BSSID mode (BSS index = 0)
3522 + * 1: 2-BSSID mode (BSS index: Byte5, bit 0)
3523 + * 2: 4-BSSID mode (BSS index: byte5, bit 0 - 1)
3524 + * 3: 8-BSSID mode (BSS index: byte5, bit 0 - 2)
3525 + * This mask is used to mask off bits 0, 1 and 2 of byte 5 of the
3526 + * BSSID. This will make sure that those bits will be ignored
3527 + * when determining the MY_BSS of RX frames.
3529 +#define MAC_BSSID_DW1 0x1014
3530 +#define MAC_BSSID_DW1_BYTE4 FIELD32(0x000000ff)
3531 +#define MAC_BSSID_DW1_BYTE5 FIELD32(0x0000ff00)
3532 +#define MAC_BSSID_DW1_BSS_ID_MASK FIELD32(0x00030000)
3533 +#define MAC_BSSID_DW1_BSS_BCN_NUM FIELD32(0x001c0000)
3536 + * MAX_LEN_CFG: Maximum frame length register.
3537 + * MAX_MPDU: rt2860b max 16k bytes
3538 + * MAX_PSDU: Maximum PSDU length
3539 + * (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
3541 +#define MAX_LEN_CFG 0x1018
3542 +#define MAX_LEN_CFG_MAX_MPDU FIELD32(0x00000fff)
3543 +#define MAX_LEN_CFG_MAX_PSDU FIELD32(0x00003000)
3544 +#define MAX_LEN_CFG_MIN_PSDU FIELD32(0x0000c000)
3545 +#define MAX_LEN_CFG_MIN_MPDU FIELD32(0x000f0000)
3548 + * BBP_CSR_CFG: BBP serial control register
3549 + * VALUE: Register value to program into BBP
3550 + * REG_NUM: Selected BBP register
3551 + * READ_CONTROL: 0 write BBP, 1 read BBP
3552 + * BUSY: ASIC is busy executing BBP commands
3553 + * BBP_PAR_DUR: 0 4 MAC clocks, 1 8 MAC clocks
3554 + * BBP_RW_MODE: 0 serial, 1 paralell
3556 +#define BBP_CSR_CFG 0x101c
3557 +#define BBP_CSR_CFG_VALUE FIELD32(0x000000ff)
3558 +#define BBP_CSR_CFG_REGNUM FIELD32(0x0000ff00)
3559 +#define BBP_CSR_CFG_READ_CONTROL FIELD32(0x00010000)
3560 +#define BBP_CSR_CFG_BUSY FIELD32(0x00020000)
3561 +#define BBP_CSR_CFG_BBP_PAR_DUR FIELD32(0x00040000)
3562 +#define BBP_CSR_CFG_BBP_RW_MODE FIELD32(0x00080000)
3565 + * RF_CSR_CFG0: RF control register
3566 + * REGID_AND_VALUE: Register value to program into RF
3567 + * BITWIDTH: Selected RF register
3568 + * STANDBYMODE: 0 high when standby, 1 low when standby
3569 + * SEL: 0 RF_LE0 activate, 1 RF_LE1 activate
3570 + * BUSY: ASIC is busy executing RF commands
3572 +#define RF_CSR_CFG0 0x1020
3573 +#define RF_CSR_CFG0_REGID_AND_VALUE FIELD32(0x00ffffff)
3574 +#define RF_CSR_CFG0_BITWIDTH FIELD32(0x1f000000)
3575 +#define RF_CSR_CFG0_REG_VALUE_BW FIELD32(0x1fffffff)
3576 +#define RF_CSR_CFG0_STANDBYMODE FIELD32(0x20000000)
3577 +#define RF_CSR_CFG0_SEL FIELD32(0x40000000)
3578 +#define RF_CSR_CFG0_BUSY FIELD32(0x80000000)
3581 + * RF_CSR_CFG1: RF control register
3582 + * REGID_AND_VALUE: Register value to program into RF
3583 + * RFGAP: Gap between BB_CONTROL_RF and RF_LE
3584 + * 0: 3 system clock cycle (37.5usec)
3585 + * 1: 5 system clock cycle (62.5usec)
3587 +#define RF_CSR_CFG1 0x1024
3588 +#define RF_CSR_CFG1_REGID_AND_VALUE FIELD32(0x00ffffff)
3589 +#define RF_CSR_CFG1_RFGAP FIELD32(0x1f000000)
3592 + * RF_CSR_CFG2: RF control register
3593 + * VALUE: Register value to program into RF
3594 + * RFGAP: Gap between BB_CONTROL_RF and RF_LE
3595 + * 0: 3 system clock cycle (37.5usec)
3596 + * 1: 5 system clock cycle (62.5usec)
3598 +#define RF_CSR_CFG2 0x1028
3599 +#define RF_CSR_CFG2_VALUE FIELD32(0x00ffffff)
3602 + * LED_CFG: LED control
3605 + * 1: blinking upon TX2
3606 + * 2: periodic slow blinking
3612 +#define LED_CFG 0x102c
3613 +#define LED_CFG_ON_PERIOD FIELD32(0x000000ff)
3614 +#define LED_CFG_OFF_PERIOD FIELD32(0x0000ff00)
3615 +#define LED_CFG_SLOW_BLINK_PERIOD FIELD32(0x003f0000)
3616 +#define LED_CFG_R_LED_MODE FIELD32(0x03000000)
3617 +#define LED_CFG_G_LED_MODE FIELD32(0x0c000000)
3618 +#define LED_CFG_Y_LED_MODE FIELD32(0x30000000)
3619 +#define LED_CFG_LED_POLAR FIELD32(0x40000000)
3622 + * XIFS_TIME_CFG: MAC timing
3623 + * CCKM_SIFS_TIME: unit 1us. Applied after CCK RX/TX
3624 + * OFDM_SIFS_TIME: unit 1us. Applied after OFDM RX/TX
3625 + * OFDM_XIFS_TIME: unit 1us. Applied after OFDM RX
3626 + * when MAC doesn't reference BBP signal BBRXEND
3628 + * BB_RXEND_ENABLE: reference RXEND signal to begin XIFS defer
3631 +#define XIFS_TIME_CFG 0x1100
3632 +#define XIFS_TIME_CFG_CCKM_SIFS_TIME FIELD32(0x000000ff)
3633 +#define XIFS_TIME_CFG_OFDM_SIFS_TIME FIELD32(0x0000ff00)
3634 +#define XIFS_TIME_CFG_OFDM_XIFS_TIME FIELD32(0x000f0000)
3635 +#define XIFS_TIME_CFG_EIFS FIELD32(0x1ff00000)
3636 +#define XIFS_TIME_CFG_BB_RXEND_ENABLE FIELD32(0x20000000)
3641 +#define BKOFF_SLOT_CFG 0x1104
3642 +#define BKOFF_SLOT_CFG_SLOT_TIME FIELD32(0x000000ff)
3643 +#define BKOFF_SLOT_CFG_CC_DELAY_TIME FIELD32(0x0000ff00)
3648 +#define NAV_TIME_CFG 0x1108
3649 +#define NAV_TIME_CFG_SIFS FIELD32(0x000000ff)
3650 +#define NAV_TIME_CFG_SLOT_TIME FIELD32(0x0000ff00)
3651 +#define NAV_TIME_CFG_EIFS FIELD32(0x01ff0000)
3652 +#define NAV_TIME_ZERO_SIFS FIELD32(0x02000000)
3655 + * CH_TIME_CFG: count as channel busy
3657 +#define CH_TIME_CFG 0x110c
3660 + * PBF_LIFE_TIMER: TX/RX MPDU timestamp timer (free run) Unit: 1us
3662 +#define PBF_LIFE_TIMER 0x1110
3666 + * BEACON_INTERVAL: in unit of 1/16 TU
3667 + * TSF_TICKING: Enable TSF auto counting
3668 + * TSF_SYNC: Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
3669 + * BEACON_GEN: Enable beacon generator
3671 +#define BCN_TIME_CFG 0x1114
3672 +#define BCN_TIME_CFG_BEACON_INTERVAL FIELD32(0x0000ffff)
3673 +#define BCN_TIME_CFG_TSF_TICKING FIELD32(0x00010000)
3674 +#define BCN_TIME_CFG_TSF_SYNC FIELD32(0x00060000)
3675 +#define BCN_TIME_CFG_TBTT_ENABLE FIELD32(0x00080000)
3676 +#define BCN_TIME_CFG_BEACON_GEN FIELD32(0x00100000)
3677 +#define BCN_TIME_CFG_TX_TIME_COMPENSATE FIELD32(0xf0000000)
3682 +#define TBTT_SYNC_CFG 0x1118
3685 + * TSF_TIMER_DW0: Local lsb TSF timer, read-only
3687 +#define TSF_TIMER_DW0 0x111c
3688 +#define TSF_TIMER_DW0_LOW_WORD FIELD32(0xffffffff)
3691 + * TSF_TIMER_DW1: Local msb TSF timer, read-only
3693 +#define TSF_TIMER_DW1 0x1120
3694 +#define TSF_TIMER_DW1_HIGH_WORD FIELD32(0xffffffff)
3697 + * TBTT_TIMER: TImer remains till next TBTT, read-only
3699 +#define TBTT_TIMER 0x1124
3704 +#define INT_TIMER_CFG 0x1128
3707 + * INT_TIMER_EN: GP-timer and pre-tbtt Int enable
3709 +#define INT_TIMER_EN 0x112c
3712 + * CH_IDLE_STA: channel idle time
3714 +#define CH_IDLE_STA 0x1130
3717 + * CH_BUSY_STA: channel busy time
3719 +#define CH_BUSY_STA 0x1134
3723 + * BBP_RF_BUSY: When set to 0, BBP and RF are stable.
3724 + * if 1 or higher one of the 2 registers is busy.
3726 +#define MAC_STATUS_CFG 0x1200
3727 +#define MAC_STATUS_CFG_BBP_RF_BUSY FIELD32(0x00000003)
3732 +#define PWR_PIN_CFG 0x1204
3735 + * AUTOWAKEUP_CFG: Manual power control / status register
3736 + * TBCN_BEFORE_WAKE: ForceWake has high privilege than PutToSleep when both set
3737 + * AUTOWAKE: 0:sleep, 1:awake
3739 +#define AUTOWAKEUP_CFG 0x1208
3740 +#define AUTOWAKEUP_CFG_AUTO_LEAD_TIME FIELD32(0x000000ff)
3741 +#define AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE FIELD32(0x00007f00)
3742 +#define AUTOWAKEUP_CFG_AUTOWAKE FIELD32(0x00008000)
3747 +#define EDCA_AC0_CFG 0x1300
3748 +#define EDCA_AC0_CFG_TX_OP FIELD32(0x000000ff)
3749 +#define EDCA_AC0_CFG_AIFSN FIELD32(0x00000f00)
3750 +#define EDCA_AC0_CFG_CWMIN FIELD32(0x0000f000)
3751 +#define EDCA_AC0_CFG_CWMAX FIELD32(0x000f0000)
3756 +#define EDCA_AC1_CFG 0x1304
3757 +#define EDCA_AC1_CFG_TX_OP FIELD32(0x000000ff)
3758 +#define EDCA_AC1_CFG_AIFSN FIELD32(0x00000f00)
3759 +#define EDCA_AC1_CFG_CWMIN FIELD32(0x0000f000)
3760 +#define EDCA_AC1_CFG_CWMAX FIELD32(0x000f0000)
3765 +#define EDCA_AC2_CFG 0x1308
3766 +#define EDCA_AC2_CFG_TX_OP FIELD32(0x000000ff)
3767 +#define EDCA_AC2_CFG_AIFSN FIELD32(0x00000f00)
3768 +#define EDCA_AC2_CFG_CWMIN FIELD32(0x0000f000)
3769 +#define EDCA_AC2_CFG_CWMAX FIELD32(0x000f0000)
3774 +#define EDCA_AC3_CFG 0x130c
3775 +#define EDCA_AC3_CFG_TX_OP FIELD32(0x000000ff)
3776 +#define EDCA_AC3_CFG_AIFSN FIELD32(0x00000f00)
3777 +#define EDCA_AC3_CFG_CWMIN FIELD32(0x0000f000)
3778 +#define EDCA_AC3_CFG_CWMAX FIELD32(0x000f0000)
3781 + * EDCA_TID_AC_MAP:
3783 +#define EDCA_TID_AC_MAP 0x1310
3788 +#define TX_PWR_CFG_0 0x1314
3789 +#define TX_PWR_CFG_0_1MBS FIELD32(0x0000000f)
3790 +#define TX_PWR_CFG_0_2MBS FIELD32(0x000000f0)
3791 +#define TX_PWR_CFG_0_55MBS FIELD32(0x00000f00)
3792 +#define TX_PWR_CFG_0_11MBS FIELD32(0x0000f000)
3793 +#define TX_PWR_CFG_0_6MBS FIELD32(0x000f0000)
3794 +#define TX_PWR_CFG_0_9MBS FIELD32(0x00f00000)
3795 +#define TX_PWR_CFG_0_12MBS FIELD32(0x0f000000)
3796 +#define TX_PWR_CFG_0_18MBS FIELD32(0xf0000000)
3801 +#define TX_PWR_CFG_1 0x1318
3802 +#define TX_PWR_CFG_1_24MBS FIELD32(0x0000000f)
3803 +#define TX_PWR_CFG_1_36MBS FIELD32(0x000000f0)
3804 +#define TX_PWR_CFG_1_48MBS FIELD32(0x00000f00)
3805 +#define TX_PWR_CFG_1_54MBS FIELD32(0x0000f000)
3806 +#define TX_PWR_CFG_1_MCS0 FIELD32(0x000f0000)
3807 +#define TX_PWR_CFG_1_MCS1 FIELD32(0x00f00000)
3808 +#define TX_PWR_CFG_1_MCS2 FIELD32(0x0f000000)
3809 +#define TX_PWR_CFG_1_MCS3 FIELD32(0xf0000000)
3814 +#define TX_PWR_CFG_2 0x131c
3815 +#define TX_PWR_CFG_2_MCS4 FIELD32(0x0000000f)
3816 +#define TX_PWR_CFG_2_MCS5 FIELD32(0x000000f0)
3817 +#define TX_PWR_CFG_2_MCS6 FIELD32(0x00000f00)
3818 +#define TX_PWR_CFG_2_MCS7 FIELD32(0x0000f000)
3819 +#define TX_PWR_CFG_2_MCS8 FIELD32(0x000f0000)
3820 +#define TX_PWR_CFG_2_MCS9 FIELD32(0x00f00000)
3821 +#define TX_PWR_CFG_2_MCS10 FIELD32(0x0f000000)
3822 +#define TX_PWR_CFG_2_MCS11 FIELD32(0xf0000000)
3827 +#define TX_PWR_CFG_3 0x1320
3828 +#define TX_PWR_CFG_3_MCS12 FIELD32(0x0000000f)
3829 +#define TX_PWR_CFG_3_MCS13 FIELD32(0x000000f0)
3830 +#define TX_PWR_CFG_3_MCS14 FIELD32(0x00000f00)
3831 +#define TX_PWR_CFG_3_MCS15 FIELD32(0x0000f000)
3832 +#define TX_PWR_CFG_3_UKNOWN1 FIELD32(0x000f0000)
3833 +#define TX_PWR_CFG_3_UKNOWN2 FIELD32(0x00f00000)
3834 +#define TX_PWR_CFG_3_UKNOWN3 FIELD32(0x0f000000)
3835 +#define TX_PWR_CFG_3_UKNOWN4 FIELD32(0xf0000000)
3840 +#define TX_PWR_CFG_4 0x1324
3841 +#define TX_PWR_CFG_4_UKNOWN5 FIELD32(0x0000000f)
3842 +#define TX_PWR_CFG_4_UKNOWN6 FIELD32(0x000000f0)
3843 +#define TX_PWR_CFG_4_UKNOWN7 FIELD32(0x00000f00)
3844 +#define TX_PWR_CFG_4_UKNOWN8 FIELD32(0x0000f000)
3849 +#define TX_PIN_CFG 0x1328
3850 +#define TX_PIN_CFG_PA_PE_A0_EN FIELD32(0x00000001)
3851 +#define TX_PIN_CFG_PA_PE_G0_EN FIELD32(0x00000002)
3852 +#define TX_PIN_CFG_PA_PE_A1_EN FIELD32(0x00000004)
3853 +#define TX_PIN_CFG_PA_PE_G1_EN FIELD32(0x00000008)
3854 +#define TX_PIN_CFG_PA_PE_A0_POL FIELD32(0x00000010)
3855 +#define TX_PIN_CFG_PA_PE_G0_POL FIELD32(0x00000020)
3856 +#define TX_PIN_CFG_PA_PE_A1_POL FIELD32(0x00000040)
3857 +#define TX_PIN_CFG_PA_PE_G1_POL FIELD32(0x00000080)
3858 +#define TX_PIN_CFG_LNA_PE_A0_EN FIELD32(0x00000100)
3859 +#define TX_PIN_CFG_LNA_PE_G0_EN FIELD32(0x00000200)
3860 +#define TX_PIN_CFG_LNA_PE_A1_EN FIELD32(0x00000400)
3861 +#define TX_PIN_CFG_LNA_PE_G1_EN FIELD32(0x00000800)
3862 +#define TX_PIN_CFG_LNA_PE_A0_POL FIELD32(0x00001000)
3863 +#define TX_PIN_CFG_LNA_PE_G0_POL FIELD32(0x00002000)
3864 +#define TX_PIN_CFG_LNA_PE_A1_POL FIELD32(0x00004000)
3865 +#define TX_PIN_CFG_LNA_PE_G1_POL FIELD32(0x00008000)
3866 +#define TX_PIN_CFG_RFTR_EN FIELD32(0x00010000)
3867 +#define TX_PIN_CFG_RFTR_POL FIELD32(0x00020000)
3868 +#define TX_PIN_CFG_TRSW_EN FIELD32(0x00040000)
3869 +#define TX_PIN_CFG_TRSW_POL FIELD32(0x00080000)
3872 + * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
3874 +#define TX_BAND_CFG 0x132c
3875 +#define TX_BAND_CFG_HT40_PLUS FIELD32(0x00000001)
3876 +#define TX_BAND_CFG_A FIELD32(0x00000002)
3877 +#define TX_BAND_CFG_BG FIELD32(0x00000004)
3882 +#define TX_SW_CFG0 0x1330
3887 +#define TX_SW_CFG1 0x1334
3892 +#define TX_SW_CFG2 0x1338
3897 +#define TXOP_THRES_CFG 0x133c
3902 +#define TXOP_CTRL_CFG 0x1340
3906 + * RTS_THRES: unit:byte
3907 + * RTS_FBK_EN: enable rts rate fallback
3909 +#define TX_RTS_CFG 0x1344
3910 +#define TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT FIELD32(0x000000ff)
3911 +#define TX_RTS_CFG_RTS_THRES FIELD32(0x00ffff00)
3912 +#define TX_RTS_CFG_RTS_FBK_EN FIELD32(0x01000000)
3916 + * MPDU_LIFETIME: expiration time = 2^(9+MPDU LIFE TIME) us
3917 + * RX_ACK_TIMEOUT: unit:slot. Used for TX procedure
3918 + * TX_OP_TIMEOUT: TXOP timeout value for TXOP truncation.
3919 + * it is recommended that:
3920 + * (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
3922 +#define TX_TIMEOUT_CFG 0x1348
3923 +#define TX_TIMEOUT_CFG_MPDU_LIFETIME FIELD32(0x000000f0)
3924 +#define TX_TIMEOUT_CFG_RX_ACK_TIMEOUT FIELD32(0x0000ff00)
3925 +#define TX_TIMEOUT_CFG_TX_OP_TIMEOUT FIELD32(0x00ff0000)
3929 + * SHORT_RTY_LIMIT: short retry limit
3930 + * LONG_RTY_LIMIT: long retry limit
3931 + * LONG_RTY_THRE: Long retry threshoold
3932 + * NON_AGG_RTY_MODE: Non-Aggregate MPDU retry mode
3933 + * 0:expired by retry limit, 1: expired by mpdu life timer
3934 + * AGG_RTY_MODE: Aggregate MPDU retry mode
3935 + * 0:expired by retry limit, 1: expired by mpdu life timer
3936 + * TX_AUTO_FB_ENABLE: Tx retry PHY rate auto fallback enable
3938 +#define TX_RTY_CFG 0x134c
3939 +#define TX_RTY_CFG_SHORT_RTY_LIMIT FIELD32(0x000000ff)
3940 +#define TX_RTY_CFG_LONG_RTY_LIMIT FIELD32(0x0000ff00)
3941 +#define TX_RTY_CFG_LONG_RTY_THRE FIELD32(0x0fff0000)
3942 +#define TX_RTY_CFG_NON_AGG_RTY_MODE FIELD32(0x10000000)
3943 +#define TX_RTY_CFG_AGG_RTY_MODE FIELD32(0x20000000)
3944 +#define TX_RTY_CFG_TX_AUTO_FB_ENABLE FIELD32(0x40000000)
3948 + * REMOTE_MFB_LIFETIME: remote MFB life time. unit: 32us
3949 + * MFB_ENABLE: TX apply remote MFB 1:enable
3950 + * REMOTE_UMFS_ENABLE: remote unsolicit MFB enable
3951 + * 0: not apply remote remote unsolicit (MFS=7)
3952 + * TX_MRQ_EN: MCS request TX enable
3953 + * TX_RDG_EN: RDG TX enable
3954 + * TX_CF_ACK_EN: Piggyback CF-ACK enable
3955 + * REMOTE_MFB: remote MCS feedback
3956 + * REMOTE_MFS: remote MCS feedback sequence number
3958 +#define TX_LINK_CFG 0x1350
3959 +#define TX_LINK_CFG_REMOTE_MFB_LIFETIME FIELD32(0x000000ff)
3960 +#define TX_LINK_CFG_MFB_ENABLE FIELD32(0x00000100)
3961 +#define TX_LINK_CFG_REMOTE_UMFS_ENABLE FIELD32(0x00000200)
3962 +#define TX_LINK_CFG_TX_MRQ_EN FIELD32(0x00000400)
3963 +#define TX_LINK_CFG_TX_RDG_EN FIELD32(0x00000800)
3964 +#define TX_LINK_CFG_TX_CF_ACK_EN FIELD32(0x00001000)
3965 +#define TX_LINK_CFG_REMOTE_MFB FIELD32(0x00ff0000)
3966 +#define TX_LINK_CFG_REMOTE_MFS FIELD32(0xff000000)
3971 +#define HT_FBK_CFG0 0x1354
3972 +#define HT_FBK_CFG0_HTMCS0FBK FIELD32(0x0000000f)
3973 +#define HT_FBK_CFG0_HTMCS1FBK FIELD32(0x000000f0)
3974 +#define HT_FBK_CFG0_HTMCS2FBK FIELD32(0x00000f00)
3975 +#define HT_FBK_CFG0_HTMCS3FBK FIELD32(0x0000f000)
3976 +#define HT_FBK_CFG0_HTMCS4FBK FIELD32(0x000f0000)
3977 +#define HT_FBK_CFG0_HTMCS5FBK FIELD32(0x00f00000)
3978 +#define HT_FBK_CFG0_HTMCS6FBK FIELD32(0x0f000000)
3979 +#define HT_FBK_CFG0_HTMCS7FBK FIELD32(0xf0000000)
3984 +#define HT_FBK_CFG1 0x1358
3985 +#define HT_FBK_CFG1_HTMCS8FBK FIELD32(0x0000000f)
3986 +#define HT_FBK_CFG1_HTMCS9FBK FIELD32(0x000000f0)
3987 +#define HT_FBK_CFG1_HTMCS10FBK FIELD32(0x00000f00)
3988 +#define HT_FBK_CFG1_HTMCS11FBK FIELD32(0x0000f000)
3989 +#define HT_FBK_CFG1_HTMCS12FBK FIELD32(0x000f0000)
3990 +#define HT_FBK_CFG1_HTMCS13FBK FIELD32(0x00f00000)
3991 +#define HT_FBK_CFG1_HTMCS14FBK FIELD32(0x0f000000)
3992 +#define HT_FBK_CFG1_HTMCS15FBK FIELD32(0xf0000000)
3997 +#define LG_FBK_CFG0 0x135c
3998 +#define LG_FBK_CFG0_OFDMMCS0FBK FIELD32(0x0000000f)
3999 +#define LG_FBK_CFG0_OFDMMCS1FBK FIELD32(0x000000f0)
4000 +#define LG_FBK_CFG0_OFDMMCS2FBK FIELD32(0x00000f00)
4001 +#define LG_FBK_CFG0_OFDMMCS3FBK FIELD32(0x0000f000)
4002 +#define LG_FBK_CFG0_OFDMMCS4FBK FIELD32(0x000f0000)
4003 +#define LG_FBK_CFG0_OFDMMCS5FBK FIELD32(0x00f00000)
4004 +#define LG_FBK_CFG0_OFDMMCS6FBK FIELD32(0x0f000000)
4005 +#define LG_FBK_CFG0_OFDMMCS7FBK FIELD32(0xf0000000)
4010 +#define LG_FBK_CFG1 0x1360
4011 +#define LG_FBK_CFG0_CCKMCS0FBK FIELD32(0x0000000f)
4012 +#define LG_FBK_CFG0_CCKMCS1FBK FIELD32(0x000000f0)
4013 +#define LG_FBK_CFG0_CCKMCS2FBK FIELD32(0x00000f00)
4014 +#define LG_FBK_CFG0_CCKMCS3FBK FIELD32(0x0000f000)
4017 + * CCK_PROT_CFG: CCK Protection
4018 + * PROTECT_RATE: Protection control frame rate for CCK TX(RTS/CTS/CFEnd)
4019 + * PROTECT_CTRL: Protection control frame type for CCK TX
4020 + * 0:none, 1:RTS/CTS, 2:CTS-to-self
4021 + * PROTECT_NAV: TXOP protection type for CCK TX
4022 + * 0:none, 1:ShortNAVprotect, 2:LongNAVProtect
4023 + * TX_OP_ALLOW_CCK: CCK TXOP allowance, 0:disallow
4024 + * TX_OP_ALLOW_OFDM: CCK TXOP allowance, 0:disallow
4025 + * TX_OP_ALLOW_MM20: CCK TXOP allowance, 0:disallow
4026 + * TX_OP_ALLOW_MM40: CCK TXOP allowance, 0:disallow
4027 + * TX_OP_ALLOW_GF20: CCK TXOP allowance, 0:disallow
4028 + * TX_OP_ALLOW_GF40: CCK TXOP allowance, 0:disallow
4029 + * RTS_TH_EN: RTS threshold enable on CCK TX
4031 +#define CCK_PROT_CFG 0x1364
4032 +#define CCK_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
4033 +#define CCK_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
4034 +#define CCK_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
4035 +#define CCK_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
4036 +#define CCK_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
4037 +#define CCK_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
4038 +#define CCK_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
4039 +#define CCK_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
4040 +#define CCK_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
4041 +#define CCK_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
4044 + * OFDM_PROT_CFG: OFDM Protection
4046 +#define OFDM_PROT_CFG 0x1368
4047 +#define OFDM_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
4048 +#define OFDM_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
4049 +#define OFDM_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
4050 +#define OFDM_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
4051 +#define OFDM_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
4052 +#define OFDM_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
4053 +#define OFDM_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
4054 +#define OFDM_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
4055 +#define OFDM_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
4056 +#define OFDM_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
4059 + * MM20_PROT_CFG: MM20 Protection
4061 +#define MM20_PROT_CFG 0x136c
4062 +#define MM20_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
4063 +#define MM20_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
4064 +#define MM20_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
4065 +#define MM20_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
4066 +#define MM20_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
4067 +#define MM20_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
4068 +#define MM20_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
4069 +#define MM20_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
4070 +#define MM20_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
4071 +#define MM20_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
4074 + * MM40_PROT_CFG: MM40 Protection
4076 +#define MM40_PROT_CFG 0x1370
4077 +#define MM40_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
4078 +#define MM40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
4079 +#define MM40_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
4080 +#define MM40_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
4081 +#define MM40_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
4082 +#define MM40_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
4083 +#define MM40_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
4084 +#define MM40_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
4085 +#define MM40_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
4086 +#define MM40_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
4089 + * GF20_PROT_CFG: GF20 Protection
4091 +#define GF20_PROT_CFG 0x1374
4092 +#define GF20_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
4093 +#define GF20_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
4094 +#define GF20_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
4095 +#define GF20_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
4096 +#define GF20_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
4097 +#define GF20_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
4098 +#define GF20_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
4099 +#define GF20_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
4100 +#define GF20_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
4101 +#define GF20_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
4104 + * GF40_PROT_CFG: GF40 Protection
4106 +#define GF40_PROT_CFG 0x1378
4107 +#define GF40_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
4108 +#define GF40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
4109 +#define GF40_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
4110 +#define GF40_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
4111 +#define GF40_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
4112 +#define GF40_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
4113 +#define GF40_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
4114 +#define GF40_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
4115 +#define GF40_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
4116 +#define GF40_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
4121 +#define EXP_CTS_TIME 0x137c
4126 +#define EXP_ACK_TIME 0x1380
4129 + * RX_FILTER_CFG: RX configuration register.
4131 +#define RX_FILTER_CFG 0x1400
4132 +#define RX_FILTER_CFG_DROP_CRC_ERROR FIELD32(0x00000001)
4133 +#define RX_FILTER_CFG_DROP_PHY_ERROR FIELD32(0x00000002)
4134 +#define RX_FILTER_CFG_DROP_NOT_TO_ME FIELD32(0x00000004)
4135 +#define RX_FILTER_CFG_DROP_NOT_MY_BSSD FIELD32(0x00000008)
4136 +#define RX_FILTER_CFG_DROP_VER_ERROR FIELD32(0x00000010)
4137 +#define RX_FILTER_CFG_DROP_MULTICAST FIELD32(0x00000020)
4138 +#define RX_FILTER_CFG_DROP_BROADCAST FIELD32(0x00000040)
4139 +#define RX_FILTER_CFG_DROP_DUPLICATE FIELD32(0x00000080)
4140 +#define RX_FILTER_CFG_DROP_CF_END_ACK FIELD32(0x00000100)
4141 +#define RX_FILTER_CFG_DROP_CF_END FIELD32(0x00000200)
4142 +#define RX_FILTER_CFG_DROP_ACK FIELD32(0x00000400)
4143 +#define RX_FILTER_CFG_DROP_CTS FIELD32(0x00000800)
4144 +#define RX_FILTER_CFG_DROP_RTS FIELD32(0x00001000)
4145 +#define RX_FILTER_CFG_DROP_PSPOLL FIELD32(0x00002000)
4146 +#define RX_FILTER_CFG_DROP_BA FIELD32(0x00004000)
4147 +#define RX_FILTER_CFG_DROP_BAR FIELD32(0x00008000)
4148 +#define RX_FILTER_CFG_DROP_CNTL FIELD32(0x00010000)
4152 + * AUTORESPONDER: 0: disable, 1: enable
4153 + * BAC_ACK_POLICY: 0:long, 1:short preamble
4154 + * CTS_40_MMODE: Response CTS 40MHz duplicate mode
4155 + * CTS_40_MREF: Response CTS 40MHz duplicate mode
4156 + * AR_PREAMBLE: Auto responder preamble 0:long, 1:short preamble
4157 + * DUAL_CTS_EN: Power bit value in control frame
4158 + * ACK_CTS_PSM_BIT:Power bit value in control frame
4160 +#define AUTO_RSP_CFG 0x1404
4161 +#define AUTO_RSP_CFG_AUTORESPONDER FIELD32(0x00000001)
4162 +#define AUTO_RSP_CFG_BAC_ACK_POLICY FIELD32(0x00000002)
4163 +#define AUTO_RSP_CFG_CTS_40_MMODE FIELD32(0x00000004)
4164 +#define AUTO_RSP_CFG_CTS_40_MREF FIELD32(0x00000008)
4165 +#define AUTO_RSP_CFG_AR_PREAMBLE FIELD32(0x00000010)
4166 +#define AUTO_RSP_CFG_DUAL_CTS_EN FIELD32(0x00000040)
4167 +#define AUTO_RSP_CFG_ACK_CTS_PSM_BIT FIELD32(0x00000080)
4170 + * LEGACY_BASIC_RATE:
4172 +#define LEGACY_BASIC_RATE 0x1408
4177 +#define HT_BASIC_RATE 0x140c
4182 +#define HT_CTRL_CFG 0x1410
4187 +#define SIFS_COST_CFG 0x1414
4191 + * Set NAV for all received frames
4193 +#define RX_PARSER_CFG 0x1418
4198 +#define TX_SEC_CNT0 0x1500
4203 +#define RX_SEC_CNT0 0x1504
4208 +#define CCMP_FC_MUTE 0x1508
4211 + * TXOP_HLDR_ADDR0:
4213 +#define TXOP_HLDR_ADDR0 0x1600
4216 + * TXOP_HLDR_ADDR1:
4218 +#define TXOP_HLDR_ADDR1 0x1604
4223 +#define TXOP_HLDR_ET 0x1608
4226 + * QOS_CFPOLL_RA_DW0:
4228 +#define QOS_CFPOLL_RA_DW0 0x160c
4231 + * QOS_CFPOLL_RA_DW1:
4233 +#define QOS_CFPOLL_RA_DW1 0x1610
4238 +#define QOS_CFPOLL_QC 0x1614
4241 + * RX_STA_CNT0: RX PLCP error count & RX CRC error count
4243 +#define RX_STA_CNT0 0x1700
4244 +#define RX_STA_CNT0_CRC_ERR FIELD32(0x0000ffff)
4245 +#define RX_STA_CNT0_PHY_ERR FIELD32(0xffff0000)
4248 + * RX_STA_CNT1: RX False CCA count & RX LONG frame count
4250 +#define RX_STA_CNT1 0x1704
4251 +#define RX_STA_CNT1_FALSE_CCA FIELD32(0x0000ffff)
4252 +#define RX_STA_CNT1_PLCP_ERR FIELD32(0xffff0000)
4257 +#define RX_STA_CNT2 0x1708
4258 +#define RX_STA_CNT2_RX_DUPLI_COUNT FIELD32(0x0000ffff)
4259 +#define RX_STA_CNT2_RX_FIFO_OVERFLOW FIELD32(0xffff0000)
4262 + * TX_STA_CNT0: TX Beacon count
4264 +#define TX_STA_CNT0 0x170c
4265 +#define TX_STA_CNT0_TX_FAIL_COUNT FIELD32(0x0000ffff)
4266 +#define TX_STA_CNT0_TX_BEACON_COUNT FIELD32(0xffff0000)
4269 + * TX_STA_CNT1: TX tx count
4271 +#define TX_STA_CNT1 0x1710
4272 +#define TX_STA_CNT1_TX_SUCCESS FIELD32(0x0000ffff)
4273 +#define TX_STA_CNT1_TX_RETRANSMIT FIELD32(0xffff0000)
4276 + * TX_STA_CNT2: TX tx count
4278 +#define TX_STA_CNT2 0x1714
4279 +#define TX_STA_CNT2_TX_ZERO_LEN_COUNT FIELD32(0x0000ffff)
4280 +#define TX_STA_CNT2_TX_UNDER_FLOW_COUNT FIELD32(0xffff0000)
4283 + * TX_STA_FIFO: TX Result for specific PID status fifo register
4285 +#define TX_STA_FIFO 0x1718
4286 +#define TX_STA_FIFO_VALID FIELD32(0x00000001)
4287 +#define TX_STA_FIFO_PID_TYPE FIELD32(0x0000001e)
4288 +#define TX_STA_FIFO_TX_SUCCESS FIELD32(0x00000020)
4289 +#define TX_STA_FIFO_TX_AGGRE FIELD32(0x00000040)
4290 +#define TX_STA_FIFO_TX_ACK_REQUIRED FIELD32(0x00000080)
4291 +#define TX_STA_FIFO_WCID FIELD32(0x0000ff00)
4292 +#define TX_STA_FIFO_SUCCESS_RATE FIELD32(0xffff0000)
4295 + * TX_AGG_CNT: Debug counter
4297 +#define TX_AGG_CNT 0x171c
4298 +#define TX_AGG_CNT_NON_AGG_TX_COUNT FIELD32(0x0000ffff)
4299 +#define TX_AGG_CNT_AGG_TX_COUNT FIELD32(0xffff0000)
4304 +#define TX_AGG_CNT0 0x1720
4305 +#define TX_AGG_CNT0_AGG_SIZE_1_COUNT FIELD32(0x0000ffff)
4306 +#define TX_AGG_CNT0_AGG_SIZE_2_COUNT FIELD32(0xffff0000)
4311 +#define TX_AGG_CNT1 0x1724
4312 +#define TX_AGG_CNT1_AGG_SIZE_3_COUNT FIELD32(0x0000ffff)
4313 +#define TX_AGG_CNT1_AGG_SIZE_4_COUNT FIELD32(0xffff0000)
4318 +#define TX_AGG_CNT2 0x1728
4319 +#define TX_AGG_CNT2_AGG_SIZE_5_COUNT FIELD32(0x0000ffff)
4320 +#define TX_AGG_CNT2_AGG_SIZE_6_COUNT FIELD32(0xffff0000)
4325 +#define TX_AGG_CNT3 0x172c
4326 +#define TX_AGG_CNT3_AGG_SIZE_7_COUNT FIELD32(0x0000ffff)
4327 +#define TX_AGG_CNT3_AGG_SIZE_8_COUNT FIELD32(0xffff0000)
4332 +#define TX_AGG_CNT4 0x1730
4333 +#define TX_AGG_CNT4_AGG_SIZE_9_COUNT FIELD32(0x0000ffff)
4334 +#define TX_AGG_CNT4_AGG_SIZE_10_COUNT FIELD32(0xffff0000)
4339 +#define TX_AGG_CNT5 0x1734
4340 +#define TX_AGG_CNT5_AGG_SIZE_11_COUNT FIELD32(0x0000ffff)
4341 +#define TX_AGG_CNT5_AGG_SIZE_12_COUNT FIELD32(0xffff0000)
4346 +#define TX_AGG_CNT6 0x1738
4347 +#define TX_AGG_CNT6_AGG_SIZE_13_COUNT FIELD32(0x0000ffff)
4348 +#define TX_AGG_CNT6_AGG_SIZE_14_COUNT FIELD32(0xffff0000)
4353 +#define TX_AGG_CNT7 0x173c
4354 +#define TX_AGG_CNT7_AGG_SIZE_15_COUNT FIELD32(0x0000ffff)
4355 +#define TX_AGG_CNT7_AGG_SIZE_16_COUNT FIELD32(0xffff0000)
4358 + * MPDU_DENSITY_CNT:
4359 + * TX_ZERO_DEL: TX zero length delimiter count
4360 + * RX_ZERO_DEL: RX zero length delimiter count
4362 +#define MPDU_DENSITY_CNT 0x1740
4363 +#define MPDU_DENSITY_CNT_TX_ZERO_DEL FIELD32(0x0000ffff)
4364 +#define MPDU_DENSITY_CNT_RX_ZERO_DEL FIELD32(0xffff0000)
4367 + * Security key table memory.
4368 + * MAC_WCID_BASE: 8-bytes (use only 6 bytes) * 256 entry
4369 + * PAIRWISE_KEY_TABLE_BASE: 32-byte * 256 entry
4370 + * MAC_IVEIV_TABLE_BASE: 8-byte * 256-entry
4371 + * MAC_WCID_ATTRIBUTE_BASE: 4-byte * 256-entry
4372 + * SHARED_KEY_TABLE_BASE: 32-byte * 16-entry
4373 + * SHARED_KEY_MODE_BASE: 4-byte * 16-entry
4375 +#define MAC_WCID_BASE 0x1800
4376 +#define PAIRWISE_KEY_TABLE_BASE 0x4000
4377 +#define MAC_IVEIV_TABLE_BASE 0x6000
4378 +#define MAC_WCID_ATTRIBUTE_BASE 0x6800
4379 +#define SHARED_KEY_TABLE_BASE 0x6c00
4380 +#define SHARED_KEY_MODE_BASE 0x7000
4382 +#define MAC_WCID_ENTRY(__idx) \
4383 + ( MAC_WCID_BASE + ((__idx) * sizeof(struct mac_wcid_entry)) )
4384 +#define PAIRWISE_KEY_ENTRY(__idx) \
4385 + ( PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) )
4386 +#define MAC_IVEIV_ENTRY(__idx) \
4387 + ( MAC_IVEIV_TABLE_BASE + ((__idx) & sizeof(struct mac_iveiv_entry)) )
4388 +#define MAC_WCID_ATTR_ENTRY(__idx) \
4389 + ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) )
4390 +#define SHARED_KEY_ENTRY(__idx) \
4391 + ( SHARED_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) )
4392 +#define SHARED_KEY_MODE_ENTRY(__idx) \
4393 + ( SHARED_KEY_MODE_BASE + ((__idx) * sizeof(u32)) )
4395 +struct mac_wcid_entry {
4398 +} __attribute__ ((packed));
4400 +struct hw_key_entry {
4404 +} __attribute__ ((packed));
4406 +struct mac_iveiv_entry {
4408 +} __attribute__ ((packed));
4411 + * MAC_WCID_ATTRIBUTE:
4413 +#define MAC_WCID_ATTRIBUTE_KEYTAB FIELD32(0x00000001)
4414 +#define MAC_WCID_ATTRIBUTE_CIPHER FIELD32(0x0000000e)
4415 +#define MAC_WCID_ATTRIBUTE_BSS_IDX FIELD32(0x00000070)
4416 +#define MAC_WCID_ATTRIBUTE_RX_WIUDF FIELD32(0x00000380)
4419 + * SHARED_KEY_MODE:
4421 +#define SHARED_KEY_MODE_BSS0_KEY0 FIELD32(0x00000007)
4422 +#define SHARED_KEY_MODE_BSS0_KEY1 FIELD32(0x00000070)
4423 +#define SHARED_KEY_MODE_BSS0_KEY2 FIELD32(0x00000700)
4424 +#define SHARED_KEY_MODE_BSS0_KEY3 FIELD32(0x00007000)
4425 +#define SHARED_KEY_MODE_BSS1_KEY0 FIELD32(0x00070000)
4426 +#define SHARED_KEY_MODE_BSS1_KEY1 FIELD32(0x00700000)
4427 +#define SHARED_KEY_MODE_BSS1_KEY2 FIELD32(0x07000000)
4428 +#define SHARED_KEY_MODE_BSS1_KEY3 FIELD32(0x70000000)
4431 + * HOST-MCU communication
4435 + * H2M_MAILBOX_CSR: Host-to-MCU Mailbox.
4437 +#define H2M_MAILBOX_CSR 0x7010
4438 +#define H2M_MAILBOX_CSR_ARG0 FIELD32(0x000000ff)
4439 +#define H2M_MAILBOX_CSR_ARG1 FIELD32(0x0000ff00)
4440 +#define H2M_MAILBOX_CSR_CMD_TOKEN FIELD32(0x00ff0000)
4441 +#define H2M_MAILBOX_CSR_OWNER FIELD32(0xff000000)
4444 + * H2M_MAILBOX_CID:
4446 +#define H2M_MAILBOX_CID 0x7014
4449 + * H2M_MAILBOX_STATUS:
4451 +#define H2M_MAILBOX_STATUS 0x701c
4456 +#define H2M_INT_SRC 0x7024
4461 +#define H2M_BBP_AGENT 0x7028
4464 + * MCU_LEDCS: LED control for MCU Mailbox.
4466 +#define MCU_LEDCS_LED_MODE FIELD8(0x1f)
4467 +#define MCU_LEDCS_POLARITY FIELD8(0x01)
4471 + * Carrier-sense CTS frame base address.
4472 + * It's where mac stores carrier-sense frame for carrier-sense function.
4474 +#define HW_CS_CTS_BASE 0x7700
4477 + * HW_DFS_CTS_BASE:
4478 + * FS CTS frame base address. It's where mac stores CTS frame for DFS.
4480 +#define HW_DFS_CTS_BASE 0x7780
4483 + * TXRX control registers - base address 0x3000
4488 + * rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
4490 +#define TXRX_CSR1 0x77d0
4493 + * HW_DEBUG_SETTING_BASE:
4494 + * since NULL frame won't be that long (256 byte)
4495 + * We steal 16 tail bytes to save debugging settings
4497 +#define HW_DEBUG_SETTING_BASE 0x77f0
4498 +#define HW_DEBUG_SETTING_BASE2 0x7770
4502 + * In order to support maximum 8 MBSS and its maximum length
4503 + * is 512 bytes for each beacon
4504 + * Three section discontinue memory segments will be used.
4505 + * 1. The original region for BCN 0~3
4506 + * 2. Extract memory from FCE table for BCN 4~5
4507 + * 3. Extract memory from Pair-wise key table for BCN 6~7
4508 + * It occupied those memory of wcid 238~253 for BCN 6
4509 + * and wcid 222~237 for BCN 7
4511 + * IMPORTANT NOTE: Not sure why legacy driver does this,
4512 + * but HW_BEACON_BASE7 is 0x0200 bytes below HW_BEACON_BASE6.
4514 +#define HW_BEACON_BASE0 0x7800
4515 +#define HW_BEACON_BASE1 0x7a00
4516 +#define HW_BEACON_BASE2 0x7c00
4517 +#define HW_BEACON_BASE3 0x7e00
4518 +#define HW_BEACON_BASE4 0x7200
4519 +#define HW_BEACON_BASE5 0x7400
4520 +#define HW_BEACON_BASE6 0x5dc0
4521 +#define HW_BEACON_BASE7 0x5bc0
4523 +#define HW_BEACON_OFFSET(__index) \
4524 + ( ((__index) < 4) ? ( HW_BEACON_BASE0 + (__index * 0x0200) ) : \
4525 + (((__index) < 6) ? ( HW_BEACON_BASE4 + ((__index - 4) * 0x0200) ) : \
4526 + (HW_BEACON_BASE6 - ((__index - 6) * 0x0200))) )
4529 + * 8051 firmware image.
4531 +#define FIRMWARE_RT2870 "rt2870.bin"
4532 +#define FIRMWARE_IMAGE_BASE 0x3000
4536 + * The wordsize of the BBP is 8 bits.
4540 + * BBP 1: TX Antenna
4542 +#define BBP1_TX_POWER FIELD8(0x07)
4543 +#define BBP1_TX_ANTENNA FIELD8(0x18)
4546 + * BBP 3: RX Antenna
4548 +#define BBP3_RX_ANTENNA FIELD8(0x18)
4549 +#define BBP3_HT40_PLUS FIELD8(0x20)
4552 + * BBP 4: Bandwidth
4554 +#define BBP4_TX_BF FIELD8(0x01)
4555 +#define BBP4_BANDWIDTH FIELD8(0x18)
4559 + * The wordsize of the RFCSR is 8 bits.
4565 +#define RFCSR6_R FIELD8(0x03)
4570 +#define RFCSR7_RF_TUNING FIELD8(0x01)
4575 +#define RFCSR12_TX_POWER FIELD8(0x1f)
4580 +#define RFCSR22_BASEBAND_LOOPBACK FIELD8(0x01)
4585 +#define RFCSR23_FREQ_OFFSET FIELD8(0x7f)
4590 +#define RFCSR30_RF_CALIBRATION FIELD8(0x80)
4599 +#define RF2_ANTENNA_RX2 FIELD32(0x00000040)
4600 +#define RF2_ANTENNA_TX1 FIELD32(0x00004000)
4601 +#define RF2_ANTENNA_RX1 FIELD32(0x00020000)
4606 +#define RF3_TXPOWER_G FIELD32(0x00003e00)
4607 +#define RF3_TXPOWER_A_7DBM_BOOST FIELD32(0x00000200)
4608 +#define RF3_TXPOWER_A FIELD32(0x00003c00)
4613 +#define RF4_TXPOWER_G FIELD32(0x000007c0)
4614 +#define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
4615 +#define RF4_TXPOWER_A FIELD32(0x00000780)
4616 +#define RF4_FREQ_OFFSET FIELD32(0x001f8000)
4617 +#define RF4_HT40 FIELD32(0x00200000)
4621 + * The wordsize of the EEPROM is 16 bits.
4627 +#define EEPROM_VERSION 0x0001
4628 +#define EEPROM_VERSION_FAE FIELD16(0x00ff)
4629 +#define EEPROM_VERSION_VERSION FIELD16(0xff00)
4634 +#define EEPROM_MAC_ADDR_0 0x0002
4635 +#define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff)
4636 +#define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00)
4637 +#define EEPROM_MAC_ADDR_1 0x0003
4638 +#define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff)
4639 +#define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00)
4640 +#define EEPROM_MAC_ADDR_2 0x0004
4641 +#define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff)
4642 +#define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
4645 + * EEPROM ANTENNA config
4646 + * RXPATH: 1: 1R, 2: 2R, 3: 3R
4647 + * TXPATH: 1: 1T, 2: 2T
4649 +#define EEPROM_ANTENNA 0x001a
4650 +#define EEPROM_ANTENNA_RXPATH FIELD16(0x000f)
4651 +#define EEPROM_ANTENNA_TXPATH FIELD16(0x00f0)
4652 +#define EEPROM_ANTENNA_RF_TYPE FIELD16(0x0f00)
4655 + * EEPROM NIC config
4656 + * CARDBUS_ACCEL: 0 - enable, 1 - disable
4658 +#define EEPROM_NIC 0x001b
4659 +#define EEPROM_NIC_HW_RADIO FIELD16(0x0001)
4660 +#define EEPROM_NIC_DYNAMIC_TX_AGC FIELD16(0x0002)
4661 +#define EEPROM_NIC_EXTERNAL_LNA_BG FIELD16(0x0004)
4662 +#define EEPROM_NIC_EXTERNAL_LNA_A FIELD16(0x0008)
4663 +#define EEPROM_NIC_CARDBUS_ACCEL FIELD16(0x0010)
4664 +#define EEPROM_NIC_BW40M_SB_BG FIELD16(0x0020)
4665 +#define EEPROM_NIC_BW40M_SB_A FIELD16(0x0040)
4666 +#define EEPROM_NIC_WPS_PBC FIELD16(0x0080)
4667 +#define EEPROM_NIC_BW40M_BG FIELD16(0x0100)
4668 +#define EEPROM_NIC_BW40M_A FIELD16(0x0200)
4671 + * EEPROM frequency
4673 +#define EEPROM_FREQ 0x001d
4674 +#define EEPROM_FREQ_OFFSET FIELD16(0x00ff)
4675 +#define EEPROM_FREQ_LED_MODE FIELD16(0x7f00)
4676 +#define EEPROM_FREQ_LED_POLARITY FIELD16(0x1000)
4680 + * POLARITY_RDY_G: Polarity RDY_G setting.
4681 + * POLARITY_RDY_A: Polarity RDY_A setting.
4682 + * POLARITY_ACT: Polarity ACT setting.
4683 + * POLARITY_GPIO_0: Polarity GPIO0 setting.
4684 + * POLARITY_GPIO_1: Polarity GPIO1 setting.
4685 + * POLARITY_GPIO_2: Polarity GPIO2 setting.
4686 + * POLARITY_GPIO_3: Polarity GPIO3 setting.
4687 + * POLARITY_GPIO_4: Polarity GPIO4 setting.
4688 + * LED_MODE: Led mode.
4690 +#define EEPROM_LED1 0x001e
4691 +#define EEPROM_LED2 0x001f
4692 +#define EEPROM_LED3 0x0020
4693 +#define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001)
4694 +#define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002)
4695 +#define EEPROM_LED_POLARITY_ACT FIELD16(0x0004)
4696 +#define EEPROM_LED_POLARITY_GPIO_0 FIELD16(0x0008)
4697 +#define EEPROM_LED_POLARITY_GPIO_1 FIELD16(0x0010)
4698 +#define EEPROM_LED_POLARITY_GPIO_2 FIELD16(0x0020)
4699 +#define EEPROM_LED_POLARITY_GPIO_3 FIELD16(0x0040)
4700 +#define EEPROM_LED_POLARITY_GPIO_4 FIELD16(0x0080)
4701 +#define EEPROM_LED_LED_MODE FIELD16(0x1f00)
4706 +#define EEPROM_LNA 0x0022
4707 +#define EEPROM_LNA_BG FIELD16(0x00ff)
4708 +#define EEPROM_LNA_A0 FIELD16(0xff00)
4711 + * EEPROM RSSI BG offset
4713 +#define EEPROM_RSSI_BG 0x0023
4714 +#define EEPROM_RSSI_BG_OFFSET0 FIELD16(0x00ff)
4715 +#define EEPROM_RSSI_BG_OFFSET1 FIELD16(0xff00)
4718 + * EEPROM RSSI BG2 offset
4720 +#define EEPROM_RSSI_BG2 0x0024
4721 +#define EEPROM_RSSI_BG2_OFFSET2 FIELD16(0x00ff)
4722 +#define EEPROM_RSSI_BG2_LNA_A1 FIELD16(0xff00)
4725 + * EEPROM RSSI A offset
4727 +#define EEPROM_RSSI_A 0x0025
4728 +#define EEPROM_RSSI_A_OFFSET0 FIELD16(0x00ff)
4729 +#define EEPROM_RSSI_A_OFFSET1 FIELD16(0xff00)
4732 + * EEPROM RSSI A2 offset
4734 +#define EEPROM_RSSI_A2 0x0026
4735 +#define EEPROM_RSSI_A2_OFFSET2 FIELD16(0x00ff)
4736 +#define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00)
4739 + * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power.
4740 + * This is delta in 40MHZ.
4741 + * VALUE: Tx Power dalta value (MAX=4)
4742 + * TYPE: 1: Plus the delta value, 0: minus the delta value
4743 + * TXPOWER: Enable:
4745 +#define EEPROM_TXPOWER_DELTA 0x0028
4746 +#define EEPROM_TXPOWER_DELTA_VALUE FIELD16(0x003f)
4747 +#define EEPROM_TXPOWER_DELTA_TYPE FIELD16(0x0040)
4748 +#define EEPROM_TXPOWER_DELTA_TXPOWER FIELD16(0x0080)
4751 + * EEPROM TXPOWER 802.11BG
4753 +#define EEPROM_TXPOWER_BG1 0x0029
4754 +#define EEPROM_TXPOWER_BG2 0x0030
4755 +#define EEPROM_TXPOWER_BG_SIZE 7
4756 +#define EEPROM_TXPOWER_BG_1 FIELD16(0x00ff)
4757 +#define EEPROM_TXPOWER_BG_2 FIELD16(0xff00)
4760 + * EEPROM TXPOWER 802.11A
4762 +#define EEPROM_TXPOWER_A1 0x003c
4763 +#define EEPROM_TXPOWER_A2 0x0053
4764 +#define EEPROM_TXPOWER_A_SIZE 6
4765 +#define EEPROM_TXPOWER_A_1 FIELD16(0x00ff)
4766 +#define EEPROM_TXPOWER_A_2 FIELD16(0xff00)
4769 + * EEPROM TXpower byrate: 20MHZ power
4771 +#define EEPROM_TXPOWER_BYRATE 0x006f
4776 +#define EEPROM_BBP_START 0x0078
4777 +#define EEPROM_BBP_SIZE 16
4778 +#define EEPROM_BBP_VALUE FIELD16(0x00ff)
4779 +#define EEPROM_BBP_REG_ID FIELD16(0xff00)
4782 + * MCU mailbox commands.
4784 +#define MCU_SLEEP 0x30
4785 +#define MCU_WAKEUP 0x31
4786 +#define MCU_LED 0x50
4787 +#define MCU_LED_STRENGTH 0x51
4788 +#define MCU_LED_1 0x52
4789 +#define MCU_LED_2 0x53
4790 +#define MCU_LED_3 0x54
4791 +#define MCU_RADAR 0x60
4792 +#define MCU_BOOT_SIGNAL 0x72
4795 + * DMA descriptor defines.
4797 +#define TXD_DESC_SIZE ( 4 * sizeof(__le32) )
4798 +#define TXINFO_DESC_SIZE ( 1 * sizeof(__le32) )
4799 +#define TXWI_DESC_SIZE ( 4 * sizeof(__le32) )
4800 +#define RXD_DESC_SIZE ( 1 * sizeof(__le32) )
4801 +#define RXWI_DESC_SIZE ( 4 * sizeof(__le32) )
4804 + * TX descriptor format for TX, PRIO and Beacon Ring.
4810 +#define TXD_W0_SD_PTR0 FIELD32(0xffffffff)
4815 +#define TXD_W1_SD_LEN1 FIELD32(0x00003fff)
4816 +#define TXD_W1_LAST_SEC1 FIELD32(0x00004000)
4817 +#define TXD_W1_BURST FIELD32(0x00008000)
4818 +#define TXD_W1_SD_LEN0 FIELD32(0x3fff0000)
4819 +#define TXD_W1_LAST_SEC0 FIELD32(0x40000000)
4820 +#define TXD_W1_DMA_DONE FIELD32(0x80000000)
4825 +#define TXD_W2_SD_PTR1 FIELD32(0xffffffff)
4829 + * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
4830 + * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
4831 + * 0:MGMT, 1:HCCA 2:EDCA
4833 +#define TXD_W3_WIV FIELD32(0x01000000)
4834 +#define TXD_W3_QSEL FIELD32(0x06000000)
4835 +#define TXD_W3_TCO FIELD32(0x20000000)
4836 +#define TXD_W3_UCO FIELD32(0x40000000)
4837 +#define TXD_W3_ICO FIELD32(0x80000000)
4840 + * TX Info structure
4845 + * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
4846 + * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
4847 + * 0:MGMT, 1:HCCA 2:EDCA
4848 + * USB_DMA_NEXT_VALID: Used ONLY in USB bulk Aggregation, NextValid
4849 + * DMA_TX_BURST: used ONLY in USB bulk Aggregation.
4850 + * Force USB DMA transmit frame from current selected endpoint
4852 +#define TXINFO_W0_USB_DMA_TX_PKT_LEN FIELD32(0x0000ffff)
4853 +#define TXINFO_W0_WIV FIELD32(0x01000000)
4854 +#define TXINFO_W0_QSEL FIELD32(0x06000000)
4855 +#define TXINFO_W0_SW_USE_LAST_ROUND FIELD32(0x08000000)
4856 +#define TXINFO_W0_USB_DMA_NEXT_VALID FIELD32(0x40000000)
4857 +#define TXINFO_W0_USB_DMA_TX_BURST FIELD32(0x80000000)
4865 + * FRAG: 1 To inform TKIP engine this is a fragment.
4866 + * MIMO_PS: The remote peer is in dynamic MIMO-PS mode
4867 + * TX_OP: 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs
4868 + * BW: Channel bandwidth 20MHz or 40 MHz
4869 + * STBC: 1: STBC support MCS =0-7, 2,3 : RESERVED
4871 +#define TXWI_W0_FRAG FIELD32(0x00000001)
4872 +#define TXWI_W0_MIMO_PS FIELD32(0x00000002)
4873 +#define TXWI_W0_CF_ACK FIELD32(0x00000004)
4874 +#define TXWI_W0_TS FIELD32(0x00000008)
4875 +#define TXWI_W0_AMPDU FIELD32(0x00000010)
4876 +#define TXWI_W0_MPDU_DENSITY FIELD32(0x000000e0)
4877 +#define TXWI_W0_TX_OP FIELD32(0x00000300)
4878 +#define TXWI_W0_MCS FIELD32(0x007f0000)
4879 +#define TXWI_W0_BW FIELD32(0x00800000)
4880 +#define TXWI_W0_SHORT_GI FIELD32(0x01000000)
4881 +#define TXWI_W0_STBC FIELD32(0x06000000)
4882 +#define TXWI_W0_IFS FIELD32(0x08000000)
4883 +#define TXWI_W0_PHYMODE FIELD32(0xc0000000)
4888 +#define TXWI_W1_ACK FIELD32(0x00000001)
4889 +#define TXWI_W1_NSEQ FIELD32(0x00000002)
4890 +#define TXWI_W1_BW_WIN_SIZE FIELD32(0x000000fc)
4891 +#define TXWI_W1_WIRELESS_CLI_ID FIELD32(0x0000ff00)
4892 +#define TXWI_W1_MPDU_TOTAL_BYTE_COUNT FIELD32(0x0fff0000)
4893 +#define TXWI_W1_PACKETID FIELD32(0xf0000000)
4898 +#define TXWI_W2_IV FIELD32(0xffffffff)
4903 +#define TXWI_W3_EIV FIELD32(0xffffffff)
4906 + * RX descriptor format for RX Ring.
4911 + * UNICAST_TO_ME: This RX frame is unicast to me.
4912 + * MULTICAST: This is a multicast frame.
4913 + * BROADCAST: This is a broadcast frame.
4914 + * MY_BSS: this frame belongs to the same BSSID.
4915 + * CRC_ERROR: CRC error.
4916 + * CIPHER_ERROR: 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid.
4917 + * AMSDU: rx with 802.3 header, not 802.11 header.
4920 +#define RXD_W0_BA FIELD32(0x00000001)
4921 +#define RXD_W0_DATA FIELD32(0x00000002)
4922 +#define RXD_W0_NULLDATA FIELD32(0x00000004)
4923 +#define RXD_W0_FRAG FIELD32(0x00000008)
4924 +#define RXD_W0_UNICAST_TO_ME FIELD32(0x00000010)
4925 +#define RXD_W0_MULTICAST FIELD32(0x00000020)
4926 +#define RXD_W0_BROADCAST FIELD32(0x00000040)
4927 +#define RXD_W0_MY_BSS FIELD32(0x00000080)
4928 +#define RXD_W0_CRC_ERROR FIELD32(0x00000100)
4929 +#define RXD_W0_CIPHER_ERROR FIELD32(0x00000600)
4930 +#define RXD_W0_AMSDU FIELD32(0x00000800)
4931 +#define RXD_W0_HTC FIELD32(0x00001000)
4932 +#define RXD_W0_RSSI FIELD32(0x00002000)
4933 +#define RXD_W0_L2PAD FIELD32(0x00004000)
4934 +#define RXD_W0_AMPDU FIELD32(0x00008000)
4935 +#define RXD_W0_DECRYPTED FIELD32(0x00010000)
4936 +#define RXD_W0_PLCP_RSSI FIELD32(0x00020000)
4937 +#define RXD_W0_CIPHER_ALG FIELD32(0x00040000)
4938 +#define RXD_W0_LAST_AMSDU FIELD32(0x00080000)
4939 +#define RXD_W0_PLCP_SIGNAL FIELD32(0xfff00000)
4948 +#define RXWI_W0_WIRELESS_CLI_ID FIELD32(0x000000ff)
4949 +#define RXWI_W0_KEY_INDEX FIELD32(0x00000300)
4950 +#define RXWI_W0_BSSID FIELD32(0x00001c00)
4951 +#define RXWI_W0_UDF FIELD32(0x0000e000)
4952 +#define RXWI_W0_MPDU_TOTAL_BYTE_COUNT FIELD32(0x0fff0000)
4953 +#define RXWI_W0_TID FIELD32(0xf0000000)
4958 +#define RXWI_W1_FRAG FIELD32(0x0000000f)
4959 +#define RXWI_W1_SEQUENCE FIELD32(0x0000fff0)
4960 +#define RXWI_W1_MCS FIELD32(0x007f0000)
4961 +#define RXWI_W1_BW FIELD32(0x00800000)
4962 +#define RXWI_W1_SHORT_GI FIELD32(0x01000000)
4963 +#define RXWI_W1_STBC FIELD32(0x06000000)
4964 +#define RXWI_W1_PHYMODE FIELD32(0xc0000000)
4969 +#define RXWI_W2_RSSI0 FIELD32(0x000000ff)
4970 +#define RXWI_W2_RSSI1 FIELD32(0x0000ff00)
4971 +#define RXWI_W2_RSSI2 FIELD32(0x00ff0000)
4976 +#define RXWI_W3_SNR0 FIELD32(0x000000ff)
4977 +#define RXWI_W3_SNR1 FIELD32(0x0000ff00)
4980 + * Macro's for converting txpower from EEPROM to mac80211 value
4981 + * and from mac80211 value to register value.
4983 +#define MIN_G_TXPOWER 0
4984 +#define MIN_A_TXPOWER -7
4985 +#define MAX_G_TXPOWER 31
4986 +#define MAX_A_TXPOWER 15
4987 +#define DEFAULT_TXPOWER 5
4989 +#define TXPOWER_G_FROM_DEV(__txpower) \
4990 + ((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
4992 +#define TXPOWER_G_TO_DEV(__txpower) \
4993 + clamp_t(char, __txpower, MIN_G_TXPOWER, MAX_G_TXPOWER)
4995 +#define TXPOWER_A_FROM_DEV(__txpower) \
4996 + ((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
4998 +#define TXPOWER_A_TO_DEV(__txpower) \
4999 + clamp_t(char, __txpower, MIN_A_TXPOWER, MAX_A_TXPOWER)
5001 +#endif /* RT2800USB_H */
5002 --- a/drivers/net/wireless/rt2x00/rt2x00.h
5003 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
5004 @@ -142,6 +142,7 @@ struct rt2x00_chip {
5005 #define RT2860D 0x0681 /* 2.4GHz, 5GHz PCI/CB */
5006 #define RT2890 0x0701 /* 2.4GHz PCIe */
5007 #define RT2890D 0x0781 /* 2.4GHz, 5GHz PCIe */
5008 +#define RT2870 0x1600
5012 @@ -780,6 +781,12 @@ struct rt2x00_dev {
5016 + * Calibration information (for rt2800usb).
5018 + u8 calibration_bw20;
5019 + u8 calibration_bw40;
5022 * Low level statistics which will have
5023 * to be kept up to date while device is running.