aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c98
1 files changed, 49 insertions, 49 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index cca1504550dc..9851cefaabf3 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -316,6 +316,17 @@ static int rt2500usb_blink_set(struct led_classdev *led_cdev,
316 316
317 return 0; 317 return 0;
318} 318}
319
320static void rt2500usb_init_led(struct rt2x00_dev *rt2x00dev,
321 struct rt2x00_led *led,
322 enum led_type type)
323{
324 led->rt2x00dev = rt2x00dev;
325 led->type = type;
326 led->led_dev.brightness_set = rt2500usb_brightness_set;
327 led->led_dev.blink_set = rt2500usb_blink_set;
328 led->flags = LED_INITIALIZED;
329}
319#endif /* CONFIG_RT2500USB_LEDS */ 330#endif /* CONFIG_RT2500USB_LEDS */
320 331
321/* 332/*
@@ -847,25 +858,32 @@ static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
847 return 0; 858 return 0;
848} 859}
849 860
850static int rt2500usb_init_bbp(struct rt2x00_dev *rt2x00dev) 861static int rt2500usb_wait_bbp_ready(struct rt2x00_dev *rt2x00dev)
851{ 862{
852 unsigned int i; 863 unsigned int i;
853 u16 eeprom;
854 u8 value; 864 u8 value;
855 u8 reg_id;
856 865
857 for (i = 0; i < REGISTER_BUSY_COUNT; i++) { 866 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
858 rt2500usb_bbp_read(rt2x00dev, 0, &value); 867 rt2500usb_bbp_read(rt2x00dev, 0, &value);
859 if ((value != 0xff) && (value != 0x00)) 868 if ((value != 0xff) && (value != 0x00))
860 goto continue_csr_init; 869 return 0;
861 NOTICE(rt2x00dev, "Waiting for BBP register.\n");
862 udelay(REGISTER_BUSY_DELAY); 870 udelay(REGISTER_BUSY_DELAY);
863 } 871 }
864 872
865 ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); 873 ERROR(rt2x00dev, "BBP register access failed, aborting.\n");
866 return -EACCES; 874 return -EACCES;
875}
876
877static int rt2500usb_init_bbp(struct rt2x00_dev *rt2x00dev)
878{
879 unsigned int i;
880 u16 eeprom;
881 u8 value;
882 u8 reg_id;
883
884 if (unlikely(rt2500usb_wait_bbp_ready(rt2x00dev)))
885 return -EACCES;
867 886
868continue_csr_init:
869 rt2500usb_bbp_write(rt2x00dev, 3, 0x02); 887 rt2500usb_bbp_write(rt2x00dev, 3, 0x02);
870 rt2500usb_bbp_write(rt2x00dev, 4, 0x19); 888 rt2500usb_bbp_write(rt2x00dev, 4, 0x19);
871 rt2500usb_bbp_write(rt2x00dev, 14, 0x1c); 889 rt2500usb_bbp_write(rt2x00dev, 14, 0x1c);
@@ -921,7 +939,8 @@ static void rt2500usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
921 939
922 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg); 940 rt2500usb_register_read(rt2x00dev, TXRX_CSR2, &reg);
923 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX, 941 rt2x00_set_field16(&reg, TXRX_CSR2_DISABLE_RX,
924 state == STATE_RADIO_RX_OFF); 942 (state == STATE_RADIO_RX_OFF) ||
943 (state == STATE_RADIO_RX_OFF_LINK));
925 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg); 944 rt2500usb_register_write(rt2x00dev, TXRX_CSR2, reg);
926} 945}
927 946
@@ -930,11 +949,9 @@ static int rt2500usb_enable_radio(struct rt2x00_dev *rt2x00dev)
930 /* 949 /*
931 * Initialize all registers. 950 * Initialize all registers.
932 */ 951 */
933 if (rt2500usb_init_registers(rt2x00dev) || 952 if (unlikely(rt2500usb_init_registers(rt2x00dev) ||
934 rt2500usb_init_bbp(rt2x00dev)) { 953 rt2500usb_init_bbp(rt2x00dev)))
935 ERROR(rt2x00dev, "Register initialization failed.\n");
936 return -EIO; 954 return -EIO;
937 }
938 955
939 return 0; 956 return 0;
940} 957}
@@ -987,10 +1004,6 @@ static int rt2500usb_set_state(struct rt2x00_dev *rt2x00dev,
987 msleep(30); 1004 msleep(30);
988 } 1005 }
989 1006
990 NOTICE(rt2x00dev, "Device failed to enter state %d, "
991 "current device state: bbp %d and rf %d.\n",
992 state, bbp_state, rf_state);
993
994 return -EBUSY; 1007 return -EBUSY;
995} 1008}
996 1009
@@ -1008,11 +1021,13 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1008 break; 1021 break;
1009 case STATE_RADIO_RX_ON: 1022 case STATE_RADIO_RX_ON:
1010 case STATE_RADIO_RX_ON_LINK: 1023 case STATE_RADIO_RX_ON_LINK:
1011 rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
1012 break;
1013 case STATE_RADIO_RX_OFF: 1024 case STATE_RADIO_RX_OFF:
1014 case STATE_RADIO_RX_OFF_LINK: 1025 case STATE_RADIO_RX_OFF_LINK:
1015 rt2500usb_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 1026 rt2500usb_toggle_rx(rt2x00dev, state);
1027 break;
1028 case STATE_RADIO_IRQ_ON:
1029 case STATE_RADIO_IRQ_OFF:
1030 /* No support, but no error either */
1016 break; 1031 break;
1017 case STATE_DEEP_SLEEP: 1032 case STATE_DEEP_SLEEP:
1018 case STATE_SLEEP: 1033 case STATE_SLEEP:
@@ -1025,6 +1040,10 @@ static int rt2500usb_set_device_state(struct rt2x00_dev *rt2x00dev,
1025 break; 1040 break;
1026 } 1041 }
1027 1042
1043 if (unlikely(retval))
1044 ERROR(rt2x00dev, "Device failed to enter state %d (%d).\n",
1045 state, retval);
1046
1028 return retval; 1047 return retval;
1029} 1048}
1030 1049
@@ -1069,7 +1088,8 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1069 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, 1088 rt2x00_set_field32(&word, TXD_W0_NEW_SEQ,
1070 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); 1089 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1071 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); 1090 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1072 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); 1091 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT,
1092 skb->len - skbdesc->desc_len);
1073 rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE); 1093 rt2x00_set_field32(&word, TXD_W0_CIPHER, CIPHER_NONE);
1074 rt2x00_desc_write(txd, 0, word); 1094 rt2x00_desc_write(txd, 0, word);
1075} 1095}
@@ -1097,8 +1117,10 @@ static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1097{ 1117{
1098 u16 reg; 1118 u16 reg;
1099 1119
1100 if (queue != QID_BEACON) 1120 if (queue != QID_BEACON) {
1121 rt2x00usb_kick_tx_queue(rt2x00dev, queue);
1101 return; 1122 return;
1123 }
1102 1124
1103 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg); 1125 rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
1104 if (!rt2x00_get_field16(reg, TXRX_CSR19_BEACON_GEN)) { 1126 if (!rt2x00_get_field16(reg, TXRX_CSR19_BEACON_GEN)) {
@@ -1134,14 +1156,10 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1134 u32 word1; 1156 u32 word1;
1135 1157
1136 /* 1158 /*
1137 * Copy descriptor to the skb->cb array, this has 2 benefits: 1159 * Copy descriptor to the skbdesc->desc buffer, making it safe from moving of
1138 * 1) Each descriptor word is 4 byte aligned. 1160 * frame data in rt2x00usb.
1139 * 2) Descriptor is safe from moving of frame data in rt2x00usb.
1140 */ 1161 */
1141 skbdesc->desc_len = 1162 memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
1142 min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb));
1143 memcpy(entry->skb->cb, rxd, skbdesc->desc_len);
1144 skbdesc->desc = entry->skb->cb;
1145 rxd = (__le32 *)skbdesc->desc; 1163 rxd = (__le32 *)skbdesc->desc;
1146 1164
1147 /* 1165 /*
@@ -1175,8 +1193,6 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1175 * Adjust the skb memory window to the frame boundaries. 1193 * Adjust the skb memory window to the frame boundaries.
1176 */ 1194 */
1177 skb_trim(entry->skb, rxdesc->size); 1195 skb_trim(entry->skb, rxdesc->size);
1178 skbdesc->data = entry->skb->data;
1179 skbdesc->data_len = rxdesc->size;
1180} 1196}
1181 1197
1182/* 1198/*
@@ -1377,23 +1393,10 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1377#ifdef CONFIG_RT2500USB_LEDS 1393#ifdef CONFIG_RT2500USB_LEDS
1378 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1394 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1379 1395
1380 rt2x00dev->led_radio.rt2x00dev = rt2x00dev; 1396 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1381 rt2x00dev->led_radio.type = LED_TYPE_RADIO; 1397 if (value == LED_MODE_TXRX_ACTIVITY)
1382 rt2x00dev->led_radio.led_dev.brightness_set = 1398 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1383 rt2500usb_brightness_set; 1399 LED_TYPE_ACTIVITY);
1384 rt2x00dev->led_radio.led_dev.blink_set =
1385 rt2500usb_blink_set;
1386 rt2x00dev->led_radio.flags = LED_INITIALIZED;
1387
1388 if (value == LED_MODE_TXRX_ACTIVITY) {
1389 rt2x00dev->led_qual.rt2x00dev = rt2x00dev;
1390 rt2x00dev->led_qual.type = LED_TYPE_ACTIVITY;
1391 rt2x00dev->led_qual.led_dev.brightness_set =
1392 rt2500usb_brightness_set;
1393 rt2x00dev->led_qual.led_dev.blink_set =
1394 rt2500usb_blink_set;
1395 rt2x00dev->led_qual.flags = LED_INITIALIZED;
1396 }
1397#endif /* CONFIG_RT2500USB_LEDS */ 1400#endif /* CONFIG_RT2500USB_LEDS */
1398 1401
1399 /* 1402 /*
@@ -1703,9 +1706,6 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
1703 */ 1706 */
1704 skbdesc = get_skb_frame_desc(skb); 1707 skbdesc = get_skb_frame_desc(skb);
1705 memset(skbdesc, 0, sizeof(*skbdesc)); 1708 memset(skbdesc, 0, sizeof(*skbdesc));
1706 skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
1707 skbdesc->data = skb->data + intf->beacon->queue->desc_size;
1708 skbdesc->data_len = skb->len - intf->beacon->queue->desc_size;
1709 skbdesc->desc = skb->data; 1709 skbdesc->desc = skb->data;
1710 skbdesc->desc_len = intf->beacon->queue->desc_size; 1710 skbdesc->desc_len = intf->beacon->queue->desc_size;
1711 skbdesc->entry = intf->beacon; 1711 skbdesc->entry = intf->beacon;