2011-12-14 20:21:36 +00:00
|
|
|
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
|
|
|
|
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
|
2017-01-24 14:23:30 +00:00
|
|
|
@@ -850,6 +850,9 @@ static inline int ath9k_dump_btcoex(stru
|
2016-05-14 15:38:56 +00:00
|
|
|
#ifdef CPTCFG_MAC80211_LEDS
|
2011-12-14 20:21:36 +00:00
|
|
|
void ath_init_leds(struct ath_softc *sc);
|
|
|
|
void ath_deinit_leds(struct ath_softc *sc);
|
|
|
|
+int ath_create_gpio_led(struct ath_softc *sc, int gpio, const char *name,
|
2016-05-14 15:38:56 +00:00
|
|
|
+ const char *trigger, bool active_low);
|
2011-12-14 20:21:36 +00:00
|
|
|
+
|
|
|
|
#else
|
|
|
|
static inline void ath_init_leds(struct ath_softc *sc)
|
|
|
|
{
|
2017-01-24 14:23:30 +00:00
|
|
|
@@ -991,6 +994,13 @@ void ath_ant_comb_scan(struct ath_softc
|
|
|
|
#define AIRTIME_USE_NEW_QUEUES BIT(2)
|
|
|
|
#define AIRTIME_ACTIVE(flags) (!!(flags & (AIRTIME_USE_TX|AIRTIME_USE_RX)))
|
2011-12-14 20:21:36 +00:00
|
|
|
|
|
|
|
+struct ath_led {
|
|
|
|
+ struct list_head list;
|
|
|
|
+ struct ath_softc *sc;
|
|
|
|
+ const struct gpio_led *gpio;
|
|
|
|
+ struct led_classdev cdev;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
struct ath_softc {
|
|
|
|
struct ieee80211_hw *hw;
|
|
|
|
struct device *dev;
|
2017-01-31 10:38:25 +00:00
|
|
|
@@ -1046,9 +1056,8 @@ struct ath_softc {
|
2014-09-27 20:51:43 +00:00
|
|
|
spinlock_t chan_lock;
|
2011-12-14 20:21:36 +00:00
|
|
|
|
2013-06-15 20:14:06 +00:00
|
|
|
#ifdef CPTCFG_MAC80211_LEDS
|
2011-12-14 20:21:36 +00:00
|
|
|
- bool led_registered;
|
|
|
|
- char led_name[32];
|
|
|
|
- struct led_classdev led_cdev;
|
|
|
|
+ const char *led_default_trigger;
|
|
|
|
+ struct list_head leds;
|
|
|
|
#endif
|
|
|
|
|
2014-09-27 20:51:43 +00:00
|
|
|
#ifdef CPTCFG_ATH9K_DEBUGFS
|
2011-12-14 20:21:36 +00:00
|
|
|
--- a/drivers/net/wireless/ath/ath9k/gpio.c
|
|
|
|
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
|
2016-10-08 11:53:14 +00:00
|
|
|
@@ -39,61 +39,111 @@ static void ath_fill_led_pin(struct ath_
|
2016-05-14 15:38:56 +00:00
|
|
|
else
|
|
|
|
ah->led_pin = ATH_LED_PIN_DEF;
|
|
|
|
}
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void ath_led_brightness(struct led_classdev *led_cdev,
|
|
|
|
+ enum led_brightness brightness)
|
|
|
|
+{
|
2011-12-14 20:21:36 +00:00
|
|
|
+ struct ath_led *led = container_of(led_cdev, struct ath_led, cdev);
|
|
|
|
+ struct ath_softc *sc = led->sc;
|
2016-05-14 15:38:56 +00:00
|
|
|
+
|
2011-12-14 20:21:36 +00:00
|
|
|
+ ath9k_ps_wakeup(sc);
|
|
|
|
+ ath9k_hw_set_gpio(sc->sc_ah, led->gpio->gpio,
|
|
|
|
+ (brightness != LED_OFF) ^ led->gpio->active_low);
|
|
|
|
+ ath9k_ps_restore(sc);
|
|
|
|
+}
|
2016-05-14 15:38:56 +00:00
|
|
|
+
|
2011-12-14 20:21:36 +00:00
|
|
|
+static int ath_add_led(struct ath_softc *sc, struct ath_led *led)
|
|
|
|
+{
|
|
|
|
+ const struct gpio_led *gpio = led->gpio;
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ led->cdev.name = gpio->name;
|
|
|
|
+ led->cdev.default_trigger = gpio->default_trigger;
|
|
|
|
+ led->cdev.brightness_set = ath_led_brightness;
|
2016-02-07 13:29:08 +00:00
|
|
|
+
|
2011-12-14 20:21:36 +00:00
|
|
|
+ ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->cdev);
|
|
|
|
+ if (ret < 0)
|
|
|
|
+ return ret;
|
|
|
|
+
|
|
|
|
+ led->sc = sc;
|
|
|
|
+ list_add(&led->list, &sc->leds);
|
2016-05-14 15:38:56 +00:00
|
|
|
|
|
|
|
/* Configure gpio for output */
|
|
|
|
- ath9k_hw_gpio_request_out(ah, ah->led_pin, "ath9k-led",
|
|
|
|
+ ath9k_hw_gpio_request_out(sc->sc_ah, gpio->gpio, gpio->name,
|
|
|
|
AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
|
|
|
|
|
|
|
|
- /* LED off, active low */
|
|
|
|
- ath9k_hw_set_gpio(ah, ah->led_pin, ah->config.led_active_high ? 0 : 1);
|
2011-12-14 20:21:36 +00:00
|
|
|
+ /* LED off */
|
|
|
|
+ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
|
|
|
|
+
|
|
|
|
+ return 0;
|
2016-05-14 15:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-static void ath_led_brightness(struct led_classdev *led_cdev,
|
|
|
|
- enum led_brightness brightness)
|
2011-12-14 20:21:36 +00:00
|
|
|
+int ath_create_gpio_led(struct ath_softc *sc, int gpio_num, const char *name,
|
|
|
|
+ const char *trigger, bool active_low)
|
2016-05-14 15:38:56 +00:00
|
|
|
{
|
|
|
|
- struct ath_softc *sc = container_of(led_cdev, struct ath_softc, led_cdev);
|
|
|
|
- u32 val = (brightness == LED_OFF);
|
2011-12-14 20:21:36 +00:00
|
|
|
+ struct ath_led *led;
|
|
|
|
+ struct gpio_led *gpio;
|
|
|
|
+ char *_name;
|
|
|
|
+ int ret;
|
2016-05-14 15:38:56 +00:00
|
|
|
|
|
|
|
- if (sc->sc_ah->config.led_active_high)
|
|
|
|
- val = !val;
|
2011-12-14 20:21:36 +00:00
|
|
|
+ led = kzalloc(sizeof(*led) + sizeof(*gpio) + strlen(name) + 1,
|
|
|
|
+ GFP_KERNEL);
|
|
|
|
+ if (!led)
|
|
|
|
+ return -ENOMEM;
|
2017-02-12 14:00:20 +00:00
|
|
|
+
|
2011-12-14 20:21:36 +00:00
|
|
|
+ led->gpio = gpio = (struct gpio_led *) (led + 1);
|
|
|
|
+ _name = (char *) (led->gpio + 1);
|
|
|
|
+
|
|
|
|
+ strcpy(_name, name);
|
|
|
|
+ gpio->name = _name;
|
|
|
|
+ gpio->gpio = gpio_num;
|
|
|
|
+ gpio->active_low = active_low;
|
|
|
|
+ gpio->default_trigger = trigger;
|
|
|
|
+
|
|
|
|
+ ret = ath_add_led(sc, led);
|
|
|
|
+ if (unlikely(ret < 0))
|
|
|
|
+ kfree(led);
|
2017-02-12 14:00:20 +00:00
|
|
|
|
|
|
|
- ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, val);
|
2011-12-14 20:21:36 +00:00
|
|
|
+ return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath_deinit_leds(struct ath_softc *sc)
|
|
|
|
{
|
|
|
|
- if (!sc->led_registered)
|
|
|
|
- return;
|
2017-02-02 11:02:22 +00:00
|
|
|
+ struct ath_led *led;
|
|
|
|
|
2017-02-12 14:00:20 +00:00
|
|
|
- ath_led_brightness(&sc->led_cdev, LED_OFF);
|
|
|
|
- led_classdev_unregister(&sc->led_cdev);
|
|
|
|
-
|
2016-05-14 15:38:56 +00:00
|
|
|
- ath9k_hw_gpio_free(sc->sc_ah, sc->sc_ah->led_pin);
|
2011-12-14 20:21:36 +00:00
|
|
|
+ while (!list_empty(&sc->leds)) {
|
|
|
|
+ led = list_first_entry(&sc->leds, struct ath_led, list);
|
|
|
|
+ list_del(&led->list);
|
|
|
|
+ ath_led_brightness(&led->cdev, LED_OFF);
|
|
|
|
+ led_classdev_unregister(&led->cdev);
|
2016-05-14 15:38:56 +00:00
|
|
|
+ ath9k_hw_gpio_free(sc->sc_ah, led->gpio->gpio);
|
2011-12-14 20:21:36 +00:00
|
|
|
+ kfree(led);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
void ath_init_leds(struct ath_softc *sc)
|
|
|
|
{
|
|
|
|
- int ret;
|
|
|
|
+ char led_name[32];
|
|
|
|
+ const char *trigger;
|
|
|
|
+
|
|
|
|
+ INIT_LIST_HEAD(&sc->leds);
|
|
|
|
|
|
|
|
if (AR_SREV_9100(sc->sc_ah))
|
|
|
|
return;
|
|
|
|
|
2016-05-14 15:38:56 +00:00
|
|
|
ath_fill_led_pin(sc);
|
|
|
|
|
2015-03-11 15:02:47 +00:00
|
|
|
- if (!ath9k_led_blink)
|
2011-12-14 20:21:36 +00:00
|
|
|
- sc->led_cdev.default_trigger =
|
|
|
|
- ieee80211_get_radio_led_name(sc->hw);
|
|
|
|
-
|
|
|
|
- snprintf(sc->led_name, sizeof(sc->led_name),
|
|
|
|
- "ath9k-%s", wiphy_name(sc->hw->wiphy));
|
|
|
|
- sc->led_cdev.name = sc->led_name;
|
|
|
|
- sc->led_cdev.brightness_set = ath_led_brightness;
|
|
|
|
+ snprintf(led_name, sizeof(led_name), "ath9k-%s",
|
|
|
|
+ wiphy_name(sc->hw->wiphy));
|
|
|
|
|
|
|
|
- ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &sc->led_cdev);
|
|
|
|
- if (ret < 0)
|
|
|
|
- return;
|
2015-03-11 15:02:47 +00:00
|
|
|
+ if (ath9k_led_blink)
|
2011-12-14 20:21:36 +00:00
|
|
|
+ trigger = sc->led_default_trigger;
|
|
|
|
+ else
|
|
|
|
+ trigger = ieee80211_get_radio_led_name(sc->hw);
|
|
|
|
|
|
|
|
- sc->led_registered = true;
|
2016-05-14 15:38:56 +00:00
|
|
|
+ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
|
|
|
|
+ !sc->sc_ah->config.led_active_high);
|
2011-12-14 20:21:36 +00:00
|
|
|
}
|
2016-05-14 15:38:56 +00:00
|
|
|
#endif
|
2011-12-14 20:21:36 +00:00
|
|
|
|
|
|
|
--- a/drivers/net/wireless/ath/ath9k/init.c
|
|
|
|
+++ b/drivers/net/wireless/ath/ath9k/init.c
|
2017-08-22 21:59:48 +00:00
|
|
|
@@ -1000,7 +1000,7 @@ int ath9k_init_device(u16 devid, struct
|
2011-12-14 20:21:36 +00:00
|
|
|
|
2013-06-15 20:14:06 +00:00
|
|
|
#ifdef CPTCFG_MAC80211_LEDS
|
2011-12-14 20:21:36 +00:00
|
|
|
/* must be initialized before ieee80211_register_hw */
|
|
|
|
- sc->led_cdev.default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
|
|
|
|
+ sc->led_default_trigger = ieee80211_create_tpt_led_trigger(sc->hw,
|
|
|
|
IEEE80211_TPT_LEDTRIG_FL_RADIO, ath9k_tpt_blink,
|
|
|
|
ARRAY_SIZE(ath9k_tpt_blink));
|
|
|
|
#endif
|
|
|
|
--- a/drivers/net/wireless/ath/ath9k/debug.c
|
|
|
|
+++ b/drivers/net/wireless/ath/ath9k/debug.c
|
2017-08-22 21:59:48 +00:00
|
|
|
@@ -1466,6 +1466,61 @@ static const struct file_operations fops
|
2012-03-01 15:22:08 +00:00
|
|
|
.llseek = default_llseek,
|
|
|
|
};
|
2011-12-14 20:21:36 +00:00
|
|
|
|
|
|
|
+#ifdef CONFIG_MAC80211_LEDS
|
|
|
|
+
|
|
|
|
+static ssize_t write_file_gpio_led(struct file *file, const char __user *ubuf,
|
|
|
|
+ size_t count, loff_t *ppos)
|
|
|
|
+{
|
|
|
|
+ struct ath_softc *sc = file->private_data;
|
|
|
|
+ char buf[32], *str, *name, *c;
|
|
|
|
+ ssize_t len;
|
|
|
|
+ unsigned int gpio;
|
|
|
|
+ bool active_low = false;
|
|
|
|
+
|
|
|
|
+ len = min(count, sizeof(buf) - 1);
|
|
|
|
+ if (copy_from_user(buf, ubuf, len))
|
|
|
|
+ return -EFAULT;
|
|
|
|
+
|
|
|
|
+ buf[len] = '\0';
|
|
|
|
+ name = strchr(buf, ',');
|
|
|
|
+ if (!name)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ *(name++) = 0;
|
|
|
|
+ if (!*name)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ c = strchr(name, '\n');
|
|
|
|
+ if (c)
|
|
|
|
+ *c = 0;
|
|
|
|
+
|
|
|
|
+ str = buf;
|
|
|
|
+ if (*str == '!') {
|
|
|
|
+ str++;
|
|
|
|
+ active_low = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (kstrtouint(str, 0, &gpio) < 0)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (gpio >= sc->sc_ah->caps.num_gpio_pins)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ if (ath_create_gpio_led(sc, gpio, name, NULL, active_low) < 0)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ return count;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static const struct file_operations fops_gpio_led = {
|
|
|
|
+ .write = write_file_gpio_led,
|
2012-04-16 21:08:41 +00:00
|
|
|
+ .open = simple_open,
|
2011-12-14 20:21:36 +00:00
|
|
|
+ .owner = THIS_MODULE,
|
|
|
|
+ .llseek = default_llseek,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
2012-03-01 15:22:08 +00:00
|
|
|
|
2013-06-15 20:14:06 +00:00
|
|
|
int ath9k_init_debug(struct ath_hw *ah)
|
|
|
|
{
|
2017-08-22 21:59:48 +00:00
|
|
|
@@ -1490,6 +1545,10 @@ int ath9k_init_debug(struct ath_hw *ah)
|
2012-12-07 16:46:04 +00:00
|
|
|
&fops_eeprom);
|
|
|
|
debugfs_create_file("chanbw", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
|
|
|
|
sc, &fops_chanbw);
|
2011-12-14 20:21:36 +00:00
|
|
|
+#ifdef CONFIG_MAC80211_LEDS
|
|
|
|
+ debugfs_create_file("gpio_led", S_IWUSR,
|
|
|
|
+ sc->debug.debugfs_phy, sc, &fops_gpio_led);
|
|
|
|
+#endif
|
2015-03-11 15:02:47 +00:00
|
|
|
debugfs_create_devm_seqfile(sc->dev, "dma", sc->debug.debugfs_phy,
|
|
|
|
read_file_dma);
|
|
|
|
debugfs_create_devm_seqfile(sc->dev, "interrupt", sc->debug.debugfs_phy,
|