2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Abstract: rt61pci device specific routines.
24 Supported chipsets: RT2561, RT2561s, RT2661.
28 * Set enviroment defines for rt2x00.h
30 #define DRV_NAME "rt61pci"
32 #include <linux/kernel.h>
33 #include <linux/module.h>
34 #include <linux/version.h>
35 #include <linux/init.h>
36 #include <linux/pci.h>
37 #include <linux/dma-mapping.h>
38 #include <linux/delay.h>
39 #include <linux/etherdevice.h>
40 #include <linux/eeprom_93cx6.h>
45 #include "rt2x00lib.h"
46 #include "rt2x00pci.h"
51 * BBP and RF register require indirect register access,
52 * and use the CSR registers PHY_CSR3 and PHY_CSR4 to achieve this.
53 * These indirect registers work with busy bits,
54 * and we will try maximal REGISTER_BUSY_COUNT times to access
55 * the register while taking a REGISTER_BUSY_DELAY us delay
56 * between each attampt. When the busy bit is still set at that time,
57 * the access attempt is considered to have failed,
58 * and we will print an error.
60 static u32
rt61pci_bbp_check(const struct rt2x00_dev
*rt2x00dev
)
65 for (i
= 0; i
< REGISTER_BUSY_COUNT
; i
++) {
66 rt2x00pci_register_read(rt2x00dev
, PHY_CSR3
, ®
);
67 if (!rt2x00_get_field32(reg
, PHY_CSR3_BUSY
))
69 udelay(REGISTER_BUSY_DELAY
);
75 static void rt61pci_bbp_write(const struct rt2x00_dev
*rt2x00dev
,
76 const u8 reg_id
, const u8 value
)
81 * Wait until the BBP becomes ready.
83 reg
= rt61pci_bbp_check(rt2x00dev
);
84 if (rt2x00_get_field32(reg
, PHY_CSR3_BUSY
)) {
85 ERROR(rt2x00dev
, "PHY_CSR3 register busy. Write failed.\n");
90 * Write the data into the BBP.
93 rt2x00_set_field32(®
, PHY_CSR3_VALUE
, value
);
94 rt2x00_set_field32(®
, PHY_CSR3_REGNUM
, reg_id
);
95 rt2x00_set_field32(®
, PHY_CSR3_BUSY
, 1);
96 rt2x00_set_field32(®
, PHY_CSR3_READ_CONTROL
, 0);
98 rt2x00pci_register_write(rt2x00dev
, PHY_CSR3
, reg
);
101 static void rt61pci_bbp_read(const struct rt2x00_dev
*rt2x00dev
,
102 const u8 reg_id
, u8
*value
)
107 * Wait until the BBP becomes ready.
109 reg
= rt61pci_bbp_check(rt2x00dev
);
110 if (rt2x00_get_field32(reg
, PHY_CSR3_BUSY
)) {
111 ERROR(rt2x00dev
, "PHY_CSR3 register busy. Read failed.\n");
116 * Write the request into the BBP.
119 rt2x00_set_field32(®
, PHY_CSR3_REGNUM
, reg_id
);
120 rt2x00_set_field32(®
, PHY_CSR3_BUSY
, 1);
121 rt2x00_set_field32(®
, PHY_CSR3_READ_CONTROL
, 1);
123 rt2x00pci_register_write(rt2x00dev
, PHY_CSR3
, reg
);
126 * Wait until the BBP becomes ready.
128 reg
= rt61pci_bbp_check(rt2x00dev
);
129 if (rt2x00_get_field32(reg
, PHY_CSR3_BUSY
)) {
130 ERROR(rt2x00dev
, "PHY_CSR3 register busy. Read failed.\n");
135 *value
= rt2x00_get_field32(reg
, PHY_CSR3_VALUE
);
138 static void rt61pci_rf_write(const struct rt2x00_dev
*rt2x00dev
,
144 for (i
= 0; i
< REGISTER_BUSY_COUNT
; i
++) {
145 rt2x00pci_register_read(rt2x00dev
, PHY_CSR4
, ®
);
146 if (!rt2x00_get_field32(reg
, PHY_CSR4_BUSY
))
148 udelay(REGISTER_BUSY_DELAY
);
151 ERROR(rt2x00dev
, "PHY_CSR4 register busy. Write failed.\n");
156 rt2x00_set_field32(®
, PHY_CSR4_VALUE
, value
);
157 rt2x00_set_field32(®
, PHY_CSR4_NUMBER_OF_BITS
, 21);
158 rt2x00_set_field32(®
, PHY_CSR4_IF_SELECT
, 0);
159 rt2x00_set_field32(®
, PHY_CSR4_BUSY
, 1);
161 rt2x00pci_register_write(rt2x00dev
, PHY_CSR4
, reg
);
164 static void rt61pci_mcu_request(const struct rt2x00_dev
*rt2x00dev
,
165 const u8 command
, const u8 token
, const u8 arg0
, const u8 arg1
)
169 rt2x00pci_register_read(rt2x00dev
, H2M_MAILBOX_CSR
, ®
);
171 if (rt2x00_get_field32(reg
, H2M_MAILBOX_CSR_OWNER
)) {
172 ERROR(rt2x00dev
, "mcu request error. "
173 "Request 0x%02x failed for token 0x%02x.\n",
178 rt2x00_set_field32(®
, H2M_MAILBOX_CSR_OWNER
, 1);
179 rt2x00_set_field32(®
, H2M_MAILBOX_CSR_CMD_TOKEN
, token
);
180 rt2x00_set_field32(®
, H2M_MAILBOX_CSR_ARG0
, arg0
);
181 rt2x00_set_field32(®
, H2M_MAILBOX_CSR_ARG1
, arg1
);
182 rt2x00pci_register_write(rt2x00dev
, H2M_MAILBOX_CSR
, reg
);
184 rt2x00pci_register_read(rt2x00dev
, HOST_CMD_CSR
, ®
);
185 rt2x00_set_field32(®
, HOST_CMD_CSR_HOST_COMMAND
, command
);
186 rt2x00_set_field32(®
, HOST_CMD_CSR_INTERRUPT_MCU
, 1);
187 rt2x00pci_register_write(rt2x00dev
, HOST_CMD_CSR
, reg
);
190 static void rt61pci_eepromregister_read(struct eeprom_93cx6
*eeprom
)
192 struct rt2x00_dev
*rt2x00dev
= eeprom
->data
;
195 rt2x00pci_register_read(rt2x00dev
, E2PROM_CSR
, ®
);
197 eeprom
->reg_data_in
= !!rt2x00_get_field32(reg
,
199 eeprom
->reg_data_out
= !!rt2x00_get_field32(reg
,
200 E2PROM_CSR_DATA_OUT
);
201 eeprom
->reg_data_clock
= !!rt2x00_get_field32(reg
,
202 E2PROM_CSR_DATA_CLOCK
);
203 eeprom
->reg_chip_select
= !!rt2x00_get_field32(reg
,
204 E2PROM_CSR_CHIP_SELECT
);
207 static void rt61pci_eepromregister_write(struct eeprom_93cx6
*eeprom
)
209 struct rt2x00_dev
*rt2x00dev
= eeprom
->data
;
212 rt2x00_set_field32(®
, E2PROM_CSR_DATA_IN
,
213 !!eeprom
->reg_data_in
);
214 rt2x00_set_field32(®
, E2PROM_CSR_DATA_OUT
,
215 !!eeprom
->reg_data_out
);
216 rt2x00_set_field32(®
, E2PROM_CSR_DATA_CLOCK
,
217 !!eeprom
->reg_data_clock
);
218 rt2x00_set_field32(®
, E2PROM_CSR_CHIP_SELECT
,
219 !!eeprom
->reg_chip_select
);
221 rt2x00pci_register_write(rt2x00dev
, E2PROM_CSR
, reg
);
224 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
225 #define CSR_OFFSET(__word) ( CSR_REG_BASE + ((__word) * sizeof(u32)) )
227 static void rt61pci_read_csr(struct rt2x00_dev
*rt2x00dev
,
228 const unsigned long word
, void *data
)
230 rt2x00pci_register_read(rt2x00dev
, CSR_OFFSET(word
), data
);
233 static void rt61pci_write_csr(struct rt2x00_dev
*rt2x00dev
,
234 const unsigned long word
, void *data
)
236 rt2x00pci_register_write(rt2x00dev
, CSR_OFFSET(word
), *((u32
*)data
));
239 static void rt61pci_read_eeprom(struct rt2x00_dev
*rt2x00dev
,
240 const unsigned long word
, void *data
)
242 rt2x00_eeprom_read(rt2x00dev
, word
, data
);
245 static void rt61pci_write_eeprom(struct rt2x00_dev
*rt2x00dev
,
246 const unsigned long word
, void *data
)
248 rt2x00_eeprom_write(rt2x00dev
, word
, *((u16
*)data
));
251 static void rt61pci_read_bbp(struct rt2x00_dev
*rt2x00dev
,
252 const unsigned long word
, void *data
)
254 rt61pci_bbp_read(rt2x00dev
, word
, data
);
257 static void rt61pci_write_bbp(struct rt2x00_dev
*rt2x00dev
,
258 const unsigned long word
, void *data
)
260 rt61pci_bbp_write(rt2x00dev
, word
, *((u8
*)data
));
263 static const struct rt2x00debug rt61pci_rt2x00debug
= {
264 .owner
= THIS_MODULE
,
266 .read
= rt61pci_read_csr
,
267 .write
= rt61pci_write_csr
,
268 .word_size
= sizeof(u32
),
269 .word_count
= CSR_REG_SIZE
/ sizeof(u32
),
272 .read
= rt61pci_read_eeprom
,
273 .write
= rt61pci_write_eeprom
,
274 .word_size
= sizeof(u16
),
275 .word_count
= EEPROM_SIZE
/ sizeof(u16
),
278 .read
= rt61pci_read_bbp
,
279 .write
= rt61pci_write_bbp
,
280 .word_size
= sizeof(u8
),
281 .word_count
= BBP_SIZE
/ sizeof(u8
),
284 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
286 #ifdef CONFIG_RT61PCI_RFKILL
287 static int rt61pci_rfkill_poll(struct rt2x00_dev
*rt2x00dev
)
291 rt2x00pci_register_read(rt2x00dev
, MAC_CSR13
, ®
);
292 return rt2x00_get_field32(reg
, MAC_CSR13_BIT5
);;
294 #endif /* CONFIG_RT2400PCI_RFKILL */
297 * Configuration handlers.
299 static void rt61pci_config_bssid(struct rt2x00_dev
*rt2x00dev
, u8
*bssid
)
303 memset(®
, 0, sizeof(reg
));
304 memcpy(®
, bssid
, ETH_ALEN
);
306 rt2x00_set_field32(®
[1], MAC_CSR5_BSS_ID_MASK
, 3);
309 * The BSSID is passed to us as an array of bytes,
310 * that array is little endian, so no need for byte ordering.
312 rt2x00pci_register_multiwrite(rt2x00dev
, MAC_CSR4
, ®
, sizeof(reg
));
315 static void rt61pci_config_promisc(struct rt2x00_dev
*rt2x00dev
,
320 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR0
, ®
);
321 rt2x00_set_field32(®
, TXRX_CSR0_DROP_NOT_TO_ME
, !promisc
);
322 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR0
, reg
);
325 static void rt61pci_config_type(struct rt2x00_dev
*rt2x00dev
,
330 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR9
, 0);
333 * Apply hardware packet filter.
335 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR0
, ®
);
337 if (!is_monitor_present(&rt2x00dev
->interface
) &&
338 (type
== IEEE80211_IF_TYPE_IBSS
|| type
== IEEE80211_IF_TYPE_STA
))
339 rt2x00_set_field32(®
, TXRX_CSR0_DROP_TO_DS
, 1);
341 rt2x00_set_field32(®
, TXRX_CSR0_DROP_TO_DS
, 0);
343 rt2x00_set_field32(®
, TXRX_CSR0_DROP_CRC
, 1);
344 if (is_monitor_present(&rt2x00dev
->interface
)) {
345 rt2x00_set_field32(®
, TXRX_CSR0_DROP_PHYSICAL
, 0);
346 rt2x00_set_field32(®
, TXRX_CSR0_DROP_CONTROL
, 0);
347 rt2x00_set_field32(®
, TXRX_CSR0_DROP_VERSION_ERROR
, 0);
349 rt2x00_set_field32(®
, TXRX_CSR0_DROP_PHYSICAL
, 1);
350 rt2x00_set_field32(®
, TXRX_CSR0_DROP_CONTROL
, 1);
351 rt2x00_set_field32(®
, TXRX_CSR0_DROP_VERSION_ERROR
, 1);
354 rt2x00_set_field32(®
, TXRX_CSR0_DROP_MULTICAST
, 0);
355 rt2x00_set_field32(®
, TXRX_CSR0_DROP_BORADCAST
, 0);
357 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR0
, reg
);
360 * Enable synchronisation.
362 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR9
, ®
);
363 if (is_interface_present(&rt2x00dev
->interface
)) {
364 rt2x00_set_field32(®
, TXRX_CSR9_TSF_TICKING
, 1);
365 rt2x00_set_field32(®
, TXRX_CSR9_TBTT_ENABLE
, 1);
368 rt2x00_set_field32(®
, TXRX_CSR9_BEACON_GEN
, 0);
369 if (type
== IEEE80211_IF_TYPE_IBSS
|| type
== IEEE80211_IF_TYPE_AP
)
370 rt2x00_set_field32(®
, TXRX_CSR9_TSF_SYNC
, 2);
371 else if (type
== IEEE80211_IF_TYPE_STA
)
372 rt2x00_set_field32(®
, TXRX_CSR9_TSF_SYNC
, 1);
373 else if (is_monitor_present(&rt2x00dev
->interface
) &&
374 !is_interface_present(&rt2x00dev
->interface
))
375 rt2x00_set_field32(®
, TXRX_CSR9_TSF_SYNC
, 0);
377 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR9
, reg
);
380 static void rt61pci_config_channel(struct rt2x00_dev
*rt2x00dev
,
381 const int value
, const int channel
, const int txpower
)
389 if (!test_bit(CONFIG_RF_SEQUENCE
, &rt2x00dev
->flags
) || channel
<= 14)
391 else if (channel
== 36 ||
392 (channel
>= 100 && channel
<= 116) ||
400 } else if (!test_bit(CONFIG_RF_SEQUENCE
, &rt2x00dev
->flags
)) {
401 if (channel
>= 36 && channel
<= 48)
403 else if (channel
>= 52 && channel
<= 64)
405 else if (channel
>= 100 && channel
<= 112)
465 } else if (channel
== 14) {
467 } else if (!test_bit(CONFIG_RF_SEQUENCE
, &rt2x00dev
->flags
)) {
558 rt2x00_set_field32(&rf3
, RF3_TXPOWER
, TXPOWER_TO_DEV(txpower
));
561 * Set Frequency offset.
563 rt2x00_set_field32(&rf4
, RF4_FREQ_OFFSET
, rt2x00dev
->freq_offset
);
565 rt61pci_rf_write(rt2x00dev
, rf1
);
566 rt61pci_rf_write(rt2x00dev
, rf2
);
567 rt61pci_rf_write(rt2x00dev
, rf3
& ~0x00000004);
568 rt61pci_rf_write(rt2x00dev
, rf4
);
572 rt61pci_rf_write(rt2x00dev
, rf1
);
573 rt61pci_rf_write(rt2x00dev
, rf2
);
574 rt61pci_rf_write(rt2x00dev
, rf3
| 0x00000004);
575 rt61pci_rf_write(rt2x00dev
, rf4
);
579 rt61pci_rf_write(rt2x00dev
, rf1
);
580 rt61pci_rf_write(rt2x00dev
, rf2
);
581 rt61pci_rf_write(rt2x00dev
, rf3
& ~0x00000004);
582 rt61pci_rf_write(rt2x00dev
, rf4
);
584 rt61pci_bbp_read(rt2x00dev
, 3, ®
);
585 if (rt2x00_rf(&rt2x00dev
->chip
, RF5225
) ||
586 rt2x00_rf(&rt2x00dev
->chip
, RF2527
))
590 rt61pci_bbp_write(rt2x00dev
, 3, reg
);
597 rt2x00dev
->rf1
= rf1
;
598 rt2x00dev
->rf2
= rf2
;
599 rt2x00dev
->rf3
= rf3
;
600 rt2x00dev
->rf4
= rf4
;
601 rt2x00dev
->tx_power
= txpower
;
604 static void rt61pci_config_txpower(struct rt2x00_dev
*rt2x00dev
,
607 rt2x00_set_field32(&rt2x00dev
->rf3
, RF3_TXPOWER
,
608 TXPOWER_TO_DEV(txpower
));
610 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf1
);
611 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf2
);
612 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf3
& ~0x00000004);
613 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf4
);
617 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf1
);
618 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf2
);
619 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf3
| 0x00000004);
620 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf4
);
624 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf1
);
625 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf2
);
626 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf3
& ~0x00000004);
627 rt61pci_rf_write(rt2x00dev
, rt2x00dev
->rf4
);
630 static void rt61pci_config_antenna(struct rt2x00_dev
*rt2x00dev
,
631 const int antenna_tx
, const int antenna_rx
)
638 rt2x00pci_register_read(rt2x00dev
, PHY_CSR0
, ®
);
640 if (rt2x00dev
->curr_hwmode
== HWMODE_A
) {
641 if (test_bit(CONFIG_EXTERNAL_LNA_A
, &rt2x00dev
->flags
)) {
642 rt61pci_bbp_write(rt2x00dev
, 17, 0x38);
643 rt61pci_bbp_write(rt2x00dev
, 96, 0x78);
644 rt61pci_bbp_write(rt2x00dev
, 104, 0x48);
645 rt61pci_bbp_write(rt2x00dev
, 75, 0x80);
646 rt61pci_bbp_write(rt2x00dev
, 86, 0x80);
647 rt61pci_bbp_write(rt2x00dev
, 88, 0x80);
649 rt61pci_bbp_write(rt2x00dev
, 17, 0x28);
650 rt61pci_bbp_write(rt2x00dev
, 96, 0x58);
651 rt61pci_bbp_write(rt2x00dev
, 104, 0x38);
652 rt61pci_bbp_write(rt2x00dev
, 75, 0xfe);
653 rt61pci_bbp_write(rt2x00dev
, 86, 0xfe);
654 rt61pci_bbp_write(rt2x00dev
, 88, 0xfe);
656 rt61pci_bbp_write(rt2x00dev
, 35, 0x60);
657 rt61pci_bbp_write(rt2x00dev
, 97, 0x58);
658 rt61pci_bbp_write(rt2x00dev
, 98, 0x58);
660 rt2x00_set_field32(®
, PHY_CSR0_PA_PE_BG
, 0);
661 rt2x00_set_field32(®
, PHY_CSR0_PA_PE_A
, 1);
663 if (test_bit(CONFIG_EXTERNAL_LNA_BG
, &rt2x00dev
->flags
)) {
664 rt61pci_bbp_write(rt2x00dev
, 17, 0x30);
665 rt61pci_bbp_write(rt2x00dev
, 96, 0x68);
666 rt61pci_bbp_write(rt2x00dev
, 104, 0x3c);
667 rt61pci_bbp_write(rt2x00dev
, 75, 0x80);
668 rt61pci_bbp_write(rt2x00dev
, 86, 0x80);
669 rt61pci_bbp_write(rt2x00dev
, 88, 0x80);
671 rt61pci_bbp_write(rt2x00dev
, 17, 0x20);
672 rt61pci_bbp_write(rt2x00dev
, 96, 0x48);
673 rt61pci_bbp_write(rt2x00dev
, 104, 0x2c);
674 rt61pci_bbp_write(rt2x00dev
, 75, 0xfe);
675 rt61pci_bbp_write(rt2x00dev
, 86, 0xfe);
676 rt61pci_bbp_write(rt2x00dev
, 88, 0xfe);
678 rt61pci_bbp_write(rt2x00dev
, 35, 0x50);
679 rt61pci_bbp_write(rt2x00dev
, 97, 0x48);
680 rt61pci_bbp_write(rt2x00dev
, 98, 0x48);
682 rt2x00_set_field32(®
, PHY_CSR0_PA_PE_BG
, 1);
683 rt2x00_set_field32(®
, PHY_CSR0_PA_PE_A
, 0);
686 rt2x00pci_register_write(rt2x00dev
, PHY_CSR0
, reg
);
688 rt61pci_bbp_read(rt2x00dev
, 3, &r3
);
689 rt61pci_bbp_read(rt2x00dev
, 4, &r4
);
690 rt61pci_bbp_read(rt2x00dev
, 77, &r77
);
692 if (rt2x00_rf(&rt2x00dev
->chip
, RF5225
) ||
693 rt2x00_rf(&rt2x00dev
->chip
, RF2527
))
694 rt2x00_set_field8(&r3
, BBP_R3_SMART_MODE
, 0);
696 if (rt2x00_rf(&rt2x00dev
->chip
, RF5225
) ||
697 rt2x00_rf(&rt2x00dev
->chip
, RF5325
)) {
698 if (antenna_rx
== ANTENNA_DIVERSITY
) {
699 rt2x00_set_field8(&r4
, BBP_R4_RX_ANTENNA
, 2);
700 if (rt2x00dev
->curr_hwmode
!= HWMODE_A
)
701 rt2x00_set_field8(&r4
, BBP_R4_RX_BG_MODE
, 1);
702 } else if (antenna_rx
== ANTENNA_A
) {
703 rt2x00_set_field8(&r4
, BBP_R4_RX_ANTENNA
, 1);
704 if (rt2x00dev
->curr_hwmode
== HWMODE_A
)
705 rt2x00_set_field8(&r77
, BBP_R77_PAIR
, 0);
707 rt2x00_set_field8(&r77
, BBP_R77_PAIR
, 3);
708 rt61pci_bbp_write(rt2x00dev
, 77, r77
);
709 } else if (antenna_rx
== ANTENNA_B
) {
710 rt2x00_set_field8(&r4
, BBP_R4_RX_ANTENNA
, 1);
711 if (rt2x00dev
->curr_hwmode
== HWMODE_A
)
712 rt2x00_set_field8(&r77
, BBP_R77_PAIR
, 3);
714 rt2x00_set_field8(&r77
, BBP_R77_PAIR
, 0);
715 rt61pci_bbp_write(rt2x00dev
, 77, r77
);
717 } else if (rt2x00_rf(&rt2x00dev
->chip
, RF2527
) ||
718 (rt2x00_rf(&rt2x00dev
->chip
, RF2529
) &&
719 test_bit(CONFIG_DOUBLE_ANTENNA
, &rt2x00dev
->flags
))) {
720 if (antenna_rx
== ANTENNA_DIVERSITY
) {
721 rt2x00_set_field8(&r4
, BBP_R4_RX_ANTENNA
, 2);
722 rt2x00_set_field8(&r4
, BBP_R4_RX_BG_MODE
, 1);
723 rt2x00_set_field8(&r4
, BBP_R4_RX_FRAME_END
,
724 test_bit(CONFIG_FRAME_TYPE
, &rt2x00dev
->flags
));
725 } else if (antenna_rx
== ANTENNA_A
) {
726 rt2x00_set_field8(&r4
, BBP_R4_RX_ANTENNA
, 1);
727 rt2x00_set_field8(&r4
, BBP_R4_RX_BG_MODE
, 1);
728 rt2x00_set_field8(&r4
, BBP_R4_RX_FRAME_END
,
729 test_bit(CONFIG_FRAME_TYPE
, &rt2x00dev
->flags
));
730 rt2x00_set_field8(&r77
, BBP_R77_PAIR
, 3);
731 rt61pci_bbp_write(rt2x00dev
, 77, r77
);
732 } else if (antenna_rx
== ANTENNA_B
) {
733 rt2x00_set_field8(&r4
, BBP_R4_RX_ANTENNA
, 1);
734 rt2x00_set_field8(&r4
, BBP_R4_RX_BG_MODE
, 1);
735 rt2x00_set_field8(&r4
, BBP_R4_RX_FRAME_END
,
736 test_bit(CONFIG_FRAME_TYPE
, &rt2x00dev
->flags
));
737 rt2x00_set_field8(&r77
, BBP_R77_PAIR
, 0);
738 rt61pci_bbp_write(rt2x00dev
, 77, r77
);
743 * TODO: RF2529 with another antenna value then 2 are ignored.
744 * The legacy driver is unclear whether in those cases there is
745 * a possibility to switch antenna.
748 rt61pci_bbp_write(rt2x00dev
, 3, r3
);
749 rt61pci_bbp_write(rt2x00dev
, 4, r4
);
752 static void rt61pci_config_duration(struct rt2x00_dev
*rt2x00dev
,
753 const int short_slot_time
, const int beacon_int
)
757 rt2x00pci_register_read(rt2x00dev
, MAC_CSR9
, ®
);
758 rt2x00_set_field32(®
, MAC_CSR9_SLOT_TIME
,
759 short_slot_time
? SHORT_SLOT_TIME
: SLOT_TIME
);
760 rt2x00pci_register_write(rt2x00dev
, MAC_CSR9
, reg
);
762 rt2x00pci_register_read(rt2x00dev
, MAC_CSR8
, ®
);
763 rt2x00_set_field32(®
, MAC_CSR8_SIFS
, SIFS
);
764 rt2x00_set_field32(®
, MAC_CSR8_SIFS_AFTER_RX_OFDM
, 3);
765 rt2x00_set_field32(®
, MAC_CSR8_EIFS
, EIFS
);
766 rt2x00pci_register_write(rt2x00dev
, MAC_CSR8
, reg
);
768 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR0
, ®
);
769 rt2x00_set_field32(®
, TXRX_CSR0_TSF_OFFSET
, IEEE80211_HEADER
);
770 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR0
, reg
);
772 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR4
, ®
);
773 rt2x00_set_field32(®
, TXRX_CSR4_AUTORESPOND_ENABLE
, 1);
774 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR4
, reg
);
776 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR9
, ®
);
777 rt2x00_set_field32(®
, TXRX_CSR9_BEACON_INTERVAL
, beacon_int
* 16);
778 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR9
, reg
);
781 static void rt61pci_config_rate(struct rt2x00_dev
*rt2x00dev
, const int rate
)
783 struct ieee80211_conf
*conf
= &rt2x00dev
->hw
->conf
;
788 preamble
= DEVICE_GET_RATE_FIELD(rate
, PREAMBLE
)
789 ? SHORT_PREAMBLE
: PREAMBLE
;
792 * Extract the allowed ratemask from the device specific rate value,
793 * We need to set TXRX_CSR5 to the basic rate mask so we need to mask
794 * off the non-basic rates.
796 reg
= DEVICE_GET_RATE_FIELD(rate
, RATEMASK
) & DEV_BASIC_RATE
;
798 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR5
, reg
);
800 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR0
, ®
);
801 value
= ((conf
->flags
& IEEE80211_CONF_SHORT_SLOT_TIME
) ?
803 PLCP
+ preamble
+ get_duration(ACK_SIZE
, 10);
804 rt2x00_set_field32(®
, TXRX_CSR0_RX_ACK_TIMEOUT
, value
);
805 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR0
, reg
);
807 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR4
, ®
);
808 if (preamble
== SHORT_PREAMBLE
)
809 rt2x00_set_field32(®
, TXRX_CSR4_AUTORESPOND_PREAMBLE
, 1);
811 rt2x00_set_field32(®
, TXRX_CSR4_AUTORESPOND_PREAMBLE
, 0);
812 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR4
, reg
);
815 static void rt61pci_config_phymode(struct rt2x00_dev
*rt2x00dev
,
818 struct ieee80211_hw_mode
*mode
;
819 struct ieee80211_rate
*rate
;
821 if (phymode
== MODE_IEEE80211A
)
822 rt2x00dev
->curr_hwmode
= HWMODE_A
;
823 else if (phymode
== MODE_IEEE80211B
)
824 rt2x00dev
->curr_hwmode
= HWMODE_B
;
826 rt2x00dev
->curr_hwmode
= HWMODE_G
;
828 mode
= &rt2x00dev
->hwmodes
[rt2x00dev
->curr_hwmode
];
829 rate
= &mode
->rates
[mode
->num_rates
- 1];
831 rt61pci_config_rate(rt2x00dev
, rate
->val2
);
834 static void rt61pci_config_mac_addr(struct rt2x00_dev
*rt2x00dev
, u8
*addr
)
838 memset(®
, 0, sizeof(reg
));
839 memcpy(®
, addr
, ETH_ALEN
);
841 rt2x00_set_field32(®
[1], MAC_CSR3_UNICAST_TO_ME_MASK
, 0xff);
844 * The MAC address is passed to us as an array of bytes,
845 * that array is little endian, so no need for byte ordering.
847 rt2x00pci_register_multiwrite(rt2x00dev
, MAC_CSR2
, ®
, sizeof(reg
));
853 static void rt61pci_enable_led(struct rt2x00_dev
*rt2x00dev
)
860 rt2x00pci_register_read(rt2x00dev
, MAC_CSR14
, ®
);
861 rt2x00_set_field32(®
, MAC_CSR14_ON_PERIOD
, 70);
862 rt2x00_set_field32(®
, MAC_CSR14_OFF_PERIOD
, 30);
863 rt2x00pci_register_write(rt2x00dev
, MAC_CSR14
, reg
);
865 led_reg
= rt2x00dev
->led_reg
;
866 rt2x00_set_field16(&led_reg
, MCU_LEDCS_RADIO_STATUS
, 1);
867 if (rt2x00dev
->rx_status
.phymode
== MODE_IEEE80211A
)
868 rt2x00_set_field16(&led_reg
, MCU_LEDCS_LINK_A_STATUS
, 1);
870 rt2x00_set_field16(&led_reg
, MCU_LEDCS_LINK_BG_STATUS
, 1);
872 arg0
= led_reg
& 0xff;
873 arg1
= (led_reg
>> 8) & 0xff;
875 rt61pci_mcu_request(rt2x00dev
, MCU_LED
, 0xff, arg0
, arg1
);
878 static void rt61pci_disable_led(struct rt2x00_dev
*rt2x00dev
)
884 led_reg
= rt2x00dev
->led_reg
;
885 rt2x00_set_field16(&led_reg
, MCU_LEDCS_RADIO_STATUS
, 0);
886 rt2x00_set_field16(&led_reg
, MCU_LEDCS_LINK_BG_STATUS
, 0);
887 rt2x00_set_field16(&led_reg
, MCU_LEDCS_LINK_A_STATUS
, 0);
889 arg0
= led_reg
& 0xff;
890 arg1
= (led_reg
>> 8) & 0xff;
892 rt61pci_mcu_request(rt2x00dev
, MCU_LED
, 0xff, arg0
, arg1
);
895 static void rt61pci_activity_led(struct rt2x00_dev
*rt2x00dev
, int rssi
)
899 if (rt2x00dev
->led_mode
!= LED_MODE_SIGNAL_STRENGTH
)
903 * Led handling requires a positive value for the rssi,
904 * to do that correctly we need to add the correction.
906 rssi
+= rt2x00dev
->rssi_offset
;
921 rt61pci_mcu_request(rt2x00dev
, MCU_LED_STRENGTH
, 0xff, led
, 0);
927 static void rt61pci_link_tuner(struct rt2x00_dev
*rt2x00dev
)
929 int rssi
= rt2x00_get_link_rssi(&rt2x00dev
->link
);
936 * Update Led strength
938 rt61pci_activity_led(rt2x00dev
, rssi
);
940 rt61pci_bbp_read(rt2x00dev
, 17, &r17
);
943 * Determine r17 bounds.
945 if (rt2x00dev
->rx_status
.phymode
== MODE_IEEE80211A
) {
948 if (test_bit(CONFIG_EXTERNAL_LNA_A
, &rt2x00dev
->flags
)) {
955 if (test_bit(CONFIG_EXTERNAL_LNA_BG
, &rt2x00dev
->flags
)) {
962 * Special big-R17 for very short distance
966 rt61pci_bbp_write(rt2x00dev
, 17, 0x60);
971 * Special big-R17 for short distance
975 rt61pci_bbp_write(rt2x00dev
, 17, up_bound
);
980 * Special big-R17 for middle-short distance
984 if (r17
!= low_bound
)
985 rt61pci_bbp_write(rt2x00dev
, 17, low_bound
);
990 * Special mid-R17 for middle distance
994 if (r17
!= low_bound
)
995 rt61pci_bbp_write(rt2x00dev
, 17, low_bound
);
1000 * Special case: Change up_bound based on the rssi.
1001 * Lower up_bound when rssi is weaker then -74 dBm.
1003 up_bound
-= 2 * (-74 - rssi
);
1004 if (low_bound
> up_bound
)
1005 up_bound
= low_bound
;
1007 if (r17
> up_bound
) {
1008 rt61pci_bbp_write(rt2x00dev
, 17, up_bound
);
1013 * r17 does not yet exceed upper limit, continue and base
1014 * the r17 tuning on the false CCA count.
1016 rt2x00pci_register_read(rt2x00dev
, STA_CSR1
, ®
);
1017 rt2x00dev
->link
.false_cca
=
1018 rt2x00_get_field32(reg
, STA_CSR1_FALSE_CCA_ERROR
);
1020 if (rt2x00dev
->link
.false_cca
> 512 && r17
< up_bound
) {
1021 if (++r17
> up_bound
)
1023 rt61pci_bbp_write(rt2x00dev
, 17, r17
);
1024 rt2x00dev
->rx_status
.noise
= r17
;
1025 } else if (rt2x00dev
->link
.false_cca
< 100 && r17
> low_bound
) {
1026 if (--r17
< low_bound
)
1028 rt61pci_bbp_write(rt2x00dev
, 17, r17
);
1029 rt2x00dev
->rx_status
.noise
= r17
;
1034 * Firmware name function.
1036 static char *rt61pci_get_fw_name(struct rt2x00_dev
*rt2x00dev
)
1040 switch (rt2x00dev
->chip
.rt
) {
1042 fw_name
= FIRMWARE_RT2561
;
1045 fw_name
= FIRMWARE_RT2561s
;
1048 fw_name
= FIRMWARE_RT2661
;
1059 * Initialization functions.
1061 static int rt61pci_load_firmware(struct rt2x00_dev
*rt2x00dev
, void *data
,
1068 * Wait for stable hardware.
1070 for (i
= 0; i
< 100; i
++) {
1071 rt2x00pci_register_read(rt2x00dev
, MAC_CSR0
, ®
);
1078 ERROR(rt2x00dev
, "Unstable hardware.\n");
1083 * Prepare MCU and mailbox for firmware loading.
1086 rt2x00_set_field32(®
, MCU_CNTL_CSR_RESET
, 1);
1087 rt2x00pci_register_write(rt2x00dev
, MCU_CNTL_CSR
, reg
);
1088 rt2x00pci_register_write(rt2x00dev
, M2H_CMD_DONE_CSR
, 0xffffffff);
1089 rt2x00pci_register_write(rt2x00dev
, H2M_MAILBOX_CSR
, 0);
1090 rt2x00pci_register_write(rt2x00dev
, HOST_CMD_CSR
, 0);
1093 * Write firmware to device.
1096 rt2x00_set_field32(®
, MCU_CNTL_CSR_RESET
, 1);
1097 rt2x00_set_field32(®
, MCU_CNTL_CSR_SELECT_BANK
, 1);
1098 rt2x00pci_register_write(rt2x00dev
, MCU_CNTL_CSR
, reg
);
1100 rt2x00pci_register_multiwrite(
1101 rt2x00dev
, FIRMWARE_IMAGE_BASE
, data
, len
);
1103 rt2x00_set_field32(®
, MCU_CNTL_CSR_SELECT_BANK
, 0);
1104 rt2x00pci_register_write(rt2x00dev
, MCU_CNTL_CSR
, reg
);
1106 rt2x00_set_field32(®
, MCU_CNTL_CSR_RESET
, 0);
1107 rt2x00pci_register_write(rt2x00dev
, MCU_CNTL_CSR
, reg
);
1109 for (i
= 0; i
< 100; i
++) {
1110 rt2x00pci_register_read(rt2x00dev
, MCU_CNTL_CSR
, ®
);
1111 if (rt2x00_get_field32(reg
, MCU_CNTL_CSR_READY
))
1117 ERROR(rt2x00dev
, "MCU Control register not ready.\n");
1122 * Reset MAC and BBP registers.
1125 rt2x00_set_field32(®
, MAC_CSR1_SOFT_RESET
, 1);
1126 rt2x00_set_field32(®
, MAC_CSR1_BBP_RESET
, 1);
1127 rt2x00pci_register_write(rt2x00dev
, MAC_CSR1
, reg
);
1129 rt2x00pci_register_read(rt2x00dev
, MAC_CSR1
, ®
);
1130 rt2x00_set_field32(®
, MAC_CSR1_SOFT_RESET
, 0);
1131 rt2x00_set_field32(®
, MAC_CSR1_BBP_RESET
, 0);
1132 rt2x00pci_register_write(rt2x00dev
, MAC_CSR1
, reg
);
1134 rt2x00pci_register_read(rt2x00dev
, MAC_CSR1
, ®
);
1135 rt2x00_set_field32(®
, MAC_CSR1_HOST_READY
, 1);
1136 rt2x00pci_register_write(rt2x00dev
, MAC_CSR1
, reg
);
1141 static void rt61pci_init_rxring(struct rt2x00_dev
*rt2x00dev
)
1143 struct data_desc
*rxd
;
1147 memset(rt2x00dev
->rx
->data_addr
, 0x00,
1148 rt2x00_get_ring_size(rt2x00dev
->rx
));
1150 for (i
= 0; i
< rt2x00dev
->rx
->stats
.limit
; i
++) {
1151 rxd
= rt2x00dev
->rx
->entry
[i
].priv
;
1153 rt2x00_desc_read(rxd
, 5, &word
);
1154 rt2x00_set_field32(&word
, RXD_W5_BUFFER_PHYSICAL_ADDRESS
,
1155 rt2x00dev
->rx
->entry
[i
].data_dma
);
1156 rt2x00_desc_write(rxd
, 5, word
);
1158 rt2x00_desc_read(rxd
, 0, &word
);
1159 rt2x00_set_field32(&word
, RXD_W0_OWNER_NIC
, 1);
1160 rt2x00_desc_write(rxd
, 0, word
);
1163 rt2x00_ring_index_clear(rt2x00dev
->rx
);
1166 static void rt61pci_init_txring(struct rt2x00_dev
*rt2x00dev
,
1169 struct data_ring
*ring
= rt2x00_get_ring(rt2x00dev
, queue
);
1170 struct data_desc
*txd
;
1174 memset(ring
->data_addr
, 0x00, rt2x00_get_ring_size(ring
));
1176 for (i
= 0; i
< ring
->stats
.limit
; i
++) {
1177 txd
= ring
->entry
[i
].priv
;
1179 rt2x00_desc_read(txd
, 1, &word
);
1180 rt2x00_set_field32(&word
, TXD_W1_BUFFER_COUNT
, 1);
1181 rt2x00_desc_write(txd
, 1, word
);
1183 rt2x00_desc_read(txd
, 5, &word
);
1184 rt2x00_set_field32(&word
, TXD_W5_PID_TYPE
, queue
);
1185 rt2x00_set_field32(&word
, TXD_W5_PID_SUBTYPE
, i
);
1186 rt2x00_desc_write(txd
, 5, word
);
1188 rt2x00_desc_read(txd
, 6, &word
);
1189 rt2x00_set_field32(&word
, TXD_W6_BUFFER_PHYSICAL_ADDRESS
,
1190 ring
->entry
[i
].data_dma
);
1191 rt2x00_desc_write(txd
, 6, word
);
1193 rt2x00_desc_read(txd
, 0, &word
);
1194 rt2x00_set_field32(&word
, TXD_W0_VALID
, 0);
1195 rt2x00_set_field32(&word
, TXD_W0_OWNER_NIC
, 0);
1196 rt2x00_desc_write(txd
, 0, word
);
1199 rt2x00_ring_index_clear(ring
);
1202 static int rt61pci_init_rings(struct rt2x00_dev
*rt2x00dev
)
1209 rt61pci_init_rxring(rt2x00dev
);
1210 rt61pci_init_txring(rt2x00dev
, IEEE80211_TX_QUEUE_DATA0
);
1211 rt61pci_init_txring(rt2x00dev
, IEEE80211_TX_QUEUE_DATA1
);
1212 rt61pci_init_txring(rt2x00dev
, IEEE80211_TX_QUEUE_DATA2
);
1213 rt61pci_init_txring(rt2x00dev
, IEEE80211_TX_QUEUE_DATA3
);
1214 rt61pci_init_txring(rt2x00dev
, IEEE80211_TX_QUEUE_DATA4
);
1215 rt61pci_init_txring(rt2x00dev
, IEEE80211_TX_QUEUE_BEACON
);
1218 * Initialize registers.
1220 rt2x00pci_register_read(rt2x00dev
, TX_RING_CSR0
, ®
);
1221 rt2x00_set_field32(®
, TX_RING_CSR0_AC0_RING_SIZE
,
1222 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA0
].stats
.limit
);
1223 rt2x00_set_field32(®
, TX_RING_CSR0_AC1_RING_SIZE
,
1224 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA1
].stats
.limit
);
1225 rt2x00_set_field32(®
, TX_RING_CSR0_AC2_RING_SIZE
,
1226 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA2
].stats
.limit
);
1227 rt2x00_set_field32(®
, TX_RING_CSR0_AC3_RING_SIZE
,
1228 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA3
].stats
.limit
);
1229 rt2x00pci_register_write(rt2x00dev
, TX_RING_CSR0
, reg
);
1231 rt2x00pci_register_read(rt2x00dev
, TX_RING_CSR1
, ®
);
1232 rt2x00_set_field32(®
, TX_RING_CSR1_MGMT_RING_SIZE
,
1233 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA4
].stats
.limit
);
1234 rt2x00_set_field32(®
, TX_RING_CSR1_TXD_SIZE
,
1235 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA0
].desc_size
/ 4);
1236 rt2x00pci_register_write(rt2x00dev
, TX_RING_CSR1
, reg
);
1238 rt2x00pci_register_read(rt2x00dev
, AC0_BASE_CSR
, ®
);
1239 rt2x00_set_field32(®
, AC0_BASE_CSR_RING_REGISTER
,
1240 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA0
].data_dma
);
1241 rt2x00pci_register_write(rt2x00dev
, AC0_BASE_CSR
, reg
);
1243 rt2x00pci_register_read(rt2x00dev
, AC1_BASE_CSR
, ®
);
1244 rt2x00_set_field32(®
, AC1_BASE_CSR_RING_REGISTER
,
1245 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA1
].data_dma
);
1246 rt2x00pci_register_write(rt2x00dev
, AC1_BASE_CSR
, reg
);
1248 rt2x00pci_register_read(rt2x00dev
, AC2_BASE_CSR
, ®
);
1249 rt2x00_set_field32(®
, AC2_BASE_CSR_RING_REGISTER
,
1250 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA2
].data_dma
);
1251 rt2x00pci_register_write(rt2x00dev
, AC2_BASE_CSR
, reg
);
1253 rt2x00pci_register_read(rt2x00dev
, AC3_BASE_CSR
, ®
);
1254 rt2x00_set_field32(®
, AC3_BASE_CSR_RING_REGISTER
,
1255 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA3
].data_dma
);
1256 rt2x00pci_register_write(rt2x00dev
, AC3_BASE_CSR
, reg
);
1258 rt2x00pci_register_read(rt2x00dev
, MGMT_BASE_CSR
, ®
);
1259 rt2x00_set_field32(®
, MGMT_BASE_CSR_RING_REGISTER
,
1260 rt2x00dev
->tx
[IEEE80211_TX_QUEUE_DATA4
].data_dma
);
1261 rt2x00pci_register_write(rt2x00dev
, MGMT_BASE_CSR
, reg
);
1263 rt2x00pci_register_read(rt2x00dev
, RX_RING_CSR
, ®
);
1264 rt2x00_set_field32(®
, RX_RING_CSR_RING_SIZE
,
1265 rt2x00dev
->rx
->stats
.limit
);
1266 rt2x00_set_field32(®
, RX_RING_CSR_RXD_SIZE
,
1267 rt2x00dev
->rx
->desc_size
/ 4);
1268 rt2x00_set_field32(®
, RX_RING_CSR_RXD_WRITEBACK_SIZE
, 4);
1269 rt2x00pci_register_write(rt2x00dev
, RX_RING_CSR
, reg
);
1271 rt2x00pci_register_read(rt2x00dev
, RX_BASE_CSR
, ®
);
1272 rt2x00_set_field32(®
, RX_BASE_CSR_RING_REGISTER
,
1273 rt2x00dev
->rx
->data_dma
);
1274 rt2x00pci_register_write(rt2x00dev
, RX_BASE_CSR
, reg
);
1276 rt2x00pci_register_write(rt2x00dev
, TX_DMA_DST_CSR
, 0x000000aa);
1277 rt2x00pci_register_write(rt2x00dev
, LOAD_TX_RING_CSR
, 0x0000001f);
1278 rt2x00pci_register_write(rt2x00dev
, RX_CNTL_CSR
, 0x00000002);
1283 static int rt61pci_init_registers(struct rt2x00_dev
*rt2x00dev
)
1287 if (rt2x00dev
->ops
->lib
->set_device_state(rt2x00dev
, STATE_AWAKE
))
1290 rt2x00pci_register_write(rt2x00dev
, MAC_CSR10
, 0x00000718);
1292 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR0
, ®
);
1293 rt2x00_set_field32(®
, TXRX_CSR0_AUTO_TX_SEQ
, 1);
1294 rt2x00_set_field32(®
, TXRX_CSR0_DISABLE_RX
, 1);
1295 rt2x00_set_field32(®
, TXRX_CSR0_DROP_ACK_CTS
, 1);
1296 rt2x00_set_field32(®
, TXRX_CSR0_TX_WITHOUT_WAITING
, 0);
1297 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR0
, reg
);
1299 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR1
, 0x9eb39eb3);
1300 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR2
, 0x8a8b8c8d);
1301 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR3
, 0x00858687);
1303 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR7
, 0x2e31353b);
1304 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR8
, 0x2a2a2a2c);
1306 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR15
, 0x0000000f);
1308 rt2x00pci_register_write(rt2x00dev
, MAC_CSR6
, 0x00000fff);
1310 rt2x00pci_register_write(rt2x00dev
, MAC_CSR13
, 0x0000e000);
1312 rt2x00pci_register_write(rt2x00dev
, SEC_CSR0
, 0x00000000);
1313 rt2x00pci_register_write(rt2x00dev
, SEC_CSR1
, 0x00000000);
1314 rt2x00pci_register_write(rt2x00dev
, SEC_CSR5
, 0x00000000);
1316 rt2x00pci_register_read(rt2x00dev
, AC_TXOP_CSR0
, ®
);
1317 rt2x00_set_field32(®
, AC_TXOP_CSR0_AC0_TX_OP
, 0);
1318 rt2x00_set_field32(®
, AC_TXOP_CSR0_AC1_TX_OP
, 0);
1319 rt2x00pci_register_write(rt2x00dev
, AC_TXOP_CSR0
, reg
);
1321 rt2x00pci_register_read(rt2x00dev
, AC_TXOP_CSR1
, ®
);
1322 rt2x00_set_field32(®
, AC_TXOP_CSR1_AC2_TX_OP
, 192);
1323 rt2x00_set_field32(®
, AC_TXOP_CSR1_AC3_TX_OP
, 48);
1324 rt2x00pci_register_write(rt2x00dev
, AC_TXOP_CSR1
, reg
);
1326 rt2x00pci_register_read(rt2x00dev
, MAC_CSR9
, ®
);
1327 rt2x00_set_field32(®
, MAC_CSR9_CW_SELECT
, 0);
1328 rt2x00pci_register_write(rt2x00dev
, MAC_CSR9
, reg
);
1330 rt2x00pci_register_write(rt2x00dev
, PHY_CSR1
, 0x000023b0);
1331 rt2x00pci_register_write(rt2x00dev
, PHY_CSR5
, 0x060a100c);
1332 rt2x00pci_register_write(rt2x00dev
, PHY_CSR6
, 0x00080606);
1333 rt2x00pci_register_write(rt2x00dev
, PHY_CSR7
, 0x00000a08);
1335 rt2x00pci_register_write(rt2x00dev
, PCI_CFG_CSR
, 0x28ca4404);
1337 rt2x00pci_register_write(rt2x00dev
, TEST_MODE_CSR
, 0x00000200);
1339 rt2x00pci_register_write(rt2x00dev
, M2H_CMD_DONE_CSR
, 0xffffffff);
1342 * We must clear the error counters.
1343 * These registers are cleared on read,
1344 * so we may pass a useless variable to store the value.
1346 rt2x00pci_register_read(rt2x00dev
, STA_CSR0
, ®
);
1347 rt2x00pci_register_read(rt2x00dev
, STA_CSR1
, ®
);
1348 rt2x00pci_register_read(rt2x00dev
, STA_CSR2
, ®
);
1351 * Reset MAC and BBP registers.
1354 rt2x00_set_field32(®
, MAC_CSR1_SOFT_RESET
, 1);
1355 rt2x00_set_field32(®
, MAC_CSR1_BBP_RESET
, 1);
1356 rt2x00pci_register_write(rt2x00dev
, MAC_CSR1
, reg
);
1358 rt2x00pci_register_read(rt2x00dev
, MAC_CSR1
, ®
);
1359 rt2x00_set_field32(®
, MAC_CSR1_SOFT_RESET
, 0);
1360 rt2x00_set_field32(®
, MAC_CSR1_BBP_RESET
, 0);
1361 rt2x00pci_register_write(rt2x00dev
, MAC_CSR1
, reg
);
1363 rt2x00pci_register_read(rt2x00dev
, MAC_CSR1
, ®
);
1364 rt2x00_set_field32(®
, MAC_CSR1_HOST_READY
, 1);
1365 rt2x00pci_register_write(rt2x00dev
, MAC_CSR1
, reg
);
1370 static int rt61pci_init_bbp(struct rt2x00_dev
*rt2x00dev
)
1377 for (i
= 0; i
< REGISTER_BUSY_COUNT
; i
++) {
1378 rt61pci_bbp_read(rt2x00dev
, 0, &value
);
1379 if ((value
!= 0xff) && (value
!= 0x00))
1380 goto continue_csr_init
;
1381 NOTICE(rt2x00dev
, "Waiting for BBP register.\n");
1382 udelay(REGISTER_BUSY_DELAY
);
1385 ERROR(rt2x00dev
, "BBP register access failed, aborting.\n");
1389 rt61pci_bbp_write(rt2x00dev
, 3, 0x00);
1390 rt61pci_bbp_write(rt2x00dev
, 15, 0x30);
1391 rt61pci_bbp_write(rt2x00dev
, 17, 0x20);
1392 rt61pci_bbp_write(rt2x00dev
, 21, 0xc8);
1393 rt61pci_bbp_write(rt2x00dev
, 22, 0x38);
1394 rt61pci_bbp_write(rt2x00dev
, 23, 0x06);
1395 rt61pci_bbp_write(rt2x00dev
, 24, 0xfe);
1396 rt61pci_bbp_write(rt2x00dev
, 25, 0x0a);
1397 rt61pci_bbp_write(rt2x00dev
, 26, 0x0d);
1398 rt61pci_bbp_write(rt2x00dev
, 34, 0x12);
1399 rt61pci_bbp_write(rt2x00dev
, 37, 0x07);
1400 rt61pci_bbp_write(rt2x00dev
, 39, 0xf8);
1401 rt61pci_bbp_write(rt2x00dev
, 41, 0x60);
1402 rt61pci_bbp_write(rt2x00dev
, 53, 0x10);
1403 rt61pci_bbp_write(rt2x00dev
, 54, 0x18);
1404 rt61pci_bbp_write(rt2x00dev
, 60, 0x10);
1405 rt61pci_bbp_write(rt2x00dev
, 61, 0x04);
1406 rt61pci_bbp_write(rt2x00dev
, 62, 0x04);
1407 rt61pci_bbp_write(rt2x00dev
, 75, 0xfe);
1408 rt61pci_bbp_write(rt2x00dev
, 86, 0xfe);
1409 rt61pci_bbp_write(rt2x00dev
, 88, 0xfe);
1410 rt61pci_bbp_write(rt2x00dev
, 90, 0x0f);
1411 rt61pci_bbp_write(rt2x00dev
, 99, 0x00);
1412 rt61pci_bbp_write(rt2x00dev
, 102, 0x16);
1413 rt61pci_bbp_write(rt2x00dev
, 107, 0x04);
1415 DEBUG(rt2x00dev
, "Start initialization from EEPROM...\n");
1416 for (i
= 0; i
< EEPROM_BBP_SIZE
; i
++) {
1417 rt2x00_eeprom_read(rt2x00dev
, EEPROM_BBP_START
+ i
, &eeprom
);
1419 if (eeprom
!= 0xffff && eeprom
!= 0x0000) {
1420 reg_id
= rt2x00_get_field16(eeprom
, EEPROM_BBP_REG_ID
);
1421 value
= rt2x00_get_field16(eeprom
, EEPROM_BBP_VALUE
);
1422 DEBUG(rt2x00dev
, "BBP: 0x%02x, value: 0x%02x.\n",
1424 rt61pci_bbp_write(rt2x00dev
, reg_id
, value
);
1427 DEBUG(rt2x00dev
, "...End initialization from EEPROM.\n");
1433 * Device state switch handlers.
1435 static void rt61pci_toggle_rx(struct rt2x00_dev
*rt2x00dev
,
1436 enum dev_state state
)
1440 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR0
, ®
);
1441 rt2x00_set_field32(®
, TXRX_CSR0_DISABLE_RX
,
1442 state
== STATE_RADIO_RX_OFF
);
1443 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR0
, reg
);
1446 static void rt61pci_toggle_irq(struct rt2x00_dev
*rt2x00dev
, int enabled
)
1451 * When interrupts are being enabled, the interrupt registers
1452 * should clear the register to assure a clean state.
1455 rt2x00pci_register_read(rt2x00dev
, INT_SOURCE_CSR
, ®
);
1456 rt2x00pci_register_write(rt2x00dev
, INT_SOURCE_CSR
, reg
);
1458 rt2x00pci_register_read(rt2x00dev
, MCU_INT_SOURCE_CSR
, ®
);
1459 rt2x00pci_register_write(rt2x00dev
, MCU_INT_SOURCE_CSR
, reg
);
1463 * Only toggle the interrupts bits we are going to use.
1464 * Non-checked interrupt bits are disabled by default.
1466 rt2x00pci_register_read(rt2x00dev
, INT_MASK_CSR
, ®
);
1467 rt2x00_set_field32(®
, INT_MASK_CSR_TXDONE
, !enabled
);
1468 rt2x00_set_field32(®
, INT_MASK_CSR_RXDONE
, !enabled
);
1469 rt2x00_set_field32(®
, INT_MASK_CSR_BEACON_DONE
, !enabled
);
1470 rt2x00_set_field32(®
, INT_MASK_CSR_ENABLE_MITIGATION
, !enabled
);
1471 rt2x00_set_field32(®
, INT_MASK_CSR_MITIGATION_PERIOD
, 0xff);
1472 rt2x00pci_register_write(rt2x00dev
, INT_MASK_CSR
, reg
);
1474 rt2x00pci_register_read(rt2x00dev
, MCU_INT_MASK_CSR
, ®
);
1475 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_0
, !enabled
);
1476 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_1
, !enabled
);
1477 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_2
, !enabled
);
1478 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_3
, !enabled
);
1479 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_4
, !enabled
);
1480 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_5
, !enabled
);
1481 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_6
, !enabled
);
1482 rt2x00_set_field32(®
, MCU_INT_MASK_CSR_7
, !enabled
);
1483 rt2x00pci_register_write(rt2x00dev
, MCU_INT_MASK_CSR
, reg
);
1486 static int rt61pci_enable_radio(struct rt2x00_dev
*rt2x00dev
)
1489 * Initialize all registers.
1491 if (rt61pci_init_rings(rt2x00dev
) ||
1492 rt61pci_init_registers(rt2x00dev
) ||
1493 rt61pci_init_bbp(rt2x00dev
)) {
1494 ERROR(rt2x00dev
, "Register initialization failed.\n");
1499 * Enable interrupts.
1501 rt61pci_toggle_irq(rt2x00dev
, 1);
1506 rt2x00pci_register_write(rt2x00dev
, RX_CNTL_CSR
, 0x00000001);
1511 rt61pci_enable_led(rt2x00dev
);
1516 static void rt61pci_disable_radio(struct rt2x00_dev
*rt2x00dev
)
1523 rt61pci_disable_led(rt2x00dev
);
1525 rt2x00pci_register_write(rt2x00dev
, MAC_CSR10
, 0x00001818);
1528 * Disable synchronisation.
1530 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR9
, 0);
1535 rt2x00pci_register_read(rt2x00dev
, TX_CNTL_CSR
, ®
);
1536 rt2x00_set_field32(®
, TX_CNTL_CSR_ABORT_TX_AC0
, 1);
1537 rt2x00_set_field32(®
, TX_CNTL_CSR_ABORT_TX_AC1
, 1);
1538 rt2x00_set_field32(®
, TX_CNTL_CSR_ABORT_TX_AC2
, 1);
1539 rt2x00_set_field32(®
, TX_CNTL_CSR_ABORT_TX_AC3
, 1);
1540 rt2x00_set_field32(®
, TX_CNTL_CSR_ABORT_TX_MGMT
, 1);
1541 rt2x00pci_register_write(rt2x00dev
, TX_CNTL_CSR
, reg
);
1544 * Disable interrupts.
1546 rt61pci_toggle_irq(rt2x00dev
, 0);
1549 static int rt61pci_set_state(struct rt2x00_dev
*rt2x00dev
,
1550 enum dev_state state
)
1557 put_to_sleep
= (state
!= STATE_AWAKE
);
1559 rt2x00pci_register_read(rt2x00dev
, MAC_CSR12
, ®
);
1560 rt2x00_set_field32(®
, MAC_CSR12_FORCE_WAKEUP
, !put_to_sleep
);
1561 rt2x00_set_field32(®
, MAC_CSR12_PUT_TO_SLEEP
, put_to_sleep
);
1562 rt2x00pci_register_write(rt2x00dev
, MAC_CSR12
, reg
);
1565 rt2x00pci_register_write(rt2x00dev
, SOFT_RESET_CSR
, 0x00000005);
1566 rt2x00pci_register_write(rt2x00dev
, IO_CNTL_CSR
, 0x0000001c);
1567 rt2x00pci_register_write(rt2x00dev
, PCI_USEC_CSR
, 0x00000060);
1568 rt61pci_mcu_request(rt2x00dev
, MCU_SLEEP
, 0xff, 0x00, 0x00);
1570 rt2x00pci_register_write(rt2x00dev
, SOFT_RESET_CSR
, 0x00000007);
1571 rt2x00pci_register_write(rt2x00dev
, IO_CNTL_CSR
, 0x00000018);
1572 rt2x00pci_register_write(rt2x00dev
, PCI_USEC_CSR
, 0x00000020);
1573 rt61pci_mcu_request(rt2x00dev
, MCU_WAKEUP
, 0xff, 0x00, 0x00);
1577 * Device is not guaranteed to be in the requested state yet.
1578 * We must wait until the register indicates that the
1579 * device has entered the correct state.
1581 for (i
= 0; i
< REGISTER_BUSY_COUNT
; i
++) {
1582 rt2x00pci_register_read(rt2x00dev
, MAC_CSR12
, ®
);
1583 current_state
= rt2x00_get_field32(reg
,
1584 MAC_CSR12_BBP_CURRENT_STATE
);
1585 if (current_state
== !put_to_sleep
)
1590 NOTICE(rt2x00dev
, "Device failed to enter state %d, "
1591 "current device state %d.\n", !put_to_sleep
, current_state
);
1596 static int rt61pci_set_device_state(struct rt2x00_dev
*rt2x00dev
,
1597 enum dev_state state
)
1602 case STATE_RADIO_ON
:
1603 retval
= rt61pci_enable_radio(rt2x00dev
);
1605 case STATE_RADIO_OFF
:
1606 rt61pci_disable_radio(rt2x00dev
);
1608 case STATE_RADIO_RX_ON
:
1609 case STATE_RADIO_RX_OFF
:
1610 rt61pci_toggle_rx(rt2x00dev
, state
);
1612 case STATE_DEEP_SLEEP
:
1616 retval
= rt61pci_set_state(rt2x00dev
, state
);
1627 * TX descriptor initialization
1629 static void rt61pci_write_tx_desc(struct rt2x00_dev
*rt2x00dev
,
1630 struct data_entry
*entry
, struct data_desc
*txd
,
1631 struct data_entry_desc
*desc
, struct ieee80211_hdr
*ieee80211hdr
,
1632 unsigned int length
, struct ieee80211_tx_control
*control
)
1637 * Start writing the descriptor words.
1639 rt2x00_desc_read(txd
, 1, &word
);
1640 rt2x00_set_field32(&word
, TXD_W1_HOST_Q_ID
, desc
->queue
);
1641 rt2x00_set_field32(&word
, TXD_W1_AIFSN
, entry
->ring
->tx_params
.aifs
);
1642 rt2x00_set_field32(&word
, TXD_W1_CWMIN
, entry
->ring
->tx_params
.cw_min
);
1643 rt2x00_set_field32(&word
, TXD_W1_CWMAX
, entry
->ring
->tx_params
.cw_max
);
1644 rt2x00_set_field32(&word
, TXD_W1_IV_OFFSET
, IEEE80211_HEADER
);
1645 rt2x00_set_field32(&word
, TXD_W1_HW_SEQUENCE
, 1);
1646 rt2x00_desc_write(txd
, 1, word
);
1648 rt2x00_desc_read(txd
, 2, &word
);
1649 rt2x00_set_field32(&word
, TXD_W2_PLCP_SIGNAL
, desc
->signal
);
1650 rt2x00_set_field32(&word
, TXD_W2_PLCP_SERVICE
, desc
->service
);
1651 rt2x00_set_field32(&word
, TXD_W2_PLCP_LENGTH_LOW
, desc
->length_low
);
1652 rt2x00_set_field32(&word
, TXD_W2_PLCP_LENGTH_HIGH
, desc
->length_high
);
1653 rt2x00_desc_write(txd
, 2, word
);
1655 rt2x00_desc_read(txd
, 5, &word
);
1656 rt2x00_set_field32(&word
, TXD_W5_TX_POWER
,
1657 TXPOWER_TO_DEV(control
->power_level
));
1658 rt2x00_set_field32(&word
, TXD_W5_WAITING_DMA_DONE_INT
, 1);
1659 rt2x00_desc_write(txd
, 5, word
);
1661 rt2x00_desc_read(txd
, 11, &word
);
1662 rt2x00_set_field32(&word
, TXD_W11_BUFFER_LENGTH0
, length
);
1663 rt2x00_desc_write(txd
, 11, word
);
1665 rt2x00_desc_read(txd
, 0, &word
);
1666 rt2x00_set_field32(&word
, TXD_W0_OWNER_NIC
, 1);
1667 rt2x00_set_field32(&word
, TXD_W0_VALID
, 1);
1668 rt2x00_set_field32(&word
, TXD_W0_MORE_FRAG
,
1669 test_bit(ENTRY_TXD_MORE_FRAG
, &entry
->flags
));
1670 rt2x00_set_field32(&word
, TXD_W0_ACK
,
1671 test_bit(ENTRY_TXD_REQ_ACK
, &entry
->flags
));
1672 rt2x00_set_field32(&word
, TXD_W0_TIMESTAMP
,
1673 test_bit(ENTRY_TXD_REQ_TIMESTAMP
, &entry
->flags
));
1674 rt2x00_set_field32(&word
, TXD_W0_OFDM
,
1675 test_bit(ENTRY_TXD_OFDM_RATE
, &entry
->flags
));
1676 rt2x00_set_field32(&word
, TXD_W0_IFS
, desc
->ifs
);
1677 rt2x00_set_field32(&word
, TXD_W0_RETRY_MODE
, 0);
1678 rt2x00_set_field32(&word
, TXD_W0_TKIP_MIC
, 0);
1679 rt2x00_set_field32(&word
, TXD_W0_DATABYTE_COUNT
, length
);
1680 rt2x00_set_field32(&word
, TXD_W0_CIPHER_ALG
, CIPHER_NONE
);
1681 rt2x00_desc_write(txd
, 0, word
);
1685 * TX data initialization
1687 static void rt61pci_kick_tx_queue(struct rt2x00_dev
*rt2x00dev
, int queue
)
1691 if (queue
== IEEE80211_TX_QUEUE_BEACON
) {
1692 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR9
, ®
);
1693 if (!rt2x00_get_field32(reg
, TXRX_CSR9_BEACON_GEN
)) {
1694 rt2x00_set_field32(®
, TXRX_CSR9_BEACON_GEN
, 1);
1695 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR9
, reg
);
1700 rt2x00pci_register_read(rt2x00dev
, TX_CNTL_CSR
, ®
);
1701 if (queue
== IEEE80211_TX_QUEUE_DATA0
)
1702 rt2x00_set_field32(®
, TX_CNTL_CSR_KICK_TX_AC0
, 1);
1703 else if (queue
== IEEE80211_TX_QUEUE_DATA1
)
1704 rt2x00_set_field32(®
, TX_CNTL_CSR_KICK_TX_AC1
, 1);
1705 else if (queue
== IEEE80211_TX_QUEUE_DATA2
)
1706 rt2x00_set_field32(®
, TX_CNTL_CSR_KICK_TX_AC2
, 1);
1707 else if (queue
== IEEE80211_TX_QUEUE_DATA3
)
1708 rt2x00_set_field32(®
, TX_CNTL_CSR_KICK_TX_AC3
, 1);
1709 else if (queue
== IEEE80211_TX_QUEUE_DATA4
)
1710 rt2x00_set_field32(®
, TX_CNTL_CSR_KICK_TX_MGMT
, 1);
1711 rt2x00pci_register_write(rt2x00dev
, TX_CNTL_CSR
, reg
);
1715 * RX control handlers
1717 static int rt61pci_agc_to_rssi(struct rt2x00_dev
*rt2x00dev
, int rxd_w1
)
1723 lna
= rt2x00_get_field32(rxd_w1
, RXD_W1_RSSI_LNA
);
1738 if (rt2x00dev
->rx_status
.phymode
== MODE_IEEE80211A
) {
1739 if (test_bit(CONFIG_EXTERNAL_LNA_A
, &rt2x00dev
->flags
))
1742 if (lna
== 3 || lna
== 2)
1745 rt2x00_eeprom_read(rt2x00dev
, EEPROM_RSSI_OFFSET_A
, &eeprom
);
1746 offset
-= rt2x00_get_field16(eeprom
, EEPROM_RSSI_OFFSET_A_1
);
1748 if (test_bit(CONFIG_EXTERNAL_LNA_BG
, &rt2x00dev
->flags
))
1751 rt2x00_eeprom_read(rt2x00dev
, EEPROM_RSSI_OFFSET_BG
, &eeprom
);
1752 offset
-= rt2x00_get_field16(eeprom
, EEPROM_RSSI_OFFSET_BG_1
);
1755 return rt2x00_get_field32(rxd_w1
, RXD_W1_RSSI_AGC
) * 2 - offset
;
1758 static int rt61pci_fill_rxdone(struct data_entry
*entry
,
1759 int *signal
, int *rssi
, int *ofdm
)
1761 struct data_desc
*rxd
= entry
->priv
;
1765 rt2x00_desc_read(rxd
, 0, &word0
);
1766 rt2x00_desc_read(rxd
, 1, &word1
);
1769 * TODO: Don't we need to keep statistics
1770 * updated about these errors?
1772 if (rt2x00_get_field32(word0
, RXD_W0_CRC
) ||
1773 rt2x00_get_field32(word0
, RXD_W0_CIPHER_ERROR
))
1777 * Obtain the status about this packet.
1779 *signal
= rt2x00_get_field32(word1
, RXD_W1_SIGNAL
);
1780 *rssi
= rt61pci_agc_to_rssi(entry
->ring
->rt2x00dev
, word1
);
1781 *ofdm
= rt2x00_get_field32(word0
, RXD_W0_OFDM
);
1783 return rt2x00_get_field32(word0
, RXD_W0_DATABYTE_COUNT
);
1787 * Interrupt functions.
1789 static void rt61pci_txdone(struct rt2x00_dev
*rt2x00dev
)
1791 struct data_ring
*ring
;
1792 struct data_entry
*entry
;
1793 struct data_desc
*txd
;
1801 rt2x00pci_register_read(rt2x00dev
, STA_CSR4
, ®
);
1802 if (!rt2x00_get_field32(reg
, STA_CSR4_VALID
))
1806 * Skip this entry when it contains an invalid
1807 * ring identication number.
1809 ring
= rt2x00_get_ring(rt2x00dev
,
1810 rt2x00_get_field32(reg
, STA_CSR4_PID_TYPE
));
1811 if (unlikely(!ring
))
1815 * Skip this entry when it contains an invalid
1818 index
= rt2x00_get_field32(reg
, STA_CSR4_PID_SUBTYPE
);
1819 if (unlikely(index
>= ring
->stats
.limit
))
1822 entry
= &ring
->entry
[index
];
1824 rt2x00_desc_read(txd
, 0, &word
);
1826 if (rt2x00_get_field32(word
, TXD_W0_OWNER_NIC
) ||
1827 !rt2x00_get_field32(word
, TXD_W0_VALID
))
1831 * Obtain the status about this packet.
1833 tx_status
= rt2x00_get_field32(reg
, STA_CSR4_TX_RESULT
);
1834 retry
= rt2x00_get_field32(reg
, STA_CSR4_RETRY_COUNT
);
1836 rt2x00lib_txdone(entry
, tx_status
, retry
);
1839 * Make this entry available for reuse.
1842 rt2x00_set_field32(&word
, TXD_W0_VALID
, 0);
1843 rt2x00_desc_write(txd
, 0, word
);
1844 rt2x00_ring_index_done_inc(entry
->ring
);
1847 * If the data ring was full before the txdone handler
1848 * we must make sure the packet queue in the mac80211 stack
1849 * is reenabled when the txdone handler has finished.
1851 if (!rt2x00_ring_full(ring
))
1852 ieee80211_wake_queue(rt2x00dev
->hw
,
1853 entry
->tx_status
.control
.queue
);
1857 static irqreturn_t
rt61pci_interrupt(int irq
, void *dev_instance
)
1859 struct rt2x00_dev
*rt2x00dev
= dev_instance
;
1863 * Get the interrupt sources & saved to local variable.
1864 * Write register value back to clear pending interrupts.
1866 rt2x00pci_register_read(rt2x00dev
, MCU_INT_SOURCE_CSR
, ®
);
1867 rt2x00pci_register_write(rt2x00dev
, MCU_INT_SOURCE_CSR
, reg
);
1869 rt2x00pci_register_read(rt2x00dev
, INT_SOURCE_CSR
, ®
);
1870 rt2x00pci_register_write(rt2x00dev
, INT_SOURCE_CSR
, reg
);
1875 if (!test_bit(DEVICE_ENABLED_RADIO
, &rt2x00dev
->flags
))
1879 * Handle interrupts, walk through all bits
1880 * and run the tasks, the bits are checked in order of
1885 * 1 - Beacon timer expired interrupt.
1887 if (rt2x00_get_field32(reg
, INT_SOURCE_CSR_BEACON_DONE
))
1888 rt2x00pci_beacondone(rt2x00dev
, IEEE80211_TX_QUEUE_BEACON
);
1891 * 2 - Rx ring done interrupt.
1893 if (rt2x00_get_field32(reg
, INT_SOURCE_CSR_RXDONE
))
1894 rt2x00pci_rxdone(rt2x00dev
);
1897 * 3 - Tx ring done interrupt.
1899 if (rt2x00_get_field32(reg
, INT_SOURCE_CSR_TXDONE
))
1900 rt61pci_txdone(rt2x00dev
);
1906 * Device initialization functions.
1908 static int rt61pci_alloc_eeprom(struct rt2x00_dev
*rt2x00dev
)
1910 struct eeprom_93cx6 eeprom
;
1917 * Allocate the eeprom memory, check the eeprom width
1918 * and copy the entire eeprom into this allocated memory.
1920 rt2x00dev
->eeprom
= kzalloc(EEPROM_SIZE
, GFP_KERNEL
);
1921 if (!rt2x00dev
->eeprom
)
1924 rt2x00pci_register_read(rt2x00dev
, E2PROM_CSR
, ®
);
1926 eeprom
.data
= rt2x00dev
;
1927 eeprom
.register_read
= rt61pci_eepromregister_read
;
1928 eeprom
.register_write
= rt61pci_eepromregister_write
;
1929 eeprom
.width
= rt2x00_get_field32(reg
, E2PROM_CSR_TYPE_93C46
) ?
1930 PCI_EEPROM_WIDTH_93C46
: PCI_EEPROM_WIDTH_93C66
;
1931 eeprom
.reg_data_in
= 0;
1932 eeprom
.reg_data_out
= 0;
1933 eeprom
.reg_data_clock
= 0;
1934 eeprom
.reg_chip_select
= 0;
1936 eeprom_93cx6_multiread(&eeprom
, EEPROM_BASE
, rt2x00dev
->eeprom
,
1937 EEPROM_SIZE
/ sizeof(u16
));
1940 * Start validation of the data that has been read.
1942 mac
= rt2x00_eeprom_addr(rt2x00dev
, EEPROM_MAC_ADDR_0
);
1943 if (!is_valid_ether_addr(mac
)) {
1944 random_ether_addr(mac
);
1945 EEPROM(rt2x00dev
, "MAC: " MAC_FMT
"\n", MAC_ARG(mac
));
1948 rt2x00_eeprom_read(rt2x00dev
, EEPROM_ANTENNA
, &word
);
1949 if (word
== 0xffff) {
1950 rt2x00_set_field16(&word
, EEPROM_ANTENNA_NUM
, 2);
1951 rt2x00_set_field16(&word
, EEPROM_ANTENNA_TX_DEFAULT
, 2);
1952 rt2x00_set_field16(&word
, EEPROM_ANTENNA_RX_DEFAULT
, 2);
1953 rt2x00_set_field16(&word
, EEPROM_ANTENNA_FRAME_TYPE
, 0);
1954 rt2x00_set_field16(&word
, EEPROM_ANTENNA_DYN_TXAGC
, 0);
1955 rt2x00_set_field16(&word
, EEPROM_ANTENNA_HARDWARE_RADIO
, 0);
1956 rt2x00_set_field16(&word
, EEPROM_ANTENNA_RF_TYPE
, RF5225
);
1957 rt2x00_eeprom_write(rt2x00dev
, EEPROM_ANTENNA
, word
);
1958 EEPROM(rt2x00dev
, "Antenna: 0x%04x\n", word
);
1961 rt2x00_eeprom_read(rt2x00dev
, EEPROM_NIC
, &word
);
1962 if (word
== 0xffff) {
1963 rt2x00_set_field16(&word
, EEPROM_NIC_ENABLE_DIVERSITY
, 0);
1964 rt2x00_set_field16(&word
, EEPROM_NIC_TX_DIVERSITY
, 0);
1965 rt2x00_set_field16(&word
, EEPROM_NIC_TX_RX_FIXED
, 0);
1966 rt2x00_set_field16(&word
, EEPROM_NIC_EXTERNAL_LNA_BG
, 0);
1967 rt2x00_set_field16(&word
, EEPROM_NIC_CARDBUS_ACCEL
, 0);
1968 rt2x00_set_field16(&word
, EEPROM_NIC_EXTERNAL_LNA_A
, 0);
1969 rt2x00_eeprom_write(rt2x00dev
, EEPROM_NIC
, word
);
1970 EEPROM(rt2x00dev
, "NIC: 0x%04x\n", word
);
1973 rt2x00_eeprom_read(rt2x00dev
, EEPROM_LED
, &word
);
1974 if (word
== 0xffff) {
1975 rt2x00_set_field16(&word
, EEPROM_LED_LED_MODE
,
1977 rt2x00_eeprom_write(rt2x00dev
, EEPROM_LED
, word
);
1978 EEPROM(rt2x00dev
, "Led: 0x%04x\n", word
);
1981 rt2x00_eeprom_read(rt2x00dev
, EEPROM_FREQ
, &word
);
1982 if (word
== 0xffff) {
1983 rt2x00_set_field16(&word
, EEPROM_FREQ_OFFSET
, 0);
1984 rt2x00_set_field16(&word
, EEPROM_FREQ_SEQ
, 0);
1985 rt2x00_eeprom_write(rt2x00dev
, EEPROM_FREQ
, word
);
1986 EEPROM(rt2x00dev
, "Freq: 0x%04x\n", word
);
1989 rt2x00_eeprom_read(rt2x00dev
, EEPROM_RSSI_OFFSET_BG
, &word
);
1990 if (word
== 0xffff) {
1991 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_BG_1
, 0);
1992 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_BG_2
, 0);
1993 rt2x00_eeprom_write(rt2x00dev
, EEPROM_RSSI_OFFSET_BG
, word
);
1994 EEPROM(rt2x00dev
, "RSSI OFFSET BG: 0x%04x\n", word
);
1996 value
= rt2x00_get_field16(word
, EEPROM_RSSI_OFFSET_BG_1
);
1997 if (value
< -10 || value
> 10)
1998 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_BG_1
, 0);
1999 value
= rt2x00_get_field16(word
, EEPROM_RSSI_OFFSET_BG_2
);
2000 if (value
< -10 || value
> 10)
2001 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_BG_2
, 0);
2002 rt2x00_eeprom_write(rt2x00dev
, EEPROM_RSSI_OFFSET_BG
, word
);
2005 rt2x00_eeprom_read(rt2x00dev
, EEPROM_RSSI_OFFSET_A
, &word
);
2006 if (word
== 0xffff) {
2007 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_A_1
, 0);
2008 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_A_2
, 0);
2009 rt2x00_eeprom_write(rt2x00dev
, EEPROM_RSSI_OFFSET_A
, word
);
2010 EEPROM(rt2x00dev
, "RSSI OFFSET BG: 0x%04x\n", word
);
2012 value
= rt2x00_get_field16(word
, EEPROM_RSSI_OFFSET_A_1
);
2013 if (value
< -10 || value
> 10)
2014 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_A_1
, 0);
2015 value
= rt2x00_get_field16(word
, EEPROM_RSSI_OFFSET_A_2
);
2016 if (value
< -10 || value
> 10)
2017 rt2x00_set_field16(&word
, EEPROM_RSSI_OFFSET_A_2
, 0);
2018 rt2x00_eeprom_write(rt2x00dev
, EEPROM_RSSI_OFFSET_A
, word
);
2024 static int rt61pci_init_eeprom(struct rt2x00_dev
*rt2x00dev
)
2032 * Read EEPROM word for configuration.
2034 rt2x00_eeprom_read(rt2x00dev
, EEPROM_ANTENNA
, &eeprom
);
2037 * Identify RF chipset.
2038 * To determine the RT chip we have to read the
2039 * PCI header of the device.
2041 pci_read_config_word(rt2x00dev_pci(rt2x00dev
),
2042 PCI_CONFIG_HEADER_DEVICE
, &device
);
2043 value
= rt2x00_get_field16(eeprom
, EEPROM_ANTENNA_RF_TYPE
);
2044 rt2x00pci_register_read(rt2x00dev
, MAC_CSR0
, ®
);
2045 rt2x00_set_chip(rt2x00dev
, device
, value
, reg
);
2047 if (!rt2x00_rf(&rt2x00dev
->chip
, RF5225
) &&
2048 !rt2x00_rf(&rt2x00dev
->chip
, RF5325
) &&
2049 !rt2x00_rf(&rt2x00dev
->chip
, RF2527
) &&
2050 !rt2x00_rf(&rt2x00dev
->chip
, RF2529
)) {
2051 ERROR(rt2x00dev
, "Invalid RF chipset detected.\n");
2056 * Identify default antenna configuration.
2058 rt2x00dev
->hw
->conf
.antenna_sel_tx
= rt2x00_get_field16(eeprom
,
2059 EEPROM_ANTENNA_TX_DEFAULT
);
2060 rt2x00dev
->hw
->conf
.antenna_sel_rx
= rt2x00_get_field16(eeprom
,
2061 EEPROM_ANTENNA_RX_DEFAULT
);
2064 * Read the Frame type.
2066 if (rt2x00_get_field16(eeprom
, EEPROM_ANTENNA_FRAME_TYPE
))
2067 __set_bit(CONFIG_FRAME_TYPE
, &rt2x00dev
->flags
);
2070 * Determine number of antenna's.
2072 if (rt2x00_get_field16(eeprom
, EEPROM_ANTENNA_NUM
) == 2)
2073 __set_bit(CONFIG_DOUBLE_ANTENNA
, &rt2x00dev
->flags
);
2076 * Detect if this device has an hardware controlled radio.
2078 if (rt2x00_get_field16(eeprom
, EEPROM_ANTENNA_HARDWARE_RADIO
))
2079 __set_bit(DEVICE_SUPPORT_HW_BUTTON
, &rt2x00dev
->flags
);
2082 * Read frequency offset and RF programming sequence.
2084 rt2x00_eeprom_read(rt2x00dev
, EEPROM_FREQ
, &eeprom
);
2085 if (rt2x00_get_field16(eeprom
, EEPROM_FREQ_SEQ
))
2086 __set_bit(CONFIG_RF_SEQUENCE
, &rt2x00dev
->flags
);
2088 rt2x00dev
->freq_offset
=
2089 rt2x00_get_field16(eeprom
, EEPROM_FREQ_OFFSET
);
2092 * Read external LNA informations.
2094 rt2x00_eeprom_read(rt2x00dev
, EEPROM_NIC
, &eeprom
);
2096 if (rt2x00_get_field16(eeprom
, EEPROM_NIC_EXTERNAL_LNA_A
))
2097 __set_bit(CONFIG_EXTERNAL_LNA_A
, &rt2x00dev
->flags
);
2098 if (rt2x00_get_field16(eeprom
, EEPROM_NIC_EXTERNAL_LNA_BG
))
2099 __set_bit(CONFIG_EXTERNAL_LNA_BG
, &rt2x00dev
->flags
);
2102 * Store led settings, for correct led behaviour.
2103 * If the eeprom value is invalid,
2104 * switch to default led mode.
2106 rt2x00_eeprom_read(rt2x00dev
, EEPROM_LED
, &eeprom
);
2108 rt2x00dev
->led_mode
= rt2x00_get_field16(eeprom
, EEPROM_LED_LED_MODE
);
2110 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_LED_MODE
,
2111 rt2x00dev
->led_mode
);
2112 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_GPIO_0
,
2113 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_GPIO_0
));
2114 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_GPIO_1
,
2115 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_GPIO_1
));
2116 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_GPIO_2
,
2117 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_GPIO_2
));
2118 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_GPIO_3
,
2119 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_GPIO_3
));
2120 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_GPIO_4
,
2121 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_GPIO_4
));
2122 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_ACT
,
2123 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_ACT
));
2124 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_READY_BG
,
2125 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_RDY_G
));
2126 rt2x00_set_field16(&rt2x00dev
->led_reg
, MCU_LEDCS_POLARITY_READY_A
,
2127 rt2x00_get_field16(eeprom
, EEPROM_LED_POLARITY_RDY_A
));
2133 * RF value list for RF5225, RF5325, RF2527 & RF2529
2136 static const u32 rf_vals_bg
[] = {
2137 0x00004786, 0x00004786, 0x0000478a, 0x0000478a, 0x0000478e,
2138 0x0000478e, 0x00004792, 0x00004792, 0x00004796, 0x00004796,
2139 0x0000479a, 0x0000479a, 0x0000479e, 0x000047a2
2143 * RF value list for RF5225 & RF5325 (supplement to vals_bg)
2144 * Supports: 5.2 GHz, rf_sequence disabled
2146 static const u32 rf_vals_a_5x_noseq
[] = {
2147 0x0000499a, 0x000049a2, 0x000049a6, 0x000049aa, 0x000049ae,
2148 0x000049b2, 0x000049ba, 0x000049be, 0x00004a2a, 0x00004a2e,
2149 0x00004a32, 0x00004a36, 0x00004a3a, 0x00004a82, 0x00004a86,
2150 0x00004a8a, 0x00004a8e, 0x00004a92, 0x00004a9a, 0x00004aa2,
2151 0x00004aa6, 0x00004aae, 0x00004ab2, 0x00004ab6
2155 * RF value list for RF5225 & RF5325 (supplement to vals_bg)
2156 * Supports: 5.2 GHz, rf_sequence enabled
2158 static const u32 rf_vals_a_5x_seq
[] = {
2159 0x0004481a, 0x00044682, 0x00044686, 0x0004468e, 0x00044692,
2160 0x0004469a, 0x000446a2, 0x000446a6, 0x0004489a, 0x000448a2,
2161 0x000448aa, 0x000448b2, 0x000448ba, 0x00044702, 0x00044706,
2162 0x0004470e, 0x00044712, 0x0004471a, 0x00044722, 0x0004472e,
2163 0x00044736, 0x0004490a, 0x00044912, 0x0004491a
2166 static void rt61pci_init_hw_mode(struct rt2x00_dev
*rt2x00dev
)
2168 struct hw_mode_spec
*spec
= &rt2x00dev
->spec
;
2173 * Initialize all hw fields.
2175 rt2x00dev
->hw
->flags
= IEEE80211_HW_HOST_GEN_BEACON
|
2176 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING
|
2177 IEEE80211_HW_WEP_INCLUDE_IV
|
2178 IEEE80211_HW_DATA_NULLFUNC_ACK
|
2179 IEEE80211_HW_NO_TKIP_WMM_HWACCEL
|
2180 IEEE80211_HW_MONITOR_DURING_OPER
|
2181 IEEE80211_HW_NO_PROBE_FILTERING
;
2182 rt2x00dev
->hw
->extra_tx_headroom
= 0;
2183 rt2x00dev
->hw
->max_rssi
= MAX_RX_SSI
;
2184 rt2x00dev
->hw
->max_noise
= MAX_RX_NOISE
;
2185 rt2x00dev
->hw
->queues
= 5;
2187 SET_IEEE80211_DEV(rt2x00dev
->hw
, &rt2x00dev_pci(rt2x00dev
)->dev
);
2188 SET_IEEE80211_PERM_ADDR(rt2x00dev
->hw
,
2189 rt2x00_eeprom_addr(rt2x00dev
, EEPROM_MAC_ADDR_0
));
2192 * Convert tx_power array in eeprom.
2194 txpower
= rt2x00_eeprom_addr(rt2x00dev
, EEPROM_TXPOWER_G_START
);
2195 for (i
= 0; i
< 14; i
++)
2196 txpower
[i
] = TXPOWER_FROM_DEV(txpower
[i
]);
2199 * Initialize hw_mode information.
2201 spec
->num_modes
= 2;
2202 spec
->num_rates
= 12;
2203 spec
->num_channels
= 14;
2204 spec
->tx_power_a
= NULL
;
2205 spec
->tx_power_bg
= txpower
;
2206 spec
->tx_power_default
= DEFAULT_TXPOWER
;
2207 spec
->chan_val_a
= NULL
;
2208 spec
->chan_val_bg
= rf_vals_bg
;
2210 if (rt2x00_rf(&rt2x00dev
->chip
, RF5225
) ||
2211 rt2x00_rf(&rt2x00dev
->chip
, RF5325
)) {
2212 spec
->num_modes
= 3;
2213 spec
->num_channels
+= 24;
2215 txpower
= rt2x00_eeprom_addr(rt2x00dev
, EEPROM_TXPOWER_A_START
);
2216 for (i
= 0; i
< 14; i
++)
2217 txpower
[i
] = TXPOWER_FROM_DEV(txpower
[i
]);
2219 spec
->tx_power_a
= txpower
;
2220 if (!test_bit(CONFIG_RF_SEQUENCE
, &rt2x00dev
->flags
))
2221 spec
->chan_val_a
= rf_vals_a_5x_noseq
;
2223 spec
->chan_val_a
= rf_vals_a_5x_seq
;
2227 static int rt61pci_init_hw(struct rt2x00_dev
*rt2x00dev
)
2232 * Allocate eeprom data.
2234 retval
= rt61pci_alloc_eeprom(rt2x00dev
);
2238 retval
= rt61pci_init_eeprom(rt2x00dev
);
2243 * Initialize hw specifications.
2245 rt61pci_init_hw_mode(rt2x00dev
);
2248 * This device requires firmware
2250 __set_bit(FIRMWARE_REQUIRED
, &rt2x00dev
->flags
);
2253 * Set the rssi offset.
2255 rt2x00dev
->rssi_offset
= DEFAULT_RSSI_OFFSET
;
2261 * IEEE80211 stack callback functions.
2263 static int rt61pci_get_stats(struct ieee80211_hw
*hw
,
2264 struct ieee80211_low_level_stats
*stats
)
2266 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
2270 * Update FCS error count from register.
2271 * The dot11ACKFailureCount, dot11RTSFailureCount and
2272 * dot11RTSSuccessCount are updated in interrupt time.
2274 rt2x00pci_register_read(rt2x00dev
, STA_CSR0
, ®
);
2275 rt2x00dev
->low_level_stats
.dot11FCSErrorCount
+=
2276 rt2x00_get_field32(reg
, STA_CSR0_FCS_ERROR
);
2278 memcpy(stats
, &rt2x00dev
->low_level_stats
, sizeof(*stats
));
2283 static int rt61pci_set_retry_limit(struct ieee80211_hw
*hw
,
2284 u32 short_retry
, u32 long_retry
)
2286 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
2289 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR4
, ®
);
2290 rt2x00_set_field32(®
, TXRX_CSR4_LONG_RETRY_LIMIT
, long_retry
);
2291 rt2x00_set_field32(®
, TXRX_CSR4_SHORT_RETRY_LIMIT
, short_retry
);
2292 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR4
, reg
);
2297 static u64
rt61pci_get_tsf(struct ieee80211_hw
*hw
)
2299 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
2303 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR13
, ®
);
2304 tsf
= (u64
)rt2x00_get_field32(reg
, TXRX_CSR13_HIGH_TSFTIMER
) << 32;
2305 rt2x00pci_register_read(rt2x00dev
, TXRX_CSR12
, ®
);
2306 tsf
|= rt2x00_get_field32(reg
, TXRX_CSR12_LOW_TSFTIMER
);
2311 static void rt61pci_reset_tsf(struct ieee80211_hw
*hw
)
2313 struct rt2x00_dev
*rt2x00dev
= hw
->priv
;
2315 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR12
, 0);
2316 rt2x00pci_register_write(rt2x00dev
, TXRX_CSR13
, 0);
2319 static const struct ieee80211_ops rt61pci_mac80211_ops
= {
2321 .reset
= rt2x00lib_reset
,
2322 .add_interface
= rt2x00lib_add_interface
,
2323 .remove_interface
= rt2x00lib_remove_interface
,
2324 .config
= rt2x00lib_config
,
2325 .config_interface
= rt2x00lib_config_interface
,
2326 .set_multicast_list
= rt2x00lib_set_multicast_list
,
2327 .get_stats
= rt61pci_get_stats
,
2328 .set_retry_limit
= rt61pci_set_retry_limit
,
2329 .conf_tx
= rt2x00lib_conf_tx
,
2330 .get_tx_stats
= rt2x00lib_get_tx_stats
,
2331 .get_tsf
= rt61pci_get_tsf
,
2332 .reset_tsf
= rt61pci_reset_tsf
,
2333 .beacon_update
= rt2x00pci_beacon_update
,
2336 static const struct rt2x00lib_ops rt61pci_rt2x00_ops
= {
2337 .irq_handler
= rt61pci_interrupt
,
2338 .init_hw
= rt61pci_init_hw
,
2339 .get_fw_name
= rt61pci_get_fw_name
,
2340 .load_firmware
= rt61pci_load_firmware
,
2341 .initialize
= rt2x00pci_initialize
,
2342 .uninitialize
= rt2x00pci_uninitialize
,
2343 .set_device_state
= rt61pci_set_device_state
,
2344 #ifdef CONFIG_RT61PCI_RFKILL
2345 .rfkill_poll
= rt61pci_rfkill_poll
,
2346 #endif /* CONFIG_RT61PCI_RFKILL */
2347 .link_tuner
= rt61pci_link_tuner
,
2348 .write_tx_desc
= rt61pci_write_tx_desc
,
2349 .write_tx_data
= rt2x00pci_write_tx_data
,
2350 .kick_tx_queue
= rt61pci_kick_tx_queue
,
2351 .fill_rxdone
= rt61pci_fill_rxdone
,
2352 .config_type
= rt61pci_config_type
,
2353 .config_phymode
= rt61pci_config_phymode
,
2354 .config_channel
= rt61pci_config_channel
,
2355 .config_mac_addr
= rt61pci_config_mac_addr
,
2356 .config_bssid
= rt61pci_config_bssid
,
2357 .config_promisc
= rt61pci_config_promisc
,
2358 .config_txpower
= rt61pci_config_txpower
,
2359 .config_antenna
= rt61pci_config_antenna
,
2360 .config_duration
= rt61pci_config_duration
,
2363 static const struct rt2x00_ops rt61pci_ops
= {
2365 .rxd_size
= RXD_DESC_SIZE
,
2366 .txd_size
= TXD_DESC_SIZE
,
2367 .lib
= &rt61pci_rt2x00_ops
,
2368 .hw
= &rt61pci_mac80211_ops
,
2369 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
2370 .debugfs
= &rt61pci_rt2x00debug
,
2371 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
2375 * RT61pci module information.
2377 static struct pci_device_id rt61pci_device_table
[] = {
2379 { PCI_DEVICE(0x1814, 0x0301), PCI_DEVICE_DATA(&rt61pci_ops
) },
2381 { PCI_DEVICE(0x1814, 0x0302), PCI_DEVICE_DATA(&rt61pci_ops
) },
2383 { PCI_DEVICE(0x1814, 0x0401), PCI_DEVICE_DATA(&rt61pci_ops
) },
2387 MODULE_AUTHOR(DRV_PROJECT
);
2388 MODULE_VERSION(DRV_VERSION
);
2389 MODULE_DESCRIPTION("Ralink RT61 PCI & PCMCIA Wireless LAN driver.");
2390 MODULE_SUPPORTED_DEVICE("Ralink RT2561, RT2561s & RT2661 "
2391 "PCI & PCMCIA chipset based cards");
2392 MODULE_DEVICE_TABLE(pci
, rt61pci_device_table
);
2393 MODULE_FIRMWARE(FIRMWARE_RT2561
);
2394 MODULE_FIRMWARE(FIRMWARE_RT2561s
);
2395 MODULE_FIRMWARE(FIRMWARE_RT2661
);
2396 MODULE_LICENSE("GPL");
2398 static struct pci_driver rt61pci_driver
= {
2400 .id_table
= rt61pci_device_table
,
2401 .probe
= rt2x00pci_probe
,
2402 .remove
= __devexit_p(rt2x00pci_remove
),
2404 .suspend
= rt2x00pci_suspend
,
2405 .resume
= rt2x00pci_resume
,
2406 #endif /* CONFIG_PM */
2409 static int __init
rt61pci_init(void)
2411 return pci_register_driver(&rt61pci_driver
);
2414 static void __exit
rt61pci_exit(void)
2416 pci_unregister_driver(&rt61pci_driver
);
2419 module_init(rt61pci_init
);
2420 module_exit(rt61pci_exit
);