ath9k: Enable LEDs for AR9287 chipsets.
authorVivek Natarajan <vivek.natraj@gmail.com>
Fri, 14 Aug 2009 06:00:52 +0000 (11:30 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 20 Aug 2009 15:35:52 +0000 (11:35 -0400)
Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/pci.c

index 2fd663c01b8ed476ccbd4afe08b91a6a5d480464..2c9f6628a8e78bc44433661bbf16a93cc5b96f71 100644 (file)
@@ -454,7 +454,8 @@ struct ath_ani {
 /*   LED Control    */
 /********************/
 
-#define ATH_LED_PIN    1
+#define ATH_LED_PIN_DEF                1
+#define ATH_LED_PIN_9287               8
 #define ATH_LED_ON_DURATION_IDLE       350     /* in msecs */
 #define ATH_LED_OFF_DURATION_IDLE      250     /* in msecs */
 
index 0336981a70ecd54ca8cd645070e8199b3ddd7d07..de31a1595f12d7fb286db093f5ddb823caba8fb6 100644 (file)
@@ -522,6 +522,7 @@ struct ath_hw {
        u32 originalGain[22];
        int initPDADC;
        int PDADCdelta;
+       u8 led_pin;
 
        struct ar5416IniArray iniModes;
        struct ar5416IniArray iniCommon;
index fa4c6e74f977a727693edad07958a2b739f6ee37..3e09b9ac165bd3f9729a8b714069518c42b063a7 100644 (file)
@@ -968,9 +968,9 @@ static void ath_led_blink_work(struct work_struct *work)
 
        if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) ||
            (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE))
-               ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0);
+               ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
        else
-               ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
+               ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
                                  (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0);
 
        ieee80211_queue_delayed_work(sc->hw,
@@ -1002,7 +1002,7 @@ static void ath_led_brightness(struct led_classdev *led_cdev,
        case LED_OFF:
                if (led->led_type == ATH_LED_ASSOC ||
                    led->led_type == ATH_LED_RADIO) {
-                       ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN,
+                       ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin,
                                (led->led_type == ATH_LED_RADIO));
                        sc->sc_flags &= ~SC_OP_LED_ASSOCIATED;
                        if (led->led_type == ATH_LED_RADIO)
@@ -1017,7 +1017,7 @@ static void ath_led_brightness(struct led_classdev *led_cdev,
                        ieee80211_queue_delayed_work(sc->hw,
                                                     &sc->ath_led_blink_work, 0);
                } else if (led->led_type == ATH_LED_RADIO) {
-                       ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0);
+                       ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
                        sc->sc_flags |= SC_OP_LED_ON;
                } else {
                        sc->led_on_cnt++;
@@ -1062,7 +1062,7 @@ static void ath_deinit_leds(struct ath_softc *sc)
        ath_unregister_led(&sc->tx_led);
        ath_unregister_led(&sc->rx_led);
        ath_unregister_led(&sc->radio_led);
-       ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
+       ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
 }
 
 static void ath_init_leds(struct ath_softc *sc)
@@ -1070,11 +1070,16 @@ static void ath_init_leds(struct ath_softc *sc)
        char *trigger;
        int ret;
 
+       if (AR_SREV_9287(sc->sc_ah))
+               sc->sc_ah->led_pin = ATH_LED_PIN_9287;
+       else
+               sc->sc_ah->led_pin = ATH_LED_PIN_DEF;
+
        /* Configure gpio 1 for output */
-       ath9k_hw_cfg_output(sc->sc_ah, ATH_LED_PIN,
+       ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
                            AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
        /* LED off, active low */
-       ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
+       ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
 
        INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work);
 
@@ -1153,9 +1158,9 @@ void ath_radio_enable(struct ath_softc *sc)
        ath9k_hw_set_interrupts(ah, sc->imask);
 
        /* Enable LED */
-       ath9k_hw_cfg_output(ah, ATH_LED_PIN,
+       ath9k_hw_cfg_output(ah, ah->led_pin,
                            AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-       ath9k_hw_set_gpio(ah, ATH_LED_PIN, 0);
+       ath9k_hw_set_gpio(ah, ah->led_pin, 0);
 
        ieee80211_wake_queues(sc->hw);
        ath9k_ps_restore(sc);
@@ -1171,8 +1176,8 @@ void ath_radio_disable(struct ath_softc *sc)
        ieee80211_stop_queues(sc->hw);
 
        /* Disable LED */
-       ath9k_hw_set_gpio(ah, ATH_LED_PIN, 1);
-       ath9k_hw_cfg_gpio_input(ah, ATH_LED_PIN);
+       ath9k_hw_set_gpio(ah, ah->led_pin, 1);
+       ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
 
        /* Disable interrupts */
        ath9k_hw_set_interrupts(ah, 0);
index 616bdff2b6a159958fec96a42dac542dd7240ff3..685a8cebb46813f5b9a974a524178f690ff7b0d2 100644 (file)
@@ -236,7 +236,7 @@ static int ath_pci_suspend(struct pci_dev *pdev, pm_message_t state)
        struct ath_wiphy *aphy = hw->priv;
        struct ath_softc *sc = aphy->sc;
 
-       ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
+       ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
 
        pci_save_state(pdev);
        pci_disable_device(pdev);
@@ -269,9 +269,9 @@ static int ath_pci_resume(struct pci_dev *pdev)
                pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
 
        /* Enable LED */
-       ath9k_hw_cfg_output(sc->sc_ah, ATH_LED_PIN,
+       ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
                            AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-       ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1);
+       ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
 
        return 0;
 }