aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt73usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-02-03 09:53:40 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:37:00 -0500
commita9450b70a755abf093600035ef5361c53343fe9a (patch)
tree94b509ea1e73454d327f805273a1fce994d95b1b /drivers/net/wireless/rt2x00/rt73usb.c
parentf2a3c7f5c8e3c1356dbbce1e9ac2e7f4d5365ba9 (diff)
rt2x00: Make use of MAC80211_LED_TRIGGERS
Make use of the led triggers provided by mac80211 to control the led status. This can be enabled through a per-driver configuration option which will automatically enable the generic handler in rt2x00lib. This has been enabled for rt2500usb and rt73usb for the moment since the led class will call set_brightness in irq context which will not work correctly with the usb drivers who need to sleep. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c165
1 files changed, 76 insertions, 89 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 9cbc879da037..ca5a9855adbd 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -278,6 +278,50 @@ static const struct rt2x00debug rt73usb_rt2x00debug = {
278}; 278};
279#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 279#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
280 280
281#ifdef CONFIG_RT73USB_LEDS
282static void rt73usb_led_brightness(struct led_classdev *led_cdev,
283 enum led_brightness brightness)
284{
285 struct rt2x00_led *led =
286 container_of(led_cdev, struct rt2x00_led, led_dev);
287 unsigned int enabled = brightness != LED_OFF;
288 unsigned int a_mode =
289 (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_5GHZ);
290 unsigned int bg_mode =
291 (enabled && led->rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
292
293 if (led->type == LED_TYPE_RADIO) {
294 rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
295 MCU_LEDCS_RADIO_STATUS, enabled);
296
297 rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL, 0,
298 led->rt2x00dev->led_mcu_reg,
299 REGISTER_TIMEOUT);
300 } else if (led->type == LED_TYPE_ASSOC) {
301 rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
302 MCU_LEDCS_LINK_BG_STATUS, bg_mode);
303 rt2x00_set_field16(&led->rt2x00dev->led_mcu_reg,
304 MCU_LEDCS_LINK_A_STATUS, a_mode);
305
306 rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL, 0,
307 led->rt2x00dev->led_mcu_reg,
308 REGISTER_TIMEOUT);
309 } else if (led->type == LED_TYPE_QUALITY) {
310 /*
311 * The brightness is divided into 6 levels (0 - 5),
312 * this means we need to convert the brightness
313 * argument into the matching level within that range.
314 */
315 rt2x00usb_vendor_request_sw(led->rt2x00dev, USB_LED_CONTROL,
316 brightness / (LED_FULL / 6),
317 led->rt2x00dev->led_mcu_reg,
318 REGISTER_TIMEOUT);
319 }
320}
321#else
322#define rt73usb_led_brightness NULL
323#endif /* CONFIG_RT73USB_LEDS */
324
281/* 325/*
282 * Configuration handlers. 326 * Configuration handlers.
283 */ 327 */
@@ -630,68 +674,6 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
630} 674}
631 675
632/* 676/*
633 * LED functions.
634 */
635static void rt73usb_enable_led(struct rt2x00_dev *rt2x00dev)
636{
637 u32 reg;
638
639 rt73usb_register_read(rt2x00dev, MAC_CSR14, &reg);
640 rt2x00_set_field32(&reg, MAC_CSR14_ON_PERIOD, 70);
641 rt2x00_set_field32(&reg, MAC_CSR14_OFF_PERIOD, 30);
642 rt73usb_register_write(rt2x00dev, MAC_CSR14, reg);
643
644 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1);
645 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
646 (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ));
647 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
648 (rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ));
649
650 rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000,
651 rt2x00dev->led_reg, REGISTER_TIMEOUT);
652}
653
654static void rt73usb_disable_led(struct rt2x00_dev *rt2x00dev)
655{
656 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 0);
657 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, 0);
658 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, 0);
659
660 rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000,
661 rt2x00dev->led_reg, REGISTER_TIMEOUT);
662}
663
664static void rt73usb_activity_led(struct rt2x00_dev *rt2x00dev, int rssi)
665{
666 u32 led;
667
668 if (rt2x00dev->led_mode != LED_MODE_SIGNAL_STRENGTH)
669 return;
670
671 /*
672 * Led handling requires a positive value for the rssi,
673 * to do that correctly we need to add the correction.
674 */
675 rssi += rt2x00dev->rssi_offset;
676
677 if (rssi <= 30)
678 led = 0;
679 else if (rssi <= 39)
680 led = 1;
681 else if (rssi <= 49)
682 led = 2;
683 else if (rssi <= 53)
684 led = 3;
685 else if (rssi <= 63)
686 led = 4;
687 else
688 led = 5;
689
690 rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, led,
691 rt2x00dev->led_reg, REGISTER_TIMEOUT);
692}
693
694/*
695 * Link tuning 677 * Link tuning
696 */ 678 */
697static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev, 679static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev,
@@ -725,11 +707,6 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
725 u8 up_bound; 707 u8 up_bound;
726 u8 low_bound; 708 u8 low_bound;
727 709
728 /*
729 * Update Led strength
730 */
731 rt73usb_activity_led(rt2x00dev, rssi);
732
733 rt73usb_bbp_read(rt2x00dev, 17, &r17); 710 rt73usb_bbp_read(rt2x00dev, 17, &r17);
734 711
735 /* 712 /*
@@ -914,8 +891,6 @@ static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
914 return status; 891 return status;
915 } 892 }
916 893
917 rt73usb_disable_led(rt2x00dev);
918
919 return 0; 894 return 0;
920} 895}
921 896
@@ -993,6 +968,11 @@ static int rt73usb_init_registers(struct rt2x00_dev *rt2x00dev)
993 968
994 rt73usb_register_write(rt2x00dev, MAC_CSR13, 0x00007f00); 969 rt73usb_register_write(rt2x00dev, MAC_CSR13, 0x00007f00);
995 970
971 rt73usb_register_read(rt2x00dev, MAC_CSR14, &reg);
972 rt2x00_set_field32(&reg, MAC_CSR14_ON_PERIOD, 70);
973 rt2x00_set_field32(&reg, MAC_CSR14_OFF_PERIOD, 30);
974 rt73usb_register_write(rt2x00dev, MAC_CSR14, reg);
975
996 /* 976 /*
997 * Invalidate all Shared Keys (SEC_CSR0), 977 * Invalidate all Shared Keys (SEC_CSR0),
998 * and clear the Shared key Cipher algorithms (SEC_CSR1 & SEC_CSR5) 978 * and clear the Shared key Cipher algorithms (SEC_CSR1 & SEC_CSR5)
@@ -1152,21 +1132,11 @@ static int rt73usb_enable_radio(struct rt2x00_dev *rt2x00dev)
1152 return -EIO; 1132 return -EIO;
1153 } 1133 }
1154 1134
1155 /*
1156 * Enable LED
1157 */
1158 rt73usb_enable_led(rt2x00dev);
1159
1160 return 0; 1135 return 0;
1161} 1136}
1162 1137
1163static void rt73usb_disable_radio(struct rt2x00_dev *rt2x00dev) 1138static void rt73usb_disable_radio(struct rt2x00_dev *rt2x00dev)
1164{ 1139{
1165 /*
1166 * Disable LED
1167 */
1168 rt73usb_disable_led(rt2x00dev);
1169
1170 rt73usb_register_write(rt2x00dev, MAC_CSR10, 0x00001818); 1140 rt73usb_register_write(rt2x00dev, MAC_CSR10, 0x00001818);
1171 1141
1172 /* 1142 /*
@@ -1615,33 +1585,49 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1615 /* 1585 /*
1616 * Store led settings, for correct led behaviour. 1586 * Store led settings, for correct led behaviour.
1617 */ 1587 */
1588#ifdef CONFIG_RT73USB_LEDS
1618 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 1589 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
1619 1590
1620 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LED_MODE, 1591 switch (value) {
1621 rt2x00dev->led_mode); 1592 case LED_MODE_TXRX_ACTIVITY:
1622 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_GPIO_0, 1593 case LED_MODE_ASUS:
1594 case LED_MODE_ALPHA:
1595 case LED_MODE_DEFAULT:
1596 rt2x00dev->led_flags =
1597 LED_SUPPORT_RADIO | LED_SUPPORT_ASSOC;
1598 break;
1599 case LED_MODE_SIGNAL_STRENGTH:
1600 rt2x00dev->led_flags =
1601 LED_SUPPORT_RADIO | LED_SUPPORT_ASSOC |
1602 LED_SUPPORT_QUALITY;
1603 break;
1604 }
1605
1606 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_LED_MODE, value);
1607 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_0,
1623 rt2x00_get_field16(eeprom, 1608 rt2x00_get_field16(eeprom,
1624 EEPROM_LED_POLARITY_GPIO_0)); 1609 EEPROM_LED_POLARITY_GPIO_0));
1625 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_GPIO_1, 1610 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_1,
1626 rt2x00_get_field16(eeprom, 1611 rt2x00_get_field16(eeprom,
1627 EEPROM_LED_POLARITY_GPIO_1)); 1612 EEPROM_LED_POLARITY_GPIO_1));
1628 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_GPIO_2, 1613 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_2,
1629 rt2x00_get_field16(eeprom, 1614 rt2x00_get_field16(eeprom,
1630 EEPROM_LED_POLARITY_GPIO_2)); 1615 EEPROM_LED_POLARITY_GPIO_2));
1631 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_GPIO_3, 1616 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_3,
1632 rt2x00_get_field16(eeprom, 1617 rt2x00_get_field16(eeprom,
1633 EEPROM_LED_POLARITY_GPIO_3)); 1618 EEPROM_LED_POLARITY_GPIO_3));
1634 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_GPIO_4, 1619 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_GPIO_4,
1635 rt2x00_get_field16(eeprom, 1620 rt2x00_get_field16(eeprom,
1636 EEPROM_LED_POLARITY_GPIO_4)); 1621 EEPROM_LED_POLARITY_GPIO_4));
1637 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_ACT, 1622 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_ACT,
1638 rt2x00_get_field16(eeprom, EEPROM_LED_POLARITY_ACT)); 1623 rt2x00_get_field16(eeprom, EEPROM_LED_POLARITY_ACT));
1639 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_READY_BG, 1624 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_BG,
1640 rt2x00_get_field16(eeprom, 1625 rt2x00_get_field16(eeprom,
1641 EEPROM_LED_POLARITY_RDY_G)); 1626 EEPROM_LED_POLARITY_RDY_G));
1642 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_POLARITY_READY_A, 1627 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_A,
1643 rt2x00_get_field16(eeprom, 1628 rt2x00_get_field16(eeprom,
1644 EEPROM_LED_POLARITY_RDY_A)); 1629 EEPROM_LED_POLARITY_RDY_A));
1630#endif /* CONFIG_RT73USB_LEDS */
1645 1631
1646 return 0; 1632 return 0;
1647} 1633}
@@ -2084,6 +2070,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2084 .link_stats = rt73usb_link_stats, 2070 .link_stats = rt73usb_link_stats,
2085 .reset_tuner = rt73usb_reset_tuner, 2071 .reset_tuner = rt73usb_reset_tuner,
2086 .link_tuner = rt73usb_link_tuner, 2072 .link_tuner = rt73usb_link_tuner,
2073 .led_brightness = rt73usb_led_brightness,
2087 .write_tx_desc = rt73usb_write_tx_desc, 2074 .write_tx_desc = rt73usb_write_tx_desc,
2088 .write_tx_data = rt2x00usb_write_tx_data, 2075 .write_tx_data = rt2x00usb_write_tx_data,
2089 .get_tx_data_len = rt73usb_get_tx_data_len, 2076 .get_tx_data_len = rt73usb_get_tx_data_len,