30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/slab.h>
42 static bool modparam_nohwcrypt;
61 static inline void rt2500usb_register_read(
struct rt2x00_dev *rt2x00dev,
72 static inline void rt2500usb_register_read_lock(
struct rt2x00_dev *rt2x00dev,
73 const unsigned int offset,
83 static inline void rt2500usb_register_multiread(
struct rt2x00_dev *rt2x00dev,
84 const unsigned int offset,
93 static inline void rt2500usb_register_write(
struct rt2x00_dev *rt2x00dev,
94 const unsigned int offset,
103 static inline void rt2500usb_register_write_lock(
struct rt2x00_dev *rt2x00dev,
104 const unsigned int offset,
113 static inline void rt2500usb_register_multiwrite(
struct rt2x00_dev *rt2x00dev,
114 const unsigned int offset,
115 void *value,
const u16 length)
123 static int rt2500usb_regbusy_read(
struct rt2x00_dev *rt2x00dev,
124 const unsigned int offset,
131 rt2500usb_register_read_lock(rt2x00dev, offset, reg);
137 ERROR(rt2x00dev,
"Indirect register access failed: "
138 "offset=0x%.08x, value=0x%.08x\n", offset, *reg);
144 #define WAIT_FOR_BBP(__dev, __reg) \
145 rt2500usb_regbusy_read((__dev), PHY_CSR8, PHY_CSR8_BUSY, (__reg))
146 #define WAIT_FOR_RF(__dev, __reg) \
147 rt2500usb_regbusy_read((__dev), PHY_CSR10, PHY_CSR10_RF_BUSY, (__reg))
149 static void rt2500usb_bbp_write(
struct rt2x00_dev *rt2x00dev,
150 const unsigned int word,
const u8 value)
166 rt2500usb_register_write_lock(rt2x00dev,
PHY_CSR7, reg);
172 static void rt2500usb_bbp_read(
struct rt2x00_dev *rt2x00dev,
173 const unsigned int word,
u8 *value)
192 rt2500usb_register_write_lock(rt2x00dev,
PHY_CSR7, reg);
195 rt2500usb_register_read_lock(rt2x00dev,
PHY_CSR7, ®);
203 static void rt2500usb_rf_write(
struct rt2x00_dev *rt2x00dev,
204 const unsigned int word,
const u32 value)
217 rt2500usb_register_write_lock(rt2x00dev,
PHY_CSR9, reg);
225 rt2500usb_register_write_lock(rt2x00dev,
PHY_CSR10, reg);
226 rt2x00_rf_write(rt2x00dev, word, value);
232 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
233 static void _rt2500usb_register_read(
struct rt2x00_dev *rt2x00dev,
234 const unsigned int offset,
237 rt2500usb_register_read(rt2x00dev, offset, (
u16 *)value);
240 static void _rt2500usb_register_write(
struct rt2x00_dev *rt2x00dev,
241 const unsigned int offset,
244 rt2500usb_register_write(rt2x00dev, offset, value);
247 static const struct rt2x00debug rt2500usb_rt2x00debug = {
250 .read = _rt2500usb_register_read,
251 .write = _rt2500usb_register_write,
254 .word_size =
sizeof(
u16),
258 .read = rt2x00_eeprom_read,
259 .write = rt2x00_eeprom_write,
261 .word_size =
sizeof(
u16),
265 .read = rt2500usb_bbp_read,
266 .write = rt2500usb_bbp_write,
268 .word_size =
sizeof(
u8),
272 .read = rt2x00_rf_read,
273 .write = rt2500usb_rf_write,
275 .word_size =
sizeof(
u32),
281 static int rt2500usb_rfkill_poll(
struct rt2x00_dev *rt2x00dev)
285 rt2500usb_register_read(rt2x00dev,
MAC_CSR19, ®);
289 #ifdef CONFIG_RT2X00_LIB_LEDS
290 static void rt2500usb_brightness_set(
struct led_classdev *led_cdev,
308 static int rt2500usb_blink_set(
struct led_classdev *led_cdev,
309 unsigned long *delay_on,
310 unsigned long *delay_off)
324 static void rt2500usb_init_led(
struct rt2x00_dev *rt2x00dev,
330 led->
led_dev.brightness_set = rt2500usb_brightness_set;
331 led->
led_dev.blink_set = rt2500usb_blink_set;
344 static int rt2500usb_config_key(
struct rt2x00_dev *rt2x00dev,
370 rt2500usb_register_read(rt2x00dev,
TXRX_CSR0, ®);
374 if (reg && reg == mask)
390 crypto->
key,
sizeof(crypto->
key));
409 rt2500usb_register_read(rt2x00dev,
TXRX_CSR0, ®);
419 rt2500usb_register_write(rt2x00dev,
TXRX_CSR0, reg);
424 static void rt2500usb_config_filter(
struct rt2x00_dev *rt2x00dev,
425 const unsigned int filter_flags)
435 rt2500usb_register_read(rt2x00dev,
TXRX_CSR2, ®);
451 rt2500usb_register_write(rt2x00dev,
TXRX_CSR2, reg);
454 static void rt2500usb_config_intf(
struct rt2x00_dev *rt2x00dev,
457 const unsigned int flags)
459 unsigned int bcn_preload;
467 rt2500usb_register_read(rt2x00dev,
TXRX_CSR20, ®);
471 rt2500usb_register_write(rt2x00dev,
TXRX_CSR20, reg);
476 rt2500usb_register_read(rt2x00dev,
TXRX_CSR18, ®);
478 rt2500usb_register_write(rt2x00dev,
TXRX_CSR18, reg);
480 rt2500usb_register_read(rt2x00dev,
TXRX_CSR19, ®);
482 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
486 rt2500usb_register_multiwrite(rt2x00dev,
MAC_CSR2, conf->
mac,
490 rt2500usb_register_multiwrite(rt2x00dev,
MAC_CSR5, conf->
bssid,
494 static void rt2500usb_config_erp(
struct rt2x00_dev *rt2x00dev,
501 rt2500usb_register_read(rt2x00dev,
TXRX_CSR10, ®);
504 rt2500usb_register_write(rt2x00dev,
TXRX_CSR10, reg);
508 rt2500usb_register_write(rt2x00dev,
TXRX_CSR11,
512 rt2500usb_register_read(rt2x00dev,
TXRX_CSR18, ®);
515 rt2500usb_register_write(rt2x00dev,
TXRX_CSR18, reg);
525 static void rt2500usb_config_ant(
struct rt2x00_dev *rt2x00dev,
540 rt2500usb_bbp_read(rt2x00dev, 2, &r2);
541 rt2500usb_bbp_read(rt2x00dev, 14, &r14);
542 rt2500usb_register_read(rt2x00dev,
PHY_CSR5, &csr5);
543 rt2500usb_register_read(rt2x00dev,
PHY_CSR6, &csr6);
586 if (rt2x00_rf(rt2x00dev,
RF2525E) || rt2x00_rf(rt2x00dev,
RF5222)) {
594 if (rt2x00_rf(rt2x00dev,
RF2525E))
601 rt2500usb_bbp_write(rt2x00dev, 2, r2);
602 rt2500usb_bbp_write(rt2x00dev, 14, r14);
603 rt2500usb_register_write(rt2x00dev,
PHY_CSR5, csr5);
604 rt2500usb_register_write(rt2x00dev,
PHY_CSR6, csr6);
607 static void rt2500usb_config_channel(
struct rt2x00_dev *rt2x00dev,
618 if (rt2x00_rf(rt2x00dev,
RF2525E)) {
619 static const u32 vals[] = {
620 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
621 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
622 0x000008ba, 0x000008be, 0x000008b7, 0x00000902,
623 0x00000902, 0x00000906
626 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->
channel - 1]);
628 rt2500usb_rf_write(rt2x00dev, 4, rf->
rf4);
631 rt2500usb_rf_write(rt2x00dev, 1, rf->
rf1);
632 rt2500usb_rf_write(rt2x00dev, 2, rf->
rf2);
633 rt2500usb_rf_write(rt2x00dev, 3, rf->
rf3);
635 rt2500usb_rf_write(rt2x00dev, 4, rf->
rf4);
638 static void rt2500usb_config_txpower(
struct rt2x00_dev *rt2x00dev,
643 rt2x00_rf_read(rt2x00dev, 3, &rf3);
645 rt2500usb_rf_write(rt2x00dev, 3, rf3);
648 static void rt2500usb_config_ps(
struct rt2x00_dev *rt2x00dev,
657 rt2500usb_register_read(rt2x00dev,
MAC_CSR18, ®);
661 libconf->
conf->listen_interval - 1);
665 rt2500usb_register_write(rt2x00dev,
MAC_CSR18, reg);
668 rt2500usb_register_write(rt2x00dev,
MAC_CSR18, reg);
670 rt2500usb_register_read(rt2x00dev,
MAC_CSR18, ®);
672 rt2500usb_register_write(rt2x00dev,
MAC_CSR18, reg);
675 rt2x00dev->
ops->lib->set_device_state(rt2x00dev, state);
678 static void rt2500usb_config(
struct rt2x00_dev *rt2x00dev,
680 const unsigned int flags)
683 rt2500usb_config_channel(rt2x00dev, &libconf->
rf,
684 libconf->
conf->power_level);
686 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
687 rt2500usb_config_txpower(rt2x00dev,
688 libconf->
conf->power_level);
690 rt2500usb_config_ps(rt2x00dev, libconf);
696 static void rt2500usb_link_stats(
struct rt2x00_dev *rt2x00dev,
704 rt2500usb_register_read(rt2x00dev,
STA_CSR0, ®);
710 rt2500usb_register_read(rt2x00dev,
STA_CSR3, ®);
714 static void rt2500usb_reset_tuner(
struct rt2x00_dev *rt2x00dev,
722 rt2500usb_bbp_write(rt2x00dev, 24, value);
726 rt2500usb_bbp_write(rt2x00dev, 25, value);
730 rt2500usb_bbp_write(rt2x00dev, 61, value);
734 rt2500usb_bbp_write(rt2x00dev, 17, value);
747 switch (queue->
qid) {
749 rt2500usb_register_read(rt2x00dev,
TXRX_CSR2, ®);
751 rt2500usb_register_write(rt2x00dev,
TXRX_CSR2, reg);
754 rt2500usb_register_read(rt2x00dev,
TXRX_CSR19, ®);
758 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
765 static void rt2500usb_stop_queue(
struct data_queue *queue)
770 switch (queue->
qid) {
772 rt2500usb_register_read(rt2x00dev,
TXRX_CSR2, ®);
774 rt2500usb_register_write(rt2x00dev,
TXRX_CSR2, reg);
777 rt2500usb_register_read(rt2x00dev,
TXRX_CSR19, ®);
781 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
791 static int rt2500usb_init_registers(
struct rt2x00_dev *rt2x00dev)
800 rt2500usb_register_read(rt2x00dev,
TXRX_CSR2, ®);
802 rt2500usb_register_write(rt2x00dev,
TXRX_CSR2, reg);
804 rt2500usb_register_write(rt2x00dev,
MAC_CSR13, 0x1111);
805 rt2500usb_register_write(rt2x00dev,
MAC_CSR14, 0x1e11);
807 rt2500usb_register_read(rt2x00dev,
MAC_CSR1, ®);
811 rt2500usb_register_write(rt2x00dev,
MAC_CSR1, reg);
813 rt2500usb_register_read(rt2x00dev,
MAC_CSR1, ®);
817 rt2500usb_register_write(rt2x00dev,
MAC_CSR1, reg);
819 rt2500usb_register_read(rt2x00dev,
TXRX_CSR5, ®);
824 rt2500usb_register_write(rt2x00dev,
TXRX_CSR5, reg);
826 rt2500usb_register_read(rt2x00dev,
TXRX_CSR6, ®);
831 rt2500usb_register_write(rt2x00dev,
TXRX_CSR6, reg);
833 rt2500usb_register_read(rt2x00dev,
TXRX_CSR7, ®);
838 rt2500usb_register_write(rt2x00dev,
TXRX_CSR7, reg);
840 rt2500usb_register_read(rt2x00dev,
TXRX_CSR8, ®);
845 rt2500usb_register_write(rt2x00dev,
TXRX_CSR8, reg);
847 rt2500usb_register_read(rt2x00dev,
TXRX_CSR19, ®);
852 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
854 rt2500usb_register_write(rt2x00dev,
TXRX_CSR21, 0xe78f);
855 rt2500usb_register_write(rt2x00dev,
MAC_CSR9, 0xff1d);
857 if (rt2x00dev->
ops->lib->set_device_state(rt2x00dev,
STATE_AWAKE))
860 rt2500usb_register_read(rt2x00dev,
MAC_CSR1, ®);
864 rt2500usb_register_write(rt2x00dev,
MAC_CSR1, reg);
867 rt2500usb_register_read(rt2x00dev,
PHY_CSR2, ®);
874 rt2500usb_register_write(rt2x00dev,
PHY_CSR2, reg);
876 rt2500usb_register_write(rt2x00dev,
MAC_CSR11, 0x0002);
877 rt2500usb_register_write(rt2x00dev,
MAC_CSR22, 0x0053);
878 rt2500usb_register_write(rt2x00dev,
MAC_CSR15, 0x01ee);
879 rt2500usb_register_write(rt2x00dev,
MAC_CSR16, 0x0000);
881 rt2500usb_register_read(rt2x00dev,
MAC_CSR8, ®);
883 rt2x00dev->
rx->data_size);
884 rt2500usb_register_write(rt2x00dev,
MAC_CSR8, reg);
886 rt2500usb_register_read(rt2x00dev,
TXRX_CSR0, ®);
890 rt2500usb_register_write(rt2x00dev,
TXRX_CSR0, reg);
892 rt2500usb_register_read(rt2x00dev,
MAC_CSR18, ®);
894 rt2500usb_register_write(rt2x00dev,
MAC_CSR18, reg);
896 rt2500usb_register_read(rt2x00dev,
PHY_CSR4, ®);
898 rt2500usb_register_write(rt2x00dev,
PHY_CSR4, reg);
900 rt2500usb_register_read(rt2x00dev,
TXRX_CSR1, ®);
902 rt2500usb_register_write(rt2x00dev,
TXRX_CSR1, reg);
907 static int rt2500usb_wait_bbp_ready(
struct rt2x00_dev *rt2x00dev)
913 rt2500usb_bbp_read(rt2x00dev, 0, &value);
914 if ((value != 0xff) && (value != 0x00))
919 ERROR(rt2x00dev,
"BBP register access failed, aborting.\n");
923 static int rt2500usb_init_bbp(
struct rt2x00_dev *rt2x00dev)
930 if (
unlikely(rt2500usb_wait_bbp_ready(rt2x00dev)))
933 rt2500usb_bbp_write(rt2x00dev, 3, 0x02);
934 rt2500usb_bbp_write(rt2x00dev, 4, 0x19);
935 rt2500usb_bbp_write(rt2x00dev, 14, 0x1c);
936 rt2500usb_bbp_write(rt2x00dev, 15, 0x30);
937 rt2500usb_bbp_write(rt2x00dev, 16, 0xac);
938 rt2500usb_bbp_write(rt2x00dev, 18, 0x18);
939 rt2500usb_bbp_write(rt2x00dev, 19, 0xff);
940 rt2500usb_bbp_write(rt2x00dev, 20, 0x1e);
941 rt2500usb_bbp_write(rt2x00dev, 21, 0x08);
942 rt2500usb_bbp_write(rt2x00dev, 22, 0x08);
943 rt2500usb_bbp_write(rt2x00dev, 23, 0x08);
944 rt2500usb_bbp_write(rt2x00dev, 24, 0x80);
945 rt2500usb_bbp_write(rt2x00dev, 25, 0x50);
946 rt2500usb_bbp_write(rt2x00dev, 26, 0x08);
947 rt2500usb_bbp_write(rt2x00dev, 27, 0x23);
948 rt2500usb_bbp_write(rt2x00dev, 30, 0x10);
949 rt2500usb_bbp_write(rt2x00dev, 31, 0x2b);
950 rt2500usb_bbp_write(rt2x00dev, 32, 0xb9);
951 rt2500usb_bbp_write(rt2x00dev, 34, 0x12);
952 rt2500usb_bbp_write(rt2x00dev, 35, 0x50);
953 rt2500usb_bbp_write(rt2x00dev, 39, 0xc4);
954 rt2500usb_bbp_write(rt2x00dev, 40, 0x02);
955 rt2500usb_bbp_write(rt2x00dev, 41, 0x60);
956 rt2500usb_bbp_write(rt2x00dev, 53, 0x10);
957 rt2500usb_bbp_write(rt2x00dev, 54, 0x18);
958 rt2500usb_bbp_write(rt2x00dev, 56, 0x08);
959 rt2500usb_bbp_write(rt2x00dev, 57, 0x10);
960 rt2500usb_bbp_write(rt2x00dev, 58, 0x08);
961 rt2500usb_bbp_write(rt2x00dev, 61, 0x60);
962 rt2500usb_bbp_write(rt2x00dev, 62, 0x10);
963 rt2500usb_bbp_write(rt2x00dev, 75, 0xff);
968 if (eeprom != 0xffff && eeprom != 0x0000) {
971 rt2500usb_bbp_write(rt2x00dev, reg_id, value);
981 static int rt2500usb_enable_radio(
struct rt2x00_dev *rt2x00dev)
986 if (
unlikely(rt2500usb_init_registers(rt2x00dev) ||
987 rt2500usb_init_bbp(rt2x00dev)))
993 static void rt2500usb_disable_radio(
struct rt2x00_dev *rt2x00dev)
995 rt2500usb_register_write(rt2x00dev,
MAC_CSR13, 0x2121);
996 rt2500usb_register_write(rt2x00dev,
MAC_CSR14, 0x2121);
1001 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, 0);
1006 static int rt2500usb_set_state(
struct rt2x00_dev *rt2x00dev,
1022 rt2500usb_register_write(rt2x00dev,
MAC_CSR17, reg);
1024 rt2500usb_register_write(rt2x00dev,
MAC_CSR17, reg);
1032 rt2500usb_register_read(rt2x00dev,
MAC_CSR17, ®2);
1035 if (bbp_state == state && rf_state == state)
1037 rt2500usb_register_write(rt2x00dev,
MAC_CSR17, reg);
1044 static int rt2500usb_set_device_state(
struct rt2x00_dev *rt2x00dev,
1051 retval = rt2500usb_enable_radio(rt2x00dev);
1054 rt2500usb_disable_radio(rt2x00dev);
1064 retval = rt2500usb_set_state(rt2x00dev, state);
1072 ERROR(rt2x00dev,
"Device failed to enter state %d (%d).\n",
1081 static void rt2500usb_write_tx_desc(
struct queue_entry *
entry,
1091 rt2x00_desc_read(txd, 0, &word);
1107 rt2x00_desc_write(txd, 0, word);
1109 rt2x00_desc_read(txd, 1, &word);
1114 rt2x00_desc_write(txd, 1, word);
1116 rt2x00_desc_read(txd, 2, &word);
1120 txdesc->
u.
plcp.length_low);
1122 txdesc->
u.
plcp.length_high);
1123 rt2x00_desc_write(txd, 2, word);
1126 _rt2x00_desc_write(txd, 3, skbdesc->
iv[0]);
1127 _rt2x00_desc_write(txd, 4, skbdesc->
iv[1]);
1134 skbdesc->
desc = txd;
1141 static void rt2500usb_beacondone(
struct urb *
urb);
1143 static void rt2500usb_write_beacon(
struct queue_entry *entry,
1146 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1149 int pipe = usb_sndbulkpipe(usb_dev, entry->queue->usb_endpoint);
1157 rt2500usb_register_read(rt2x00dev,
TXRX_CSR19, ®);
1159 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
1170 rt2500usb_write_tx_desc(entry, txdesc);
1182 length = rt2x00dev->
ops->lib->get_tx_data_len(entry);
1184 usb_fill_bulk_urb(bcn_priv->
urb, usb_dev, pipe,
1185 entry->skb->data, length, rt2500usb_beacondone,
1194 usb_fill_bulk_urb(bcn_priv->
guardian_urb, usb_dev, pipe,
1217 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
1218 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg0);
1219 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
1220 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg0);
1221 rt2500usb_register_write(rt2x00dev,
TXRX_CSR19, reg);
1224 static int rt2500usb_get_tx_data_len(
struct queue_entry *entry)
1232 length =
roundup(entry->skb->len, 2);
1233 length += (2 * !(length % entry->queue->usb_maxpacket));
1241 static void rt2500usb_fill_rxdone(
struct queue_entry *entry,
1244 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1248 (
__le32 *)(entry->skb->data +
1249 (entry_priv->
urb->actual_length -
1250 entry->queue->desc_size));
1264 rt2x00_desc_read(rxd, 0, &word0);
1265 rt2x00_desc_read(rxd, 1, &word1);
1277 _rt2x00_desc_read(rxd, 2, &rxdesc->
iv[0]);
1278 _rt2x00_desc_read(rxd, 3, &rxdesc->
iv[1]);
1317 static void rt2500usb_beacondone(
struct urb *
urb)
1319 struct queue_entry *entry = (
struct queue_entry *)urb->context;
1333 }
else if (bcn_priv->
urb == urb) {
1334 dev_kfree_skb(entry->skb);
1342 static int rt2500usb_validate_eeprom(
struct rt2x00_dev *rt2x00dev)
1354 if (!is_valid_ether_addr(mac)) {
1355 eth_random_addr(mac);
1356 EEPROM(rt2x00dev,
"MAC: %pM\n", mac);
1360 if (word == 0xffff) {
1372 EEPROM(rt2x00dev,
"Antenna: 0x%04x\n", word);
1375 rt2x00_eeprom_read(rt2x00dev,
EEPROM_NIC, &word);
1376 if (word == 0xffff) {
1380 rt2x00_eeprom_write(rt2x00dev,
EEPROM_NIC, word);
1381 EEPROM(rt2x00dev,
"NIC: 0x%04x\n", word);
1385 if (word == 0xffff) {
1389 EEPROM(rt2x00dev,
"Calibrate offset: 0x%04x\n", word);
1393 if (word == 0xffff) {
1396 EEPROM(rt2x00dev,
"BBPtune: 0x%04x\n", word);
1403 rt2500usb_bbp_read(rt2x00dev, 17, &bbp);
1407 if (word == 0xffff) {
1411 EEPROM(rt2x00dev,
"BBPtune vgc: 0x%04x\n", word);
1418 if (word == 0xffff) {
1422 EEPROM(rt2x00dev,
"BBPtune r17: 0x%04x\n", word);
1426 if (word == 0xffff) {
1430 EEPROM(rt2x00dev,
"BBPtune r24: 0x%04x\n", word);
1434 if (word == 0xffff) {
1438 EEPROM(rt2x00dev,
"BBPtune r25: 0x%04x\n", word);
1442 if (word == 0xffff) {
1446 EEPROM(rt2x00dev,
"BBPtune r61: 0x%04x\n", word);
1452 static int rt2500usb_init_eeprom(
struct rt2x00_dev *rt2x00dev)
1467 rt2500usb_register_read(rt2x00dev,
MAC_CSR0, ®);
1468 rt2x00_set_chip(rt2x00dev,
RT2570, value, reg);
1470 if (((reg & 0xfff0) != 0) || ((reg & 0x0000000f) == 0)) {
1471 ERROR(rt2x00dev,
"Invalid RT chipset detected.\n");
1475 if (!rt2x00_rf(rt2x00dev,
RF2522) &&
1476 !rt2x00_rf(rt2x00dev,
RF2523) &&
1477 !rt2x00_rf(rt2x00dev,
RF2524) &&
1478 !rt2x00_rf(rt2x00dev,
RF2525) &&
1479 !rt2x00_rf(rt2x00dev,
RF2525E) &&
1480 !rt2x00_rf(rt2x00dev,
RF5222)) {
1481 ERROR(rt2x00dev,
"Invalid RF chipset detected.\n");
1507 #ifdef CONFIG_RT2X00_LIB_LEDS
1510 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio,
LED_TYPE_RADIO);
1514 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1538 static const struct rf_channel rf_vals_bg_2522[] = {
1539 { 1, 0x00002050, 0x000c1fda, 0x00000101, 0 },
1540 { 2, 0x00002050, 0x000c1fee, 0x00000101, 0 },
1541 { 3, 0x00002050, 0x000c2002, 0x00000101, 0 },
1542 { 4, 0x00002050, 0x000c2016, 0x00000101, 0 },
1543 { 5, 0x00002050, 0x000c202a, 0x00000101, 0 },
1544 { 6, 0x00002050, 0x000c203e, 0x00000101, 0 },
1545 { 7, 0x00002050, 0x000c2052, 0x00000101, 0 },
1546 { 8, 0x00002050, 0x000c2066, 0x00000101, 0 },
1547 { 9, 0x00002050, 0x000c207a, 0x00000101, 0 },
1548 { 10, 0x00002050, 0x000c208e, 0x00000101, 0 },
1549 { 11, 0x00002050, 0x000c20a2, 0x00000101, 0 },
1550 { 12, 0x00002050, 0x000c20b6, 0x00000101, 0 },
1551 { 13, 0x00002050, 0x000c20ca, 0x00000101, 0 },
1552 { 14, 0x00002050, 0x000c20fa, 0x00000101, 0 },
1559 static const struct rf_channel rf_vals_bg_2523[] = {
1560 { 1, 0x00022010, 0x00000c9e, 0x000e0111, 0x00000a1b },
1561 { 2, 0x00022010, 0x00000ca2, 0x000e0111, 0x00000a1b },
1562 { 3, 0x00022010, 0x00000ca6, 0x000e0111, 0x00000a1b },
1563 { 4, 0x00022010, 0x00000caa, 0x000e0111, 0x00000a1b },
1564 { 5, 0x00022010, 0x00000cae, 0x000e0111, 0x00000a1b },
1565 { 6, 0x00022010, 0x00000cb2, 0x000e0111, 0x00000a1b },
1566 { 7, 0x00022010, 0x00000cb6, 0x000e0111, 0x00000a1b },
1567 { 8, 0x00022010, 0x00000cba, 0x000e0111, 0x00000a1b },
1568 { 9, 0x00022010, 0x00000cbe, 0x000e0111, 0x00000a1b },
1569 { 10, 0x00022010, 0x00000d02, 0x000e0111, 0x00000a1b },
1570 { 11, 0x00022010, 0x00000d06, 0x000e0111, 0x00000a1b },
1571 { 12, 0x00022010, 0x00000d0a, 0x000e0111, 0x00000a1b },
1572 { 13, 0x00022010, 0x00000d0e, 0x000e0111, 0x00000a1b },
1573 { 14, 0x00022010, 0x00000d1a, 0x000e0111, 0x00000a03 },
1580 static const struct rf_channel rf_vals_bg_2524[] = {
1581 { 1, 0x00032020, 0x00000c9e, 0x00000101, 0x00000a1b },
1582 { 2, 0x00032020, 0x00000ca2, 0x00000101, 0x00000a1b },
1583 { 3, 0x00032020, 0x00000ca6, 0x00000101, 0x00000a1b },
1584 { 4, 0x00032020, 0x00000caa, 0x00000101, 0x00000a1b },
1585 { 5, 0x00032020, 0x00000cae, 0x00000101, 0x00000a1b },
1586 { 6, 0x00032020, 0x00000cb2, 0x00000101, 0x00000a1b },
1587 { 7, 0x00032020, 0x00000cb6, 0x00000101, 0x00000a1b },
1588 { 8, 0x00032020, 0x00000cba, 0x00000101, 0x00000a1b },
1589 { 9, 0x00032020, 0x00000cbe, 0x00000101, 0x00000a1b },
1590 { 10, 0x00032020, 0x00000d02, 0x00000101, 0x00000a1b },
1591 { 11, 0x00032020, 0x00000d06, 0x00000101, 0x00000a1b },
1592 { 12, 0x00032020, 0x00000d0a, 0x00000101, 0x00000a1b },
1593 { 13, 0x00032020, 0x00000d0e, 0x00000101, 0x00000a1b },
1594 { 14, 0x00032020, 0x00000d1a, 0x00000101, 0x00000a03 },
1601 static const struct rf_channel rf_vals_bg_2525[] = {
1602 { 1, 0x00022020, 0x00080c9e, 0x00060111, 0x00000a1b },
1603 { 2, 0x00022020, 0x00080ca2, 0x00060111, 0x00000a1b },
1604 { 3, 0x00022020, 0x00080ca6, 0x00060111, 0x00000a1b },
1605 { 4, 0x00022020, 0x00080caa, 0x00060111, 0x00000a1b },
1606 { 5, 0x00022020, 0x00080cae, 0x00060111, 0x00000a1b },
1607 { 6, 0x00022020, 0x00080cb2, 0x00060111, 0x00000a1b },
1608 { 7, 0x00022020, 0x00080cb6, 0x00060111, 0x00000a1b },
1609 { 8, 0x00022020, 0x00080cba, 0x00060111, 0x00000a1b },
1610 { 9, 0x00022020, 0x00080cbe, 0x00060111, 0x00000a1b },
1611 { 10, 0x00022020, 0x00080d02, 0x00060111, 0x00000a1b },
1612 { 11, 0x00022020, 0x00080d06, 0x00060111, 0x00000a1b },
1613 { 12, 0x00022020, 0x00080d0a, 0x00060111, 0x00000a1b },
1614 { 13, 0x00022020, 0x00080d0e, 0x00060111, 0x00000a1b },
1615 { 14, 0x00022020, 0x00080d1a, 0x00060111, 0x00000a03 },
1622 static const struct rf_channel rf_vals_bg_2525e[] = {
1623 { 1, 0x00022010, 0x0000089a, 0x00060111, 0x00000e1b },
1624 { 2, 0x00022010, 0x0000089e, 0x00060111, 0x00000e07 },
1625 { 3, 0x00022010, 0x0000089e, 0x00060111, 0x00000e1b },
1626 { 4, 0x00022010, 0x000008a2, 0x00060111, 0x00000e07 },
1627 { 5, 0x00022010, 0x000008a2, 0x00060111, 0x00000e1b },
1628 { 6, 0x00022010, 0x000008a6, 0x00060111, 0x00000e07 },
1629 { 7, 0x00022010, 0x000008a6, 0x00060111, 0x00000e1b },
1630 { 8, 0x00022010, 0x000008aa, 0x00060111, 0x00000e07 },
1631 { 9, 0x00022010, 0x000008aa, 0x00060111, 0x00000e1b },
1632 { 10, 0x00022010, 0x000008ae, 0x00060111, 0x00000e07 },
1633 { 11, 0x00022010, 0x000008ae, 0x00060111, 0x00000e1b },
1634 { 12, 0x00022010, 0x000008b2, 0x00060111, 0x00000e07 },
1635 { 13, 0x00022010, 0x000008b2, 0x00060111, 0x00000e1b },
1636 { 14, 0x00022010, 0x000008b6, 0x00060111, 0x00000e23 },
1643 static const struct rf_channel rf_vals_5222[] = {
1644 { 1, 0x00022020, 0x00001136, 0x00000101, 0x00000a0b },
1645 { 2, 0x00022020, 0x0000113a, 0x00000101, 0x00000a0b },
1646 { 3, 0x00022020, 0x0000113e, 0x00000101, 0x00000a0b },
1647 { 4, 0x00022020, 0x00001182, 0x00000101, 0x00000a0b },
1648 { 5, 0x00022020, 0x00001186, 0x00000101, 0x00000a0b },
1649 { 6, 0x00022020, 0x0000118a, 0x00000101, 0x00000a0b },
1650 { 7, 0x00022020, 0x0000118e, 0x00000101, 0x00000a0b },
1651 { 8, 0x00022020, 0x00001192, 0x00000101, 0x00000a0b },
1652 { 9, 0x00022020, 0x00001196, 0x00000101, 0x00000a0b },
1653 { 10, 0x00022020, 0x0000119a, 0x00000101, 0x00000a0b },
1654 { 11, 0x00022020, 0x0000119e, 0x00000101, 0x00000a0b },
1655 { 12, 0x00022020, 0x000011a2, 0x00000101, 0x00000a0b },
1656 { 13, 0x00022020, 0x000011a6, 0x00000101, 0x00000a0b },
1657 { 14, 0x00022020, 0x000011ae, 0x00000101, 0x00000a1b },
1660 { 36, 0x00022010, 0x00018896, 0x00000101, 0x00000a1f },
1661 { 40, 0x00022010, 0x0001889a, 0x00000101, 0x00000a1f },
1662 { 44, 0x00022010, 0x0001889e, 0x00000101, 0x00000a1f },
1663 { 48, 0x00022010, 0x000188a2, 0x00000101, 0x00000a1f },
1664 { 52, 0x00022010, 0x000188a6, 0x00000101, 0x00000a1f },
1665 { 66, 0x00022010, 0x000188aa, 0x00000101, 0x00000a1f },
1666 { 60, 0x00022010, 0x000188ae, 0x00000101, 0x00000a1f },
1667 { 64, 0x00022010, 0x000188b2, 0x00000101, 0x00000a1f },
1670 { 100, 0x00022010, 0x00008802, 0x00000101, 0x00000a0f },
1671 { 104, 0x00022010, 0x00008806, 0x00000101, 0x00000a0f },
1672 { 108, 0x00022010, 0x0000880a, 0x00000101, 0x00000a0f },
1673 { 112, 0x00022010, 0x0000880e, 0x00000101, 0x00000a0f },
1674 { 116, 0x00022010, 0x00008812, 0x00000101, 0x00000a0f },
1675 { 120, 0x00022010, 0x00008816, 0x00000101, 0x00000a0f },
1676 { 124, 0x00022010, 0x0000881a, 0x00000101, 0x00000a0f },
1677 { 128, 0x00022010, 0x0000881e, 0x00000101, 0x00000a0f },
1678 { 132, 0x00022010, 0x00008822, 0x00000101, 0x00000a0f },
1679 { 136, 0x00022010, 0x00008826, 0x00000101, 0x00000a0f },
1682 { 140, 0x00022010, 0x0000882a, 0x00000101, 0x00000a0f },
1683 { 149, 0x00022020, 0x000090a6, 0x00000101, 0x00000a07 },
1684 { 153, 0x00022020, 0x000090ae, 0x00000101, 0x00000a07 },
1685 { 157, 0x00022020, 0x000090b6, 0x00000101, 0x00000a07 },
1686 { 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
1689 static int rt2500usb_probe_hw_mode(
struct rt2x00_dev *rt2x00dev)
1705 rt2x00dev->
hw->flags =
1711 SET_IEEE80211_DEV(rt2x00dev->
hw, rt2x00dev->
dev);
1712 SET_IEEE80211_PERM_ADDR(rt2x00dev->
hw,
1713 rt2x00_eeprom_addr(rt2x00dev,
1722 if (rt2x00_rf(rt2x00dev,
RF2522)) {
1725 }
else if (rt2x00_rf(rt2x00dev,
RF2523)) {
1728 }
else if (rt2x00_rf(rt2x00dev,
RF2524)) {
1731 }
else if (rt2x00_rf(rt2x00dev,
RF2525)) {
1734 }
else if (rt2x00_rf(rt2x00dev,
RF2525E)) {
1737 }
else if (rt2x00_rf(rt2x00dev,
RF5222)) {
1753 for (i = 0; i < 14; i++) {
1768 static int rt2500usb_probe_hw(
struct rt2x00_dev *rt2x00dev)
1776 retval = rt2500usb_validate_eeprom(rt2x00dev);
1780 retval = rt2500usb_init_eeprom(rt2x00dev);
1788 rt2500usb_register_read(rt2x00dev,
MAC_CSR19, ®);
1790 rt2500usb_register_write(rt2x00dev,
MAC_CSR19, reg);
1795 retval = rt2500usb_probe_hw_mode(rt2x00dev);
1804 if (!modparam_nohwcrypt) {
1819 static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1843 .probe_hw = rt2500usb_probe_hw,
1847 .set_device_state = rt2500usb_set_device_state,
1848 .rfkill_poll = rt2500usb_rfkill_poll,
1849 .link_stats = rt2500usb_link_stats,
1850 .reset_tuner = rt2500usb_reset_tuner,
1852 .start_queue = rt2500usb_start_queue,
1854 .stop_queue = rt2500usb_stop_queue,
1856 .write_tx_desc = rt2500usb_write_tx_desc,
1857 .write_beacon = rt2500usb_write_beacon,
1858 .get_tx_data_len = rt2500usb_get_tx_data_len,
1859 .fill_rxdone = rt2500usb_fill_rxdone,
1860 .config_shared_key = rt2500usb_config_key,
1861 .config_pairwise_key = rt2500usb_config_key,
1862 .config_filter = rt2500usb_config_filter,
1863 .config_intf = rt2500usb_config_intf,
1864 .config_erp = rt2500usb_config_erp,
1865 .config_ant = rt2500usb_config_ant,
1866 .config = rt2500usb_config,
1897 static const struct rt2x00_ops rt2500usb_ops = {
1898 .name = KBUILD_MODNAME,
1904 .rx = &rt2500usb_queue_rx,
1905 .tx = &rt2500usb_queue_tx,
1906 .bcn = &rt2500usb_queue_bcn,
1907 .atim = &rt2500usb_queue_atim,
1908 .lib = &rt2500usb_rt2x00_ops,
1909 .hw = &rt2500usb_mac80211_ops,
1910 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
1911 .debugfs = &rt2500usb_rt2x00debug,
1920 { USB_DEVICE(0x0b05, 0x1706) },
1921 { USB_DEVICE(0x0b05, 0x1707) },
1923 { USB_DEVICE(0x050d, 0x7050) },
1924 { USB_DEVICE(0x050d, 0x7051) },
1926 { USB_DEVICE(0x13b1, 0x000d) },
1927 { USB_DEVICE(0x13b1, 0x0011) },
1928 { USB_DEVICE(0x13b1, 0x001a) },
1930 { USB_DEVICE(0x14b2, 0x3c02) },
1932 { USB_DEVICE(0x2001, 0x3c00) },
1934 { USB_DEVICE(0x1044, 0x8001) },
1935 { USB_DEVICE(0x1044, 0x8007) },
1937 { USB_DEVICE(0x06f8, 0xe000) },
1939 { USB_DEVICE(0x0411, 0x005e) },
1940 { USB_DEVICE(0x0411, 0x0066) },
1941 { USB_DEVICE(0x0411, 0x0067) },
1942 { USB_DEVICE(0x0411, 0x008b) },
1943 { USB_DEVICE(0x0411, 0x0097) },
1945 { USB_DEVICE(0x0db0, 0x6861) },
1946 { USB_DEVICE(0x0db0, 0x6865) },
1947 { USB_DEVICE(0x0db0, 0x6869) },
1949 { USB_DEVICE(0x148f, 0x1706) },
1950 { USB_DEVICE(0x148f, 0x2570) },
1951 { USB_DEVICE(0x148f, 0x9020) },
1953 { USB_DEVICE(0x079b, 0x004b) },
1955 { USB_DEVICE(0x0681, 0x3c06) },
1957 { USB_DEVICE(0x0707, 0xee13) },
1959 { USB_DEVICE(0x114b, 0x0110) },
1961 { USB_DEVICE(0x0769, 0x11f3) },
1963 { USB_DEVICE(0x0eb0, 0x9020) },
1965 { USB_DEVICE(0x0f88, 0x3012) },
1967 { USB_DEVICE(0x5a57, 0x0260) },
1984 static struct usb_driver rt2500usb_driver = {
1985 .name = KBUILD_MODNAME,
1986 .id_table = rt2500usb_device_table,
1987 .probe = rt2500usb_probe,
1992 .disable_hub_initiated_lpm = 1,