]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ath9k: add an interface for overriding the value of specific GPIO pins
authorFelix Fietkau <nbd@openwrt.org>
Sat, 19 Mar 2011 12:55:38 +0000 (13:55 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 30 Mar 2011 18:15:15 +0000 (14:15 -0400)
Some devices control antenna settings or other things through GPIO pins
of the wireless interface. Add a debugfs interface for changing those
and keeping them set across card resets.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/debug.c
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h

index 9fe86939d93ee1859eef6c885995336edd93e6c3..a762cadb3ab754c4621b7973a8b3af1bc0535b2d 100644 (file)
@@ -1119,6 +1119,12 @@ int ath9k_init_debug(struct ath_hw *ah)
        debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy, sc,
                            &fops_regdump);
 
+       debugfs_create_u32("gpio_mask", S_IRUSR | S_IWUSR,
+                          sc->debug.debugfs_phy, &sc->sc_ah->gpio_mask);
+
+       debugfs_create_u32("gpio_val", S_IRUSR | S_IWUSR,
+                          sc->debug.debugfs_phy, &sc->sc_ah->gpio_val);
+
        sc->debug.regidx = 0;
        return 0;
 }
index 338b07502f1adc5621c60815a8f5ce8c0e0345e6..b170c455a40bd3e82735d1afd01db628552f35da 100644 (file)
@@ -1212,6 +1212,20 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
        return true;
 }
 
+static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
+{
+       u32 gpio_mask = ah->gpio_mask;
+       int i;
+
+       for (i = 0; gpio_mask; i++, gpio_mask >>= 1) {
+               if (!(gpio_mask & 1))
+                       continue;
+
+               ath9k_hw_cfg_output(ah, i, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+               ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
+       }
+}
+
 bool ath9k_hw_check_alive(struct ath_hw *ah)
 {
        int count = 50;
@@ -1500,6 +1514,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        if (AR_SREV_9300_20_OR_LATER(ah))
                ar9003_hw_bb_watchdog_config(ah);
 
+       ath9k_hw_apply_gpio_override(ah);
+
        return 0;
 }
 EXPORT_SYMBOL(ath9k_hw_reset);
index c86eea28a88fa1fbcd4014343bf8a12aafcd0e73..775c0eb10b953d4d603ec75f8b82e8f9ea9f24d3 100644 (file)
@@ -799,6 +799,8 @@ struct ath_hw {
        int initPDADC;
        int PDADCdelta;
        u8 led_pin;
+       u32 gpio_mask;
+       u32 gpio_val;
 
        struct ar5416IniArray iniModes;
        struct ar5416IniArray iniCommon;