aboutsummaryrefslogtreecommitdiffstats
path: root/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch
diff options
context:
space:
mode:
authorAnsuel Smith <ansuelsmth@gmail.com>2021-06-02 01:49:50 +0200
committerDavid Bauer <mail@david-bauer.net>2021-06-04 22:44:40 +0200
commit3394af677cadd1f9b877100312c830d87488fcfb (patch)
treeb07d71fd6b6b7d059c5624597866f9949c07469b /package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch
parent89bd8607f8cdacea7e8d13c1233a2a8b13fdf64c (diff)
downloadupstream-3394af677cadd1f9b877100312c830d87488fcfb.tar.gz
upstream-3394af677cadd1f9b877100312c830d87488fcfb.tar.bz2
upstream-3394af677cadd1f9b877100312c830d87488fcfb.zip
mac80211: split ath patch in dedicated subdir
The ath patch number is already large and adding other patch for ath11k will add more confusion with the patch numbering. Since the support of ath11k based device is imminent, prepare the mac80211 ath patch dir and split it in the dedicated ath5k, ath9k, ath10k and ath11k (empty for now). Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
Diffstat (limited to 'package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch')
-rw-r--r--package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch143
1 files changed, 143 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch b/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch
new file mode 100644
index 0000000000..83076b8ae4
--- /dev/null
+++ b/package/kernel/mac80211/patches/ath9k/549-ath9k_enable_gpio_buttons.patch
@@ -0,0 +1,143 @@
+From: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+Subject: [PATCH v5 5/8] mac80211: ath9k: enable GPIO buttons
+
+Enable platform-defined GPIO button support for ath9k device.
+Key poller is activated for attached platform buttons.
+Requires ath9k GPIO chip access.
+
+Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+--- a/drivers/net/wireless/ath/ath9k/ath9k.h
++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
+@@ -1056,6 +1056,7 @@ struct ath_softc {
+ struct list_head leds;
+ #ifdef CONFIG_GPIOLIB
+ struct ath9k_gpio_chip *gpiochip;
++ struct platform_device *btnpdev; /* gpio-keys-polled */
+ #endif
+ #endif
+
+--- a/drivers/net/wireless/ath/ath9k/gpio.c
++++ b/drivers/net/wireless/ath/ath9k/gpio.c
+@@ -17,6 +17,8 @@
+ #include "ath9k.h"
+ #include <linux/ath9k_platform.h>
+ #include <linux/gpio.h>
++#include <linux/platform_device.h>
++#include <linux/gpio_keys.h>
+
+ #ifdef CPTCFG_MAC80211_LEDS
+
+@@ -133,6 +135,67 @@ static void ath9k_unregister_gpio_chip(s
+ sc->gpiochip = NULL;
+ }
+
++/******************/
++/* GPIO Buttons */
++/******************/
++
++/* add GPIO buttons */
++static void ath9k_init_buttons(struct ath_softc *sc)
++{
++ struct ath9k_platform_data *pdata = sc->dev->platform_data;
++ struct platform_device *pdev;
++ struct gpio_keys_platform_data gkpdata;
++ struct gpio_keys_button *bt;
++ int i;
++
++ if (!sc->gpiochip)
++ return;
++
++ if (!pdata || !pdata->btns || !pdata->num_btns)
++ return;
++
++ bt = devm_kmemdup(sc->dev, pdata->btns,
++ pdata->num_btns * sizeof(struct gpio_keys_button),
++ GFP_KERNEL);
++ if (!bt)
++ return;
++
++ for (i = 0; i < pdata->num_btns; i++) {
++ if (pdata->btns[i].gpio == sc->sc_ah->led_pin)
++ sc->sc_ah->led_pin = -1;
++
++ ath9k_hw_gpio_request_in(sc->sc_ah, pdata->btns[i].gpio,
++ "ath9k-gpio");
++ bt[i].gpio = sc->gpiochip->gchip.base + pdata->btns[i].gpio;
++ }
++
++ memset(&gkpdata, 0, sizeof(struct gpio_keys_platform_data));
++ gkpdata.buttons = bt;
++ gkpdata.nbuttons = pdata->num_btns;
++ gkpdata.poll_interval = pdata->btn_poll_interval;
++
++ pdev = platform_device_register_data(sc->dev, "gpio-keys-polled",
++ PLATFORM_DEVID_AUTO, &gkpdata,
++ sizeof(gkpdata));
++ if (!IS_ERR_OR_NULL(pdev))
++ sc->btnpdev = pdev;
++ else {
++ sc->btnpdev = NULL;
++ devm_kfree(sc->dev, bt);
++ }
++}
++
++/* remove GPIO buttons */
++static void ath9k_deinit_buttons(struct ath_softc *sc)
++{
++ if (!sc->gpiochip || !sc->btnpdev)
++ return;
++
++ platform_device_unregister(sc->btnpdev);
++
++ sc->btnpdev = NULL;
++}
++
+ #else /* CONFIG_GPIOLIB */
+
+ static inline void ath9k_register_gpio_chip(struct ath_softc *sc)
+@@ -143,6 +206,14 @@ static inline void ath9k_unregister_gpio
+ {
+ }
+
++static inline void ath9k_init_buttons(struct ath_softc *sc)
++{
++}
++
++static inline void ath9k_deinit_buttons(struct ath_softc *sc)
++{
++}
++
+ #endif /* CONFIG_GPIOLIB */
+
+ /********************************/
+@@ -266,6 +337,7 @@ void ath_deinit_leds(struct ath_softc *s
+ {
+ struct ath_led *led;
+
++ ath9k_deinit_buttons(sc);
+ while (!list_empty(&sc->leds)) {
+ led = list_first_entry(&sc->leds, struct ath_led, list);
+ #ifdef CONFIG_GPIOLIB
+@@ -305,6 +377,7 @@ void ath_init_leds(struct ath_softc *sc)
+ }
+
+ ath_fill_led_pin(sc);
++ ath9k_init_buttons(sc);
+
+ if (pdata && pdata->leds && pdata->num_leds)
+ for (i = 0; i < pdata->num_leds; i++) {
+--- a/include/linux/ath9k_platform.h
++++ b/include/linux/ath9k_platform.h
+@@ -49,6 +49,10 @@ struct ath9k_platform_data {
+
+ int num_leds;
+ const struct gpio_led *leds;
++
++ unsigned num_btns;
++ const struct gpio_keys_button *btns;
++ unsigned btn_poll_interval;
+ };
+
+ #endif /* _LINUX_ATH9K_PLATFORM_H */