30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/pci.h>
34 #include <linux/slab.h>
53 #define WAIT_FOR_BBP(__dev, __reg) \
54 rt2x00pci_regbusy_read((__dev), BBPCSR, BBPCSR_BUSY, (__reg))
55 #define WAIT_FOR_RF(__dev, __reg) \
56 rt2x00pci_regbusy_read((__dev), RFCSR, RFCSR_BUSY, (__reg))
58 static void rt2500pci_bbp_write(
struct rt2x00_dev *rt2x00dev,
76 rt2x00pci_register_write(rt2x00dev,
BBPCSR, reg);
82 static void rt2500pci_bbp_read(
struct rt2x00_dev *rt2x00dev,
103 rt2x00pci_register_write(rt2x00dev,
BBPCSR, reg);
113 static void rt2500pci_rf_write(
struct rt2x00_dev *rt2x00dev,
114 const unsigned int word,
const u32 value)
131 rt2x00pci_register_write(rt2x00dev,
RFCSR, reg);
132 rt2x00_rf_write(rt2x00dev, word, value);
143 rt2x00pci_register_read(rt2x00dev,
CSR21, ®);
165 rt2x00pci_register_write(rt2x00dev,
CSR21, reg);
168 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
169 static const struct rt2x00debug rt2500pci_rt2x00debug = {
172 .read = rt2x00pci_register_read,
173 .write = rt2x00pci_register_write,
176 .word_size =
sizeof(
u32),
180 .read = rt2x00_eeprom_read,
181 .write = rt2x00_eeprom_write,
183 .word_size =
sizeof(
u16),
187 .read = rt2500pci_bbp_read,
188 .write = rt2500pci_bbp_write,
190 .word_size =
sizeof(
u8),
194 .read = rt2x00_rf_read,
195 .write = rt2500pci_rf_write,
197 .word_size =
sizeof(
u32),
203 static int rt2500pci_rfkill_poll(
struct rt2x00_dev *rt2x00dev)
207 rt2x00pci_register_read(rt2x00dev,
GPIOCSR, ®);
211 #ifdef CONFIG_RT2X00_LIB_LEDS
212 static void rt2500pci_brightness_set(
struct led_classdev *led_cdev,
230 static int rt2500pci_blink_set(
struct led_classdev *led_cdev,
231 unsigned long *delay_on,
232 unsigned long *delay_off)
246 static void rt2500pci_init_led(
struct rt2x00_dev *rt2x00dev,
252 led->
led_dev.brightness_set = rt2500pci_brightness_set;
253 led->
led_dev.blink_set = rt2500pci_blink_set;
261 static void rt2500pci_config_filter(
struct rt2x00_dev *rt2x00dev,
262 const unsigned int filter_flags)
272 rt2x00pci_register_read(rt2x00dev,
RXCSR0, ®);
288 rt2x00pci_register_write(rt2x00dev,
RXCSR0, reg);
291 static void rt2500pci_config_intf(
struct rt2x00_dev *rt2x00dev,
294 const unsigned int flags)
297 unsigned int bcn_preload;
305 rt2x00pci_register_read(rt2x00dev,
BCNCSR1, ®);
308 rt2x00pci_register_write(rt2x00dev,
BCNCSR1, reg);
313 rt2x00pci_register_read(rt2x00dev,
CSR14, ®);
315 rt2x00pci_register_write(rt2x00dev,
CSR14, reg);
319 rt2x00pci_register_multiwrite(rt2x00dev,
CSR3,
320 conf->
mac,
sizeof(conf->
mac));
323 rt2x00pci_register_multiwrite(rt2x00dev,
CSR5,
327 static void rt2500pci_config_erp(
struct rt2x00_dev *rt2x00dev,
340 rt2x00pci_register_read(rt2x00dev,
TXCSR1, ®);
345 rt2x00pci_register_write(rt2x00dev,
TXCSR1, reg);
347 rt2x00pci_register_read(rt2x00dev,
ARCSR2, ®);
352 rt2x00pci_register_write(rt2x00dev,
ARCSR2, reg);
354 rt2x00pci_register_read(rt2x00dev,
ARCSR3, ®);
359 rt2x00pci_register_write(rt2x00dev,
ARCSR3, reg);
361 rt2x00pci_register_read(rt2x00dev,
ARCSR4, ®);
366 rt2x00pci_register_write(rt2x00dev,
ARCSR4, reg);
368 rt2x00pci_register_read(rt2x00dev,
ARCSR5, ®);
373 rt2x00pci_register_write(rt2x00dev,
ARCSR5, reg);
380 rt2x00pci_register_read(rt2x00dev,
CSR11, ®);
382 rt2x00pci_register_write(rt2x00dev,
CSR11, reg);
384 rt2x00pci_register_read(rt2x00dev,
CSR18, ®);
387 rt2x00pci_register_write(rt2x00dev,
CSR18, reg);
389 rt2x00pci_register_read(rt2x00dev,
CSR19, ®);
392 rt2x00pci_register_write(rt2x00dev,
CSR19, reg);
396 rt2x00pci_register_read(rt2x00dev,
CSR12, ®);
401 rt2x00pci_register_write(rt2x00dev,
CSR12, reg);
406 static void rt2500pci_config_ant(
struct rt2x00_dev *rt2x00dev,
420 rt2x00pci_register_read(rt2x00dev,
BBPCSR1, ®);
421 rt2500pci_bbp_read(rt2x00dev, 14, &r14);
422 rt2500pci_bbp_read(rt2x00dev, 2, &r2);
457 if (rt2x00_rf(rt2x00dev,
RF2525E) || rt2x00_rf(rt2x00dev,
RF5222)) {
465 if (rt2x00_rf(rt2x00dev,
RF2525E))
472 rt2x00pci_register_write(rt2x00dev,
BBPCSR1, reg);
473 rt2500pci_bbp_write(rt2x00dev, 14, r14);
474 rt2500pci_bbp_write(rt2x00dev, 2, r2);
477 static void rt2500pci_config_channel(
struct rt2x00_dev *rt2x00dev,
491 if (!rt2x00_rf(rt2x00dev,
RF2523))
498 if (rt2x00_rf(rt2x00dev,
RF2525)) {
499 static const u32 vals[] = {
500 0x00080cbe, 0x00080d02, 0x00080d06, 0x00080d0a,
501 0x00080d0e, 0x00080d12, 0x00080d16, 0x00080d1a,
502 0x00080d1e, 0x00080d22, 0x00080d26, 0x00080d2a,
503 0x00080d2e, 0x00080d3a
506 rt2500pci_rf_write(rt2x00dev, 1, rf->
rf1);
507 rt2500pci_rf_write(rt2x00dev, 2, vals[rf->
channel - 1]);
508 rt2500pci_rf_write(rt2x00dev, 3, rf->
rf3);
510 rt2500pci_rf_write(rt2x00dev, 4, rf->
rf4);
513 rt2500pci_rf_write(rt2x00dev, 1, rf->
rf1);
514 rt2500pci_rf_write(rt2x00dev, 2, rf->
rf2);
515 rt2500pci_rf_write(rt2x00dev, 3, rf->
rf3);
517 rt2500pci_rf_write(rt2x00dev, 4, rf->
rf4);
524 rt2500pci_bbp_write(rt2x00dev, 70, r70);
532 if (!rt2x00_rf(rt2x00dev,
RF2523)) {
534 rt2500pci_rf_write(rt2x00dev, 1, rf->
rf1);
538 rt2500pci_rf_write(rt2x00dev, 3, rf->
rf3);
543 rt2x00pci_register_read(rt2x00dev,
CNT0, &rf->
rf1);
546 static void rt2500pci_config_txpower(
struct rt2x00_dev *rt2x00dev,
551 rt2x00_rf_read(rt2x00dev, 3, &rf3);
553 rt2500pci_rf_write(rt2x00dev, 3, rf3);
556 static void rt2500pci_config_retry_limit(
struct rt2x00_dev *rt2x00dev,
561 rt2x00pci_register_read(rt2x00dev,
CSR11, ®);
563 libconf->
conf->long_frame_max_tx_count);
565 libconf->
conf->short_frame_max_tx_count);
566 rt2x00pci_register_write(rt2x00dev,
CSR11, reg);
569 static void rt2500pci_config_ps(
struct rt2x00_dev *rt2x00dev,
578 rt2x00pci_register_read(rt2x00dev,
CSR20, ®);
582 libconf->
conf->listen_interval - 1);
586 rt2x00pci_register_write(rt2x00dev,
CSR20, reg);
589 rt2x00pci_register_write(rt2x00dev,
CSR20, reg);
591 rt2x00pci_register_read(rt2x00dev,
CSR20, ®);
593 rt2x00pci_register_write(rt2x00dev,
CSR20, reg);
596 rt2x00dev->
ops->lib->set_device_state(rt2x00dev, state);
599 static void rt2500pci_config(
struct rt2x00_dev *rt2x00dev,
601 const unsigned int flags)
604 rt2500pci_config_channel(rt2x00dev, &libconf->
rf,
605 libconf->
conf->power_level);
607 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
608 rt2500pci_config_txpower(rt2x00dev,
609 libconf->
conf->power_level);
611 rt2500pci_config_retry_limit(rt2x00dev, libconf);
613 rt2500pci_config_ps(rt2x00dev, libconf);
619 static void rt2500pci_link_stats(
struct rt2x00_dev *rt2x00dev,
627 rt2x00pci_register_read(rt2x00dev,
CNT0, ®);
633 rt2x00pci_register_read(rt2x00dev,
CNT3, ®);
637 static inline void rt2500pci_set_vgc(
struct rt2x00_dev *rt2x00dev,
641 rt2500pci_bbp_write(rt2x00dev, 17, vgc_level);
647 static void rt2500pci_reset_tuner(
struct rt2x00_dev *rt2x00dev,
650 rt2500pci_set_vgc(rt2x00dev, qual, 0x48);
653 static void rt2500pci_link_tuner(
struct rt2x00_dev *rt2x00dev,
673 goto dynamic_cca_tune;
680 if (qual->
rssi < -80 && count > 20) {
682 rt2500pci_set_vgc(rt2x00dev, qual, qual->
vgc_level);
689 if (qual->
rssi >= -58) {
690 rt2500pci_set_vgc(rt2x00dev, qual, 0x50);
697 if (qual->
rssi >= -74) {
698 rt2500pci_set_vgc(rt2x00dev, qual, 0x41);
707 rt2500pci_set_vgc(rt2x00dev, qual, qual->
vgc_level);
726 static void rt2500pci_start_queue(
struct data_queue *queue)
731 switch (queue->
qid) {
733 rt2x00pci_register_read(rt2x00dev,
RXCSR0, ®);
735 rt2x00pci_register_write(rt2x00dev,
RXCSR0, reg);
738 rt2x00pci_register_read(rt2x00dev,
CSR14, ®);
742 rt2x00pci_register_write(rt2x00dev,
CSR14, reg);
749 static void rt2500pci_kick_queue(
struct data_queue *queue)
754 switch (queue->
qid) {
756 rt2x00pci_register_read(rt2x00dev,
TXCSR0, ®);
758 rt2x00pci_register_write(rt2x00dev,
TXCSR0, reg);
761 rt2x00pci_register_read(rt2x00dev,
TXCSR0, ®);
763 rt2x00pci_register_write(rt2x00dev,
TXCSR0, reg);
766 rt2x00pci_register_read(rt2x00dev,
TXCSR0, ®);
768 rt2x00pci_register_write(rt2x00dev,
TXCSR0, reg);
775 static void rt2500pci_stop_queue(
struct data_queue *queue)
780 switch (queue->
qid) {
784 rt2x00pci_register_read(rt2x00dev,
TXCSR0, ®);
786 rt2x00pci_register_write(rt2x00dev,
TXCSR0, reg);
789 rt2x00pci_register_read(rt2x00dev,
RXCSR0, ®);
791 rt2x00pci_register_write(rt2x00dev,
RXCSR0, reg);
794 rt2x00pci_register_read(rt2x00dev,
CSR14, ®);
798 rt2x00pci_register_write(rt2x00dev,
CSR14, reg);
813 static bool rt2500pci_get_entry_state(
struct queue_entry *
entry)
818 if (entry->queue->qid ==
QID_RX) {
819 rt2x00_desc_read(entry_priv->
desc, 0, &word);
823 rt2x00_desc_read(entry_priv->
desc, 0, &word);
830 static void rt2500pci_clear_entry(
struct queue_entry *entry)
836 if (entry->queue->qid ==
QID_RX) {
837 rt2x00_desc_read(entry_priv->
desc, 1, &word);
839 rt2x00_desc_write(entry_priv->
desc, 1, word);
841 rt2x00_desc_read(entry_priv->
desc, 0, &word);
843 rt2x00_desc_write(entry_priv->
desc, 0, word);
845 rt2x00_desc_read(entry_priv->
desc, 0, &word);
848 rt2x00_desc_write(entry_priv->
desc, 0, word);
852 static int rt2500pci_init_queues(
struct rt2x00_dev *rt2x00dev)
860 rt2x00pci_register_read(rt2x00dev,
TXCSR2, ®);
865 rt2x00pci_register_write(rt2x00dev,
TXCSR2, reg);
867 entry_priv = rt2x00dev->
tx[1].entries[0].priv_data;
868 rt2x00pci_register_read(rt2x00dev,
TXCSR3, ®);
871 rt2x00pci_register_write(rt2x00dev,
TXCSR3, reg);
873 entry_priv = rt2x00dev->
tx[0].entries[0].priv_data;
874 rt2x00pci_register_read(rt2x00dev,
TXCSR5, ®);
877 rt2x00pci_register_write(rt2x00dev,
TXCSR5, reg);
879 entry_priv = rt2x00dev->
atim->entries[0].priv_data;
880 rt2x00pci_register_read(rt2x00dev,
TXCSR4, ®);
883 rt2x00pci_register_write(rt2x00dev,
TXCSR4, reg);
885 entry_priv = rt2x00dev->
bcn->entries[0].priv_data;
886 rt2x00pci_register_read(rt2x00dev,
TXCSR6, ®);
889 rt2x00pci_register_write(rt2x00dev,
TXCSR6, reg);
891 rt2x00pci_register_read(rt2x00dev,
RXCSR1, ®);
894 rt2x00pci_register_write(rt2x00dev,
RXCSR1, reg);
896 entry_priv = rt2x00dev->
rx->entries[0].priv_data;
897 rt2x00pci_register_read(rt2x00dev,
RXCSR2, ®);
900 rt2x00pci_register_write(rt2x00dev,
RXCSR2, reg);
905 static int rt2500pci_init_registers(
struct rt2x00_dev *rt2x00dev)
909 rt2x00pci_register_write(rt2x00dev,
PSCSR0, 0x00020002);
910 rt2x00pci_register_write(rt2x00dev,
PSCSR1, 0x00000002);
911 rt2x00pci_register_write(rt2x00dev,
PSCSR2, 0x00020002);
912 rt2x00pci_register_write(rt2x00dev,
PSCSR3, 0x00000002);
914 rt2x00pci_register_read(rt2x00dev,
TIMECSR, ®);
918 rt2x00pci_register_write(rt2x00dev,
TIMECSR, reg);
920 rt2x00pci_register_read(rt2x00dev,
CSR9, ®);
922 rt2x00dev->
rx->data_size / 128);
923 rt2x00pci_register_write(rt2x00dev,
CSR9, reg);
928 rt2x00pci_register_read(rt2x00dev,
CSR11, ®);
930 rt2x00pci_register_write(rt2x00dev,
CSR11, reg);
932 rt2x00pci_register_read(rt2x00dev,
CSR14, ®);
941 rt2x00pci_register_write(rt2x00dev,
CSR14, reg);
943 rt2x00pci_register_write(rt2x00dev,
CNT3, 0);
945 rt2x00pci_register_read(rt2x00dev,
TXCSR8, ®);
954 rt2x00pci_register_write(rt2x00dev,
TXCSR8, reg);
956 rt2x00pci_register_read(rt2x00dev,
ARTCSR0, ®);
961 rt2x00pci_register_write(rt2x00dev,
ARTCSR0, reg);
963 rt2x00pci_register_read(rt2x00dev,
ARTCSR1, ®);
968 rt2x00pci_register_write(rt2x00dev,
ARTCSR1, reg);
970 rt2x00pci_register_read(rt2x00dev,
ARTCSR2, ®);
975 rt2x00pci_register_write(rt2x00dev,
ARTCSR2, reg);
977 rt2x00pci_register_read(rt2x00dev,
RXCSR3, ®);
986 rt2x00pci_register_write(rt2x00dev,
RXCSR3, reg);
988 rt2x00pci_register_read(rt2x00dev,
PCICSR, ®);
996 rt2x00pci_register_write(rt2x00dev,
PCICSR, reg);
998 rt2x00pci_register_write(rt2x00dev,
PWRCSR0, 0x3f3b3100);
1000 rt2x00pci_register_write(rt2x00dev,
GPIOCSR, 0x0000ff00);
1001 rt2x00pci_register_write(rt2x00dev,
TESTCSR, 0x000000f0);
1003 if (rt2x00dev->
ops->lib->set_device_state(rt2x00dev,
STATE_AWAKE))
1006 rt2x00pci_register_write(rt2x00dev,
MACCSR0, 0x00213223);
1007 rt2x00pci_register_write(rt2x00dev,
MACCSR1, 0x00235518);
1009 rt2x00pci_register_read(rt2x00dev,
MACCSR2, ®);
1011 rt2x00pci_register_write(rt2x00dev,
MACCSR2, reg);
1013 rt2x00pci_register_read(rt2x00dev,
RALINKCSR, ®);
1020 rt2x00pci_register_write(rt2x00dev,
RALINKCSR, reg);
1022 rt2x00pci_register_write(rt2x00dev,
BBPCSR1, 0x82188200);
1024 rt2x00pci_register_write(rt2x00dev,
TXACKCSR0, 0x00000020);
1026 rt2x00pci_register_read(rt2x00dev,
CSR1, ®);
1030 rt2x00pci_register_write(rt2x00dev,
CSR1, reg);
1032 rt2x00pci_register_read(rt2x00dev,
CSR1, ®);
1035 rt2x00pci_register_write(rt2x00dev,
CSR1, reg);
1042 rt2x00pci_register_read(rt2x00dev,
CNT0, ®);
1043 rt2x00pci_register_read(rt2x00dev,
CNT4, ®);
1048 static int rt2500pci_wait_bbp_ready(
struct rt2x00_dev *rt2x00dev)
1054 rt2500pci_bbp_read(rt2x00dev, 0, &value);
1055 if ((value != 0xff) && (value != 0x00))
1060 ERROR(rt2x00dev,
"BBP register access failed, aborting.\n");
1064 static int rt2500pci_init_bbp(
struct rt2x00_dev *rt2x00dev)
1071 if (
unlikely(rt2500pci_wait_bbp_ready(rt2x00dev)))
1074 rt2500pci_bbp_write(rt2x00dev, 3, 0x02);
1075 rt2500pci_bbp_write(rt2x00dev, 4, 0x19);
1076 rt2500pci_bbp_write(rt2x00dev, 14, 0x1c);
1077 rt2500pci_bbp_write(rt2x00dev, 15, 0x30);
1078 rt2500pci_bbp_write(rt2x00dev, 16, 0xac);
1079 rt2500pci_bbp_write(rt2x00dev, 18, 0x18);
1080 rt2500pci_bbp_write(rt2x00dev, 19, 0xff);
1081 rt2500pci_bbp_write(rt2x00dev, 20, 0x1e);
1082 rt2500pci_bbp_write(rt2x00dev, 21, 0x08);
1083 rt2500pci_bbp_write(rt2x00dev, 22, 0x08);
1084 rt2500pci_bbp_write(rt2x00dev, 23, 0x08);
1085 rt2500pci_bbp_write(rt2x00dev, 24, 0x70);
1086 rt2500pci_bbp_write(rt2x00dev, 25, 0x40);
1087 rt2500pci_bbp_write(rt2x00dev, 26, 0x08);
1088 rt2500pci_bbp_write(rt2x00dev, 27, 0x23);
1089 rt2500pci_bbp_write(rt2x00dev, 30, 0x10);
1090 rt2500pci_bbp_write(rt2x00dev, 31, 0x2b);
1091 rt2500pci_bbp_write(rt2x00dev, 32, 0xb9);
1092 rt2500pci_bbp_write(rt2x00dev, 34, 0x12);
1093 rt2500pci_bbp_write(rt2x00dev, 35, 0x50);
1094 rt2500pci_bbp_write(rt2x00dev, 39, 0xc4);
1095 rt2500pci_bbp_write(rt2x00dev, 40, 0x02);
1096 rt2500pci_bbp_write(rt2x00dev, 41, 0x60);
1097 rt2500pci_bbp_write(rt2x00dev, 53, 0x10);
1098 rt2500pci_bbp_write(rt2x00dev, 54, 0x18);
1099 rt2500pci_bbp_write(rt2x00dev, 56, 0x08);
1100 rt2500pci_bbp_write(rt2x00dev, 57, 0x10);
1101 rt2500pci_bbp_write(rt2x00dev, 58, 0x08);
1102 rt2500pci_bbp_write(rt2x00dev, 61, 0x6d);
1103 rt2500pci_bbp_write(rt2x00dev, 62, 0x10);
1108 if (eeprom != 0xffff && eeprom != 0x0000) {
1111 rt2500pci_bbp_write(rt2x00dev, reg_id, value);
1121 static void rt2500pci_toggle_irq(
struct rt2x00_dev *rt2x00dev,
1126 unsigned long flags;
1133 rt2x00pci_register_read(rt2x00dev,
CSR7, ®);
1134 rt2x00pci_register_write(rt2x00dev,
CSR7, reg);
1143 rt2x00pci_register_read(rt2x00dev,
CSR8, ®);
1149 rt2x00pci_register_write(rt2x00dev,
CSR8, reg);
1151 spin_unlock_irqrestore(&rt2x00dev->
irqmask_lock, flags);
1163 static int rt2500pci_enable_radio(
struct rt2x00_dev *rt2x00dev)
1168 if (
unlikely(rt2500pci_init_queues(rt2x00dev) ||
1169 rt2500pci_init_registers(rt2x00dev) ||
1170 rt2500pci_init_bbp(rt2x00dev)))
1176 static void rt2500pci_disable_radio(
struct rt2x00_dev *rt2x00dev)
1181 rt2x00pci_register_write(rt2x00dev,
PWRCSR0, 0);
1184 static int rt2500pci_set_state(
struct rt2x00_dev *rt2x00dev,
1195 rt2x00pci_register_read(rt2x00dev,
PWRCSR1, ®);
1200 rt2x00pci_register_write(rt2x00dev,
PWRCSR1, reg);
1208 rt2x00pci_register_read(rt2x00dev,
PWRCSR1, ®2);
1211 if (bbp_state == state && rf_state == state)
1213 rt2x00pci_register_write(rt2x00dev,
PWRCSR1, reg);
1220 static int rt2500pci_set_device_state(
struct rt2x00_dev *rt2x00dev,
1227 retval = rt2500pci_enable_radio(rt2x00dev);
1230 rt2500pci_disable_radio(rt2x00dev);
1234 rt2500pci_toggle_irq(rt2x00dev, state);
1240 retval = rt2500pci_set_state(rt2x00dev, state);
1248 ERROR(rt2x00dev,
"Device failed to enter state %d (%d).\n",
1257 static void rt2500pci_write_tx_desc(
struct queue_entry *entry,
1268 rt2x00_desc_read(txd, 1, &word);
1270 rt2x00_desc_write(txd, 1, word);
1272 rt2x00_desc_read(txd, 2, &word);
1277 rt2x00_desc_write(txd, 2, word);
1279 rt2x00_desc_read(txd, 3, &word);
1283 txdesc->
u.
plcp.length_low);
1285 txdesc->
u.
plcp.length_high);
1286 rt2x00_desc_write(txd, 3, word);
1288 rt2x00_desc_read(txd, 10, &word);
1291 rt2x00_desc_write(txd, 10, word);
1298 rt2x00_desc_read(txd, 0, &word);
1315 rt2x00_desc_write(txd, 0, word);
1320 skbdesc->
desc = txd;
1327 static void rt2500pci_write_beacon(
struct queue_entry *entry,
1330 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
1337 rt2x00pci_register_read(rt2x00dev,
CSR14, ®);
1339 rt2x00pci_register_write(rt2x00dev,
CSR14, reg);
1346 rt2500pci_write_tx_desc(entry, txdesc);
1357 rt2x00pci_register_write(rt2x00dev,
CSR14, reg);
1363 static void rt2500pci_fill_rxdone(
struct queue_entry *entry,
1370 rt2x00_desc_read(entry_priv->
desc, 0, &word0);
1371 rt2x00_desc_read(entry_priv->
desc, 2, &word2);
1386 entry->queue->rt2x00dev->rssi_offset;
1400 static void rt2500pci_txdone(
struct rt2x00_dev *rt2x00dev,
1403 struct data_queue *queue = rt2x00queue_get_tx_queue(rt2x00dev, queue_idx);
1405 struct queue_entry *
entry;
1409 while (!rt2x00queue_empty(queue)) {
1411 entry_priv = entry->priv_data;
1412 rt2x00_desc_read(entry_priv->
desc, 0, &word);
1439 static inline void rt2500pci_enable_interrupt(
struct rt2x00_dev *rt2x00dev,
1450 rt2x00pci_register_read(rt2x00dev,
CSR8, ®);
1452 rt2x00pci_register_write(rt2x00dev,
CSR8, reg);
1457 static void rt2500pci_txstatus_tasklet(
unsigned long data)
1465 rt2500pci_txdone(rt2x00dev,
QID_ATIM);
1475 rt2x00pci_register_read(rt2x00dev,
CSR8, ®);
1479 rt2x00pci_register_write(rt2x00dev,
CSR8, reg);
1485 static void rt2500pci_tbtt_tasklet(
unsigned long data)
1493 static void rt2500pci_rxdone_tasklet(
unsigned long data)
1499 rt2500pci_enable_interrupt(rt2x00dev,
CSR8_RXDONE);
1502 static irqreturn_t rt2500pci_interrupt(
int irq,
void *dev_instance)
1511 rt2x00pci_register_read(rt2x00dev,
CSR7, ®);
1512 rt2x00pci_register_write(rt2x00dev,
CSR7, reg);
1549 rt2x00pci_register_read(rt2x00dev,
CSR8, ®);
1551 rt2x00pci_register_write(rt2x00dev,
CSR8, reg);
1561 static int rt2500pci_validate_eeprom(
struct rt2x00_dev *rt2x00dev)
1568 rt2x00pci_register_read(rt2x00dev,
CSR21, ®);
1570 eeprom.data = rt2x00dev;
1571 eeprom.register_read = rt2500pci_eepromregister_read;
1572 eeprom.register_write = rt2500pci_eepromregister_write;
1575 eeprom.reg_data_in = 0;
1576 eeprom.reg_data_out = 0;
1577 eeprom.reg_data_clock = 0;
1578 eeprom.reg_chip_select = 0;
1587 if (!is_valid_ether_addr(mac)) {
1588 eth_random_addr(mac);
1589 EEPROM(rt2x00dev,
"MAC: %pM\n", mac);
1593 if (word == 0xffff) {
1605 EEPROM(rt2x00dev,
"Antenna: 0x%04x\n", word);
1608 rt2x00_eeprom_read(rt2x00dev,
EEPROM_NIC, &word);
1609 if (word == 0xffff) {
1613 rt2x00_eeprom_write(rt2x00dev,
EEPROM_NIC, word);
1614 EEPROM(rt2x00dev,
"NIC: 0x%04x\n", word);
1618 if (word == 0xffff) {
1622 EEPROM(rt2x00dev,
"Calibrate offset: 0x%04x\n", word);
1628 static int rt2500pci_init_eeprom(
struct rt2x00_dev *rt2x00dev)
1643 rt2x00pci_register_read(rt2x00dev,
CSR0, ®);
1644 rt2x00_set_chip(rt2x00dev,
RT2560, value,
1647 if (!rt2x00_rf(rt2x00dev,
RF2522) &&
1648 !rt2x00_rf(rt2x00dev,
RF2523) &&
1649 !rt2x00_rf(rt2x00dev,
RF2524) &&
1650 !rt2x00_rf(rt2x00dev,
RF2525) &&
1651 !rt2x00_rf(rt2x00dev,
RF2525E) &&
1652 !rt2x00_rf(rt2x00dev,
RF5222)) {
1653 ERROR(rt2x00dev,
"Invalid RF chipset detected.\n");
1668 #ifdef CONFIG_RT2X00_LIB_LEDS
1671 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio,
LED_TYPE_RADIO);
1675 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
1688 rt2x00_eeprom_read(rt2x00dev,
EEPROM_NIC, &eeprom);
1706 static const struct rf_channel rf_vals_bg_2522[] = {
1707 { 1, 0x00002050, 0x000c1fda, 0x00000101, 0 },
1708 { 2, 0x00002050, 0x000c1fee, 0x00000101, 0 },
1709 { 3, 0x00002050, 0x000c2002, 0x00000101, 0 },
1710 { 4, 0x00002050, 0x000c2016, 0x00000101, 0 },
1711 { 5, 0x00002050, 0x000c202a, 0x00000101, 0 },
1712 { 6, 0x00002050, 0x000c203e, 0x00000101, 0 },
1713 { 7, 0x00002050, 0x000c2052, 0x00000101, 0 },
1714 { 8, 0x00002050, 0x000c2066, 0x00000101, 0 },
1715 { 9, 0x00002050, 0x000c207a, 0x00000101, 0 },
1716 { 10, 0x00002050, 0x000c208e, 0x00000101, 0 },
1717 { 11, 0x00002050, 0x000c20a2, 0x00000101, 0 },
1718 { 12, 0x00002050, 0x000c20b6, 0x00000101, 0 },
1719 { 13, 0x00002050, 0x000c20ca, 0x00000101, 0 },
1720 { 14, 0x00002050, 0x000c20fa, 0x00000101, 0 },
1727 static const struct rf_channel rf_vals_bg_2523[] = {
1728 { 1, 0x00022010, 0x00000c9e, 0x000e0111, 0x00000a1b },
1729 { 2, 0x00022010, 0x00000ca2, 0x000e0111, 0x00000a1b },
1730 { 3, 0x00022010, 0x00000ca6, 0x000e0111, 0x00000a1b },
1731 { 4, 0x00022010, 0x00000caa, 0x000e0111, 0x00000a1b },
1732 { 5, 0x00022010, 0x00000cae, 0x000e0111, 0x00000a1b },
1733 { 6, 0x00022010, 0x00000cb2, 0x000e0111, 0x00000a1b },
1734 { 7, 0x00022010, 0x00000cb6, 0x000e0111, 0x00000a1b },
1735 { 8, 0x00022010, 0x00000cba, 0x000e0111, 0x00000a1b },
1736 { 9, 0x00022010, 0x00000cbe, 0x000e0111, 0x00000a1b },
1737 { 10, 0x00022010, 0x00000d02, 0x000e0111, 0x00000a1b },
1738 { 11, 0x00022010, 0x00000d06, 0x000e0111, 0x00000a1b },
1739 { 12, 0x00022010, 0x00000d0a, 0x000e0111, 0x00000a1b },
1740 { 13, 0x00022010, 0x00000d0e, 0x000e0111, 0x00000a1b },
1741 { 14, 0x00022010, 0x00000d1a, 0x000e0111, 0x00000a03 },
1748 static const struct rf_channel rf_vals_bg_2524[] = {
1749 { 1, 0x00032020, 0x00000c9e, 0x00000101, 0x00000a1b },
1750 { 2, 0x00032020, 0x00000ca2, 0x00000101, 0x00000a1b },
1751 { 3, 0x00032020, 0x00000ca6, 0x00000101, 0x00000a1b },
1752 { 4, 0x00032020, 0x00000caa, 0x00000101, 0x00000a1b },
1753 { 5, 0x00032020, 0x00000cae, 0x00000101, 0x00000a1b },
1754 { 6, 0x00032020, 0x00000cb2, 0x00000101, 0x00000a1b },
1755 { 7, 0x00032020, 0x00000cb6, 0x00000101, 0x00000a1b },
1756 { 8, 0x00032020, 0x00000cba, 0x00000101, 0x00000a1b },
1757 { 9, 0x00032020, 0x00000cbe, 0x00000101, 0x00000a1b },
1758 { 10, 0x00032020, 0x00000d02, 0x00000101, 0x00000a1b },
1759 { 11, 0x00032020, 0x00000d06, 0x00000101, 0x00000a1b },
1760 { 12, 0x00032020, 0x00000d0a, 0x00000101, 0x00000a1b },
1761 { 13, 0x00032020, 0x00000d0e, 0x00000101, 0x00000a1b },
1762 { 14, 0x00032020, 0x00000d1a, 0x00000101, 0x00000a03 },
1769 static const struct rf_channel rf_vals_bg_2525[] = {
1770 { 1, 0x00022020, 0x00080c9e, 0x00060111, 0x00000a1b },
1771 { 2, 0x00022020, 0x00080ca2, 0x00060111, 0x00000a1b },
1772 { 3, 0x00022020, 0x00080ca6, 0x00060111, 0x00000a1b },
1773 { 4, 0x00022020, 0x00080caa, 0x00060111, 0x00000a1b },
1774 { 5, 0x00022020, 0x00080cae, 0x00060111, 0x00000a1b },
1775 { 6, 0x00022020, 0x00080cb2, 0x00060111, 0x00000a1b },
1776 { 7, 0x00022020, 0x00080cb6, 0x00060111, 0x00000a1b },
1777 { 8, 0x00022020, 0x00080cba, 0x00060111, 0x00000a1b },
1778 { 9, 0x00022020, 0x00080cbe, 0x00060111, 0x00000a1b },
1779 { 10, 0x00022020, 0x00080d02, 0x00060111, 0x00000a1b },
1780 { 11, 0x00022020, 0x00080d06, 0x00060111, 0x00000a1b },
1781 { 12, 0x00022020, 0x00080d0a, 0x00060111, 0x00000a1b },
1782 { 13, 0x00022020, 0x00080d0e, 0x00060111, 0x00000a1b },
1783 { 14, 0x00022020, 0x00080d1a, 0x00060111, 0x00000a03 },
1790 static const struct rf_channel rf_vals_bg_2525e[] = {
1791 { 1, 0x00022020, 0x00081136, 0x00060111, 0x00000a0b },
1792 { 2, 0x00022020, 0x0008113a, 0x00060111, 0x00000a0b },
1793 { 3, 0x00022020, 0x0008113e, 0x00060111, 0x00000a0b },
1794 { 4, 0x00022020, 0x00081182, 0x00060111, 0x00000a0b },
1795 { 5, 0x00022020, 0x00081186, 0x00060111, 0x00000a0b },
1796 { 6, 0x00022020, 0x0008118a, 0x00060111, 0x00000a0b },
1797 { 7, 0x00022020, 0x0008118e, 0x00060111, 0x00000a0b },
1798 { 8, 0x00022020, 0x00081192, 0x00060111, 0x00000a0b },
1799 { 9, 0x00022020, 0x00081196, 0x00060111, 0x00000a0b },
1800 { 10, 0x00022020, 0x0008119a, 0x00060111, 0x00000a0b },
1801 { 11, 0x00022020, 0x0008119e, 0x00060111, 0x00000a0b },
1802 { 12, 0x00022020, 0x000811a2, 0x00060111, 0x00000a0b },
1803 { 13, 0x00022020, 0x000811a6, 0x00060111, 0x00000a0b },
1804 { 14, 0x00022020, 0x000811ae, 0x00060111, 0x00000a1b },
1811 static const struct rf_channel rf_vals_5222[] = {
1812 { 1, 0x00022020, 0x00001136, 0x00000101, 0x00000a0b },
1813 { 2, 0x00022020, 0x0000113a, 0x00000101, 0x00000a0b },
1814 { 3, 0x00022020, 0x0000113e, 0x00000101, 0x00000a0b },
1815 { 4, 0x00022020, 0x00001182, 0x00000101, 0x00000a0b },
1816 { 5, 0x00022020, 0x00001186, 0x00000101, 0x00000a0b },
1817 { 6, 0x00022020, 0x0000118a, 0x00000101, 0x00000a0b },
1818 { 7, 0x00022020, 0x0000118e, 0x00000101, 0x00000a0b },
1819 { 8, 0x00022020, 0x00001192, 0x00000101, 0x00000a0b },
1820 { 9, 0x00022020, 0x00001196, 0x00000101, 0x00000a0b },
1821 { 10, 0x00022020, 0x0000119a, 0x00000101, 0x00000a0b },
1822 { 11, 0x00022020, 0x0000119e, 0x00000101, 0x00000a0b },
1823 { 12, 0x00022020, 0x000011a2, 0x00000101, 0x00000a0b },
1824 { 13, 0x00022020, 0x000011a6, 0x00000101, 0x00000a0b },
1825 { 14, 0x00022020, 0x000011ae, 0x00000101, 0x00000a1b },
1828 { 36, 0x00022010, 0x00018896, 0x00000101, 0x00000a1f },
1829 { 40, 0x00022010, 0x0001889a, 0x00000101, 0x00000a1f },
1830 { 44, 0x00022010, 0x0001889e, 0x00000101, 0x00000a1f },
1831 { 48, 0x00022010, 0x000188a2, 0x00000101, 0x00000a1f },
1832 { 52, 0x00022010, 0x000188a6, 0x00000101, 0x00000a1f },
1833 { 66, 0x00022010, 0x000188aa, 0x00000101, 0x00000a1f },
1834 { 60, 0x00022010, 0x000188ae, 0x00000101, 0x00000a1f },
1835 { 64, 0x00022010, 0x000188b2, 0x00000101, 0x00000a1f },
1838 { 100, 0x00022010, 0x00008802, 0x00000101, 0x00000a0f },
1839 { 104, 0x00022010, 0x00008806, 0x00000101, 0x00000a0f },
1840 { 108, 0x00022010, 0x0000880a, 0x00000101, 0x00000a0f },
1841 { 112, 0x00022010, 0x0000880e, 0x00000101, 0x00000a0f },
1842 { 116, 0x00022010, 0x00008812, 0x00000101, 0x00000a0f },
1843 { 120, 0x00022010, 0x00008816, 0x00000101, 0x00000a0f },
1844 { 124, 0x00022010, 0x0000881a, 0x00000101, 0x00000a0f },
1845 { 128, 0x00022010, 0x0000881e, 0x00000101, 0x00000a0f },
1846 { 132, 0x00022010, 0x00008822, 0x00000101, 0x00000a0f },
1847 { 136, 0x00022010, 0x00008826, 0x00000101, 0x00000a0f },
1850 { 140, 0x00022010, 0x0000882a, 0x00000101, 0x00000a0f },
1851 { 149, 0x00022020, 0x000090a6, 0x00000101, 0x00000a07 },
1852 { 153, 0x00022020, 0x000090ae, 0x00000101, 0x00000a07 },
1853 { 157, 0x00022020, 0x000090b6, 0x00000101, 0x00000a07 },
1854 { 161, 0x00022020, 0x000090be, 0x00000101, 0x00000a07 },
1857 static int rt2500pci_probe_hw_mode(
struct rt2x00_dev *rt2x00dev)
1872 SET_IEEE80211_DEV(rt2x00dev->
hw, rt2x00dev->
dev);
1873 SET_IEEE80211_PERM_ADDR(rt2x00dev->
hw,
1874 rt2x00_eeprom_addr(rt2x00dev,
1883 if (rt2x00_rf(rt2x00dev,
RF2522)) {
1886 }
else if (rt2x00_rf(rt2x00dev,
RF2523)) {
1889 }
else if (rt2x00_rf(rt2x00dev,
RF2524)) {
1892 }
else if (rt2x00_rf(rt2x00dev,
RF2525)) {
1895 }
else if (rt2x00_rf(rt2x00dev,
RF2525E)) {
1898 }
else if (rt2x00_rf(rt2x00dev,
RF5222)) {
1914 for (i = 0; i < 14; i++) {
1929 static int rt2500pci_probe_hw(
struct rt2x00_dev *rt2x00dev)
1937 retval = rt2500pci_validate_eeprom(rt2x00dev);
1941 retval = rt2500pci_init_eeprom(rt2x00dev);
1949 rt2x00pci_register_read(rt2x00dev,
GPIOCSR, ®);
1951 rt2x00pci_register_write(rt2x00dev,
GPIOCSR, reg);
1956 retval = rt2500pci_probe_hw_mode(rt2x00dev);
1985 rt2x00pci_register_read(rt2x00dev,
CSR17, ®);
1987 rt2x00pci_register_read(rt2x00dev,
CSR16, ®);
1993 static int rt2500pci_tx_last_beacon(
struct ieee80211_hw *hw)
1998 rt2x00pci_register_read(rt2x00dev,
CSR15, ®);
2002 static const struct ieee80211_ops rt2500pci_mac80211_ops = {
2015 .get_tsf = rt2500pci_get_tsf,
2016 .tx_last_beacon = rt2500pci_tx_last_beacon,
2026 .irq_handler = rt2500pci_interrupt,
2027 .txstatus_tasklet = rt2500pci_txstatus_tasklet,
2028 .tbtt_tasklet = rt2500pci_tbtt_tasklet,
2029 .rxdone_tasklet = rt2500pci_rxdone_tasklet,
2030 .probe_hw = rt2500pci_probe_hw,
2033 .get_entry_state = rt2500pci_get_entry_state,
2034 .clear_entry = rt2500pci_clear_entry,
2035 .set_device_state = rt2500pci_set_device_state,
2036 .rfkill_poll = rt2500pci_rfkill_poll,
2037 .link_stats = rt2500pci_link_stats,
2038 .reset_tuner = rt2500pci_reset_tuner,
2039 .link_tuner = rt2500pci_link_tuner,
2040 .start_queue = rt2500pci_start_queue,
2041 .kick_queue = rt2500pci_kick_queue,
2042 .stop_queue = rt2500pci_stop_queue,
2044 .write_tx_desc = rt2500pci_write_tx_desc,
2045 .write_beacon = rt2500pci_write_beacon,
2046 .fill_rxdone = rt2500pci_fill_rxdone,
2047 .config_filter = rt2500pci_config_filter,
2048 .config_intf = rt2500pci_config_intf,
2049 .config_erp = rt2500pci_config_erp,
2050 .config_ant = rt2500pci_config_ant,
2051 .config = rt2500pci_config,
2082 static const struct rt2x00_ops rt2500pci_ops = {
2083 .name = KBUILD_MODNAME,
2088 .extra_tx_headroom = 0,
2089 .rx = &rt2500pci_queue_rx,
2090 .tx = &rt2500pci_queue_tx,
2091 .bcn = &rt2500pci_queue_bcn,
2092 .atim = &rt2500pci_queue_atim,
2093 .lib = &rt2500pci_rt2x00_ops,
2094 .hw = &rt2500pci_mac80211_ops,
2095 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
2096 .debugfs = &rt2500pci_rt2x00debug,
2121 static struct pci_driver rt2500pci_driver = {
2122 .name = KBUILD_MODNAME,
2123 .id_table = rt2500pci_device_table,
2124 .probe = rt2500pci_probe,