aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasanthakumar Thiagarajan <vasanth@atheros.com>2009-01-29 07:22:19 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-02-09 15:03:40 -0500
commitf2bffa7ea012befc2230331f97bf9b002c0b62bb (patch)
tree5f29b3ef4a32ee974ee9aa0ce70f77697d910b53
parentc0415b547d37e8065ad4adf289d11db2f3b16dfd (diff)
ath9k: Fix LED blink pattern
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath9k/core.h10
-rw-r--r--drivers/net/wireless/ath9k/main.c52
2 files changed, 56 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 29251f8dabb0..9a7bb1b5cd51 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -600,6 +600,8 @@ struct ath_ani {
600/********************/ 600/********************/
601 601
602#define ATH_LED_PIN 1 602#define ATH_LED_PIN 1
603#define ATH_LED_ON_DURATION_IDLE 350 /* in msecs */
604#define ATH_LED_OFF_DURATION_IDLE 250 /* in msecs */
603 605
604enum ath_led_type { 606enum ath_led_type {
605 ATH_LED_RADIO, 607 ATH_LED_RADIO,
@@ -677,6 +679,7 @@ enum PROT_MODE {
677#define SC_OP_RFKILL_SW_BLOCKED BIT(12) 679#define SC_OP_RFKILL_SW_BLOCKED BIT(12)
678#define SC_OP_RFKILL_HW_BLOCKED BIT(13) 680#define SC_OP_RFKILL_HW_BLOCKED BIT(13)
679#define SC_OP_WAIT_FOR_BEACON BIT(14) 681#define SC_OP_WAIT_FOR_BEACON BIT(14)
682#define SC_OP_LED_ON BIT(15)
680 683
681struct ath_bus_ops { 684struct ath_bus_ops {
682 void (*read_cachesize)(struct ath_softc *sc, int *csz); 685 void (*read_cachesize)(struct ath_softc *sc, int *csz);
@@ -725,10 +728,17 @@ struct ath_softc {
725 struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX]; 728 struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
726 struct ath_rate_table *cur_rate_table; 729 struct ath_rate_table *cur_rate_table;
727 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; 730 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
731
728 struct ath_led radio_led; 732 struct ath_led radio_led;
729 struct ath_led assoc_led; 733 struct ath_led assoc_led;
730 struct ath_led tx_led; 734 struct ath_led tx_led;
731 struct ath_led rx_led; 735 struct ath_led rx_led;
736 struct delayed_work ath_led_blink_work;
737 int led_on_duration;
738 int led_off_duration;
739 int led_on_cnt;
740 int led_off_cnt;
741
732 struct ath_rfkill rf_kill; 742 struct ath_rfkill rf_kill;
733 struct ath_ani sc_ani; 743 struct ath_ani sc_ani;
734 struct ath9k_node_stats sc_halstats; 744 struct ath9k_node_stats sc_halstats;
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 91f7a7b69a30..e98f2d79af68 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -935,6 +935,32 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc,
935/* LED functions */ 935/* LED functions */
936/********************************/ 936/********************************/
937 937
938static void ath_led_blink_work(struct work_struct *work)
939{
940 struct ath_softc *sc = container_of(work, struct ath_softc,
941 ath_led_blink_work.work);
942
943 if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED))
944 return;
945 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
946 (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0);
947
948 queue_delayed_work(sc->hw->workqueue, &sc->ath_led_blink_work,
949 (sc->sc_flags & SC_OP_LED_ON) ?
950 msecs_to_jiffies(sc->led_off_duration) :
951 msecs_to_jiffies(sc->led_on_duration));
952
953 sc->led_on_duration =
954 max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25);
955 sc->led_off_duration =
956 max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10);
957 sc->led_on_cnt = sc->led_off_cnt = 0;
958 if (sc->sc_flags & SC_OP_LED_ON)
959 sc->sc_flags &= ~SC_OP_LED_ON;
960 else
961 sc->sc_flags |= SC_OP_LED_ON;
962}
963
938static void ath_led_brightness(struct led_classdev *led_cdev, 964static void ath_led_brightness(struct led_classdev *led_cdev,
939 enum led_brightness brightness) 965 enum led_brightness brightness)
940{ 966{
@@ -944,16 +970,27 @@ static void ath_led_brightness(struct led_classdev *led_cdev,
944 switch (brightness) { 970 switch (brightness) {
945 case LED_OFF: 971 case LED_OFF:
946 if (led->led_type == ATH_LED_ASSOC || 972 if (led->led_type == ATH_LED_ASSOC ||
947 led->led_type == ATH_LED_RADIO) 973 led->led_type == ATH_LED_RADIO) {
974 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
975 (led->led_type == ATH_LED_RADIO));
948 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; 976 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
949 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 977 if (led->led_type == ATH_LED_RADIO)
950 (led->led_type == ATH_LED_RADIO) ? 1 : 978 sc->sc_flags &= ~SC_OP_LED_ON;
951 !!(sc->sc_flags & SC_OP_LED_ASSOCIATED)); 979 } else {
980 sc->led_off_cnt++;
981 }
952 break; 982 break;
953 case LED_FULL: 983 case LED_FULL:
954 if (led->led_type == ATH_LED_ASSOC) 984 if (led->led_type == ATH_LED_ASSOC) {
955 sc->sc_flags |= SC_OP_LED_ASSOCIATED; 985 sc->sc_flags |= SC_OP_LED_ASSOCIATED;
956 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0); 986 queue_delayed_work(sc->hw->workqueue,
987 &sc->ath_led_blink_work, 0);
988 } else if (led->led_type == ATH_LED_RADIO) {
989 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0);
990 sc->sc_flags |= SC_OP_LED_ON;
991 } else {
992 sc->led_on_cnt++;
993 }
957 break; 994 break;
958 default: 995 default:
959 break; 996 break;
@@ -989,6 +1026,7 @@ static void ath_unregister_led(struct ath_led *led)
989 1026
990static void ath_deinit_leds(struct ath_softc *sc) 1027static void ath_deinit_leds(struct ath_softc *sc)
991{ 1028{
1029 cancel_delayed_work_sync(&sc->ath_led_blink_work);
992 ath_unregister_led(&sc->assoc_led); 1030 ath_unregister_led(&sc->assoc_led);
993 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; 1031 sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
994 ath_unregister_led(&sc->tx_led); 1032 ath_unregister_led(&sc->tx_led);
@@ -1008,6 +1046,8 @@ static void ath_init_leds(struct ath_softc *sc)
1008 /* LED off, active low */ 1046 /* LED off, active low */
1009 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1); 1047 ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
1010 1048
1049 INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work);
1050
1011 trigger = ieee80211_get_radio_led_name(sc->hw); 1051 trigger = ieee80211_get_radio_led_name(sc->hw);
1012 snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), 1052 snprintf(sc->radio_led.name, sizeof(sc->radio_led.name),
1013 "ath9k-%s:radio", wiphy_name(sc->hw->wiphy)); 1053 "ath9k-%s:radio", wiphy_name(sc->hw->wiphy));