aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 673350953b8..b08932d7bf2 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -924,25 +924,32 @@ static int rt2500pci_init_registers(struct rt2x00_dev *rt2x00dev)
924 return 0; 924 return 0;
925} 925}
926 926
927static int rt2500pci_init_bbp(struct rt2x00_dev *rt2x00dev) 927static int rt2500pci_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
928{ 928{
929 unsigned int i; 929 unsigned int i;
930 u16 eeprom;
931 u8 reg_id;
932 u8 value; 930 u8 value;
933 931
934 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 932 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
935 rt2500pci_bbp_read(rt2x00dev, 0, &value); 933 rt2500pci_bbp_read(rt2x00dev, 0, &value);
936 if ((value != 0xff) && (value != 0x00)) 934 if ((value != 0xff) && (value != 0x00))
937 goto continue_csr_init; 935 return 0;
938 NOTICE(rt2x00dev, "Waiting for BBP register.\n");
939 udelay(REGISTER_BUSY_DELAY); 936 udelay(REGISTER_BUSY_DELAY);
940 } 937 }
941 938
942 ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 939 ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
943 return -EACCES; 940 return -EACCES;
941}
942
943static int rt2500pci_init_bbp(struct rt2x00_dev *rt2x00dev)
944{
945 unsigned int i;
946 u16 eeprom;
947 u8 reg_id;
948 u8 value;
949
950 if (unlikely(rt2500pci_wait_bbp_ready(rt2x00dev)))
951 return -EACCES;
944 952
945continue_csr_init:
946 rt2500pci_bbp_write(rt2x00dev, 3, 0x02); 953 rt2500pci_bbp_write(rt2x00dev, 3, 0x02);
947 rt2500pci_bbp_write(rt2x00dev, 4, 0x19); 954 rt2500pci_bbp_write(rt2x00dev, 4, 0x19);
948 rt2500pci_bbp_write(rt2x00dev, 14, 0x1c); 955 rt2500pci_bbp_write(rt2x00dev, 14, 0x1c);
@@ -997,7 +1004,8 @@ static void rt2500pci_toggle_rx(struct rt2x00_dev *rt2x00dev,
997 1004
998 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg); 1005 rt2x00pci_register_read(rt2x00dev, RXCSR0, &reg);
999 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX, 1006 rt2x00_set_field32(&reg, RXCSR0_DISABLE_RX,
1000 state == STATE_RADIO_RX_OFF); 1007 (state == STATE_RADIO_RX_OFF) ||
1008 (state == STATE_RADIO_RX_OFF_LINK));
1001 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg); 1009 rt2x00pci_register_write(rt2x00dev, RXCSR0, reg);
1002} 1010}
1003 1011
@@ -1034,17 +1042,10 @@ static int rt2500pci_enable_radio(struct rt2x00_dev *rt2x00dev)
1034 /* 1042 /*
1035 * Initialize all registers. 1043 * Initialize all registers.
1036 */ 1044 */
1037 if (rt2500pci_init_queues(rt2x00dev) || 1045 if (unlikely(rt2500pci_init_queues(rt2x00dev) ||
1038 rt2500pci_init_registers(rt2x00dev) || 1046 rt2500pci_init_registers(rt2x00dev) ||
1039 rt2500pci_init_bbp(rt2x00dev)) { 1047 rt2500pci_init_bbp(rt2x00dev)))
1040 ERROR(rt2x00dev, "Register initialization failed.\n");
1041 return -EIO; 1048 return -EIO;
1042 }
1043
1044 /*
1045 * Enable interrupts.
1046 */
1047 rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_ON);
1048 1049
1049 return 0; 1050 return 0;
1050} 1051}
@@ -1066,11 +1067,6 @@ static void rt2500pci_disable_radio(struct rt2x00_dev *rt2x00dev)
1066 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg); 1067 rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
1067 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1); 1068 rt2x00_set_field32(&reg, TXCSR0_ABORT, 1);
1068 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg); 1069 rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
1069
1070 /*
1071 * Disable interrupts.
1072 */
1073 rt2500pci_toggle_irq(rt2x00dev, STATE_RADIO_IRQ_OFF);
1074} 1070}
1075 1071
1076static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev, 1072static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
@@ -1105,10 +1101,6 @@ static int rt2500pci_set_state(struct rt2x00_dev *rt2x00dev,
1105 msleep(10); 1101 msleep(10);
1106 } 1102 }
1107 1103
1108 NOTICE(rt2x00dev, "Device failed to enter state %d, "
1109 "current device state: bbp %d and rf %d.\n",
1110 state, bbp_state, rf_state);
1111
1112 return -EBUSY; 1104 return -EBUSY;
1113} 1105}
1114 1106
@@ -1126,11 +1118,13 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1126 break; 1118 break;
1127 case STATE_RADIO_RX_ON: 1119 case STATE_RADIO_RX_ON:
1128 case STATE_RADIO_RX_ON_LINK: 1120 case STATE_RADIO_RX_ON_LINK:
1129 rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1130 break;
1131 case STATE_RADIO_RX_OFF: 1121 case STATE_RADIO_RX_OFF:
1132 case STATE_RADIO_RX_OFF_LINK: 1122 case STATE_RADIO_RX_OFF_LINK:
1133 rt2500pci_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 1123 rt2500pci_toggle_rx(rt2x00dev, state);
1124 break;
1125 case STATE_RADIO_IRQ_ON:
1126 case STATE_RADIO_IRQ_OFF:
1127 rt2500pci_toggle_irq(rt2x00dev, state);
1134 break; 1128 break;
1135 case STATE_DEEP_SLEEP: 1129 case STATE_DEEP_SLEEP:
1136 case STATE_SLEEP: 1130 case STATE_SLEEP:
@@ -1143,6 +1137,10 @@ static int rt2500pci_set_device_state(struct rt2x00_dev *rt2x00dev,
1143 break; 1137 break;
1144 } 1138 }
1145 1139
1140 if (unlikely(retval))
1141 ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
1142 state, retval);
1143
1146 return retval; 1144 return retval;
1147} 1145}
1148 1146