1 From: Ivo van Doorn <IvDoorn@gmail.com>
2 Date: Sun, 28 Dec 2008 12:48:56 +0000 (+0100)
3 Subject: rt2x00: Implement support for rt2800usb
4 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Fivd%2Frt2x00.git;a=commitdiff_plain;h=e0af839d714d1d04af044d00858ce4113ebd602b
6 rt2x00: Implement support for rt2800usb
8 Add support for the rt2800usb chipset.
10 Includes various patches from Mattias and Felix.
12 Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
13 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
14 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
17 --- a/drivers/net/wireless/rt2x00/Makefile
18 +++ b/drivers/net/wireless/rt2x00/Makefile
19 @@ -19,3 +19,4 @@ obj-$(CONFIG_RT61PCI) += rt61pci.o
20 obj-$(CONFIG_RT2800PCI) += rt2800pci.o
21 obj-$(CONFIG_RT2500USB) += rt2500usb.o
22 obj-$(CONFIG_RT73USB) += rt73usb.o
23 +obj-$(CONFIG_RT2800USB) += rt2800usb.o
25 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
28 + Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
29 + <http://rt2x00.serialmonkey.com>
31 + This program is free software; you can redistribute it and/or modify
32 + it under the terms of the GNU General Public License as published by
33 + the Free Software Foundation; either version 2 of the License, or
34 + (at your option) any later version.
36 + This program is distributed in the hope that it will be useful,
37 + but WITHOUT ANY WARRANTY; without even the implied warranty of
38 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 + GNU General Public License for more details.
41 + You should have received a copy of the GNU General Public License
42 + along with this program; if not, write to the
43 + Free Software Foundation, Inc.,
44 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
49 + Abstract: rt2800usb device specific routines.
50 + Supported chipsets: RT2800U.
53 +#include <linux/crc-ccitt.h>
54 +#include <linux/delay.h>
55 +#include <linux/etherdevice.h>
56 +#include <linux/init.h>
57 +#include <linux/kernel.h>
58 +#include <linux/module.h>
59 +#include <linux/usb.h>
62 +#include "rt2x00usb.h"
63 +#include "rt2800usb.h"
66 + * Allow hardware encryption to be disabled.
68 +static int modparam_nohwcrypt = 0;
69 +module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
70 +MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
74 + * All access to the CSR registers will go through the methods
75 + * rt2x00usb_register_read and rt2x00usb_register_write.
76 + * BBP and RF register require indirect register access,
77 + * and use the CSR registers BBPCSR and RFCSR to achieve this.
78 + * These indirect registers work with busy bits,
79 + * and we will try maximal REGISTER_BUSY_COUNT times to access
80 + * the register while taking a REGISTER_BUSY_DELAY us delay
81 + * between each attampt. When the busy bit is still set at that time,
82 + * the access attempt is considered to have failed,
83 + * and we will print an error.
84 + * The _lock versions must be used if you already hold the csr_mutex
86 +#define WAIT_FOR_BBP(__dev, __reg) \
87 + rt2x00usb_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg))
88 +#define WAIT_FOR_RF(__dev, __reg) \
89 + rt2x00usb_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg))
90 +#define WAIT_FOR_MCU(__dev, __reg) \
91 + rt2x00usb_regbusy_read((__dev), H2M_MAILBOX_CSR, \
92 + H2M_MAILBOX_CSR_OWNER, (__reg))
94 +static void rt2800usb_bbp_write(struct rt2x00_dev *rt2x00dev,
95 + const unsigned int word, const u8 value)
99 + mutex_lock(&rt2x00dev->csr_mutex);
102 + * Wait until the BBP becomes available, afterwards we
103 + * can safely write the new data into the register.
105 + if (WAIT_FOR_BBP(rt2x00dev, ®)) {
107 + rt2x00_set_field32(®, BBP_CSR_CFG_VALUE, value);
108 + rt2x00_set_field32(®, BBP_CSR_CFG_REGNUM, word);
109 + rt2x00_set_field32(®, BBP_CSR_CFG_BUSY, 1);
110 + rt2x00_set_field32(®, BBP_CSR_CFG_READ_CONTROL, 0);
112 + rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
115 + mutex_unlock(&rt2x00dev->csr_mutex);
118 +static void rt2800usb_bbp_read(struct rt2x00_dev *rt2x00dev,
119 + const unsigned int word, u8 *value)
123 + mutex_lock(&rt2x00dev->csr_mutex);
126 + * Wait until the BBP becomes available, afterwards we
127 + * can safely write the read request into the register.
128 + * After the data has been written, we wait until hardware
129 + * returns the correct value, if at any time the register
130 + * doesn't become available in time, reg will be 0xffffffff
131 + * which means we return 0xff to the caller.
133 + if (WAIT_FOR_BBP(rt2x00dev, ®)) {
135 + rt2x00_set_field32(®, BBP_CSR_CFG_REGNUM, word);
136 + rt2x00_set_field32(®, BBP_CSR_CFG_BUSY, 1);
137 + rt2x00_set_field32(®, BBP_CSR_CFG_READ_CONTROL, 1);
139 + rt2x00usb_register_write_lock(rt2x00dev, BBP_CSR_CFG, reg);
141 + WAIT_FOR_BBP(rt2x00dev, ®);
144 + *value = rt2x00_get_field32(reg, BBP_CSR_CFG_VALUE);
146 + mutex_unlock(&rt2x00dev->csr_mutex);
149 +static void rt2800usb_rf_write(struct rt2x00_dev *rt2x00dev,
150 + const unsigned int word, const u32 value)
157 + mutex_lock(&rt2x00dev->csr_mutex);
160 + * Wait until the RF becomes available, afterwards we
161 + * can safely write the new data into the register.
163 + if (WAIT_FOR_RF(rt2x00dev, ®)) {
165 + rt2x00_set_field32(®, RF_CSR_CFG0_REG_VALUE_BW, value);
166 + rt2x00_set_field32(®, RF_CSR_CFG0_STANDBYMODE, 0);
167 + rt2x00_set_field32(®, RF_CSR_CFG0_SEL, 0);
168 + rt2x00_set_field32(®, RF_CSR_CFG0_BUSY, 1);
170 + rt2x00usb_register_write_lock(rt2x00dev, RF_CSR_CFG0, reg);
171 + rt2x00_rf_write(rt2x00dev, word, value);
174 + mutex_unlock(&rt2x00dev->csr_mutex);
177 +static void rt2800usb_mcu_request(struct rt2x00_dev *rt2x00dev,
178 + const u8 command, const u8 token,
179 + const u8 arg0, const u8 arg1)
183 + mutex_lock(&rt2x00dev->csr_mutex);
186 + * Wait until the MCU becomes available, afterwards we
187 + * can safely write the new data into the register.
189 + if (WAIT_FOR_MCU(rt2x00dev, ®)) {
190 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_OWNER, 1);
191 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_CMD_TOKEN, token);
192 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_ARG0, arg0);
193 + rt2x00_set_field32(®, H2M_MAILBOX_CSR_ARG1, arg1);
194 + rt2x00usb_register_write_lock(rt2x00dev, H2M_MAILBOX_CSR, reg);
197 + rt2x00_set_field32(®, HOST_CMD_CSR_HOST_COMMAND, command);
198 + rt2x00usb_register_write_lock(rt2x00dev, HOST_CMD_CSR, reg);
201 + mutex_unlock(&rt2x00dev->csr_mutex);
204 +#ifdef CONFIG_RT2X00_LIB_DEBUGFS
205 +static const struct rt2x00debug rt2800usb_rt2x00debug = {
206 + .owner = THIS_MODULE,
208 + .read = rt2x00usb_register_read,
209 + .write = rt2x00usb_register_write,
210 + .flags = RT2X00DEBUGFS_OFFSET,
211 + .word_base = CSR_REG_BASE,
212 + .word_size = sizeof(u32),
213 + .word_count = CSR_REG_SIZE / sizeof(u32),
216 + .read = rt2x00_eeprom_read,
217 + .write = rt2x00_eeprom_write,
218 + .word_base = EEPROM_BASE,
219 + .word_size = sizeof(u16),
220 + .word_count = EEPROM_SIZE / sizeof(u16),
223 + .read = rt2800usb_bbp_read,
224 + .write = rt2800usb_bbp_write,
225 + .word_base = BBP_BASE,
226 + .word_size = sizeof(u8),
227 + .word_count = BBP_SIZE / sizeof(u8),
230 + .read = rt2x00_rf_read,
231 + .write = rt2800usb_rf_write,
232 + .word_base = RF_BASE,
233 + .word_size = sizeof(u32),
234 + .word_count = RF_SIZE / sizeof(u32),
237 +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
239 +#ifdef CONFIG_RT2X00_LIB_RFKILL
240 +static int rt2800usb_rfkill_poll(struct rt2x00_dev *rt2x00dev)
244 + rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, ®);
245 + return rt2x00_get_field32(reg, GPIO_CTRL_CFG_BIT2);
248 +#define rt2800usb_rfkill_poll NULL
249 +#endif /* CONFIG_RT2X00_LIB_RFKILL */
251 +#ifdef CONFIG_RT2X00_LIB_LEDS
252 +static void rt2800usb_brightness_set(struct led_classdev *led_cdev,
253 + enum led_brightness brightness)
255 + struct rt2x00_led *led =
256 + container_of(led_cdev, struct rt2x00_led, led_dev);
257 + unsigned int enabled = brightness != LED_OFF;
258 + unsigned int bg_mode =
259 + (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
260 + unsigned int polarity =
261 + rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
262 + EEPROM_FREQ_LED_POLARITY);
263 + unsigned int ledmode =
264 + rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
265 + EEPROM_FREQ_LED_MODE);
267 + if (led->type == LED_TYPE_RADIO) {
268 + rt2800usb_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
269 + enabled ? 0x20 : 0);
270 + } else if (led->type == LED_TYPE_ASSOC) {
271 + rt2800usb_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
272 + enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
273 + } else if (led->type == LED_TYPE_QUALITY) {
275 + * The brightness is divided into 6 levels (0 - 5),
276 + * The specs tell us the following levels:
277 + * 0, 1 ,3, 7, 15, 31
278 + * to determine the level in a simple way we can simply
279 + * work with bitshifting:
282 + rt2800usb_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
283 + (1 << brightness / (LED_FULL / 6)) - 1,
288 +static int rt2800usb_blink_set(struct led_classdev *led_cdev,
289 + unsigned long *delay_on,
290 + unsigned long *delay_off)
292 + struct rt2x00_led *led =
293 + container_of(led_cdev, struct rt2x00_led, led_dev);
296 + rt2x00usb_register_read(led->rt2x00dev, LED_CFG, ®);
297 + rt2x00_set_field32(®, LED_CFG_ON_PERIOD, *delay_on);
298 + rt2x00_set_field32(®, LED_CFG_OFF_PERIOD, *delay_off);
299 + rt2x00_set_field32(®, LED_CFG_SLOW_BLINK_PERIOD, 3);
300 + rt2x00_set_field32(®, LED_CFG_R_LED_MODE, 3);
301 + rt2x00_set_field32(®, LED_CFG_G_LED_MODE, 12);
302 + rt2x00_set_field32(®, LED_CFG_Y_LED_MODE, 3);
303 + rt2x00_set_field32(®, LED_CFG_LED_POLAR, 1);
304 + rt2x00usb_register_write(led->rt2x00dev, LED_CFG, reg);
309 +static void rt2800usb_init_led(struct rt2x00_dev *rt2x00dev,
310 + struct rt2x00_led *led,
311 + enum led_type type)
313 + led->rt2x00dev = rt2x00dev;
315 + led->led_dev.brightness_set = rt2800usb_brightness_set;
316 + led->led_dev.blink_set = rt2800usb_blink_set;
317 + led->flags = LED_INITIALIZED;
319 +#endif /* CONFIG_RT2X00_LIB_LEDS */
322 + * Configuration handlers.
324 +static void rt2800usb_config_wcid_attr(struct rt2x00_dev *rt2x00dev,
325 + struct rt2x00lib_crypto *crypto,
326 + struct ieee80211_key_conf *key)
331 + offset = MAC_WCID_ATTR_ENTRY(crypto->aid);
334 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_KEYTAB,
335 + !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE));
336 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_PAIRKEY_MODE,
338 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_BSS_IDX,
339 + (crypto->cmd == SET_KEY) ? crypto->bssidx : 0);
340 + rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_RX_WIUDF, 0);
341 + rt2x00usb_register_write(rt2x00dev, offset, reg);
344 +static int rt2800usb_config_shared_key(struct rt2x00_dev *rt2x00dev,
345 + struct rt2x00lib_crypto *crypto,
346 + struct ieee80211_key_conf *key)
348 + struct hw_key_entry key_entry;
349 + struct rt2x00_field32 field;
355 + if (crypto->cmd == SET_KEY) {
356 + memcpy(key_entry.key, crypto->key,
357 + sizeof(key_entry.key));
358 + memcpy(key_entry.tx_mic, crypto->tx_mic,
359 + sizeof(key_entry.tx_mic));
360 + memcpy(key_entry.rx_mic, crypto->rx_mic,
361 + sizeof(key_entry.rx_mic));
363 + offset = SHARED_KEY_ENTRY(key->hw_key_idx);
364 + timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
365 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
366 + USB_VENDOR_REQUEST_OUT,
367 + offset, &key_entry,
372 + * The driver does not support the IV/EIV generation
373 + * in hardware. However it doesn't support the IV/EIV
374 + * inside the ieee80211 frame either, but requires it
375 + * to be provided seperately for the descriptor.
376 + * rt2x00lib will cut the IV/EIV data out of all frames
377 + * given to us by mac80211, but we must tell mac80211
378 + * to generate the IV/EIV data.
380 + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
384 + * The cipher types are stored over multiple registers
385 + * starting with SHARED_KEY_MODE_BASE each word will have
386 + * 32 bits and contains the cipher types for 2 modes each.
387 + * Using the correct defines correctly will cause overhead,
388 + * so just calculate the correct offset.
390 + mask = key->hw_key_idx % 8;
391 + field.bit_offset = (3 * mask);
392 + field.bit_mask = 0x7 << field.bit_offset;
394 + offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8);
395 + rt2x00usb_register_read(rt2x00dev, offset, ®);
396 + rt2x00_set_field32(®, field,
397 + (crypto->cmd == SET_KEY) ? crypto->cipher : 0);
398 + rt2x00usb_register_write(rt2x00dev, offset, reg);
401 + * Update WCID information
403 + rt2800usb_config_wcid_attr(rt2x00dev, crypto, key);
408 +static int rt2800usb_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
409 + struct rt2x00lib_crypto *crypto,
410 + struct ieee80211_key_conf *key)
412 + struct hw_key_entry key_entry;
417 + * 1 pairwise key is possible per AID, this means that the AID
418 + * equals our hw_key_idx.
420 + key->hw_key_idx = crypto->aid;
422 + if (crypto->cmd == SET_KEY) {
423 + memcpy(key_entry.key, crypto->key,
424 + sizeof(key_entry.key));
425 + memcpy(key_entry.tx_mic, crypto->tx_mic,
426 + sizeof(key_entry.tx_mic));
427 + memcpy(key_entry.rx_mic, crypto->rx_mic,
428 + sizeof(key_entry.rx_mic));
430 + offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx);
431 + timeout = REGISTER_TIMEOUT32(sizeof(key_entry));
432 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
433 + USB_VENDOR_REQUEST_OUT,
434 + offset, &key_entry,
439 + * The driver does not support the IV/EIV generation
440 + * in hardware. However it doesn't support the IV/EIV
441 + * inside the ieee80211 frame either, but requires it
442 + * to be provided seperately for the descriptor.
443 + * rt2x00lib will cut the IV/EIV data out of all frames
444 + * given to us by mac80211, but we must tell mac80211
445 + * to generate the IV/EIV data.
447 + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
451 + * Update WCID information
453 + rt2800usb_config_wcid_attr(rt2x00dev, crypto, key);
458 +static void rt2800usb_config_filter(struct rt2x00_dev *rt2x00dev,
459 + const unsigned int filter_flags)
464 + * Start configuration steps.
465 + * Note that the version error will always be dropped
466 + * and broadcast frames will always be accepted since
467 + * there is no filter for it at this time.
469 + rt2x00usb_register_read(rt2x00dev, RX_FILTER_CFG, ®);
470 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CRC_ERROR,
471 + !(filter_flags & FIF_FCSFAIL));
472 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_PHY_ERROR,
473 + !(filter_flags & FIF_PLCPFAIL));
474 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_NOT_TO_ME,
475 + !(filter_flags & FIF_PROMISC_IN_BSS));
476 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_NOT_MY_BSSD,
477 + !(filter_flags & FIF_OTHER_BSS));
478 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_VER_ERROR, 1);
479 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_MULTICAST,
480 + !(filter_flags & FIF_ALLMULTI));
481 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BROADCAST, 0);
482 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_DUPLICATE, 1);
483 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CF_END_ACK,
484 + !(filter_flags & FIF_CONTROL));
485 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CF_END,
486 + !(filter_flags & FIF_CONTROL));
487 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_ACK,
488 + !(filter_flags & FIF_CONTROL));
489 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CTS,
490 + !(filter_flags & FIF_CONTROL));
491 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_RTS,
492 + !(filter_flags & FIF_CONTROL));
493 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_PSPOLL,
494 + !(filter_flags & FIF_CONTROL));
495 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BA, 1);
496 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BAR, 1);
497 + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CNTL,
498 + !(filter_flags & FIF_CONTROL));
499 + rt2x00usb_register_write(rt2x00dev, RX_FILTER_CFG, reg);
502 +static void rt2800usb_config_intf(struct rt2x00_dev *rt2x00dev,
503 + struct rt2x00_intf *intf,
504 + struct rt2x00intf_conf *conf,
505 + const unsigned int flags)
507 + unsigned int beacon_base;
510 + if (flags & CONFIG_UPDATE_TYPE) {
512 + * Clear current synchronisation setup.
513 + * For the Beacon base registers we only need to clear
514 + * the first byte since that byte contains the VALID and OWNER
515 + * bits which (when set to 0) will invalidate the entire beacon.
517 + beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
518 + rt2x00usb_register_write(rt2x00dev, beacon_base, 0);
521 + * Enable synchronisation.
523 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
524 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1);
525 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync);
526 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1);
527 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
530 + if (flags & CONFIG_UPDATE_MAC) {
531 + reg = le32_to_cpu(conf->mac[1]);
532 + rt2x00_set_field32(®, MAC_ADDR_DW1_UNICAST_TO_ME_MASK, 0xff);
533 + conf->mac[1] = cpu_to_le32(reg);
535 + rt2x00usb_register_multiwrite(rt2x00dev, MAC_ADDR_DW0,
536 + conf->mac, sizeof(conf->mac));
539 + if (flags & CONFIG_UPDATE_BSSID) {
540 + reg = le32_to_cpu(conf->bssid[1]);
541 + rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_ID_MASK, 0);
542 + rt2x00_set_field32(®, MAC_BSSID_DW1_BSS_BCN_NUM, 0);
543 + conf->bssid[1] = cpu_to_le32(reg);
545 + rt2x00usb_register_multiwrite(rt2x00dev, MAC_BSSID_DW0,
546 + conf->bssid, sizeof(conf->bssid));
550 +static void rt2800usb_config_erp(struct rt2x00_dev *rt2x00dev,
551 + struct rt2x00lib_erp *erp)
555 + rt2x00usb_register_read(rt2x00dev, TX_TIMEOUT_CFG, ®);
556 + rt2x00_set_field32(®, TX_TIMEOUT_CFG_RX_ACK_TIMEOUT,
558 + rt2x00usb_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg);
560 + rt2x00usb_register_read(rt2x00dev, AUTO_RSP_CFG, ®);
561 + rt2x00_set_field32(®, AUTO_RSP_CFG_BAC_ACK_POLICY,
562 + !!erp->short_preamble);
563 + rt2x00_set_field32(®, AUTO_RSP_CFG_AR_PREAMBLE,
564 + !!erp->short_preamble);
565 + rt2x00usb_register_write(rt2x00dev, AUTO_RSP_CFG, reg);
567 + rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, ®);
568 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL,
569 + erp->cts_protection ? 2 : 0);
570 + rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
572 + rt2x00usb_register_write(rt2x00dev, LEGACY_BASIC_RATE,
574 + rt2x00usb_register_write(rt2x00dev, HT_BASIC_RATE,
575 + erp->basic_rates >> 32);
577 + rt2x00usb_register_read(rt2x00dev, BKOFF_SLOT_CFG, ®);
578 + rt2x00_set_field32(®, BKOFF_SLOT_CFG_SLOT_TIME, erp->slot_time);
579 + rt2x00_set_field32(®, BKOFF_SLOT_CFG_CC_DELAY_TIME, 2);
580 + rt2x00usb_register_write(rt2x00dev, BKOFF_SLOT_CFG, reg);
582 + rt2x00usb_register_read(rt2x00dev, XIFS_TIME_CFG, ®);
583 + rt2x00_set_field32(®, XIFS_TIME_CFG_CCKM_SIFS_TIME, erp->sifs);
584 + rt2x00_set_field32(®, XIFS_TIME_CFG_OFDM_SIFS_TIME, erp->sifs);
585 + rt2x00_set_field32(®, XIFS_TIME_CFG_OFDM_XIFS_TIME, 4);
586 + rt2x00_set_field32(®, XIFS_TIME_CFG_EIFS, erp->eifs);
587 + rt2x00_set_field32(®, XIFS_TIME_CFG_BB_RXEND_ENABLE, 1);
588 + rt2x00usb_register_write(rt2x00dev, XIFS_TIME_CFG, reg);
591 +static void rt2800usb_config_ant(struct rt2x00_dev *rt2x00dev,
592 + struct antenna_setup *ant)
599 + * FIXME: Use requested antenna configuration.
602 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
604 + rt2800usb_bbp_read(rt2x00dev, 1, &r1);
605 + rt2800usb_bbp_read(rt2x00dev, 3, &r3);
608 + * Configure the TX antenna.
610 + switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH)) {
612 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
621 + * Configure the RX antenna.
623 + switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
625 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
628 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 1);
631 + rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 2);
635 + rt2800usb_bbp_write(rt2x00dev, 3, r3);
636 + rt2800usb_bbp_write(rt2x00dev, 1, r1);
639 +static void rt2800usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
640 + struct rt2x00lib_conf *libconf)
645 + if (libconf->rf.channel <= 14) {
646 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
647 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_BG);
648 + } else if (libconf->rf.channel <= 64) {
649 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &eeprom);
650 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_LNA_A0);
651 + } else if (libconf->rf.channel <= 128) {
652 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &eeprom);
653 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_BG2_LNA_A1);
655 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &eeprom);
656 + lna_gain = rt2x00_get_field16(eeprom, EEPROM_RSSI_A2_LNA_A2);
659 + rt2x00dev->lna_gain = lna_gain;
662 +static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
663 + struct rf_channel *rf,
664 + struct channel_info *info)
667 + unsigned int tx_pin;
671 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
672 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
673 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
674 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
675 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
676 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
677 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
679 + rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
682 + * Determine antenna settings from EEPROM
684 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
685 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) {
686 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
687 + /* Turn off unused PA or LNA when only 1T or 1R */
688 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 0);
689 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 0);
692 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) {
693 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1);
694 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
695 + /* Turn off unused PA or LNA when only 1T or 1R */
696 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 0);
697 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 0);
698 + } else if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 2)
699 + rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
701 + if (rf->channel > 14) {
703 + * When TX power is below 0, we should increase it by 7 to
704 + * make it a positive value (Minumum value is -7).
705 + * However this means that values between 0 and 7 have
706 + * double meaning, and we should set a 7DBm boost flag.
708 + rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST,
709 + (info->tx_power1 >= 0));
711 + if (info->tx_power1 < 0)
712 + info->tx_power1 += 7;
714 + rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A,
715 + TXPOWER_A_TO_DEV(info->tx_power1));
717 + rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST,
718 + (info->tx_power2 >= 0));
720 + if (info->tx_power2 < 0)
721 + info->tx_power2 += 7;
723 + rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A,
724 + TXPOWER_A_TO_DEV(info->tx_power2));
726 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, 1);
728 + rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G,
729 + TXPOWER_G_TO_DEV(info->tx_power1));
730 + rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G,
731 + TXPOWER_G_TO_DEV(info->tx_power2));
733 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
736 + rt2x00_set_field32(&rf->rf4, RF4_BW40,
737 + test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags));
739 + rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
740 + rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
741 + rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
742 + rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
746 + rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
747 + rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
748 + rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004);
749 + rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
753 + rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
754 + rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
755 + rt2800usb_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004);
756 + rt2800usb_rf_write(rt2x00dev, 4, rf->rf4);
759 + * Change BBP settings
761 + rt2800usb_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
762 + rt2800usb_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
763 + rt2800usb_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
764 + rt2800usb_bbp_write(rt2x00dev, 86, 0);
766 + if (rf->channel <= 14) {
767 + if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags)) {
768 + rt2800usb_bbp_write(rt2x00dev, 82, 0x62);
769 + rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
771 + rt2800usb_bbp_write(rt2x00dev, 82, 0x84);
772 + rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
775 + rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
776 + rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 0);
777 + rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 1);
778 + rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
780 + rt2800usb_bbp_write(rt2x00dev, 82, 0xf2);
782 + if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
783 + rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
785 + rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
787 + rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
788 + rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 1);
789 + rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 0);
790 + rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
793 + rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
798 +static void rt2800usb_config_txpower(struct rt2x00_dev *rt2x00dev,
802 + u32 value = TXPOWER_G_TO_DEV(txpower);
805 + rt2800usb_bbp_read(rt2x00dev, 1, &r1);
806 + rt2x00_set_field8(®, BBP1_TX_POWER, 0);
807 + rt2800usb_bbp_write(rt2x00dev, 1, r1);
809 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_0, ®);
810 + rt2x00_set_field32(®, TX_PWR_CFG_0_1MBS, value);
811 + rt2x00_set_field32(®, TX_PWR_CFG_0_2MBS, value);
812 + rt2x00_set_field32(®, TX_PWR_CFG_0_55MBS, value);
813 + rt2x00_set_field32(®, TX_PWR_CFG_0_11MBS, value);
814 + rt2x00_set_field32(®, TX_PWR_CFG_0_6MBS, value);
815 + rt2x00_set_field32(®, TX_PWR_CFG_0_9MBS, value);
816 + rt2x00_set_field32(®, TX_PWR_CFG_0_12MBS, value);
817 + rt2x00_set_field32(®, TX_PWR_CFG_0_18MBS, value);
818 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_0, reg);
820 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_1, ®);
821 + rt2x00_set_field32(®, TX_PWR_CFG_1_24MBS, value);
822 + rt2x00_set_field32(®, TX_PWR_CFG_1_36MBS, value);
823 + rt2x00_set_field32(®, TX_PWR_CFG_1_48MBS, value);
824 + rt2x00_set_field32(®, TX_PWR_CFG_1_54MBS, value);
825 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS0, value);
826 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS1, value);
827 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS2, value);
828 + rt2x00_set_field32(®, TX_PWR_CFG_1_MCS3, value);
829 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_1, reg);
831 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_2, ®);
832 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS4, value);
833 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS5, value);
834 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS6, value);
835 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS7, value);
836 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS8, value);
837 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS9, value);
838 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS10, value);
839 + rt2x00_set_field32(®, TX_PWR_CFG_2_MCS11, value);
840 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_2, reg);
842 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_3, ®);
843 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS12, value);
844 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS13, value);
845 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS14, value);
846 + rt2x00_set_field32(®, TX_PWR_CFG_3_MCS15, value);
847 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN1, value);
848 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN2, value);
849 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN3, value);
850 + rt2x00_set_field32(®, TX_PWR_CFG_3_UKNOWN4, value);
851 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_3, reg);
853 + rt2x00usb_register_read(rt2x00dev, TX_PWR_CFG_4, ®);
854 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN5, value);
855 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN6, value);
856 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN7, value);
857 + rt2x00_set_field32(®, TX_PWR_CFG_4_UKNOWN8, value);
858 + rt2x00usb_register_write(rt2x00dev, TX_PWR_CFG_4, reg);
861 +static void rt2800usb_config_retry_limit(struct rt2x00_dev *rt2x00dev,
862 + struct rt2x00lib_conf *libconf)
866 + rt2x00usb_register_read(rt2x00dev, TX_RTY_CFG, ®);
867 + rt2x00_set_field32(®, TX_RTY_CFG_SHORT_RTY_LIMIT,
868 + libconf->conf->short_frame_max_tx_count);
869 + rt2x00_set_field32(®, TX_RTY_CFG_LONG_RTY_LIMIT,
870 + libconf->conf->long_frame_max_tx_count);
871 + rt2x00_set_field32(®, TX_RTY_CFG_LONG_RTY_THRE, 2000);
872 + rt2x00_set_field32(®, TX_RTY_CFG_NON_AGG_RTY_MODE, 0);
873 + rt2x00_set_field32(®, TX_RTY_CFG_AGG_RTY_MODE, 0);
874 + rt2x00_set_field32(®, TX_RTY_CFG_TX_AUTO_FB_ENABLE, 1);
875 + rt2x00usb_register_write(rt2x00dev, TX_RTY_CFG, reg);
878 +static void rt2800usb_config_duration(struct rt2x00_dev *rt2x00dev,
879 + struct rt2x00lib_conf *libconf)
883 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
884 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL,
885 + libconf->conf->beacon_int * 16);
886 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
889 +static void rt2800usb_config(struct rt2x00_dev *rt2x00dev,
890 + struct rt2x00lib_conf *libconf,
891 + const unsigned int flags)
893 + /* Always recalculate LNA gain before changing configuration */
894 + rt2800usb_config_lna_gain(rt2x00dev, libconf);
896 + if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
897 + rt2800usb_config_channel(rt2x00dev, &libconf->rf,
898 + &libconf->channel);
899 + if (flags & IEEE80211_CONF_CHANGE_POWER)
900 + rt2800usb_config_txpower(rt2x00dev, libconf->conf->power_level);
901 + if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
902 + rt2800usb_config_retry_limit(rt2x00dev, libconf);
903 + if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
904 + rt2800usb_config_duration(rt2x00dev, libconf);
910 +static void rt2800usb_link_stats(struct rt2x00_dev *rt2x00dev,
911 + struct link_qual *qual)
916 + * Update FCS error count from register.
918 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT0, ®);
919 + qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR);
922 + * Update False CCA count from register.
924 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT1, ®);
925 + qual->false_cca = rt2x00_get_field32(reg, RX_STA_CNT1_FALSE_CCA);
928 +static u8 rt2800usb_get_default_vgc(struct rt2x00_dev *rt2x00dev)
930 + if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ)
931 + return 0x2e + rt2x00dev->lna_gain;
933 + if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags))
934 + return 0x32 + (rt2x00dev->lna_gain * 5) / 3;
936 + return 0x3a + (rt2x00dev->lna_gain * 5) / 3;
939 +static inline void rt2800usb_set_vgc(struct rt2x00_dev *rt2x00dev,
940 + struct link_qual *qual, u8 vgc_level)
942 + if (qual->vgc_level != vgc_level) {
943 + rt2800usb_bbp_write(rt2x00dev, 66, vgc_level);
944 + qual->vgc_level = vgc_level;
945 + qual->vgc_level_reg = vgc_level;
949 +static void rt2800usb_reset_tuner(struct rt2x00_dev *rt2x00dev,
950 + struct link_qual *qual)
952 + rt2800usb_set_vgc(rt2x00dev, qual,
953 + rt2800usb_get_default_vgc(rt2x00dev));
956 +static void rt2800usb_link_tuner(struct rt2x00_dev *rt2x00dev,
957 + struct link_qual *qual, const u32 count)
959 + if (rt2x00_rev(&rt2x00dev->chip) == RT2870_VERSION_C)
963 + * When RSSI is better then -80 increase VGC level with 0x10
965 + rt2800usb_set_vgc(rt2x00dev, qual,
966 + rt2800usb_get_default_vgc(rt2x00dev) +
967 + ((qual->rssi > -80) * 0x10));
971 + * Firmware functions
973 +static char *rt2800usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
975 + return FIRMWARE_RT2870;
978 +static u16 rt2800usb_get_firmware_crc(const void *data, const size_t len)
983 + * Use the crc ccitt algorithm.
984 + * This will return the same value as the legacy driver which
985 + * used bit ordering reversion on the both the firmware bytes
986 + * before input input as well as on the final output.
987 + * Obviously using crc ccitt directly is much more efficient.
988 + * The last 2 bytes in the firmware array are the crc checksum itself,
989 + * this means that we should never pass those 2 bytes to the crc
992 + crc = crc_ccitt(~0, data, len - 2);
995 + * There is a small difference between the crc-itu-t + bitrev and
996 + * the crc-ccitt crc calculation. In the latter method the 2 bytes
997 + * will be swapped, use swab16 to convert the crc to the correct
1000 + return swab16(crc);
1003 +static int rt2800usb_load_firmware(struct rt2x00_dev *rt2x00dev,
1004 + const void *data, const size_t len)
1011 + * Wait for stable hardware.
1013 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1014 + rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
1015 + if (reg && reg != ~0)
1020 + if (i == REGISTER_BUSY_COUNT) {
1021 + ERROR(rt2x00dev, "Unstable hardware.\n");
1026 + * Write firmware to device.
1028 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
1029 + USB_VENDOR_REQUEST_OUT,
1030 + FIRMWARE_IMAGE_BASE,
1032 + REGISTER_TIMEOUT32(len));
1034 + rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
1035 + rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);
1038 + * Send firmware request to device to load firmware,
1039 + * we need to specify a long timeout time.
1041 + status = rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE,
1042 + 0, USB_MODE_FIRMWARE,
1043 + REGISTER_TIMEOUT_FIRMWARE);
1045 + ERROR(rt2x00dev, "Failed to write Firmware to device.\n");
1050 + * Wait for device to stabilize.
1052 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1053 + rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, ®);
1054 + if (rt2x00_get_field32(reg, PBF_SYS_CTRL_READY))
1059 + if (i == REGISTER_BUSY_COUNT) {
1060 + ERROR(rt2x00dev, "PBF system register not ready.\n");
1065 + * Initialize firmware.
1067 + rt2x00usb_register_write(rt2x00dev, H2M_BBP_AGENT, 0);
1068 + rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0);
1075 + * Initialization functions.
1077 +static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
1083 + * Wait untill BBP and RF are ready.
1085 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1086 + rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
1087 + if (reg && reg != ~0)
1092 + if (i == REGISTER_BUSY_COUNT) {
1093 + ERROR(rt2x00dev, "Unstable hardware.\n");
1097 + rt2x00usb_register_read(rt2x00dev, PBF_SYS_CTRL, ®);
1098 + rt2x00usb_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
1100 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1101 + rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1);
1102 + rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1);
1103 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1105 + rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
1107 + rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
1108 + USB_MODE_RESET, REGISTER_TIMEOUT);
1110 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
1112 + rt2x00usb_register_read(rt2x00dev, BCN_OFFSET0, ®);
1113 + rt2x00_set_field32(®, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */
1114 + rt2x00_set_field32(®, BCN_OFFSET0_BCN1, 0xe8); /* 0x3a00 */
1115 + rt2x00_set_field32(®, BCN_OFFSET0_BCN2, 0xf0); /* 0x3c00 */
1116 + rt2x00_set_field32(®, BCN_OFFSET0_BCN3, 0xf8); /* 0x3e00 */
1117 + rt2x00usb_register_write(rt2x00dev, BCN_OFFSET0, reg);
1119 + rt2x00usb_register_read(rt2x00dev, BCN_OFFSET1, ®);
1120 + rt2x00_set_field32(®, BCN_OFFSET1_BCN4, 0xc8); /* 0x3200 */
1121 + rt2x00_set_field32(®, BCN_OFFSET1_BCN5, 0xd0); /* 0x3400 */
1122 + rt2x00_set_field32(®, BCN_OFFSET1_BCN6, 0x77); /* 0x1dc0 */
1123 + rt2x00_set_field32(®, BCN_OFFSET1_BCN7, 0x6f); /* 0x1bc0 */
1124 + rt2x00usb_register_write(rt2x00dev, BCN_OFFSET1, reg);
1126 + rt2x00usb_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f);
1127 + rt2x00usb_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003);
1129 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
1131 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
1132 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL, 0);
1133 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 0);
1134 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, 0);
1135 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 0);
1136 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0);
1137 + rt2x00_set_field32(®, BCN_TIME_CFG_TX_TIME_COMPENSATE, 0);
1138 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1140 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG0, 0x00040a06);
1141 + rt2x00usb_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
1143 + rt2x00usb_register_read(rt2x00dev, TX_LINK_CFG, ®);
1144 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFB_LIFETIME, 32);
1145 + rt2x00_set_field32(®, TX_LINK_CFG_MFB_ENABLE, 0);
1146 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_UMFS_ENABLE, 0);
1147 + rt2x00_set_field32(®, TX_LINK_CFG_TX_MRQ_EN, 0);
1148 + rt2x00_set_field32(®, TX_LINK_CFG_TX_RDG_EN, 0);
1149 + rt2x00_set_field32(®, TX_LINK_CFG_TX_CF_ACK_EN, 1);
1150 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFB, 0);
1151 + rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFS, 0);
1152 + rt2x00usb_register_write(rt2x00dev, TX_LINK_CFG, reg);
1154 + rt2x00usb_register_read(rt2x00dev, TX_TIMEOUT_CFG, ®);
1155 + rt2x00_set_field32(®, TX_TIMEOUT_CFG_MPDU_LIFETIME, 9);
1156 + rt2x00_set_field32(®, TX_TIMEOUT_CFG_TX_OP_TIMEOUT, 10);
1157 + rt2x00usb_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg);
1159 + rt2x00usb_register_read(rt2x00dev, MAX_LEN_CFG, ®);
1160 + rt2x00_set_field32(®, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE);
1161 + rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 1);
1162 + rt2x00_set_field32(®, MAX_LEN_CFG_MIN_PSDU, 0);
1163 + rt2x00_set_field32(®, MAX_LEN_CFG_MIN_MPDU, 0);
1164 + rt2x00usb_register_write(rt2x00dev, MAX_LEN_CFG, reg);
1166 + rt2x00usb_register_write(rt2x00dev, PBF_MAX_PCNT, 0x1f3fbf9f);
1168 + rt2x00usb_register_read(rt2x00dev, AUTO_RSP_CFG, ®);
1169 + rt2x00_set_field32(®, AUTO_RSP_CFG_AUTORESPONDER, 1);
1170 + rt2x00_set_field32(®, AUTO_RSP_CFG_CTS_40_MMODE, 0);
1171 + rt2x00_set_field32(®, AUTO_RSP_CFG_CTS_40_MREF, 0);
1172 + rt2x00_set_field32(®, AUTO_RSP_CFG_DUAL_CTS_EN, 0);
1173 + rt2x00_set_field32(®, AUTO_RSP_CFG_ACK_CTS_PSM_BIT, 0);
1174 + rt2x00usb_register_write(rt2x00dev, AUTO_RSP_CFG, reg);
1176 + rt2x00usb_register_read(rt2x00dev, CCK_PROT_CFG, ®);
1177 + rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_RATE, 3);
1178 + rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_CTRL, 0);
1179 + rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_NAV, 1);
1180 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1181 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1182 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1183 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM40, 0);
1184 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1185 + rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1186 + rt2x00usb_register_write(rt2x00dev, CCK_PROT_CFG, reg);
1188 + rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, ®);
1189 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_RATE, 3);
1190 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL, 0);
1191 + rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_NAV, 1);
1192 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1193 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1194 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1195 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM40, 0);
1196 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1197 + rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1198 + rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
1200 + rt2x00usb_register_read(rt2x00dev, MM20_PROT_CFG, ®);
1201 + rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_RATE, 0x4004);
1202 + rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_CTRL, 0);
1203 + rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_NAV, 1);
1204 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1205 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1206 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1207 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_MM40, 0);
1208 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1209 + rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_GF40, 0);
1210 + rt2x00usb_register_write(rt2x00dev, MM20_PROT_CFG, reg);
1212 + rt2x00usb_register_read(rt2x00dev, MM40_PROT_CFG, ®);
1213 + rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_RATE, 0x4084);
1214 + rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_CTRL, 0);
1215 + rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_NAV, 1);
1216 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1217 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1218 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1219 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_MM40, 1);
1220 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1221 + rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1222 + rt2x00usb_register_write(rt2x00dev, MM40_PROT_CFG, reg);
1224 + rt2x00usb_register_read(rt2x00dev, GF20_PROT_CFG, ®);
1225 + rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_RATE, 0x4004);
1226 + rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_CTRL, 0);
1227 + rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_NAV, 1);
1228 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1229 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1230 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1231 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_MM40, 0);
1232 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1233 + rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_GF40, 0);
1234 + rt2x00usb_register_write(rt2x00dev, GF20_PROT_CFG, reg);
1236 + rt2x00usb_register_read(rt2x00dev, GF40_PROT_CFG, ®);
1237 + rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_RATE, 0x4084);
1238 + rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_CTRL, 0);
1239 + rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_NAV, 1);
1240 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_CCK, 1);
1241 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_OFDM, 1);
1242 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_MM20, 1);
1243 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_MM40, 1);
1244 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_GF20, 1);
1245 + rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_GF40, 1);
1246 + rt2x00usb_register_write(rt2x00dev, GF40_PROT_CFG, reg);
1248 + rt2x00usb_register_write(rt2x00dev, PBF_CFG, 0xf40006);
1250 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1251 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
1252 + rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_DMA_BUSY, 0);
1253 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
1254 + rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_DMA_BUSY, 0);
1255 + rt2x00_set_field32(®, WPDMA_GLO_CFG_WP_DMA_BURST_SIZE, 3);
1256 + rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 0);
1257 + rt2x00_set_field32(®, WPDMA_GLO_CFG_BIG_ENDIAN, 0);
1258 + rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_HDR_SCATTER, 0);
1259 + rt2x00_set_field32(®, WPDMA_GLO_CFG_HDR_SEG_LEN, 0);
1260 + rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
1262 + rt2x00usb_register_write(rt2x00dev, TXOP_CTRL_CFG, 0x0000583f);
1263 + rt2x00usb_register_write(rt2x00dev, TXOP_HLDR_ET, 0x00000002);
1265 + rt2x00usb_register_read(rt2x00dev, TX_RTS_CFG, ®);
1266 + rt2x00_set_field32(®, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 32);
1267 + rt2x00_set_field32(®, TX_RTS_CFG_RTS_FBK_EN, 0);
1268 + rt2x00usb_register_write(rt2x00dev, TX_RTS_CFG, reg);
1270 + rt2x00usb_register_write(rt2x00dev, EXP_ACK_TIME, 0x002400ca);
1271 + rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
1274 + * ASIC will keep garbage value after boot, clear encryption keys.
1276 + for (i = 0; i < 254; i++) {
1277 + u32 wcid[2] = { 0xffffffff, 0x0000ffff };
1278 + rt2x00usb_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
1279 + wcid, sizeof(wcid));
1282 + for (i = 0; i < 4; i++)
1283 + rt2x00usb_register_write(rt2x00dev,
1284 + SHARED_KEY_MODE_ENTRY(i), 0);
1286 + for (i = 0; i < 256; i++)
1287 + rt2x00usb_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1);
1290 + * Clear all beacons
1291 + * For the Beacon base registers we only need to clear
1292 + * the first byte since that byte contains the VALID and OWNER
1293 + * bits which (when set to 0) will invalidate the entire beacon.
1295 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE0, 0);
1296 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE1, 0);
1297 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE2, 0);
1298 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE3, 0);
1299 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE4, 0);
1300 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE5, 0);
1301 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE6, 0);
1302 + rt2x00usb_register_write(rt2x00dev, HW_BEACON_BASE7, 0);
1304 + rt2x00usb_register_read(rt2x00dev, USB_CYC_CFG, ®);
1305 + rt2x00_set_field32(®, USB_CYC_CFG_CLOCK_CYCLE, 30);
1306 + rt2x00usb_register_write(rt2x00dev, USB_CYC_CFG, reg);
1308 + rt2x00usb_register_read(rt2x00dev, HT_FBK_CFG0, ®);
1309 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS0FBK, 0);
1310 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS1FBK, 0);
1311 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS2FBK, 1);
1312 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS3FBK, 2);
1313 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS4FBK, 3);
1314 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS5FBK, 4);
1315 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS6FBK, 5);
1316 + rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS7FBK, 6);
1317 + rt2x00usb_register_write(rt2x00dev, HT_FBK_CFG0, reg);
1319 + rt2x00usb_register_read(rt2x00dev, HT_FBK_CFG1, ®);
1320 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS8FBK, 8);
1321 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS9FBK, 8);
1322 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS10FBK, 9);
1323 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS11FBK, 10);
1324 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS12FBK, 11);
1325 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS13FBK, 12);
1326 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS14FBK, 13);
1327 + rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS15FBK, 14);
1328 + rt2x00usb_register_write(rt2x00dev, HT_FBK_CFG1, reg);
1330 + rt2x00usb_register_read(rt2x00dev, LG_FBK_CFG0, ®);
1331 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS0FBK, 8);
1332 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS1FBK, 8);
1333 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS2FBK, 10);
1334 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS3FBK, 11);
1335 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS4FBK, 12);
1336 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS5FBK, 13);
1337 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS6FBK, 14);
1338 + rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS7FBK, 15);
1339 + rt2x00usb_register_write(rt2x00dev, LG_FBK_CFG0, reg);
1341 + rt2x00usb_register_read(rt2x00dev, LG_FBK_CFG1, ®);
1342 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS0FBK, 0);
1343 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS1FBK, 0);
1344 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS2FBK, 1);
1345 + rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS3FBK, 2);
1346 + rt2x00usb_register_write(rt2x00dev, LG_FBK_CFG1, reg);
1349 + * We must clear the error counters.
1350 + * These registers are cleared on read,
1351 + * so we may pass a useless variable to store the value.
1353 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT0, ®);
1354 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT1, ®);
1355 + rt2x00usb_register_read(rt2x00dev, RX_STA_CNT2, ®);
1356 + rt2x00usb_register_read(rt2x00dev, TX_STA_CNT0, ®);
1357 + rt2x00usb_register_read(rt2x00dev, TX_STA_CNT1, ®);
1358 + rt2x00usb_register_read(rt2x00dev, TX_STA_CNT2, ®);
1363 +static int rt2800usb_wait_bbp_rf_ready(struct rt2x00_dev *rt2x00dev)
1368 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1369 + rt2x00usb_register_read(rt2x00dev, MAC_STATUS_CFG, ®);
1370 + if (!rt2x00_get_field32(reg, MAC_STATUS_CFG_BBP_RF_BUSY))
1373 + udelay(REGISTER_BUSY_DELAY);
1376 + ERROR(rt2x00dev, "BBP/RF register access failed, aborting.\n");
1380 +static int rt2800usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
1385 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1386 + rt2800usb_bbp_read(rt2x00dev, 0, &value);
1387 + if ((value != 0xff) && (value != 0x00))
1389 + udelay(REGISTER_BUSY_DELAY);
1392 + ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
1396 +static int rt2800usb_init_bbp(struct rt2x00_dev *rt2x00dev)
1403 + if (unlikely(rt2800usb_wait_bbp_rf_ready(rt2x00dev) ||
1404 + rt2800usb_wait_bbp_ready(rt2x00dev)))
1407 + rt2800usb_bbp_write(rt2x00dev, 65, 0x2c);
1408 + rt2800usb_bbp_write(rt2x00dev, 66, 0x38);
1409 + rt2800usb_bbp_write(rt2x00dev, 69, 0x12);
1410 + rt2800usb_bbp_write(rt2x00dev, 70, 0x0a);
1411 + rt2800usb_bbp_write(rt2x00dev, 73, 0x10);
1412 + rt2800usb_bbp_write(rt2x00dev, 81, 0x37);
1413 + rt2800usb_bbp_write(rt2x00dev, 82, 0x62);
1414 + rt2800usb_bbp_write(rt2x00dev, 83, 0x6a);
1415 + rt2800usb_bbp_write(rt2x00dev, 84, 0x99);
1416 + rt2800usb_bbp_write(rt2x00dev, 86, 0x00);
1417 + rt2800usb_bbp_write(rt2x00dev, 91, 0x04);
1418 + rt2800usb_bbp_write(rt2x00dev, 92, 0x00);
1419 + rt2800usb_bbp_write(rt2x00dev, 105, 0x05);
1421 + if (rt2x00_rev(&rt2x00dev->chip) == RT2870_VERSION_C) {
1422 + rt2800usb_bbp_write(rt2x00dev, 69, 0x16);
1423 + rt2800usb_bbp_write(rt2x00dev, 73, 0x12);
1426 + if (rt2x00_rev(&rt2x00dev->chip) != RT2870_VERSION_D)
1427 + rt2800usb_bbp_write(rt2x00dev, 84, 0x19);
1429 + for (i = 0; i < EEPROM_BBP_SIZE; i++) {
1430 + rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
1432 + if (eeprom != 0xffff && eeprom != 0x0000) {
1433 + reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID);
1434 + value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE);
1435 + rt2800usb_bbp_write(rt2x00dev, reg_id, value);
1443 + * Device state switch handlers.
1445 +static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
1446 + enum dev_state state)
1450 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1451 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX,
1452 + (state == STATE_RADIO_RX_ON) ||
1453 + (state == STATE_RADIO_RX_ON_LINK));
1454 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1457 +static int rt2800usb_wait_wpdma_ready(struct rt2x00_dev *rt2x00dev)
1462 + for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
1463 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1464 + if (!rt2x00_get_field32(reg, WPDMA_GLO_CFG_TX_DMA_BUSY) &&
1465 + !rt2x00_get_field32(reg, WPDMA_GLO_CFG_RX_DMA_BUSY))
1471 + ERROR(rt2x00dev, "WPDMA TX/RX busy, aborting.\n");
1475 +static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1481 + * Initialize all registers.
1483 + if (unlikely(rt2800usb_wait_wpdma_ready(rt2x00dev) ||
1484 + rt2800usb_init_registers(rt2x00dev) ||
1485 + rt2800usb_init_bbp(rt2x00dev)))
1488 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1489 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1);
1490 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1494 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1495 + rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
1496 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1);
1497 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 1);
1498 + rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
1501 + rt2x00usb_register_read(rt2x00dev, USB_DMA_CFG, ®);
1502 + rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0);
1503 + /* Don't use bulk in aggregation when working with USB 1.1 */
1504 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN,
1505 + (rt2x00dev->rx->usb_maxpacket == 512));
1506 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_TIMEOUT, 128);
1507 + /* FIXME: Calculate this value based on Aggregation defines */
1508 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_LIMIT, 21);
1509 + rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_EN, 1);
1510 + rt2x00_set_field32(®, USB_DMA_CFG_TX_BULK_EN, 1);
1511 + rt2x00usb_register_write(rt2x00dev, USB_DMA_CFG, reg);
1513 + rt2x00usb_register_read(rt2x00dev, MAC_SYS_CTRL, ®);
1514 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1);
1515 + rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, 1);
1516 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
1519 + * Initialize LED control
1521 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word);
1522 + rt2800usb_mcu_request(rt2x00dev, MCU_LED_1, 0xff,
1523 + word & 0xff, (word >> 8) & 0xff);
1525 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word);
1526 + rt2800usb_mcu_request(rt2x00dev, MCU_LED_2, 0xff,
1527 + word & 0xff, (word >> 8) & 0xff);
1529 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word);
1530 + rt2800usb_mcu_request(rt2x00dev, MCU_LED_3, 0xff,
1531 + word & 0xff, (word >> 8) & 0xff);
1534 + * Send signal to firmware during boot time.
1536 + rt2800usb_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0xff, 0, 0);
1541 +static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
1545 + rt2x00usb_register_read(rt2x00dev, WPDMA_GLO_CFG, ®);
1546 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
1547 + rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0);
1548 + rt2x00usb_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
1550 + rt2x00usb_register_write(rt2x00dev, MAC_SYS_CTRL, 0);
1551 + rt2x00usb_register_write(rt2x00dev, PWR_PIN_CFG, 0);
1552 + rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, 0);
1554 + /* Wait for DMA, ignore error */
1555 + rt2800usb_wait_wpdma_ready(rt2x00dev);
1557 + rt2x00usb_disable_radio(rt2x00dev);
1560 +static int rt2800usb_set_state(struct rt2x00_dev *rt2x00dev,
1561 + enum dev_state state)
1563 + rt2x00usb_register_write(rt2x00dev, AUTOWAKEUP_CFG, 0);
1565 + if (state == STATE_AWAKE)
1566 + rt2800usb_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
1568 + rt2800usb_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 2);
1573 +static int rt2800usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1574 + enum dev_state state)
1579 + case STATE_RADIO_ON:
1581 + * Before the radio can be enabled, the device first has
1582 + * to be woken up. After that it needs a bit of time
1583 + * to be fully awake and the radio can be enabled.
1585 + rt2800usb_set_state(rt2x00dev, STATE_AWAKE);
1587 + retval = rt2800usb_enable_radio(rt2x00dev);
1589 + case STATE_RADIO_OFF:
1591 + * After the radio has been disablee, the device should
1592 + * be put to sleep for powersaving.
1594 + rt2800usb_disable_radio(rt2x00dev);
1595 + rt2800usb_set_state(rt2x00dev, STATE_SLEEP);
1597 + case STATE_RADIO_RX_ON:
1598 + case STATE_RADIO_RX_ON_LINK:
1599 + case STATE_RADIO_RX_OFF:
1600 + case STATE_RADIO_RX_OFF_LINK:
1601 + rt2800usb_toggle_rx(rt2x00dev, state);
1603 + case STATE_RADIO_IRQ_ON:
1604 + case STATE_RADIO_IRQ_OFF:
1605 + /* No support, but no error either */
1607 + case STATE_DEEP_SLEEP:
1609 + case STATE_STANDBY:
1611 + retval = rt2800usb_set_state(rt2x00dev, state);
1614 + retval = -ENOTSUPP;
1618 + if (unlikely(retval))
1619 + ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
1626 + * TX descriptor initialization
1628 +static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1629 + struct sk_buff *skb,
1630 + struct txentry_desc *txdesc)
1632 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb);
1633 + __le32 *txd = skbdesc->desc;
1634 + __le32 *txwi = txd + TXD_DESC_SIZE;
1638 + * Initialize TX Info descriptor
1640 + rt2x00_desc_read(txwi, 0, &word);
1641 + rt2x00_set_field32(&word, TXWI_W0_FRAG,
1642 + test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags) ||
1643 + test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1644 + rt2x00_set_field32(&word, TXWI_W0_MIMO_PS, 0);
1645 + rt2x00_set_field32(&word, TXWI_W0_CF_ACK, 0);
1646 + rt2x00_set_field32(&word, TXWI_W0_TS,
1647 + test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1648 + rt2x00_set_field32(&word, TXWI_W0_AMPDU,
1649 + test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags));
1650 + rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY, txdesc->mpdu_density);
1651 + rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->ifs);
1652 + rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->mcs);
1653 + rt2x00_set_field32(&word, TXWI_W0_BW,
1654 + test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags));
1655 + rt2x00_set_field32(&word, TXWI_W0_SHORT_GI,
1656 + test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags));
1657 + rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->stbc);
1658 + rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode);
1659 + rt2x00_desc_write(txwi, 0, word);
1661 + rt2x00_desc_read(txwi, 1, &word);
1662 + rt2x00_set_field32(&word, TXWI_W1_ACK,
1663 + test_bit(ENTRY_TXD_ACK, &txdesc->flags));
1664 + rt2x00_set_field32(&word, TXWI_W1_ACK,
1665 + test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1666 + rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->ba_size);
1667 + rt2x00_set_field32(&word, TXWI_W1_WIRELESS_CLI_ID, 0xff);
1668 + rt2x00_set_field32(&word, TXWI_W1_MPDU_TOTAL_BYTE_COUNT, skb->len);
1669 + rt2x00_set_field32(&word, TXWI_W1_PACKETID,
1670 + skbdesc->entry->entry_idx);
1671 + rt2x00_desc_write(txwi, 1, word);
1673 + if (test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags)) {
1674 + _rt2x00_desc_write(txwi, 2, skbdesc->iv[0]);
1675 + _rt2x00_desc_write(txwi, 3, skbdesc->iv[1]);
1679 + * Initialize TX descriptor
1681 + rt2x00_desc_read(txd, 0, &word);
1682 + rt2x00_set_field32(&word, TXD_W0_SD_PTR0, skbdesc->skb_dma);
1683 + rt2x00_desc_write(txd, 0, word);
1685 + rt2x00_desc_read(txd, 1, &word);
1686 + rt2x00_set_field32(&word, TXD_W1_SD_LEN1, skb->len);
1687 + rt2x00_set_field32(&word, TXD_W1_LAST_SEC1, 1);
1688 + rt2x00_set_field32(&word, TXD_W1_BURST,
1689 + test_bit(ENTRY_TXD_BURST, &txdesc->flags));
1690 + rt2x00_set_field32(&word, TXD_W1_SD_LEN0,
1691 + rt2x00dev->hw->extra_tx_headroom);
1692 + rt2x00_set_field32(&word, TXD_W1_LAST_SEC0,
1693 + !test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags));
1694 + rt2x00_set_field32(&word, TXD_W1_DMA_DONE, 0);
1695 + rt2x00_desc_write(txd, 1, word);
1697 + rt2x00_desc_read(txd, 2, &word);
1698 + rt2x00_set_field32(&word, TXD_W2_SD_PTR1,
1699 + skbdesc->skb_dma + rt2x00dev->hw->extra_tx_headroom);
1700 + rt2x00_desc_write(txd, 2, word);
1702 + rt2x00_desc_read(txd, 3, &word);
1703 + rt2x00_set_field32(&word, TXD_W3_WIV, 1);
1704 + rt2x00_set_field32(&word, TXD_W3_QSEL, 2);
1705 + rt2x00_desc_write(txd, 3, word);
1709 + * TX data initialization
1711 +static void rt2800usb_write_beacon(struct queue_entry *entry)
1713 + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1714 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1715 + unsigned int beacon_base;
1719 + * Add the descriptor in front of the skb.
1721 + skb_push(entry->skb, entry->queue->desc_size);
1722 + memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len);
1723 + skbdesc->desc = entry->skb->data;
1726 + * Disable beaconing while we are reloading the beacon data,
1727 + * otherwise we might be sending out invalid data.
1729 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
1730 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 0);
1731 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 0);
1732 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0);
1733 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1736 + * Write entire beacon with descriptor to register.
1738 + beacon_base = HW_BEACON_OFFSET(entry->entry_idx);
1739 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE,
1740 + USB_VENDOR_REQUEST_OUT, beacon_base,
1741 + entry->skb->data, entry->skb->len,
1742 + REGISTER_TIMEOUT32(entry->skb->len));
1745 + * Clean up the beacon skb.
1747 + dev_kfree_skb(entry->skb);
1748 + entry->skb = NULL;
1751 +static int rt2800usb_get_tx_data_len(struct queue_entry *entry)
1756 + * The length _must_ be a multiple of 4,
1757 + * but it must _not_ be a multiple of the USB packet size.
1759 + length = roundup(entry->skb->len, 4);
1760 + length += (4 * !(length % entry->queue->usb_maxpacket));
1765 +static void rt2800usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1766 + const enum data_queue_qid queue)
1770 + if (queue != QID_BEACON) {
1771 + rt2x00usb_kick_tx_queue(rt2x00dev, queue);
1775 + rt2x00usb_register_read(rt2x00dev, BCN_TIME_CFG, ®);
1776 + if (!rt2x00_get_field32(reg, BCN_TIME_CFG_BEACON_GEN)) {
1777 + rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1);
1778 + rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1);
1779 + rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 1);
1780 + rt2x00usb_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1785 + * RX control handlers
1787 +static void rt2800usb_fill_rxdone(struct queue_entry *entry,
1788 + struct rxdone_entry_desc *rxdesc)
1790 + struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1791 + struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1792 + __le32 *rxd = (__le32 *)entry->skb->data;
1793 + __le32 *rxwi = (__le32 *)(entry->skb->data + skbdesc->desc_len);
1801 + * Copy descriptor to the skbdesc->desc buffer, making it safe from
1802 + * moving of frame data in rt2x00usb.
1804 + memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
1805 + rxd = (__le32 *)skbdesc->desc;
1808 + * It is now safe to read the descriptor on all architectures.
1810 + rt2x00_desc_read(rxd, 0, &rxd0);
1811 + rt2x00_desc_read(rxwi, 0, &rxwi0);
1812 + rt2x00_desc_read(rxwi, 1, &rxwi1);
1813 + rt2x00_desc_read(rxwi, 2, &rxwi2);
1814 + rt2x00_desc_read(rxwi, 3, &rxwi3);
1816 + if (rt2x00_get_field32(rxd0, RXD_W0_CRC_ERROR))
1817 + rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC;
1819 + if (test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags)) {
1821 + * Unfortunately we don't know the cipher type used during
1822 + * decryption. This prevents us from correct providing
1823 + * correct statistics through debugfs.
1825 + rxdesc->cipher = CIPHER_NONE;
1826 + rxdesc->cipher_status =
1827 + rt2x00_get_field32(rxd0, RXD_W0_CIPHER_ERROR);
1830 + if (rt2x00_get_field32(rxd0, RXD_W0_DECRYPTED)) {
1832 + * Hardware has stripped IV/EIV data from 802.11 frame during
1833 + * decryption. Unfortunately the descriptor doesn't contain
1834 + * any fields with the EIV/IV data either, so they can't
1835 + * be restored by rt2x00lib.
1837 + rxdesc->flags |= RX_FLAG_IV_STRIPPED;
1839 + if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
1840 + rxdesc->flags |= RX_FLAG_DECRYPTED;
1841 + else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
1842 + rxdesc->flags |= RX_FLAG_MMIC_ERROR;
1845 + if (rt2x00_get_field32(rxd0, RXD_W0_MY_BSS))
1846 + rxdesc->dev_flags |= RXDONE_MY_BSS;
1848 + if (rt2x00_get_field32(rxwi1, RXWI_W1_SHORT_GI))
1849 + rxdesc->flags |= RX_FLAG_SHORT_GI;
1851 + if (rt2x00_get_field32(rxwi1, RXWI_W1_BW))
1852 + rxdesc->flags |= RX_FLAG_40MHZ;
1854 + switch (rt2x00_get_field32(rxwi1, RXWI_W1_PHYMODE)) {
1855 + case RATE_MODE_CCK:
1857 + * Mask of 0x8 bit to remove the short preamble flag.
1860 + (RATE_MODE_CCK << 8) |
1861 + (rt2x00_get_field32(rxwi1, RXWI_W1_MCS) & ~0x8);
1863 + case RATE_MODE_OFDM:
1865 + (RATE_MODE_OFDM << 8) |
1866 + rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
1868 + case RATE_MODE_HT_MIX:
1869 + case RATE_MODE_HT_GREENFIELD:
1870 + rxdesc->signal = rt2x00_get_field32(rxwi1, RXWI_W1_MCS);
1871 + rxdesc->flags |= RX_FLAG_HT;
1876 + (rt2x00_get_field32(rxwi2, RXWI_W2_RSSI0) +
1877 + rt2x00_get_field32(rxwi2, RXWI_W2_RSSI1) +
1878 + rt2x00_get_field32(rxwi2, RXWI_W2_RSSI2)) / 3;
1881 + (rt2x00_get_field32(rxwi3, RXWI_W3_SNR0) +
1882 + rt2x00_get_field32(rxwi3, RXWI_W3_SNR1)) / 2;
1884 + rxdesc->size = rt2x00_get_field32(rxwi0, RXWI_W0_MPDU_TOTAL_BYTE_COUNT);
1887 + * Remove TXWI descriptor from start of buffer.
1889 + skb_pull(entry->skb, TXWI_DESC_SIZE + skbdesc->desc_len);
1890 + skb_trim(entry->skb, rxdesc->size);
1894 + * Device probe functions.
1896 +static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1900 + u8 default_lna_gain;
1902 + rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE);
1905 + * Start validation of the data that has been read.
1907 + mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0);
1908 + if (!is_valid_ether_addr(mac)) {
1909 + DECLARE_MAC_BUF(macbuf);
1911 + random_ether_addr(mac);
1912 + EEPROM(rt2x00dev, "MAC: %s\n", print_mac(macbuf, mac));
1915 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
1916 + if (word == 0xffff) {
1917 + rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2);
1918 + rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1);
1919 + rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820);
1920 + rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word);
1921 + EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word);
1924 + rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word);
1926 + /* NIC configuration must always be 0. */
1928 + rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word);
1929 + EEPROM(rt2x00dev, "NIC: 0x%04x\n", word);
1932 + rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word);
1933 + if ((word & 0x00ff) == 0x00ff) {
1934 + rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0);
1935 + rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE,
1936 + LED_MODE_TXRX_ACTIVITY);
1937 + rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0);
1938 + rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word);
1939 + rt2x00_eeprom_write(rt2x00dev, EEPROM_LED1, 0x5555);
1940 + rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221);
1941 + rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8);
1942 + EEPROM(rt2x00dev, "Freq: 0x%04x\n", word);
1946 + * During the LNA validation we are going to use
1947 + * lna0 as correct value. Note that EEPROM_LNA
1948 + * is never validated.
1950 + rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word);
1951 + default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0);
1953 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word);
1954 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10)
1955 + rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0);
1956 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10)
1957 + rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0);
1958 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word);
1960 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word);
1961 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10)
1962 + rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);
1963 + if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 ||
1964 + rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff)
1965 + rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1,
1966 + default_lna_gain);
1967 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word);
1969 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word);
1970 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10)
1971 + rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0);
1972 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10)
1973 + rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0);
1974 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word);
1976 + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word);
1977 + if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10)
1978 + rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0);
1979 + if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 ||
1980 + rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff)
1981 + rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2,
1982 + default_lna_gain);
1983 + rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word);
1988 +static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1996 + * Read EEPROM word for configuration.
1998 + rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
2001 + * Identify RF chipset.
2003 + value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
2004 + rt2x00usb_register_read(rt2x00dev, MAC_CSR0, ®);
2005 + rev = rt2x00_get_field32(reg, MAC_CSR0_ASIC_REV);
2006 + rt2x00_set_chip(rt2x00dev, RT2870, value, rev);
2009 + * The check for rt2860 is not a typo, some rt2870 hardware
2010 + * identifies itself as rt2860 in the CSR register.
2012 + if ((rt2x00_get_field32(reg, MAC_CSR0_ASIC_VER) != 0x2860) &&
2013 + (rt2x00_get_field32(reg, MAC_CSR0_ASIC_VER) != 0x2870)) {
2014 + ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
2018 + if (!rt2x00_rf(&rt2x00dev->chip, RF2820) &&
2019 + !rt2x00_rf(&rt2x00dev->chip, RF2850) &&
2020 + !rt2x00_rf(&rt2x00dev->chip, RF2720) &&
2021 + !rt2x00_rf(&rt2x00dev->chip, RF2750)) {
2022 + ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
2027 + * Read frequency offset and RF programming sequence.
2029 + rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
2030 + rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
2033 + * Read external LNA informations.
2035 + rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom);
2037 + if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A))
2038 + __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
2039 + if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG))
2040 + __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
2043 + * Detect if this device has an hardware controlled radio.
2045 +#ifdef CONFIG_RT2X00_LIB_RFKILL
2046 + if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO))
2047 + __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
2048 +#endif /* CONFIG_RT2X00_LIB_RFKILL */
2051 + * Store led settings, for correct led behaviour.
2053 +#ifdef CONFIG_RT2X00_LIB_LEDS
2054 + rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
2055 + rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC);
2056 + rt2800usb_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY);
2058 + rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ,
2059 + &rt2x00dev->led_mcu_reg);
2060 +#endif /* CONFIG_RT2X00_LIB_LEDS */
2066 + * RF value list for rt2870
2067 + * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
2069 +static const struct rf_channel rf_vals[] = {
2070 + { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
2071 + { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
2072 + { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
2073 + { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
2074 + { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
2075 + { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
2076 + { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
2077 + { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
2078 + { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
2079 + { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
2080 + { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
2081 + { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
2082 + { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
2083 + { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
2085 + /* 802.11 UNI / HyperLan 2 */
2086 + { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
2087 + { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
2088 + { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
2089 + { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
2090 + { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
2091 + { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
2092 + { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
2093 + { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
2094 + { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
2095 + { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
2096 + { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
2097 + { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
2099 + /* 802.11 HyperLan 2 */
2100 + { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
2101 + { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
2102 + { 104, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed1a3 },
2103 + { 108, 0x18402ecc, 0x184c0a32, 0x18578a55, 0x180ed193 },
2104 + { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
2105 + { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
2106 + { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
2107 + { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
2108 + { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
2109 + { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
2110 + { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
2111 + { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
2112 + { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
2113 + { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
2114 + { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
2115 + { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
2118 + { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
2119 + { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
2120 + { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
2121 + { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
2122 + { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
2123 + { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
2124 + { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
2126 + /* 802.11 Japan */
2127 + { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
2128 + { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
2129 + { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
2130 + { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
2131 + { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
2132 + { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
2133 + { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
2136 +static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2138 + struct hw_mode_spec *spec = &rt2x00dev->spec;
2139 + struct channel_info *info;
2145 + * Initialize all hw fields.
2147 + rt2x00dev->hw->flags =
2148 + IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
2149 + IEEE80211_HW_SIGNAL_DBM;
2150 + rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE + TXINFO_DESC_SIZE;
2152 + SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
2153 + SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
2154 + rt2x00_eeprom_addr(rt2x00dev,
2155 + EEPROM_MAC_ADDR_0));
2158 + * Initialize HT information.
2160 + spec->ht.ht_supported = true;
2162 + IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
2163 + IEEE80211_HT_CAP_GRN_FLD |
2164 + IEEE80211_HT_CAP_SGI_20 |
2165 + IEEE80211_HT_CAP_SGI_40 |
2166 + IEEE80211_HT_CAP_TX_STBC |
2167 + IEEE80211_HT_CAP_RX_STBC |
2168 + IEEE80211_HT_CAP_PSMP_SUPPORT;
2169 + spec->ht.ampdu_factor = 3;
2170 + spec->ht.ampdu_density = 4;
2171 + spec->ht.mcs.rx_mask[0] = 0xff;
2172 + spec->ht.mcs.rx_mask[1] = 0xff;
2173 + spec->ht.mcs.tx_params =
2174 + IEEE80211_HT_MCS_TX_DEFINED;
2177 + * Initialize hw_mode information.
2179 + spec->supported_bands = SUPPORT_BAND_2GHZ;
2180 + spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
2182 + if (rt2x00_rf(&rt2x00dev->chip, RF2820) ||
2183 + rt2x00_rf(&rt2x00dev->chip, RF2720)) {
2184 + spec->num_channels = 14;
2185 + spec->channels = rf_vals;
2186 + } else if (rt2x00_rf(&rt2x00dev->chip, RF2850) ||
2187 + rt2x00_rf(&rt2x00dev->chip, RF2750)) {
2188 + spec->supported_bands |= SUPPORT_BAND_5GHZ;
2189 + spec->num_channels = ARRAY_SIZE(rf_vals);
2190 + spec->channels = rf_vals;
2194 + * Create channel information array
2196 + info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
2200 + spec->channels_info = info;
2202 + tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
2203 + tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
2205 + for (i = 0; i < 14; i++) {
2206 + info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
2207 + info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
2210 + if (spec->num_channels > 14) {
2211 + tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
2212 + tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
2214 + for (i = 14; i < spec->num_channels; i++) {
2215 + info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
2216 + info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
2223 +static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
2228 + * Allocate eeprom data.
2230 + retval = rt2800usb_validate_eeprom(rt2x00dev);
2234 + retval = rt2800usb_init_eeprom(rt2x00dev);
2239 + * Initialize hw specifications.
2241 + retval = rt2800usb_probe_hw_mode(rt2x00dev);
2246 + * This device requires firmware.
2248 + __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
2249 + __set_bit(DRIVER_REQUIRE_SCHEDULED, &rt2x00dev->flags);
2250 + if (!modparam_nohwcrypt)
2251 + __set_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags);
2254 + * Set the rssi offset.
2256 + rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET;
2262 + * IEEE80211 stack callback functions.
2264 +static int rt2800usb_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
2266 + struct rt2x00_dev *rt2x00dev = hw->priv;
2269 + rt2x00usb_register_read(rt2x00dev, TX_RTS_CFG, ®);
2270 + rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES, value);
2271 + rt2x00usb_register_write(rt2x00dev, TX_RTS_CFG, reg);
2273 + rt2x00usb_register_read(rt2x00dev, CCK_PROT_CFG, ®);
2274 + rt2x00_set_field32(®, CCK_PROT_CFG_RTS_TH_EN, 1);
2275 + rt2x00usb_register_write(rt2x00dev, CCK_PROT_CFG, reg);
2277 + rt2x00usb_register_read(rt2x00dev, OFDM_PROT_CFG, ®);
2278 + rt2x00_set_field32(®, OFDM_PROT_CFG_RTS_TH_EN, 1);
2279 + rt2x00usb_register_write(rt2x00dev, OFDM_PROT_CFG, reg);
2281 + rt2x00usb_register_read(rt2x00dev, MM20_PROT_CFG, ®);
2282 + rt2x00_set_field32(®, MM20_PROT_CFG_RTS_TH_EN, 1);
2283 + rt2x00usb_register_write(rt2x00dev, MM20_PROT_CFG, reg);
2285 + rt2x00usb_register_read(rt2x00dev, MM40_PROT_CFG, ®);
2286 + rt2x00_set_field32(®, MM40_PROT_CFG_RTS_TH_EN, 1);
2287 + rt2x00usb_register_write(rt2x00dev, MM40_PROT_CFG, reg);
2289 + rt2x00usb_register_read(rt2x00dev, GF20_PROT_CFG, ®);
2290 + rt2x00_set_field32(®, GF20_PROT_CFG_RTS_TH_EN, 1);
2291 + rt2x00usb_register_write(rt2x00dev, GF20_PROT_CFG, reg);
2293 + rt2x00usb_register_read(rt2x00dev, GF40_PROT_CFG, ®);
2294 + rt2x00_set_field32(®, GF40_PROT_CFG_RTS_TH_EN, 1);
2295 + rt2x00usb_register_write(rt2x00dev, GF40_PROT_CFG, reg);
2300 +static int rt2800usb_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2301 + const struct ieee80211_tx_queue_params *params)
2303 + struct rt2x00_dev *rt2x00dev = hw->priv;
2304 + struct data_queue *queue;
2305 + struct rt2x00_field32 field;
2311 + * First pass the configuration through rt2x00lib, that will
2312 + * update the queue settings and validate the input. After that
2313 + * we are free to update the registers based on the value
2314 + * in the queue parameter.
2316 + retval = rt2x00mac_conf_tx(hw, queue_idx, params);
2320 + queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
2322 + /* Update WMM TXOP register */
2323 + if (queue_idx < 2) {
2324 + field.bit_offset = queue_idx * 16;
2325 + field.bit_mask = 0xffff << field.bit_offset;
2327 + rt2x00usb_register_read(rt2x00dev, WMM_TXOP0_CFG, ®);
2328 + rt2x00_set_field32(®, field, queue->txop);
2329 + rt2x00usb_register_write(rt2x00dev, WMM_TXOP0_CFG, reg);
2330 + } else if (queue_idx < 4) {
2331 + field.bit_offset = (queue_idx - 2) * 16;
2332 + field.bit_mask = 0xffff << field.bit_offset;
2334 + rt2x00usb_register_read(rt2x00dev, WMM_TXOP1_CFG, ®);
2335 + rt2x00_set_field32(®, field, queue->txop);
2336 + rt2x00usb_register_write(rt2x00dev, WMM_TXOP1_CFG, reg);
2339 + /* Update WMM registers */
2340 + field.bit_offset = queue_idx * 4;
2341 + field.bit_mask = 0xf << field.bit_offset;
2343 + rt2x00usb_register_read(rt2x00dev, WMM_AIFSN_CFG, ®);
2344 + rt2x00_set_field32(®, field, queue->aifs);
2345 + rt2x00usb_register_write(rt2x00dev, WMM_AIFSN_CFG, reg);
2347 + rt2x00usb_register_read(rt2x00dev, WMM_CWMIN_CFG, ®);
2348 + rt2x00_set_field32(®, field, queue->cw_min);
2349 + rt2x00usb_register_write(rt2x00dev, WMM_CWMIN_CFG, reg);
2351 + rt2x00usb_register_read(rt2x00dev, WMM_CWMAX_CFG, ®);
2352 + rt2x00_set_field32(®, field, queue->cw_max);
2353 + rt2x00usb_register_write(rt2x00dev, WMM_CWMAX_CFG, reg);
2355 + /* Update EDCA registers */
2356 + if (queue_idx < 4) {
2357 + offset = EDCA_AC0_CFG + (sizeof(u32) * queue_idx);
2359 + rt2x00usb_register_read(rt2x00dev, offset, ®);
2360 + rt2x00_set_field32(®, EDCA_AC0_CFG_AIFSN, queue->aifs);
2361 + rt2x00_set_field32(®, EDCA_AC0_CFG_CWMIN, queue->cw_min);
2362 + rt2x00_set_field32(®, EDCA_AC0_CFG_CWMAX, queue->cw_max);
2363 + rt2x00usb_register_write(rt2x00dev, offset, reg);
2371 + * Mac80211 demands get_tsf must be atomic.
2372 + * This is not possible for rt2800usb since all register access
2373 + * functions require sleeping. Untill mac80211 no longer needs
2374 + * get_tsf to be atomic, this function should be disabled.
2376 +static u64 rt2800usb_get_tsf(struct ieee80211_hw *hw)
2378 + struct rt2x00_dev *rt2x00dev = hw->priv;
2382 + rt2x00usb_register_read(rt2x00dev, TSF_TIMER_DW1, ®);
2383 + tsf = (u64) rt2x00_get_field32(reg, TSF_TIMER_DW1_HIGH_WORD) << 32;
2384 + rt2x00usb_register_read(rt2x00dev, TSF_TIMER_DW0, ®);
2385 + tsf |= rt2x00_get_field32(reg, TSF_TIMER_DW0_LOW_WORD);
2390 +#define rt2800usb_get_tsf NULL
2393 +static const struct ieee80211_ops rt2800usb_mac80211_ops = {
2394 + .tx = rt2x00mac_tx,
2395 + .start = rt2x00mac_start,
2396 + .stop = rt2x00mac_stop,
2397 + .add_interface = rt2x00mac_add_interface,
2398 + .remove_interface = rt2x00mac_remove_interface,
2399 + .config = rt2x00mac_config,
2400 + .config_interface = rt2x00mac_config_interface,
2401 + .configure_filter = rt2x00mac_configure_filter,
2402 + .set_key = rt2x00mac_set_key,
2403 + .get_stats = rt2x00mac_get_stats,
2404 + .set_rts_threshold = rt2800usb_set_rts_threshold,
2405 + .bss_info_changed = rt2x00mac_bss_info_changed,
2406 + .conf_tx = rt2800usb_conf_tx,
2407 + .get_tx_stats = rt2x00mac_get_tx_stats,
2408 + .get_tsf = rt2800usb_get_tsf,
2411 +static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
2412 + .probe_hw = rt2800usb_probe_hw,
2413 + .get_firmware_name = rt2800usb_get_firmware_name,
2414 + .get_firmware_crc = rt2800usb_get_firmware_crc,
2415 + .load_firmware = rt2800usb_load_firmware,
2416 + .initialize = rt2x00usb_initialize,
2417 + .uninitialize = rt2x00usb_uninitialize,
2418 + .clear_entry = rt2x00usb_clear_entry,
2419 + .set_device_state = rt2800usb_set_device_state,
2420 + .rfkill_poll = rt2800usb_rfkill_poll,
2421 + .link_stats = rt2800usb_link_stats,
2422 + .reset_tuner = rt2800usb_reset_tuner,
2423 + .link_tuner = rt2800usb_link_tuner,
2424 + .write_tx_desc = rt2800usb_write_tx_desc,
2425 + .write_tx_data = rt2x00usb_write_tx_data,
2426 + .write_beacon = rt2800usb_write_beacon,
2427 + .get_tx_data_len = rt2800usb_get_tx_data_len,
2428 + .kick_tx_queue = rt2800usb_kick_tx_queue,
2429 + .fill_rxdone = rt2800usb_fill_rxdone,
2430 + .config_shared_key = rt2800usb_config_shared_key,
2431 + .config_pairwise_key = rt2800usb_config_pairwise_key,
2432 + .config_filter = rt2800usb_config_filter,
2433 + .config_intf = rt2800usb_config_intf,
2434 + .config_erp = rt2800usb_config_erp,
2435 + .config_ant = rt2800usb_config_ant,
2436 + .config = rt2800usb_config,
2439 +static const struct data_queue_desc rt2800usb_queue_rx = {
2440 + .entry_num = RX_ENTRIES,
2441 + .data_size = DATA_FRAME_SIZE,
2442 + .desc_size = RXD_DESC_SIZE,
2443 + .priv_size = sizeof(struct queue_entry_priv_usb),
2446 +static const struct data_queue_desc rt2800usb_queue_tx = {
2447 + .entry_num = TX_ENTRIES,
2448 + .data_size = DATA_FRAME_SIZE,
2449 + .desc_size = TXD_DESC_SIZE,
2450 + .priv_size = sizeof(struct queue_entry_priv_usb),
2453 +static const struct data_queue_desc rt2800usb_queue_bcn = {
2454 + .entry_num = 8 * BEACON_ENTRIES,
2455 + .data_size = MGMT_FRAME_SIZE,
2456 + .desc_size = TXWI_DESC_SIZE,
2457 + .priv_size = sizeof(struct queue_entry_priv_usb),
2460 +static const struct rt2x00_ops rt2800usb_ops = {
2461 + .name = KBUILD_MODNAME,
2462 + .max_sta_intf = 1,
2464 + .eeprom_size = EEPROM_SIZE,
2465 + .rf_size = RF_SIZE,
2466 + .tx_queues = NUM_TX_QUEUES,
2467 + .rx = &rt2800usb_queue_rx,
2468 + .tx = &rt2800usb_queue_tx,
2469 + .bcn = &rt2800usb_queue_bcn,
2470 + .lib = &rt2800usb_rt2x00_ops,
2471 + .hw = &rt2800usb_mac80211_ops,
2472 +#ifdef CONFIG_RT2X00_LIB_DEBUGFS
2473 + .debugfs = &rt2800usb_rt2x00debug,
2474 +#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
2478 + * rt2800usb module information.
2480 +static struct usb_device_id rt2800usb_device_table[] = {
2482 + { USB_DEVICE(0x15c5, 0x0008), USB_DEVICE_DATA(&rt2800usb_ops) },
2484 + { USB_DEVICE(0x0b05, 0x1731), USB_DEVICE_DATA(&rt2800usb_ops) },
2485 + { USB_DEVICE(0x0b05, 0x1732), USB_DEVICE_DATA(&rt2800usb_ops) },
2486 + { USB_DEVICE(0x0b05, 0x1742), USB_DEVICE_DATA(&rt2800usb_ops) },
2488 + { USB_DEVICE(0x13d3, 0x3247), USB_DEVICE_DATA(&rt2800usb_ops) },
2490 + { USB_DEVICE(0x050d, 0x8053), USB_DEVICE_DATA(&rt2800usb_ops) },
2491 + /* Conceptronic */
2492 + { USB_DEVICE(0x14b2, 0x3c06), USB_DEVICE_DATA(&rt2800usb_ops) },
2493 + { USB_DEVICE(0x14b2, 0x3c07), USB_DEVICE_DATA(&rt2800usb_ops) },
2494 + { USB_DEVICE(0x14b2, 0x3c23), USB_DEVICE_DATA(&rt2800usb_ops) },
2495 + { USB_DEVICE(0x14b2, 0x3c25), USB_DEVICE_DATA(&rt2800usb_ops) },
2496 + { USB_DEVICE(0x14b2, 0x3c27), USB_DEVICE_DATA(&rt2800usb_ops) },
2497 + { USB_DEVICE(0x14b2, 0x3c28), USB_DEVICE_DATA(&rt2800usb_ops) },
2499 + { USB_DEVICE(0x07aa, 0x002f), USB_DEVICE_DATA(&rt2800usb_ops) },
2500 + { USB_DEVICE(0x07aa, 0x003c), USB_DEVICE_DATA(&rt2800usb_ops) },
2501 + { USB_DEVICE(0x07aa, 0x003f), USB_DEVICE_DATA(&rt2800usb_ops) },
2503 + { USB_DEVICE(0x07d1, 0x3c09), USB_DEVICE_DATA(&rt2800usb_ops) },
2504 + { USB_DEVICE(0x07d1, 0x3c11), USB_DEVICE_DATA(&rt2800usb_ops) },
2506 + { USB_DEVICE(0X1740, 0x9701), USB_DEVICE_DATA(&rt2800usb_ops) },
2507 + { USB_DEVICE(0x1740, 0x9702), USB_DEVICE_DATA(&rt2800usb_ops) },
2509 + { USB_DEVICE(0x1044, 0x800b), USB_DEVICE_DATA(&rt2800usb_ops) },
2511 + { USB_DEVICE(0x0e66, 0x0001), USB_DEVICE_DATA(&rt2800usb_ops) },
2512 + { USB_DEVICE(0x0e66, 0x0003), USB_DEVICE_DATA(&rt2800usb_ops) },
2514 + { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) },
2516 + { USB_DEVICE(0x0471, 0x200f), USB_DEVICE_DATA(&rt2800usb_ops) },
2518 + { USB_DEVICE(0x2019, 0xed06), USB_DEVICE_DATA(&rt2800usb_ops) },
2520 + { USB_DEVICE(0x148f, 0x2770), USB_DEVICE_DATA(&rt2800usb_ops) },
2521 + { USB_DEVICE(0x148f, 0x2870), USB_DEVICE_DATA(&rt2800usb_ops) },
2523 + { USB_DEVICE(0x129b, 0x1828), USB_DEVICE_DATA(&rt2800usb_ops) },
2525 + { USB_DEVICE(0x0df6, 0x0017), USB_DEVICE_DATA(&rt2800usb_ops) },
2526 + { USB_DEVICE(0x0df6, 0x002b), USB_DEVICE_DATA(&rt2800usb_ops) },
2527 + { USB_DEVICE(0x0df6, 0x002c), USB_DEVICE_DATA(&rt2800usb_ops) },
2528 + { USB_DEVICE(0x0df6, 0x002d), USB_DEVICE_DATA(&rt2800usb_ops) },
2530 + { USB_DEVICE(0x083a, 0x6618), USB_DEVICE_DATA(&rt2800usb_ops) },
2531 + { USB_DEVICE(0x083a, 0x7522), USB_DEVICE_DATA(&rt2800usb_ops) },
2532 + { USB_DEVICE(0x083a, 0xb522), USB_DEVICE_DATA(&rt2800usb_ops) },
2533 + { USB_DEVICE(0x083a, 0xa618), USB_DEVICE_DATA(&rt2800usb_ops) },
2535 + { USB_DEVICE(0x15a9, 0x0006), USB_DEVICE_DATA(&rt2800usb_ops) },
2537 + { USB_DEVICE(0x157e, 0x300e), USB_DEVICE_DATA(&rt2800usb_ops) },
2539 + { USB_DEVICE(0x0cde, 0x0022), USB_DEVICE_DATA(&rt2800usb_ops) },
2540 + { USB_DEVICE(0x0cde, 0x0025), USB_DEVICE_DATA(&rt2800usb_ops) },
2542 + { USB_DEVICE(0x0586, 0x3416), USB_DEVICE_DATA(&rt2800usb_ops) },
2546 +MODULE_AUTHOR(DRV_PROJECT);
2547 +MODULE_VERSION(DRV_VERSION);
2548 +MODULE_DESCRIPTION("Ralink RT2800 USB Wireless LAN driver.");
2549 +MODULE_SUPPORTED_DEVICE("Ralink RT2870 USB chipset based cards");
2550 +MODULE_DEVICE_TABLE(usb, rt2800usb_device_table);
2551 +MODULE_FIRMWARE(FIRMWARE_RT2870);
2552 +MODULE_LICENSE("GPL");
2554 +static struct usb_driver rt2800usb_driver = {
2555 + .name = KBUILD_MODNAME,
2556 + .id_table = rt2800usb_device_table,
2557 + .probe = rt2x00usb_probe,
2558 + .disconnect = rt2x00usb_disconnect,
2559 + .suspend = rt2x00usb_suspend,
2560 + .resume = rt2x00usb_resume,
2563 +static int __init rt2800usb_init(void)
2565 + return usb_register(&rt2800usb_driver);
2568 +static void __exit rt2800usb_exit(void)
2570 + usb_deregister(&rt2800usb_driver);
2573 +module_init(rt2800usb_init);
2574 +module_exit(rt2800usb_exit);
2576 +++ b/drivers/net/wireless/rt2x00/rt2800usb.h
2579 + Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
2580 + <http://rt2x00.serialmonkey.com>
2582 + This program is free software; you can redistribute it and/or modify
2583 + it under the terms of the GNU General Public License as published by
2584 + the Free Software Foundation; either version 2 of the License, or
2585 + (at your option) any later version.
2587 + This program is distributed in the hope that it will be useful,
2588 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2589 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2590 + GNU General Public License for more details.
2592 + You should have received a copy of the GNU General Public License
2593 + along with this program; if not, write to the
2594 + Free Software Foundation, Inc.,
2595 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2600 + Abstract: Data structures and registers for the rt2800usb module.
2601 + Supported chipsets: RT2800U.
2604 +#ifndef RT2800USB_H
2605 +#define RT2800USB_H
2608 + * RF chip defines.
2610 + * RF2820 2.4G 2T3R
2611 + * RF2850 2.4G/5G 2T3R
2612 + * RF2720 2.4G 1T2R
2613 + * RF2750 2.4G/5G 1T2R
2614 + * RF3020 2.4G 1T1R
2617 +#define RF2820 0x0001
2618 +#define RF2850 0x0002
2619 +#define RF2720 0x0003
2620 +#define RF2750 0x0004
2621 +#define RF3020 0x0005
2622 +#define RF2020 0x0006
2627 +#define RT2870_VERSION_C 0x0100
2628 +#define RT2870_VERSION_D 0x0101
2629 +#define RT2870_VERSION_E 0x0200
2632 + * Signal information.
2633 + * Defaul offset is required for RSSI <-> dBm conversion.
2635 +#define DEFAULT_RSSI_OFFSET 120 /* FIXME */
2638 + * Register layout information.
2640 +#define CSR_REG_BASE 0x1000
2641 +#define CSR_REG_SIZE 0x0800
2642 +#define EEPROM_BASE 0x0000
2643 +#define EEPROM_SIZE 0x0110
2644 +#define BBP_BASE 0x0000
2645 +#define BBP_SIZE 0x0080
2646 +#define RF_BASE 0x0000
2647 +#define RF_SIZE 0x0014
2650 + * Number of TX queues.
2652 +#define NUM_TX_QUEUES 4
2659 + * HOST-MCU shared memory
2661 +#define HOST_CMD_CSR 0x0404
2662 +#define HOST_CMD_CSR_HOST_COMMAND FIELD32(0x000000ff)
2665 + * INT_SOURCE_CSR: Interrupt source register.
2666 + * Write one to clear corresponding bit.
2667 + * TX_FIFO_STATUS: FIFO Statistics is full, sw should read 0x171c
2669 +#define INT_SOURCE_CSR 0x0200
2670 +#define INT_SOURCE_CSR_RXDELAYINT FIELD32(0x00000001)
2671 +#define INT_SOURCE_CSR_TXDELAYINT FIELD32(0x00000002)
2672 +#define INT_SOURCE_CSR_RX_DONE FIELD32(0x00000004)
2673 +#define INT_SOURCE_CSR_AC0_DMA_DONE FIELD32(0x00000008)
2674 +#define INT_SOURCE_CSR_AC1_DMA_DONE FIELD32(0x00000010)
2675 +#define INT_SOURCE_CSR_AC2_DMA_DONE FIELD32(0x00000020)
2676 +#define INT_SOURCE_CSR_AC3_DMA_DONE FIELD32(0x00000040)
2677 +#define INT_SOURCE_CSR_HCCA_DMA_DONE FIELD32(0x00000080)
2678 +#define INT_SOURCE_CSR_MGMT_DMA_DONE FIELD32(0x00000100)
2679 +#define INT_SOURCE_CSR_MCU_COMMAND FIELD32(0x00000200)
2680 +#define INT_SOURCE_CSR_RXTX_COHERENT FIELD32(0x00000400)
2681 +#define INT_SOURCE_CSR_TBTT FIELD32(0x00000800)
2682 +#define INT_SOURCE_CSR_PRE_TBTT FIELD32(0x00001000)
2683 +#define INT_SOURCE_CSR_TX_FIFO_STATUS FIELD32(0x00002000)
2684 +#define INT_SOURCE_CSR_AUTO_WAKEUP FIELD32(0x00004000)
2685 +#define INT_SOURCE_CSR_GPTIMER FIELD32(0x00008000)
2686 +#define INT_SOURCE_CSR_RX_COHERENT FIELD32(0x00010000)
2687 +#define INT_SOURCE_CSR_TX_COHERENT FIELD32(0x00020000)
2690 + * INT_MASK_CSR: Interrupt MASK register. 1: the interrupt is mask OFF.
2692 +#define INT_MASK_CSR 0x0204
2693 +#define INT_MASK_CSR_RXDELAYINT FIELD32(0x00000001)
2694 +#define INT_MASK_CSR_TXDELAYINT FIELD32(0x00000002)
2695 +#define INT_MASK_CSR_RX_DONE FIELD32(0x00000004)
2696 +#define INT_MASK_CSR_AC0_DMA_DONE FIELD32(0x00000008)
2697 +#define INT_MASK_CSR_AC1_DMA_DONE FIELD32(0x00000010)
2698 +#define INT_MASK_CSR_AC2_DMA_DONE FIELD32(0x00000020)
2699 +#define INT_MASK_CSR_AC3_DMA_DONE FIELD32(0x00000040)
2700 +#define INT_MASK_CSR_HCCA_DMA_DONE FIELD32(0x00000080)
2701 +#define INT_MASK_CSR_MGMT_DMA_DONE FIELD32(0x00000100)
2702 +#define INT_MASK_CSR_MCU_COMMAND FIELD32(0x00000200)
2703 +#define INT_MASK_CSR_RX_COHERENT FIELD32(0x40000000)
2704 +#define INT_MASK_CSR_TX_COHERENT FIELD32(0x80000000)
2709 +#define WPDMA_GLO_CFG 0x0208
2710 +#define WPDMA_GLO_CFG_ENABLE_TX_DMA FIELD32(0x00000001)
2711 +#define WPDMA_GLO_CFG_TX_DMA_BUSY FIELD32(0x00000002)
2712 +#define WPDMA_GLO_CFG_ENABLE_RX_DMA FIELD32(0x00000004)
2713 +#define WPDMA_GLO_CFG_RX_DMA_BUSY FIELD32(0x00000008)
2714 +#define WPDMA_GLO_CFG_WP_DMA_BURST_SIZE FIELD32(0x00000030)
2715 +#define WPDMA_GLO_CFG_TX_WRITEBACK_DONE FIELD32(0x00000040)
2716 +#define WPDMA_GLO_CFG_BIG_ENDIAN FIELD32(0x00000080)
2717 +#define WPDMA_GLO_CFG_RX_HDR_SCATTER FIELD32(0x0000ff00)
2718 +#define WPDMA_GLO_CFG_HDR_SEG_LEN FIELD32(0xffff0000)
2723 +#define WPDMA_RST_IDX 0x020c
2724 +#define WPDMA_RST_IDX_DTX_IDX0 FIELD32(0x00000001)
2725 +#define WPDMA_RST_IDX_DTX_IDX1 FIELD32(0x00000002)
2726 +#define WPDMA_RST_IDX_DTX_IDX2 FIELD32(0x00000004)
2727 +#define WPDMA_RST_IDX_DTX_IDX3 FIELD32(0x00000008)
2728 +#define WPDMA_RST_IDX_DTX_IDX4 FIELD32(0x00000010)
2729 +#define WPDMA_RST_IDX_DTX_IDX5 FIELD32(0x00000020)
2730 +#define WPDMA_RST_IDX_DRX_IDX0 FIELD32(0x00010000)
2735 +#define DELAY_INT_CFG 0x0210
2736 +#define DELAY_INT_CFG_RXMAX_PTIME FIELD32(0x000000ff)
2737 +#define DELAY_INT_CFG_RXMAX_PINT FIELD32(0x00007f00)
2738 +#define DELAY_INT_CFG_RXDLY_INT_EN FIELD32(0x00008000)
2739 +#define DELAY_INT_CFG_TXMAX_PTIME FIELD32(0x00ff0000)
2740 +#define DELAY_INT_CFG_TXMAX_PINT FIELD32(0x7f000000)
2741 +#define DELAY_INT_CFG_TXDLY_INT_EN FIELD32(0x80000000)
2744 + * WMM_AIFSN_CFG: Aifsn for each EDCA AC
2750 +#define WMM_AIFSN_CFG 0x0214
2751 +#define WMM_AIFSN_CFG_AIFSN0 FIELD32(0x0000000f)
2752 +#define WMM_AIFSN_CFG_AIFSN1 FIELD32(0x000000f0)
2753 +#define WMM_AIFSN_CFG_AIFSN2 FIELD32(0x00000f00)
2754 +#define WMM_AIFSN_CFG_AIFSN3 FIELD32(0x0000f000)
2757 + * WMM_CWMIN_CSR: CWmin for each EDCA AC
2763 +#define WMM_CWMIN_CFG 0x0218
2764 +#define WMM_CWMIN_CFG_CWMIN0 FIELD32(0x0000000f)
2765 +#define WMM_CWMIN_CFG_CWMIN1 FIELD32(0x000000f0)
2766 +#define WMM_CWMIN_CFG_CWMIN2 FIELD32(0x00000f00)
2767 +#define WMM_CWMIN_CFG_CWMIN3 FIELD32(0x0000f000)
2770 + * WMM_CWMAX_CSR: CWmax for each EDCA AC
2776 +#define WMM_CWMAX_CFG 0x021c
2777 +#define WMM_CWMAX_CFG_CWMAX0 FIELD32(0x0000000f)
2778 +#define WMM_CWMAX_CFG_CWMAX1 FIELD32(0x000000f0)
2779 +#define WMM_CWMAX_CFG_CWMAX2 FIELD32(0x00000f00)
2780 +#define WMM_CWMAX_CFG_CWMAX3 FIELD32(0x0000f000)
2783 + * AC_TXOP0: AC_BK/AC_BE TXOP register
2784 + * AC0TXOP: AC_BK in unit of 32us
2785 + * AC1TXOP: AC_BE in unit of 32us
2787 +#define WMM_TXOP0_CFG 0x0220
2788 +#define WMM_TXOP0_CFG_AC0TXOP FIELD32(0x0000ffff)
2789 +#define WMM_TXOP0_CFG_AC1TXOP FIELD32(0xffff0000)
2792 + * AC_TXOP1: AC_VO/AC_VI TXOP register
2793 + * AC2TXOP: AC_VI in unit of 32us
2794 + * AC3TXOP: AC_VO in unit of 32us
2796 +#define WMM_TXOP1_CFG 0x0224
2797 +#define WMM_TXOP1_CFG_AC2TXOP FIELD32(0x0000ffff)
2798 +#define WMM_TXOP1_CFG_AC3TXOP FIELD32(0xffff0000)
2803 +#define RINGREG_DIFF 0x0010
2808 +#define GPIO_CTRL_CFG 0x0228
2809 +#define GPIO_CTRL_CFG_BIT0 FIELD32(0x00000001)
2810 +#define GPIO_CTRL_CFG_BIT1 FIELD32(0x00000002)
2811 +#define GPIO_CTRL_CFG_BIT2 FIELD32(0x00000004)
2812 +#define GPIO_CTRL_CFG_BIT3 FIELD32(0x00000008)
2813 +#define GPIO_CTRL_CFG_BIT4 FIELD32(0x00000010)
2814 +#define GPIO_CTRL_CFG_BIT5 FIELD32(0x00000020)
2815 +#define GPIO_CTRL_CFG_BIT6 FIELD32(0x00000040)
2816 +#define GPIO_CTRL_CFG_BIT7 FIELD32(0x00000080)
2817 +#define GPIO_CTRL_CFG_BIT8 FIELD32(0x00000100)
2822 +#define MCU_CMD_CFG 0x022c
2825 + * AC_BK register offsets
2827 +#define TX_BASE_PTR0 0x0230
2828 +#define TX_MAX_CNT0 0x0234
2829 +#define TX_CTX_IDX0 0x0238
2830 +#define TX_DTX_IDX0 0x023c
2833 + * AC_BE register offsets
2835 +#define TX_BASE_PTR1 0x0240
2836 +#define TX_MAX_CNT1 0x0244
2837 +#define TX_CTX_IDX1 0x0248
2838 +#define TX_DTX_IDX1 0x024c
2841 + * AC_VI register offsets
2843 +#define TX_BASE_PTR2 0x0250
2844 +#define TX_MAX_CNT2 0x0254
2845 +#define TX_CTX_IDX2 0x0258
2846 +#define TX_DTX_IDX2 0x025c
2849 + * AC_VO register offsets
2851 +#define TX_BASE_PTR3 0x0260
2852 +#define TX_MAX_CNT3 0x0264
2853 +#define TX_CTX_IDX3 0x0268
2854 +#define TX_DTX_IDX3 0x026c
2857 + * HCCA register offsets
2859 +#define TX_BASE_PTR4 0x0270
2860 +#define TX_MAX_CNT4 0x0274
2861 +#define TX_CTX_IDX4 0x0278
2862 +#define TX_DTX_IDX4 0x027c
2865 + * MGMT register offsets
2867 +#define TX_BASE_PTR5 0x0280
2868 +#define TX_MAX_CNT5 0x0284
2869 +#define TX_CTX_IDX5 0x0288
2870 +#define TX_DTX_IDX5 0x028c
2873 + * RX register offsets
2875 +#define RX_BASE_PTR 0x0290
2876 +#define RX_MAX_CNT 0x0294
2877 +#define RX_CRX_IDX 0x0298
2878 +#define RX_DRX_IDX 0x029c
2882 + * RX_BULK_AGG_TIMEOUT: Rx Bulk Aggregation TimeOut in unit of 33ns.
2883 + * RX_BULK_AGG_LIMIT: Rx Bulk Aggregation Limit in unit of 256 bytes.
2884 + * PHY_CLEAR: phy watch dog enable.
2885 + * TX_CLEAR: Clear USB DMA TX path.
2886 + * TXOP_HALT: Halt TXOP count down when TX buffer is full.
2887 + * RX_BULK_AGG_EN: Enable Rx Bulk Aggregation.
2888 + * RX_BULK_EN: Enable USB DMA Rx.
2889 + * TX_BULK_EN: Enable USB DMA Tx.
2890 + * EP_OUT_VALID: OUT endpoint data valid.
2891 + * RX_BUSY: USB DMA RX FSM busy.
2892 + * TX_BUSY: USB DMA TX FSM busy.
2894 +#define USB_DMA_CFG 0x02a0
2895 +#define USB_DMA_CFG_RX_BULK_AGG_TIMEOUT FIELD32(0x000000ff)
2896 +#define USB_DMA_CFG_RX_BULK_AGG_LIMIT FIELD32(0x0000ff00)
2897 +#define USB_DMA_CFG_PHY_CLEAR FIELD32(0x00010000)
2898 +#define USB_DMA_CFG_TX_CLEAR FIELD32(0x00080000)
2899 +#define USB_DMA_CFG_TXOP_HALT FIELD32(0x00100000)
2900 +#define USB_DMA_CFG_RX_BULK_AGG_EN FIELD32(0x00200000)
2901 +#define USB_DMA_CFG_RX_BULK_EN FIELD32(0x00400000)
2902 +#define USB_DMA_CFG_TX_BULK_EN FIELD32(0x00800000)
2903 +#define USB_DMA_CFG_EP_OUT_VALID FIELD32(0x3f000000)
2904 +#define USB_DMA_CFG_RX_BUSY FIELD32(0x40000000)
2905 +#define USB_DMA_CFG_TX_BUSY FIELD32(0x80000000)
2910 +#define USB_CYC_CFG 0x02a4
2911 +#define USB_CYC_CFG_CLOCK_CYCLE FIELD32(0x000000ff)
2915 + * HOST_RAM_WRITE: enable Host program ram write selection
2917 +#define PBF_SYS_CTRL 0x0400
2918 +#define PBF_SYS_CTRL_READY FIELD32(0x00000080)
2919 +#define PBF_SYS_CTRL_HOST_RAM_WRITE FIELD32(0x00010000)
2923 + * Most are for debug. Driver doesn't touch PBF register.
2925 +#define PBF_CFG 0x0408
2926 +#define PBF_MAX_PCNT 0x040c
2927 +#define PBF_CTRL 0x0410
2928 +#define PBF_INT_STA 0x0414
2929 +#define PBF_INT_ENA 0x0418
2934 +#define BCN_OFFSET0 0x042c
2935 +#define BCN_OFFSET0_BCN0 FIELD32(0x000000ff)
2936 +#define BCN_OFFSET0_BCN1 FIELD32(0x0000ff00)
2937 +#define BCN_OFFSET0_BCN2 FIELD32(0x00ff0000)
2938 +#define BCN_OFFSET0_BCN3 FIELD32(0xff000000)
2943 +#define BCN_OFFSET1 0x0430
2944 +#define BCN_OFFSET1_BCN4 FIELD32(0x000000ff)
2945 +#define BCN_OFFSET1_BCN5 FIELD32(0x0000ff00)
2946 +#define BCN_OFFSET1_BCN6 FIELD32(0x00ff0000)
2947 +#define BCN_OFFSET1_BCN7 FIELD32(0xff000000)
2951 + * Most are for debug. Driver doesn't touch PBF register.
2953 +#define TXRXQ_PCNT 0x0438
2954 +#define PBF_DBG 0x043c
2957 + * MAC Control/Status Registers(CSR).
2958 + * Some values are set in TU, whereas 1 TU == 1024 us.
2962 + * MAC_CSR0: ASIC revision number.
2966 +#define MAC_CSR0 0x1000
2967 +#define MAC_CSR0_ASIC_REV FIELD32(0x0000ffff)
2968 +#define MAC_CSR0_ASIC_VER FIELD32(0xffff0000)
2973 +#define MAC_SYS_CTRL 0x1004
2974 +#define MAC_SYS_CTRL_RESET_CSR FIELD32(0x00000001)
2975 +#define MAC_SYS_CTRL_RESET_BBP FIELD32(0x00000002)
2976 +#define MAC_SYS_CTRL_ENABLE_TX FIELD32(0x00000004)
2977 +#define MAC_SYS_CTRL_ENABLE_RX FIELD32(0x00000008)
2978 +#define MAC_SYS_CTRL_CONTINUOUS_TX FIELD32(0x00000010)
2979 +#define MAC_SYS_CTRL_LOOPBACK FIELD32(0x00000020)
2980 +#define MAC_SYS_CTRL_WLAN_HALT FIELD32(0x00000040)
2981 +#define MAC_SYS_CTRL_RX_TIMESTAMP FIELD32(0x00000080)
2984 + * MAC_ADDR_DW0: STA MAC register 0
2986 +#define MAC_ADDR_DW0 0x1008
2987 +#define MAC_ADDR_DW0_BYTE0 FIELD32(0x000000ff)
2988 +#define MAC_ADDR_DW0_BYTE1 FIELD32(0x0000ff00)
2989 +#define MAC_ADDR_DW0_BYTE2 FIELD32(0x00ff0000)
2990 +#define MAC_ADDR_DW0_BYTE3 FIELD32(0xff000000)
2993 + * MAC_ADDR_DW1: STA MAC register 1
2994 + * UNICAST_TO_ME_MASK:
2995 + * Used to mask off bits from byte 5 of the MAC address
2996 + * to determine the UNICAST_TO_ME bit for RX frames.
2997 + * The full mask is complemented by BSS_ID_MASK:
2998 + * MASK = BSS_ID_MASK & UNICAST_TO_ME_MASK
3000 +#define MAC_ADDR_DW1 0x100c
3001 +#define MAC_ADDR_DW1_BYTE4 FIELD32(0x000000ff)
3002 +#define MAC_ADDR_DW1_BYTE5 FIELD32(0x0000ff00)
3003 +#define MAC_ADDR_DW1_UNICAST_TO_ME_MASK FIELD32(0x00ff0000)
3006 + * MAC_BSSID_DW0: BSSID register 0
3008 +#define MAC_BSSID_DW0 0x1010
3009 +#define MAC_BSSID_DW0_BYTE0 FIELD32(0x000000ff)
3010 +#define MAC_BSSID_DW0_BYTE1 FIELD32(0x0000ff00)
3011 +#define MAC_BSSID_DW0_BYTE2 FIELD32(0x00ff0000)
3012 +#define MAC_BSSID_DW0_BYTE3 FIELD32(0xff000000)
3015 + * MAC_BSSID_DW1: BSSID register 1
3017 + * 0: 1-BSSID mode (BSS index = 0)
3018 + * 1: 2-BSSID mode (BSS index: Byte5, bit 0)
3019 + * 2: 4-BSSID mode (BSS index: byte5, bit 0 - 1)
3020 + * 3: 8-BSSID mode (BSS index: byte5, bit 0 - 2)
3021 + * This mask is used to mask off bits 0, 1 and 2 of byte 5 of the
3022 + * BSSID. This will make sure that those bits will be ignored
3023 + * when determining the MY_BSS of RX frames.
3025 +#define MAC_BSSID_DW1 0x1014
3026 +#define MAC_BSSID_DW1_BYTE4 FIELD32(0x000000ff)
3027 +#define MAC_BSSID_DW1_BYTE5 FIELD32(0x0000ff00)
3028 +#define MAC_BSSID_DW1_BSS_ID_MASK FIELD32(0x00030000)
3029 +#define MAC_BSSID_DW1_BSS_BCN_NUM FIELD32(0x001c0000)
3032 + * MAX_LEN_CFG: Maximum frame length register.
3033 + * MAX_MPDU: rt2860b max 16k bytes
3034 + * MAX_PSDU: Maximum PSDU length
3035 + * (power factor) 0:2^13, 1:2^14, 2:2^15, 3:2^16
3037 +#define MAX_LEN_CFG 0x1018
3038 +#define MAX_LEN_CFG_MAX_MPDU FIELD32(0x00000fff)
3039 +#define MAX_LEN_CFG_MAX_PSDU FIELD32(0x00003000)
3040 +#define MAX_LEN_CFG_MIN_PSDU FIELD32(0x0000c000)
3041 +#define MAX_LEN_CFG_MIN_MPDU FIELD32(0x000f0000)
3044 + * BBP_CSR_CFG: BBP serial control register
3045 + * VALUE: Register value to program into BBP
3046 + * REG_NUM: Selected BBP register
3047 + * READ_CONTROL: 0 write BBP, 1 read BBP
3048 + * BUSY: ASIC is busy executing BBP commands
3049 + * BBP_PAR_DUR: 0 4 MAC clocks, 1 8 MAC clocks
3050 + * BBP_RW_MODE: 0 serial, 1 paralell
3052 +#define BBP_CSR_CFG 0x101c
3053 +#define BBP_CSR_CFG_VALUE FIELD32(0x000000ff)
3054 +#define BBP_CSR_CFG_REGNUM FIELD32(0x0000ff00)
3055 +#define BBP_CSR_CFG_READ_CONTROL FIELD32(0x00010000)
3056 +#define BBP_CSR_CFG_BUSY FIELD32(0x00020000)
3057 +#define BBP_CSR_CFG_BBP_PAR_DUR FIELD32(0x00040000)
3058 +#define BBP_CSR_CFG_BBP_RW_MODE FIELD32(0x00080000)
3061 + * RF_CSR_CFG0: RF control register
3062 + * REGID_AND_VALUE: Register value to program into RF
3063 + * BITWIDTH: Selected RF register
3064 + * STANDBYMODE: 0 high when standby, 1 low when standby
3065 + * SEL: 0 RF_LE0 activate, 1 RF_LE1 activate
3066 + * BUSY: ASIC is busy executing RF commands
3068 +#define RF_CSR_CFG0 0x1020
3069 +#define RF_CSR_CFG0_REGID_AND_VALUE FIELD32(0x00ffffff)
3070 +#define RF_CSR_CFG0_BITWIDTH FIELD32(0x1f000000)
3071 +#define RF_CSR_CFG0_REG_VALUE_BW FIELD32(0x1fffffff)
3072 +#define RF_CSR_CFG0_STANDBYMODE FIELD32(0x20000000)
3073 +#define RF_CSR_CFG0_SEL FIELD32(0x40000000)
3074 +#define RF_CSR_CFG0_BUSY FIELD32(0x80000000)
3077 + * RF_CSR_CFG1: RF control register
3078 + * REGID_AND_VALUE: Register value to program into RF
3079 + * RFGAP: Gap between BB_CONTROL_RF and RF_LE
3080 + * 0: 3 system clock cycle (37.5usec)
3081 + * 1: 5 system clock cycle (62.5usec)
3083 +#define RF_CSR_CFG1 0x1024
3084 +#define RF_CSR_CFG1_REGID_AND_VALUE FIELD32(0x00ffffff)
3085 +#define RF_CSR_CFG1_RFGAP FIELD32(0x1f000000)
3088 + * RF_CSR_CFG2: RF control register
3089 + * VALUE: Register value to program into RF
3090 + * RFGAP: Gap between BB_CONTROL_RF and RF_LE
3091 + * 0: 3 system clock cycle (37.5usec)
3092 + * 1: 5 system clock cycle (62.5usec)
3094 +#define RF_CSR_CFG2 0x1028
3095 +#define RF_CSR_CFG2_VALUE FIELD32(0x00ffffff)
3098 + * LED_CFG: LED control
3101 + * 1: blinking upon TX2
3102 + * 2: periodic slow blinking
3108 +#define LED_CFG 0x102c
3109 +#define LED_CFG_ON_PERIOD FIELD32(0x000000ff)
3110 +#define LED_CFG_OFF_PERIOD FIELD32(0x0000ff00)
3111 +#define LED_CFG_SLOW_BLINK_PERIOD FIELD32(0x003f0000)
3112 +#define LED_CFG_R_LED_MODE FIELD32(0x03000000)
3113 +#define LED_CFG_G_LED_MODE FIELD32(0x0c000000)
3114 +#define LED_CFG_Y_LED_MODE FIELD32(0x30000000)
3115 +#define LED_CFG_LED_POLAR FIELD32(0x40000000)
3118 + * XIFS_TIME_CFG: MAC timing
3119 + * CCKM_SIFS_TIME: unit 1us. Applied after CCK RX/TX
3120 + * OFDM_SIFS_TIME: unit 1us. Applied after OFDM RX/TX
3121 + * OFDM_XIFS_TIME: unit 1us. Applied after OFDM RX
3122 + * when MAC doesn't reference BBP signal BBRXEND
3124 + * BB_RXEND_ENABLE: reference RXEND signal to begin XIFS defer
3127 +#define XIFS_TIME_CFG 0x1100
3128 +#define XIFS_TIME_CFG_CCKM_SIFS_TIME FIELD32(0x000000ff)
3129 +#define XIFS_TIME_CFG_OFDM_SIFS_TIME FIELD32(0x0000ff00)
3130 +#define XIFS_TIME_CFG_OFDM_XIFS_TIME FIELD32(0x000f0000)
3131 +#define XIFS_TIME_CFG_EIFS FIELD32(0x1ff00000)
3132 +#define XIFS_TIME_CFG_BB_RXEND_ENABLE FIELD32(0x20000000)
3137 +#define BKOFF_SLOT_CFG 0x1104
3138 +#define BKOFF_SLOT_CFG_SLOT_TIME FIELD32(0x000000ff)
3139 +#define BKOFF_SLOT_CFG_CC_DELAY_TIME FIELD32(0x0000ff00)
3144 +#define NAV_TIME_CFG 0x1108
3145 +#define NAV_TIME_CFG_SIFS FIELD32(0x000000ff)
3146 +#define NAV_TIME_CFG_SLOT_TIME FIELD32(0x0000ff00)
3147 +#define NAV_TIME_CFG_EIFS FIELD32(0x01ff0000)
3148 +#define NAV_TIME_ZERO_SIFS FIELD32(0x02000000)
3151 + * CH_TIME_CFG: count as channel busy
3153 +#define CH_TIME_CFG 0x110c
3156 + * PBF_LIFE_TIMER: TX/RX MPDU timestamp timer (free run) Unit: 1us
3158 +#define PBF_LIFE_TIMER 0x1110
3162 + * BEACON_INTERVAL: in unit of 1/16 TU
3163 + * TSF_TICKING: Enable TSF auto counting
3164 + * TSF_SYNC: Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode
3165 + * BEACON_GEN: Enable beacon generator
3167 +#define BCN_TIME_CFG 0x1114
3168 +#define BCN_TIME_CFG_BEACON_INTERVAL FIELD32(0x0000ffff)
3169 +#define BCN_TIME_CFG_TSF_TICKING FIELD32(0x00010000)
3170 +#define BCN_TIME_CFG_TSF_SYNC FIELD32(0x00060000)
3171 +#define BCN_TIME_CFG_TBTT_ENABLE FIELD32(0x00080000)
3172 +#define BCN_TIME_CFG_BEACON_GEN FIELD32(0x00100000)
3173 +#define BCN_TIME_CFG_TX_TIME_COMPENSATE FIELD32(0xf0000000)
3178 +#define TBTT_SYNC_CFG 0x1118
3181 + * TSF_TIMER_DW0: Local lsb TSF timer, read-only
3183 +#define TSF_TIMER_DW0 0x111c
3184 +#define TSF_TIMER_DW0_LOW_WORD FIELD32(0xffffffff)
3187 + * TSF_TIMER_DW1: Local msb TSF timer, read-only
3189 +#define TSF_TIMER_DW1 0x1120
3190 +#define TSF_TIMER_DW1_HIGH_WORD FIELD32(0xffffffff)
3193 + * TBTT_TIMER: TImer remains till next TBTT, read-only
3195 +#define TBTT_TIMER 0x1124
3200 +#define INT_TIMER_CFG 0x1128
3203 + * INT_TIMER_EN: GP-timer and pre-tbtt Int enable
3205 +#define INT_TIMER_EN 0x112c
3208 + * CH_IDLE_STA: channel idle time
3210 +#define CH_IDLE_STA 0x1130
3213 + * CH_BUSY_STA: channel busy time
3215 +#define CH_BUSY_STA 0x1134
3219 + * BBP_RF_BUSY: When set to 0, BBP and RF are stable.
3220 + * if 1 or higher one of the 2 registers is busy.
3222 +#define MAC_STATUS_CFG 0x1200
3223 +#define MAC_STATUS_CFG_BBP_RF_BUSY FIELD32(0x00000003)
3228 +#define PWR_PIN_CFG 0x1204
3231 + * AUTOWAKEUP_CFG: Manual power control / status register
3232 + * TBCN_BEFORE_WAKE: ForceWake has high privilege than PutToSleep when both set
3233 + * AUTOWAKE: 0:sleep, 1:awake
3235 +#define AUTOWAKEUP_CFG 0x1208
3236 +#define AUTOWAKEUP_CFG_AUTO_LEAD_TIME FIELD32(0x000000ff)
3237 +#define AUTOWAKEUP_CFG_TBCN_BEFORE_WAKE FIELD32(0x00007f00)
3238 +#define AUTOWAKEUP_CFG_AUTOWAKE FIELD32(0x00008000)
3243 +#define EDCA_AC0_CFG 0x1300
3244 +#define EDCA_AC0_CFG_AC_TX_OP FIELD32(0x000000ff)
3245 +#define EDCA_AC0_CFG_AIFSN FIELD32(0x00000f00)
3246 +#define EDCA_AC0_CFG_CWMIN FIELD32(0x0000f000)
3247 +#define EDCA_AC0_CFG_CWMAX FIELD32(0x000f0000)
3252 +#define EDCA_AC1_CFG 0x1304
3253 +#define EDCA_AC1_CFG_AC_TX_OP FIELD32(0x000000ff)
3254 +#define EDCA_AC1_CFG_AIFSN FIELD32(0x00000f00)
3255 +#define EDCA_AC1_CFG_CWMIN FIELD32(0x0000f000)
3256 +#define EDCA_AC1_CFG_CWMAX FIELD32(0x000f0000)
3261 +#define EDCA_AC2_CFG 0x1308
3262 +#define EDCA_AC2_CFG_AC_TX_OP FIELD32(0x000000ff)
3263 +#define EDCA_AC2_CFG_AIFSN FIELD32(0x00000f00)
3264 +#define EDCA_AC2_CFG_CWMIN FIELD32(0x0000f000)
3265 +#define EDCA_AC2_CFG_CWMAX FIELD32(0x000f0000)
3270 +#define EDCA_AC3_CFG 0x130c
3271 +#define EDCA_AC3_CFG_AC_TX_OP FIELD32(0x000000ff)
3272 +#define EDCA_AC3_CFG_AIFSN FIELD32(0x00000f00)
3273 +#define EDCA_AC3_CFG_CWMIN FIELD32(0x0000f000)
3274 +#define EDCA_AC3_CFG_CWMAX FIELD32(0x000f0000)
3277 + * EDCA_TID_AC_MAP:
3279 +#define EDCA_TID_AC_MAP 0x1310
3284 +#define TX_PWR_CFG_0 0x1314
3285 +#define TX_PWR_CFG_0_1MBS FIELD32(0x0000000f)
3286 +#define TX_PWR_CFG_0_2MBS FIELD32(0x000000f0)
3287 +#define TX_PWR_CFG_0_55MBS FIELD32(0x00000f00)
3288 +#define TX_PWR_CFG_0_11MBS FIELD32(0x0000f000)
3289 +#define TX_PWR_CFG_0_6MBS FIELD32(0x000f0000)
3290 +#define TX_PWR_CFG_0_9MBS FIELD32(0x00f00000)
3291 +#define TX_PWR_CFG_0_12MBS FIELD32(0x0f000000)
3292 +#define TX_PWR_CFG_0_18MBS FIELD32(0xf0000000)
3297 +#define TX_PWR_CFG_1 0x1318
3298 +#define TX_PWR_CFG_1_24MBS FIELD32(0x0000000f)
3299 +#define TX_PWR_CFG_1_36MBS FIELD32(0x000000f0)
3300 +#define TX_PWR_CFG_1_48MBS FIELD32(0x00000f00)
3301 +#define TX_PWR_CFG_1_54MBS FIELD32(0x0000f000)
3302 +#define TX_PWR_CFG_1_MCS0 FIELD32(0x000f0000)
3303 +#define TX_PWR_CFG_1_MCS1 FIELD32(0x00f00000)
3304 +#define TX_PWR_CFG_1_MCS2 FIELD32(0x0f000000)
3305 +#define TX_PWR_CFG_1_MCS3 FIELD32(0xf0000000)
3310 +#define TX_PWR_CFG_2 0x131c
3311 +#define TX_PWR_CFG_2_MCS4 FIELD32(0x0000000f)
3312 +#define TX_PWR_CFG_2_MCS5 FIELD32(0x000000f0)
3313 +#define TX_PWR_CFG_2_MCS6 FIELD32(0x00000f00)
3314 +#define TX_PWR_CFG_2_MCS7 FIELD32(0x0000f000)
3315 +#define TX_PWR_CFG_2_MCS8 FIELD32(0x000f0000)
3316 +#define TX_PWR_CFG_2_MCS9 FIELD32(0x00f00000)
3317 +#define TX_PWR_CFG_2_MCS10 FIELD32(0x0f000000)
3318 +#define TX_PWR_CFG_2_MCS11 FIELD32(0xf0000000)
3323 +#define TX_PWR_CFG_3 0x1320
3324 +#define TX_PWR_CFG_3_MCS12 FIELD32(0x0000000f)
3325 +#define TX_PWR_CFG_3_MCS13 FIELD32(0x000000f0)
3326 +#define TX_PWR_CFG_3_MCS14 FIELD32(0x00000f00)
3327 +#define TX_PWR_CFG_3_MCS15 FIELD32(0x0000f000)
3328 +#define TX_PWR_CFG_3_UKNOWN1 FIELD32(0x000f0000)
3329 +#define TX_PWR_CFG_3_UKNOWN2 FIELD32(0x00f00000)
3330 +#define TX_PWR_CFG_3_UKNOWN3 FIELD32(0x0f000000)
3331 +#define TX_PWR_CFG_3_UKNOWN4 FIELD32(0xf0000000)
3336 +#define TX_PWR_CFG_4 0x1324
3337 +#define TX_PWR_CFG_4_UKNOWN5 FIELD32(0x0000000f)
3338 +#define TX_PWR_CFG_4_UKNOWN6 FIELD32(0x000000f0)
3339 +#define TX_PWR_CFG_4_UKNOWN7 FIELD32(0x00000f00)
3340 +#define TX_PWR_CFG_4_UKNOWN8 FIELD32(0x0000f000)
3345 +#define TX_PIN_CFG 0x1328
3346 +#define TX_PIN_CFG_PA_PE_A0_EN FIELD32(0x00000001)
3347 +#define TX_PIN_CFG_PA_PE_G0_EN FIELD32(0x00000002)
3348 +#define TX_PIN_CFG_PA_PE_A1_EN FIELD32(0x00000004)
3349 +#define TX_PIN_CFG_PA_PE_G1_EN FIELD32(0x00000008)
3350 +#define TX_PIN_CFG_PA_PE_A0_POL FIELD32(0x00000010)
3351 +#define TX_PIN_CFG_PA_PE_G0_POL FIELD32(0x00000020)
3352 +#define TX_PIN_CFG_PA_PE_A1_POL FIELD32(0x00000040)
3353 +#define TX_PIN_CFG_PA_PE_G1_POL FIELD32(0x00000080)
3354 +#define TX_PIN_CFG_LNA_PE_A0_EN FIELD32(0x00000100)
3355 +#define TX_PIN_CFG_LNA_PE_G0_EN FIELD32(0x00000200)
3356 +#define TX_PIN_CFG_LNA_PE_A1_EN FIELD32(0x00000400)
3357 +#define TX_PIN_CFG_LNA_PE_G1_EN FIELD32(0x00000800)
3358 +#define TX_PIN_CFG_LNA_PE_A0_POL FIELD32(0x00001000)
3359 +#define TX_PIN_CFG_LNA_PE_G0_POL FIELD32(0x00002000)
3360 +#define TX_PIN_CFG_LNA_PE_A1_POL FIELD32(0x00004000)
3361 +#define TX_PIN_CFG_LNA_PE_G1_POL FIELD32(0x00008000)
3362 +#define TX_PIN_CFG_RFTR_EN FIELD32(0x00010000)
3363 +#define TX_PIN_CFG_RFTR_POL FIELD32(0x00020000)
3364 +#define TX_PIN_CFG_TRSW_EN FIELD32(0x00040000)
3365 +#define TX_PIN_CFG_TRSW_POL FIELD32(0x00080000)
3368 + * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
3370 +#define TX_BAND_CFG 0x132c
3371 +#define TX_BAND_CFG_A FIELD32(0x00000002)
3372 +#define TX_BAND_CFG_BG FIELD32(0x00000004)
3377 +#define TX_SW_CFG0 0x1330
3382 +#define TX_SW_CFG1 0x1334
3387 +#define TX_SW_CFG2 0x1338
3392 +#define TXOP_THRES_CFG 0x133c
3397 +#define TXOP_CTRL_CFG 0x1340
3401 + * RTS_THRES: unit:byte
3402 + * RTS_FBK_EN: enable rts rate fallback
3404 +#define TX_RTS_CFG 0x1344
3405 +#define TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT FIELD32(0x000000ff)
3406 +#define TX_RTS_CFG_RTS_THRES FIELD32(0x00ffff00)
3407 +#define TX_RTS_CFG_RTS_FBK_EN FIELD32(0x01000000)
3411 + * MPDU_LIFETIME: expiration time = 2^(9+MPDU LIFE TIME) us
3412 + * RX_ACK_TIMEOUT: unit:slot. Used for TX procedure
3413 + * TX_OP_TIMEOUT: TXOP timeout value for TXOP truncation.
3414 + * it is recommended that:
3415 + * (SLOT_TIME) > (TX_OP_TIMEOUT) > (RX_ACK_TIMEOUT)
3417 +#define TX_TIMEOUT_CFG 0x1348
3418 +#define TX_TIMEOUT_CFG_MPDU_LIFETIME FIELD32(0x000000f0)
3419 +#define TX_TIMEOUT_CFG_RX_ACK_TIMEOUT FIELD32(0x0000ff00)
3420 +#define TX_TIMEOUT_CFG_TX_OP_TIMEOUT FIELD32(0x00ff0000)
3424 + * SHORT_RTY_LIMIT: short retry limit
3425 + * LONG_RTY_LIMIT: long retry limit
3426 + * LONG_RTY_THRE: Long retry threshoold
3427 + * NON_AGG_RTY_MODE: Non-Aggregate MPDU retry mode
3428 + * 0:expired by retry limit, 1: expired by mpdu life timer
3429 + * AGG_RTY_MODE: Aggregate MPDU retry mode
3430 + * 0:expired by retry limit, 1: expired by mpdu life timer
3431 + * TX_AUTO_FB_ENABLE: Tx retry PHY rate auto fallback enable
3433 +#define TX_RTY_CFG 0x134c
3434 +#define TX_RTY_CFG_SHORT_RTY_LIMIT FIELD32(0x000000ff)
3435 +#define TX_RTY_CFG_LONG_RTY_LIMIT FIELD32(0x0000ff00)
3436 +#define TX_RTY_CFG_LONG_RTY_THRE FIELD32(0x0fff0000)
3437 +#define TX_RTY_CFG_NON_AGG_RTY_MODE FIELD32(0x10000000)
3438 +#define TX_RTY_CFG_AGG_RTY_MODE FIELD32(0x20000000)
3439 +#define TX_RTY_CFG_TX_AUTO_FB_ENABLE FIELD32(0x40000000)
3443 + * REMOTE_MFB_LIFETIME: remote MFB life time. unit: 32us
3444 + * MFB_ENABLE: TX apply remote MFB 1:enable
3445 + * REMOTE_UMFS_ENABLE: remote unsolicit MFB enable
3446 + * 0: not apply remote remote unsolicit (MFS=7)
3447 + * TX_MRQ_EN: MCS request TX enable
3448 + * TX_RDG_EN: RDG TX enable
3449 + * TX_CF_ACK_EN: Piggyback CF-ACK enable
3450 + * REMOTE_MFB: remote MCS feedback
3451 + * REMOTE_MFS: remote MCS feedback sequence number
3453 +#define TX_LINK_CFG 0x1350
3454 +#define TX_LINK_CFG_REMOTE_MFB_LIFETIME FIELD32(0x000000ff)
3455 +#define TX_LINK_CFG_MFB_ENABLE FIELD32(0x00000100)
3456 +#define TX_LINK_CFG_REMOTE_UMFS_ENABLE FIELD32(0x00000200)
3457 +#define TX_LINK_CFG_TX_MRQ_EN FIELD32(0x00000400)
3458 +#define TX_LINK_CFG_TX_RDG_EN FIELD32(0x00000800)
3459 +#define TX_LINK_CFG_TX_CF_ACK_EN FIELD32(0x00001000)
3460 +#define TX_LINK_CFG_REMOTE_MFB FIELD32(0x00ff0000)
3461 +#define TX_LINK_CFG_REMOTE_MFS FIELD32(0xff000000)
3466 +#define HT_FBK_CFG0 0x1354
3467 +#define HT_FBK_CFG0_HTMCS0FBK FIELD32(0x0000000f)
3468 +#define HT_FBK_CFG0_HTMCS1FBK FIELD32(0x000000f0)
3469 +#define HT_FBK_CFG0_HTMCS2FBK FIELD32(0x00000f00)
3470 +#define HT_FBK_CFG0_HTMCS3FBK FIELD32(0x0000f000)
3471 +#define HT_FBK_CFG0_HTMCS4FBK FIELD32(0x000f0000)
3472 +#define HT_FBK_CFG0_HTMCS5FBK FIELD32(0x00f00000)
3473 +#define HT_FBK_CFG0_HTMCS6FBK FIELD32(0x0f000000)
3474 +#define HT_FBK_CFG0_HTMCS7FBK FIELD32(0xf0000000)
3479 +#define HT_FBK_CFG1 0x1358
3480 +#define HT_FBK_CFG1_HTMCS8FBK FIELD32(0x0000000f)
3481 +#define HT_FBK_CFG1_HTMCS9FBK FIELD32(0x000000f0)
3482 +#define HT_FBK_CFG1_HTMCS10FBK FIELD32(0x00000f00)
3483 +#define HT_FBK_CFG1_HTMCS11FBK FIELD32(0x0000f000)
3484 +#define HT_FBK_CFG1_HTMCS12FBK FIELD32(0x000f0000)
3485 +#define HT_FBK_CFG1_HTMCS13FBK FIELD32(0x00f00000)
3486 +#define HT_FBK_CFG1_HTMCS14FBK FIELD32(0x0f000000)
3487 +#define HT_FBK_CFG1_HTMCS15FBK FIELD32(0xf0000000)
3492 +#define LG_FBK_CFG0 0x135c
3493 +#define LG_FBK_CFG0_OFDMMCS0FBK FIELD32(0x0000000f)
3494 +#define LG_FBK_CFG0_OFDMMCS1FBK FIELD32(0x000000f0)
3495 +#define LG_FBK_CFG0_OFDMMCS2FBK FIELD32(0x00000f00)
3496 +#define LG_FBK_CFG0_OFDMMCS3FBK FIELD32(0x0000f000)
3497 +#define LG_FBK_CFG0_OFDMMCS4FBK FIELD32(0x000f0000)
3498 +#define LG_FBK_CFG0_OFDMMCS5FBK FIELD32(0x00f00000)
3499 +#define LG_FBK_CFG0_OFDMMCS6FBK FIELD32(0x0f000000)
3500 +#define LG_FBK_CFG0_OFDMMCS7FBK FIELD32(0xf0000000)
3505 +#define LG_FBK_CFG1 0x1360
3506 +#define LG_FBK_CFG0_CCKMCS0FBK FIELD32(0x0000000f)
3507 +#define LG_FBK_CFG0_CCKMCS1FBK FIELD32(0x000000f0)
3508 +#define LG_FBK_CFG0_CCKMCS2FBK FIELD32(0x00000f00)
3509 +#define LG_FBK_CFG0_CCKMCS3FBK FIELD32(0x0000f000)
3512 + * CCK_PROT_CFG: CCK Protection
3513 + * PROTECT_RATE: Protection control frame rate for CCK TX(RTS/CTS/CFEnd)
3514 + * PROTECT_CTRL: Protection control frame type for CCK TX
3515 + * 0:none, 1:RTS/CTS, 2:CTS-to-self
3516 + * PROTECT_NAV: TXOP protection type for CCK TX
3517 + * 0:none, 1:ShortNAVprotect, 2:LongNAVProtect
3518 + * TX_OP_ALLOW_CCK: CCK TXOP allowance, 0:disallow
3519 + * TX_OP_ALLOW_OFDM: CCK TXOP allowance, 0:disallow
3520 + * TX_OP_ALLOW_MM20: CCK TXOP allowance, 0:disallow
3521 + * TX_OP_ALLOW_MM40: CCK TXOP allowance, 0:disallow
3522 + * TX_OP_ALLOW_GF20: CCK TXOP allowance, 0:disallow
3523 + * TX_OP_ALLOW_GF40: CCK TXOP allowance, 0:disallow
3524 + * RTS_TH_EN: RTS threshold enable on CCK TX
3526 +#define CCK_PROT_CFG 0x1364
3527 +#define CCK_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
3528 +#define CCK_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
3529 +#define CCK_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
3530 +#define CCK_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
3531 +#define CCK_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
3532 +#define CCK_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
3533 +#define CCK_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
3534 +#define CCK_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
3535 +#define CCK_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
3536 +#define CCK_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
3539 + * OFDM_PROT_CFG: OFDM Protection
3541 +#define OFDM_PROT_CFG 0x1368
3542 +#define OFDM_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
3543 +#define OFDM_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
3544 +#define OFDM_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
3545 +#define OFDM_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
3546 +#define OFDM_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
3547 +#define OFDM_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
3548 +#define OFDM_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
3549 +#define OFDM_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
3550 +#define OFDM_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
3551 +#define OFDM_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
3554 + * MM20_PROT_CFG: MM20 Protection
3556 +#define MM20_PROT_CFG 0x136c
3557 +#define MM20_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
3558 +#define MM20_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
3559 +#define MM20_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
3560 +#define MM20_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
3561 +#define MM20_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
3562 +#define MM20_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
3563 +#define MM20_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
3564 +#define MM20_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
3565 +#define MM20_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
3566 +#define MM20_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
3569 + * MM40_PROT_CFG: MM40 Protection
3571 +#define MM40_PROT_CFG 0x1370
3572 +#define MM40_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
3573 +#define MM40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
3574 +#define MM40_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
3575 +#define MM40_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
3576 +#define MM40_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
3577 +#define MM40_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
3578 +#define MM40_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
3579 +#define MM40_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
3580 +#define MM40_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
3581 +#define MM40_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
3584 + * GF20_PROT_CFG: GF20 Protection
3586 +#define GF20_PROT_CFG 0x1374
3587 +#define GF20_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
3588 +#define GF20_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
3589 +#define GF20_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
3590 +#define GF20_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
3591 +#define GF20_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
3592 +#define GF20_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
3593 +#define GF20_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
3594 +#define GF20_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
3595 +#define GF20_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
3596 +#define GF20_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
3599 + * GF40_PROT_CFG: GF40 Protection
3601 +#define GF40_PROT_CFG 0x1378
3602 +#define GF40_PROT_CFG_PROTECT_RATE FIELD32(0x0000ffff)
3603 +#define GF40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
3604 +#define GF40_PROT_CFG_PROTECT_NAV FIELD32(0x000c0000)
3605 +#define GF40_PROT_CFG_TX_OP_ALLOW_CCK FIELD32(0x00100000)
3606 +#define GF40_PROT_CFG_TX_OP_ALLOW_OFDM FIELD32(0x00200000)
3607 +#define GF40_PROT_CFG_TX_OP_ALLOW_MM20 FIELD32(0x00400000)
3608 +#define GF40_PROT_CFG_TX_OP_ALLOW_MM40 FIELD32(0x00800000)
3609 +#define GF40_PROT_CFG_TX_OP_ALLOW_GF20 FIELD32(0x01000000)
3610 +#define GF40_PROT_CFG_TX_OP_ALLOW_GF40 FIELD32(0x02000000)
3611 +#define GF40_PROT_CFG_RTS_TH_EN FIELD32(0x04000000)
3616 +#define EXP_CTS_TIME 0x137c
3621 +#define EXP_ACK_TIME 0x1380
3624 + * RX_FILTER_CFG: RX configuration register.
3626 +#define RX_FILTER_CFG 0x1400
3627 +#define RX_FILTER_CFG_DROP_CRC_ERROR FIELD32(0x00000001)
3628 +#define RX_FILTER_CFG_DROP_PHY_ERROR FIELD32(0x00000002)
3629 +#define RX_FILTER_CFG_DROP_NOT_TO_ME FIELD32(0x00000004)
3630 +#define RX_FILTER_CFG_DROP_NOT_MY_BSSD FIELD32(0x00000008)
3631 +#define RX_FILTER_CFG_DROP_VER_ERROR FIELD32(0x00000010)
3632 +#define RX_FILTER_CFG_DROP_MULTICAST FIELD32(0x00000020)
3633 +#define RX_FILTER_CFG_DROP_BROADCAST FIELD32(0x00000040)
3634 +#define RX_FILTER_CFG_DROP_DUPLICATE FIELD32(0x00000080)
3635 +#define RX_FILTER_CFG_DROP_CF_END_ACK FIELD32(0x00000100)
3636 +#define RX_FILTER_CFG_DROP_CF_END FIELD32(0x00000200)
3637 +#define RX_FILTER_CFG_DROP_ACK FIELD32(0x00000400)
3638 +#define RX_FILTER_CFG_DROP_CTS FIELD32(0x00000800)
3639 +#define RX_FILTER_CFG_DROP_RTS FIELD32(0x00001000)
3640 +#define RX_FILTER_CFG_DROP_PSPOLL FIELD32(0x00002000)
3641 +#define RX_FILTER_CFG_DROP_BA FIELD32(0x00004000)
3642 +#define RX_FILTER_CFG_DROP_BAR FIELD32(0x00008000)
3643 +#define RX_FILTER_CFG_DROP_CNTL FIELD32(0x00010000)
3647 + * AUTORESPONDER: 0: disable, 1: enable
3648 + * BAC_ACK_POLICY: 0:long, 1:short preamble
3649 + * CTS_40_MMODE: Response CTS 40MHz duplicate mode
3650 + * CTS_40_MREF: Response CTS 40MHz duplicate mode
3651 + * AR_PREAMBLE: Auto responder preamble 0:long, 1:short preamble
3652 + * DUAL_CTS_EN: Power bit value in control frame
3653 + * ACK_CTS_PSM_BIT:Power bit value in control frame
3655 +#define AUTO_RSP_CFG 0x1404
3656 +#define AUTO_RSP_CFG_AUTORESPONDER FIELD32(0x00000001)
3657 +#define AUTO_RSP_CFG_BAC_ACK_POLICY FIELD32(0x00000002)
3658 +#define AUTO_RSP_CFG_CTS_40_MMODE FIELD32(0x00000004)
3659 +#define AUTO_RSP_CFG_CTS_40_MREF FIELD32(0x00000008)
3660 +#define AUTO_RSP_CFG_AR_PREAMBLE FIELD32(0x00000010)
3661 +#define AUTO_RSP_CFG_DUAL_CTS_EN FIELD32(0x00000040)
3662 +#define AUTO_RSP_CFG_ACK_CTS_PSM_BIT FIELD32(0x00000080)
3665 + * LEGACY_BASIC_RATE:
3667 +#define LEGACY_BASIC_RATE 0x1408
3672 +#define HT_BASIC_RATE 0x140c
3677 +#define HT_CTRL_CFG 0x1410
3682 +#define SIFS_COST_CFG 0x1414
3686 + * Set NAV for all received frames
3688 +#define RX_PARSER_CFG 0x1418
3693 +#define TX_SEC_CNT0 0x1500
3698 +#define RX_SEC_CNT0 0x1504
3703 +#define CCMP_FC_MUTE 0x1508
3706 + * TXOP_HLDR_ADDR0:
3708 +#define TXOP_HLDR_ADDR0 0x1600
3711 + * TXOP_HLDR_ADDR1:
3713 +#define TXOP_HLDR_ADDR1 0x1604
3718 +#define TXOP_HLDR_ET 0x1608
3721 + * QOS_CFPOLL_RA_DW0:
3723 +#define QOS_CFPOLL_RA_DW0 0x160c
3726 + * QOS_CFPOLL_RA_DW1:
3728 +#define QOS_CFPOLL_RA_DW1 0x1610
3733 +#define QOS_CFPOLL_QC 0x1614
3736 + * RX_STA_CNT0: RX PLCP error count & RX CRC error count
3738 +#define RX_STA_CNT0 0x1700
3739 +#define RX_STA_CNT0_CRC_ERR FIELD32(0x0000ffff)
3740 +#define RX_STA_CNT0_PHY_ERR FIELD32(0xffff0000)
3743 + * RX_STA_CNT1: RX False CCA count & RX LONG frame count
3745 +#define RX_STA_CNT1 0x1704
3746 +#define RX_STA_CNT1_FALSE_CCA FIELD32(0x0000ffff)
3747 +#define RX_STA_CNT1_PLCP_ERR FIELD32(0xffff0000)
3752 +#define RX_STA_CNT2 0x1708
3753 +#define RX_STA_CNT2_RX_DUPLI_COUNT FIELD32(0x0000ffff)
3754 +#define RX_STA_CNT2_RX_FIFO_OVERFLOW FIELD32(0xffff0000)
3757 + * TX_STA_CNT0: TX Beacon count
3759 +#define TX_STA_CNT0 0x170c
3760 +#define TX_STA_CNT0_TX_FAIL_COUNT FIELD32(0x0000ffff)
3761 +#define TX_STA_CNT0_TX_BEACON_COUNT FIELD32(0xffff0000)
3764 + * TX_STA_CNT1: TX tx count
3766 +#define TX_STA_CNT1 0x1710
3767 +#define TX_STA_CNT1_TX_SUCCESS FIELD32(0x0000ffff)
3768 +#define TX_STA_CNT1_TX_RETRANSMIT FIELD32(0xffff0000)
3771 + * TX_STA_CNT2: TX tx count
3773 +#define TX_STA_CNT2 0x1714
3774 +#define TX_STA_CNT2_TX_ZERO_LEN_COUNT FIELD32(0x0000ffff)
3775 +#define TX_STA_CNT2_TX_UNDER_FLOW_COUNT FIELD32(0xffff0000)
3778 + * TX_STA_FIFO: TX Result for specific PID status fifo register
3780 +#define TX_STA_FIFO 0x1718
3781 +#define TX_STA_FIFO_B_VALID FIELD32(0x00000001)
3782 +#define TX_STA_FIFO_PID_TYPE FIELD32(0x0000001e)
3783 +#define TX_STA_FIFO_TX_SUCCESS FIELD32(0x00000020)
3784 +#define TX_STA_FIFO_TX_AGGRE FIELD32(0x00000040)
3785 +#define TX_STA_FIFO_TX_ACK_REQUIRED FIELD32(0x00000080)
3786 +#define TX_STA_FIFO_WCID FIELD32(0x0000ff00)
3787 +#define TX_STA_FIFO_SUCCESS_RATE FIELD32(0xffff0000)
3790 + * TX_AGG_CNT: Debug counter
3792 +#define TX_AGG_CNT 0x171c
3793 +#define TX_AGG_CNT_NON_AGG_TX_COUNT FIELD32(0x0000ffff)
3794 +#define TX_AGG_CNT_AGG_TX_COUNT FIELD32(0xffff0000)
3799 +#define TX_AGG_CNT0 0x1720
3800 +#define TX_AGG_CNT0_AGG_SIZE_1_COUNT FIELD32(0x0000ffff)
3801 +#define TX_AGG_CNT0_AGG_SIZE_2_COUNT FIELD32(0xffff0000)
3806 +#define TX_AGG_CNT1 0x1724
3807 +#define TX_AGG_CNT1_AGG_SIZE_3_COUNT FIELD32(0x0000ffff)
3808 +#define TX_AGG_CNT1_AGG_SIZE_4_COUNT FIELD32(0xffff0000)
3813 +#define TX_AGG_CNT2 0x1728
3814 +#define TX_AGG_CNT2_AGG_SIZE_5_COUNT FIELD32(0x0000ffff)
3815 +#define TX_AGG_CNT2_AGG_SIZE_6_COUNT FIELD32(0xffff0000)
3820 +#define TX_AGG_CNT3 0x172c
3821 +#define TX_AGG_CNT3_AGG_SIZE_7_COUNT FIELD32(0x0000ffff)
3822 +#define TX_AGG_CNT3_AGG_SIZE_8_COUNT FIELD32(0xffff0000)
3827 +#define TX_AGG_CNT4 0x1730
3828 +#define TX_AGG_CNT4_AGG_SIZE_9_COUNT FIELD32(0x0000ffff)
3829 +#define TX_AGG_CNT4_AGG_SIZE_10_COUNT FIELD32(0xffff0000)
3834 +#define TX_AGG_CNT5 0x1734
3835 +#define TX_AGG_CNT5_AGG_SIZE_11_COUNT FIELD32(0x0000ffff)
3836 +#define TX_AGG_CNT5_AGG_SIZE_12_COUNT FIELD32(0xffff0000)
3841 +#define TX_AGG_CNT6 0x1738
3842 +#define TX_AGG_CNT6_AGG_SIZE_13_COUNT FIELD32(0x0000ffff)
3843 +#define TX_AGG_CNT6_AGG_SIZE_14_COUNT FIELD32(0xffff0000)
3848 +#define TX_AGG_CNT7 0x173c
3849 +#define TX_AGG_CNT7_AGG_SIZE_15_COUNT FIELD32(0x0000ffff)
3850 +#define TX_AGG_CNT7_AGG_SIZE_16_COUNT FIELD32(0xffff0000)
3853 + * MPDU_DENSITY_CNT:
3854 + * TX_ZERO_DEL: TX zero length delimiter count
3855 + * RX_ZERO_DEL: RX zero length delimiter count
3857 +#define MPDU_DENSITY_CNT 0x1740
3858 +#define MPDU_DENSITY_CNT_TX_ZERO_DEL FIELD32(0x0000ffff)
3859 +#define MPDU_DENSITY_CNT_RX_ZERO_DEL FIELD32(0xffff0000)
3862 + * Security key table memory, base address = 0x1800
3864 +struct hw_pairwise_ta_entry {
3867 +} __attribute__ ((packed));
3869 +struct wcid_entry {
3873 +} __attribute__ ((packed));
3875 +struct hw_key_entry {
3879 +} __attribute__ ((packed));
3882 + * Security key table memory.
3883 + * MAC_WCID_BASE: 8-bytes (use only 6 bytes) * 256 entry
3884 + * PAIRWISE_KEY_TABLE_BASE: 32-byte * 256 entry
3885 + * PAIRWISE_IVEIV_TABLE_BASE: 8-byte * 256-entry
3886 + * MAC_IVEIV_TABLE_BASE: 8-byte * 256-entry
3887 + * MAC_WCID_ATTRIBUTE_BASE: 4-byte * 256-entry
3888 + * SHARED_KEY_TABLE_BASE: 32-byte * 16-entry
3889 + * SHARED_KEY_MODE_BASE: 32-byte * 16-entry
3891 +#define MAC_WCID_BASE 0x1800
3892 +#define PAIRWISE_KEY_TABLE_BASE 0x4000
3893 +#define PAIRWISE_IVEIV_TABLE_BASE 0x6000
3894 +#define MAC_IVEIV_TABLE_BASE 0x6000
3895 +#define MAC_WCID_ATTRIBUTE_BASE 0x6800
3896 +#define SHARED_KEY_TABLE_BASE 0x6c00
3897 +#define SHARED_KEY_MODE_BASE 0x7000
3899 +#define SHARED_KEY_ENTRY(__idx) \
3900 + ( SHARED_KEY_TABLE_BASE + \
3901 + ((__idx) * sizeof(struct hw_key_entry)) )
3902 +#define SHARED_KEY_MODE_ENTRY(__idx) \
3903 + ( SHARED_KEY_MODE_BASE + ((__idx) * sizeof(u32)) )
3904 +#define PAIRWISE_KEY_ENTRY(__idx) \
3905 + ( PAIRWISE_KEY_TABLE_BASE + \
3906 + ((__idx) * sizeof(struct hw_key_entry)) )
3908 +#define MAC_WCID_ENTRY(__idx) \
3909 + ( MAC_WCID_BASE + (2 * sizeof(u32) * (__idx)) )
3910 +#define MAC_WCID_ATTR_ENTRY(__idx) \
3911 + ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) )
3914 + * MAC_WCID_ATTRIBUTE:
3915 + * KEYTAB: 0: shared key table, 1: pairwise key table
3916 + * BSS_IDX: multipleBSS index for the WCID
3918 +#define MAC_WCID_ATTRIBUTE_KEYTAB FIELD32(0x00000001)
3919 +#define MAC_WCID_ATTRIBUTE_PAIRKEY_MODE FIELD32(0x0000000e)
3920 +#define MAC_WCID_ATTRIBUTE_BSS_IDX FIELD32(0x00000070)
3921 +#define MAC_WCID_ATTRIBUTE_RX_WIUDF FIELD32(0x00000380)
3924 + * SHARED_KEY_MODE:
3926 +#define SHARED_KEY_MODE_BSS0_KEY0 FIELD32(0x00000007)
3927 +#define SHARED_KEY_MODE_BSS0_KEY1 FIELD32(0x00000070)
3928 +#define SHARED_KEY_MODE_BSS0_KEY2 FIELD32(0x00000700)
3929 +#define SHARED_KEY_MODE_BSS0_KEY3 FIELD32(0x00007000)
3930 +#define SHARED_KEY_MODE_BSS1_KEY0 FIELD32(0x00070000)
3931 +#define SHARED_KEY_MODE_BSS1_KEY1 FIELD32(0x00700000)
3932 +#define SHARED_KEY_MODE_BSS1_KEY2 FIELD32(0x07000000)
3933 +#define SHARED_KEY_MODE_BSS1_KEY3 FIELD32(0x70000000)
3936 + * HOST-MCU communication
3940 + * H2M_MAILBOX_CSR: Host-to-MCU Mailbox.
3942 +#define H2M_MAILBOX_CSR 0x7010
3943 +#define H2M_MAILBOX_CSR_ARG0 FIELD32(0x000000ff)
3944 +#define H2M_MAILBOX_CSR_ARG1 FIELD32(0x0000ff00)
3945 +#define H2M_MAILBOX_CSR_CMD_TOKEN FIELD32(0x00ff0000)
3946 +#define H2M_MAILBOX_CSR_OWNER FIELD32(0xff000000)
3949 + * H2M_MAILBOX_CID:
3951 +#define H2M_MAILBOX_CID 0x7014
3954 + * H2M_MAILBOX_STATUS:
3956 +#define H2M_MAILBOX_STATUS 0x701c
3961 +#define H2M_INT_SRC 0x7024
3966 +#define H2M_BBP_AGENT 0x7028
3969 + * MCU_LEDCS: LED control for MCU Mailbox.
3971 +#define MCU_LEDCS_LED_MODE FIELD8(0x1f)
3972 +#define MCU_LEDCS_POLARITY FIELD8(0x01)
3976 + * Carrier-sense CTS frame base address.
3977 + * It's where mac stores carrier-sense frame for carrier-sense function.
3979 +#define HW_CS_CTS_BASE 0x7700
3982 + * HW_DFS_CTS_BASE:
3983 + * FS CTS frame base address. It's where mac stores CTS frame for DFS.
3985 +#define HW_DFS_CTS_BASE 0x7780
3988 + * TXRX control registers - base address 0x3000
3993 + * rt2860b UNKNOWN reg use R/O Reg Addr 0x77d0 first..
3995 +#define TXRX_CSR1 0x77d0
3998 + * HW_DEBUG_SETTING_BASE:
3999 + * since NULL frame won't be that long (256 byte)
4000 + * We steal 16 tail bytes to save debugging settings
4002 +#define HW_DEBUG_SETTING_BASE 0x77f0
4003 +#define HW_DEBUG_SETTING_BASE2 0x7770
4007 + * In order to support maximum 8 MBSS and its maximum length
4008 + * is 512 bytes for each beacon
4009 + * Three section discontinue memory segments will be used.
4010 + * 1. The original region for BCN 0~3
4011 + * 2. Extract memory from FCE table for BCN 4~5
4012 + * 3. Extract memory from Pair-wise key table for BCN 6~7
4013 + * It occupied those memory of wcid 238~253 for BCN 6
4014 + * and wcid 222~237 for BCN 7
4016 + * IMPORTANT NOTE: Not sure why legacy driver does this,
4017 + * but HW_BEACON_BASE7 is 0x0200 bytes below HW_BEACON_BASE6.
4019 +#define HW_BEACON_BASE0 0x7800
4020 +#define HW_BEACON_BASE1 0x7a00
4021 +#define HW_BEACON_BASE2 0x7c00
4022 +#define HW_BEACON_BASE3 0x7e00
4023 +#define HW_BEACON_BASE4 0x7200
4024 +#define HW_BEACON_BASE5 0x7400
4025 +#define HW_BEACON_BASE6 0x5dc0
4026 +#define HW_BEACON_BASE7 0x5bc0
4028 +#define HW_BEACON_OFFSET(__index) \
4029 + ( ((__index) < 4) ? ( HW_BEACON_BASE0 + (__index * 0x0200) ) : \
4030 + (((__index) < 6) ? ( HW_BEACON_BASE4 + ((__index - 4) * 0x0200) ) : \
4031 + (HW_BEACON_BASE6 - ((__index - 6) * 0x0200))) )
4034 + * 8051 firmware image.
4036 +#define FIRMWARE_RT2870 "rt2870.bin"
4037 +#define FIRMWARE_IMAGE_BASE 0x3000
4041 + * The wordsize of the BBP is 8 bits.
4045 + * BBP 1: TX Antenna
4047 +#define BBP1_TX_POWER FIELD8(0x07)
4048 +#define BBP1_TX_ANTENNA FIELD8(0x18)
4051 + * BBP 3: RX Antenna
4053 +#define BBP3_RX_ANTENNA FIELD8(0x18)
4062 +#define RF2_ANTENNA_RX2 FIELD32(0x00000040)
4063 +#define RF2_ANTENNA_TX1 FIELD32(0x00004000)
4064 +#define RF2_ANTENNA_RX1 FIELD32(0x00020000)
4069 +#define RF3_TXPOWER_G FIELD32(0x00003e00)
4070 +#define RF3_TXPOWER_A_7DBM_BOOST FIELD32(0x00000200)
4071 +#define RF3_TXPOWER_A FIELD32(0x00003c00)
4076 +#define RF4_TXPOWER_G FIELD32(0x000007c0)
4077 +#define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
4078 +#define RF4_TXPOWER_A FIELD32(0x00000780)
4079 +#define RF4_FREQ_OFFSET FIELD32(0x001f8000)
4080 +#define RF4_BW40 FIELD32(0x00200000)
4084 + * The wordsize of the EEPROM is 16 bits.
4090 +#define EEPROM_VERSION 0x0001
4091 +#define EEPROM_VERSION_FAE FIELD16(0x00ff)
4092 +#define EEPROM_VERSION_VERSION FIELD16(0xff00)
4097 +#define EEPROM_MAC_ADDR_0 0x0002
4098 +#define EEPROM_MAC_ADDR_BYTE0 FIELD16(0x00ff)
4099 +#define EEPROM_MAC_ADDR_BYTE1 FIELD16(0xff00)
4100 +#define EEPROM_MAC_ADDR1 0x0003
4101 +#define EEPROM_MAC_ADDR_BYTE2 FIELD16(0x00ff)
4102 +#define EEPROM_MAC_ADDR_BYTE3 FIELD16(0xff00)
4103 +#define EEPROM_MAC_ADDR_2 0x0004
4104 +#define EEPROM_MAC_ADDR_BYTE4 FIELD16(0x00ff)
4105 +#define EEPROM_MAC_ADDR_BYTE5 FIELD16(0xff00)
4108 + * EEPROM ANTENNA config
4109 + * RXPATH: 1: 1R, 2: 2R, 3: 3R
4110 + * TXPATH: 1: 1T, 2: 2T
4112 +#define EEPROM_ANTENNA 0x001a
4113 +#define EEPROM_ANTENNA_RXPATH FIELD16(0x000f)
4114 +#define EEPROM_ANTENNA_TXPATH FIELD16(0x00f0)
4115 +#define EEPROM_ANTENNA_RF_TYPE FIELD16(0x0f00)
4118 + * EEPROM NIC config
4119 + * CARDBUS_ACCEL: 0 - enable, 1 - disable
4121 +#define EEPROM_NIC 0x001b
4122 +#define EEPROM_NIC_HW_RADIO FIELD16(0x0001)
4123 +#define EEPROM_NIC_DYNAMIC_TX_AGC FIELD16(0x0002)
4124 +#define EEPROM_NIC_EXTERNAL_LNA_BG FIELD16(0x0004)
4125 +#define EEPROM_NIC_EXTERNAL_LNA_A FIELD16(0x0008)
4126 +#define EEPROM_NIC_CARDBUS_ACCEL FIELD16(0x0010)
4127 +#define EEPROM_NIC_BW40M_SB_BG FIELD16(0x0020)
4128 +#define EEPROM_NIC_BW40M_SB_A FIELD16(0x0040)
4129 +#define EEPROM_NIC_WPS_PBC FIELD16(0x0080)
4130 +#define EEPROM_NIC_BW40M_BG FIELD16(0x0100)
4131 +#define EEPROM_NIC_BW40M_A FIELD16(0x0200)
4134 + * EEPROM frequency
4136 +#define EEPROM_FREQ 0x001d
4137 +#define EEPROM_FREQ_OFFSET FIELD16(0x00ff)
4138 +#define EEPROM_FREQ_LED_MODE FIELD16(0x7f00)
4139 +#define EEPROM_FREQ_LED_POLARITY FIELD16(0x1000)
4143 + * POLARITY_RDY_G: Polarity RDY_G setting.
4144 + * POLARITY_RDY_A: Polarity RDY_A setting.
4145 + * POLARITY_ACT: Polarity ACT setting.
4146 + * POLARITY_GPIO_0: Polarity GPIO0 setting.
4147 + * POLARITY_GPIO_1: Polarity GPIO1 setting.
4148 + * POLARITY_GPIO_2: Polarity GPIO2 setting.
4149 + * POLARITY_GPIO_3: Polarity GPIO3 setting.
4150 + * POLARITY_GPIO_4: Polarity GPIO4 setting.
4151 + * LED_MODE: Led mode.
4153 +#define EEPROM_LED1 0x001e
4154 +#define EEPROM_LED2 0x001f
4155 +#define EEPROM_LED3 0x0020
4156 +#define EEPROM_LED_POLARITY_RDY_BG FIELD16(0x0001)
4157 +#define EEPROM_LED_POLARITY_RDY_A FIELD16(0x0002)
4158 +#define EEPROM_LED_POLARITY_ACT FIELD16(0x0004)
4159 +#define EEPROM_LED_POLARITY_GPIO_0 FIELD16(0x0008)
4160 +#define EEPROM_LED_POLARITY_GPIO_1 FIELD16(0x0010)
4161 +#define EEPROM_LED_POLARITY_GPIO_2 FIELD16(0x0020)
4162 +#define EEPROM_LED_POLARITY_GPIO_3 FIELD16(0x0040)
4163 +#define EEPROM_LED_POLARITY_GPIO_4 FIELD16(0x0080)
4164 +#define EEPROM_LED_LED_MODE FIELD16(0x1f00)
4169 +#define EEPROM_LNA 0x0022
4170 +#define EEPROM_LNA_BG FIELD16(0x00ff)
4171 +#define EEPROM_LNA_A0 FIELD16(0xff00)
4174 + * EEPROM RSSI BG offset
4176 +#define EEPROM_RSSI_BG 0x0023
4177 +#define EEPROM_RSSI_BG_OFFSET0 FIELD16(0x00ff)
4178 +#define EEPROM_RSSI_BG_OFFSET1 FIELD16(0xff00)
4181 + * EEPROM RSSI BG2 offset
4183 +#define EEPROM_RSSI_BG2 0x0024
4184 +#define EEPROM_RSSI_BG2_OFFSET2 FIELD16(0x00ff)
4185 +#define EEPROM_RSSI_BG2_LNA_A1 FIELD16(0xff00)
4188 + * EEPROM RSSI A offset
4190 +#define EEPROM_RSSI_A 0x0025
4191 +#define EEPROM_RSSI_A_OFFSET0 FIELD16(0x00ff)
4192 +#define EEPROM_RSSI_A_OFFSET1 FIELD16(0xff00)
4195 + * EEPROM RSSI A2 offset
4197 +#define EEPROM_RSSI_A2 0x0026
4198 +#define EEPROM_RSSI_A2_OFFSET2 FIELD16(0x00ff)
4199 +#define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00)
4202 + * EEPROM TXpower delta: 20MHZ AND 40 MHZ use different power.
4203 + * This is delta in 40MHZ.
4204 + * VALUE: Tx Power dalta value (MAX=4)
4205 + * TYPE: 1: Plus the delta value, 0: minus the delta value
4206 + * TXPOWER: Enable:
4208 +#define EEPROM_TXPOWER_DELTA 0x0028
4209 +#define EEPROM_TXPOWER_DELTA_VALUE FIELD16(0x003f)
4210 +#define EEPROM_TXPOWER_DELTA_TYPE FIELD16(0x0040)
4211 +#define EEPROM_TXPOWER_DELTA_TXPOWER FIELD16(0x0080)
4214 + * EEPROM TXPOWER 802.11BG
4216 +#define EEPROM_TXPOWER_BG1 0x0029
4217 +#define EEPROM_TXPOWER_BG2 0x0030
4218 +#define EEPROM_TXPOWER_BG_SIZE 7
4219 +#define EEPROM_TXPOWER_BG_1 FIELD16(0x00ff)
4220 +#define EEPROM_TXPOWER_BG_2 FIELD16(0xff00)
4223 + * EEPROM TXPOWER 802.11A
4225 +#define EEPROM_TXPOWER_A1 0x003c
4226 +#define EEPROM_TXPOWER_A2 0x0053
4227 +#define EEPROM_TXPOWER_A_SIZE 6
4228 +#define EEPROM_TXPOWER_A_1 FIELD16(0x00ff)
4229 +#define EEPROM_TXPOWER_A_2 FIELD16(0xff00)
4232 + * EEPROM TXpower byrate: 20MHZ power
4234 +#define EEPROM_TXPOWER_BYRATE 0x006f
4239 +#define EEPROM_BBP_START 0x0078
4240 +#define EEPROM_BBP_SIZE 16
4241 +#define EEPROM_BBP_VALUE FIELD16(0x00ff)
4242 +#define EEPROM_BBP_REG_ID FIELD16(0xff00)
4245 + * MCU mailbox commands.
4247 +#define MCU_SLEEP 0x30
4248 +#define MCU_WAKEUP 0x31
4249 +#define MCU_LED 0x50
4250 +#define MCU_LED_STRENGTH 0x51
4251 +#define MCU_LED_1 0x52
4252 +#define MCU_LED_2 0x53
4253 +#define MCU_LED_3 0x54
4254 +#define MCU_RADAR 0x60
4255 +#define MCU_BOOT_SIGNAL 0x72
4258 + * DMA descriptor defines.
4260 +#define TXD_DESC_SIZE ( 4 * sizeof(__le32) )
4261 +#define TXINFO_DESC_SIZE ( 1 * sizeof(__le32) )
4262 +#define TXWI_DESC_SIZE ( 4 * sizeof(__le32) )
4263 +#define RXD_DESC_SIZE ( 1 * sizeof(__le32) )
4264 +#define RXWI_DESC_SIZE ( 4 * sizeof(__le32) )
4267 + * TX descriptor format for TX, PRIO and Beacon Ring.
4273 +#define TXD_W0_SD_PTR0 FIELD32(0xffffffff)
4278 +#define TXD_W1_SD_LEN1 FIELD32(0x00003fff)
4279 +#define TXD_W1_LAST_SEC1 FIELD32(0x00004000)
4280 +#define TXD_W1_BURST FIELD32(0x00008000)
4281 +#define TXD_W1_SD_LEN0 FIELD32(0x3fff0000)
4282 +#define TXD_W1_LAST_SEC0 FIELD32(0x40000000)
4283 +#define TXD_W1_DMA_DONE FIELD32(0x80000000)
4288 +#define TXD_W2_SD_PTR1 FIELD32(0xffffffff)
4292 + * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
4293 + * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
4294 + * 0:MGMT, 1:HCCA 2:EDCA
4296 +#define TXD_W3_WIV FIELD32(0x01000000)
4297 +#define TXD_W3_QSEL FIELD32(0x06000000)
4298 +#define TXD_W3_TCO FIELD32(0x20000000)
4299 +#define TXD_W3_UCO FIELD32(0x40000000)
4300 +#define TXD_W3_ICO FIELD32(0x80000000)
4303 + * TX Info structure
4308 + * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
4309 + * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
4310 + * 0:MGMT, 1:HCCA 2:EDCA
4311 + * USB_DMA_NEXT_VALID: Used ONLY in USB bulk Aggregation, NextValid
4312 + * DMA_TX_BURST: used ONLY in USB bulk Aggregation.
4313 + * Force USB DMA transmit frame from current selected endpoint
4315 +#define TXINFO_W0_USB_DMA_TX_PKT_LEN FIELD32(0x0000ffff)
4316 +#define TXINFO_W0_WIV FIELD32(0x01000000)
4317 +#define TXINFO_W0_QSEL FIELD32(0x06000000)
4318 +#define TXINFO_W0_USB_DMA_NEXT_VALID FIELD32(0x40000000)
4319 +#define TXINFO_W0_USB_DMA_TX_BURST FIELD32(0x80000000)
4327 + * FRAG: 1 To inform TKIP engine this is a fragment.
4328 + * MIMO_PS: The remote peer is in dynamic MIMO-PS mode
4329 + * TX_OP: 0:HT TXOP rule , 1:PIFS TX ,2:Backoff, 3:sifs
4330 + * BW: Channel bandwidth 20MHz or 40 MHz
4331 + * STBC: 1: STBC support MCS =0-7, 2,3 : RESERVED
4333 +#define TXWI_W0_FRAG FIELD32(0x00000001)
4334 +#define TXWI_W0_MIMO_PS FIELD32(0x00000002)
4335 +#define TXWI_W0_CF_ACK FIELD32(0x00000004)
4336 +#define TXWI_W0_TS FIELD32(0x00000008)
4337 +#define TXWI_W0_AMPDU FIELD32(0x00000010)
4338 +#define TXWI_W0_MPDU_DENSITY FIELD32(0x000000e0)
4339 +#define TXWI_W0_TX_OP FIELD32(0x00000300)
4340 +#define TXWI_W0_MCS FIELD32(0x007f0000)
4341 +#define TXWI_W0_BW FIELD32(0x00800000)
4342 +#define TXWI_W0_SHORT_GI FIELD32(0x01000000)
4343 +#define TXWI_W0_STBC FIELD32(0x06000000)
4344 +#define TXWI_W0_IFS FIELD32(0x08000000)
4345 +#define TXWI_W0_PHYMODE FIELD32(0xc0000000)
4350 +#define TXWI_W1_ACK FIELD32(0x00000001)
4351 +#define TXWI_W1_NSEQ FIELD32(0x00000002)
4352 +#define TXWI_W1_BW_WIN_SIZE FIELD32(0x000000fc)
4353 +#define TXWI_W1_WIRELESS_CLI_ID FIELD32(0x0000ff00)
4354 +#define TXWI_W1_MPDU_TOTAL_BYTE_COUNT FIELD32(0x0fff0000)
4355 +#define TXWI_W1_PACKETID FIELD32(0xf0000000)
4360 +#define TXWI_W2_IV FIELD32(0xffffffff)
4365 +#define TXWI_W3_EIV FIELD32(0xffffffff)
4368 + * RX descriptor format for RX Ring.
4373 + * UNICAST_TO_ME: This RX frame is unicast to me.
4374 + * MULTICAST: This is a multicast frame.
4375 + * BROADCAST: This is a broadcast frame.
4376 + * MY_BSS: this frame belongs to the same BSSID.
4377 + * CRC_ERROR: CRC error.
4378 + * CIPHER_ERROR: 0: decryption okay, 1:ICV error, 2:MIC error, 3:KEY not valid.
4379 + * AMSDU: rx with 802.3 header, not 802.11 header.
4382 +#define RXD_W0_BA FIELD32(0x00000001)
4383 +#define RXD_W0_DATA FIELD32(0x00000002)
4384 +#define RXD_W0_NULLDATA FIELD32(0x00000004)
4385 +#define RXD_W0_FRAG FIELD32(0x00000008)
4386 +#define RXD_W0_UNICAST_TO_ME FIELD32(0x00000010)
4387 +#define RXD_W0_MULTICAST FIELD32(0x00000020)
4388 +#define RXD_W0_BROADCAST FIELD32(0x00000040)
4389 +#define RXD_W0_MY_BSS FIELD32(0x00000080)
4390 +#define RXD_W0_CRC_ERROR FIELD32(0x00000100)
4391 +#define RXD_W0_CIPHER_ERROR FIELD32(0x00000600)
4392 +#define RXD_W0_AMSDU FIELD32(0x00000800)
4393 +#define RXD_W0_HTC FIELD32(0x00001000)
4394 +#define RXD_W0_RSSI FIELD32(0x00002000)
4395 +#define RXD_W0_L2PAD FIELD32(0x00004000)
4396 +#define RXD_W0_AMPDU FIELD32(0x00008000)
4397 +#define RXD_W0_DECRYPTED FIELD32(0x00010000)
4398 +#define RXD_W0_PLCP_RSSI FIELD32(0x00020000)
4399 +#define RXD_W0_CIPHER_ALG FIELD32(0x00040000)
4400 +#define RXD_W0_LAST_AMSDU FIELD32(0x00080000)
4401 +#define RXD_W0_PLCP_SIGNAL FIELD32(0xfff00000)
4410 +#define RXWI_W0_WIRELESS_CLI_ID FIELD32(0x000000ff)
4411 +#define RXWI_W0_KEY_INDEX FIELD32(0x00000300)
4412 +#define RXWI_W0_BSSID FIELD32(0x00001c00)
4413 +#define RXWI_W0_UDF FIELD32(0x0000e000)
4414 +#define RXWI_W0_MPDU_TOTAL_BYTE_COUNT FIELD32(0x0fff0000)
4415 +#define RXWI_W0_TID FIELD32(0xf0000000)
4420 +#define RXWI_W1_FRAG FIELD32(0x0000000f)
4421 +#define RXWI_W1_SEQUENCE FIELD32(0x0000fff0)
4422 +#define RXWI_W1_MCS FIELD32(0x007f0000)
4423 +#define RXWI_W1_BW FIELD32(0x00800000)
4424 +#define RXWI_W1_SHORT_GI FIELD32(0x01000000)
4425 +#define RXWI_W1_STBC FIELD32(0x06000000)
4426 +#define RXWI_W1_PHYMODE FIELD32(0xc0000000)
4431 +#define RXWI_W2_RSSI0 FIELD32(0x000000ff)
4432 +#define RXWI_W2_RSSI1 FIELD32(0x0000ff00)
4433 +#define RXWI_W2_RSSI2 FIELD32(0x00ff0000)
4438 +#define RXWI_W3_SNR0 FIELD32(0x000000ff)
4439 +#define RXWI_W3_SNR1 FIELD32(0x0000ff00)
4442 + * Macro's for converting txpower from EEPROM to mac80211 value
4443 + * and from mac80211 value to register value.
4445 +#define MIN_G_TXPOWER 0
4446 +#define MIN_A_TXPOWER -7
4447 +#define MAX_G_TXPOWER 31
4448 +#define MAX_A_TXPOWER 15
4449 +#define DEFAULT_TXPOWER 5
4451 +#define TXPOWER_G_FROM_DEV(__txpower) \
4452 + ((__txpower) > MAX_G_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
4454 +#define TXPOWER_G_TO_DEV(__txpower) \
4455 + clamp_t(char, __txpower, MIN_G_TXPOWER, MAX_G_TXPOWER)
4457 +#define TXPOWER_A_FROM_DEV(__txpower) \
4458 + ((__txpower) > MAX_A_TXPOWER) ? DEFAULT_TXPOWER : (__txpower)
4460 +#define TXPOWER_A_TO_DEV(__txpower) \
4461 + clamp_t(char, __txpower, MIN_A_TXPOWER, MAX_A_TXPOWER)
4463 +#endif /* RT2800USB_H */
4464 --- a/drivers/net/wireless/rt2x00/rt2x00.h
4465 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
4466 @@ -142,6 +142,7 @@ struct rt2x00_chip {
4467 #define RT2860D 0x0681 /* 2.4GHz, 5GHz PCI/CB */
4468 #define RT2890 0x0701 /* 2.4GHz PCIe */
4469 #define RT2890D 0x0781 /* 2.4GHz, 5GHz PCIe */
4470 +#define RT2870 0x1600