summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2016-03-07 09:20:22 +0000
committerFelix Fietkau <nbd@openwrt.org>2016-03-07 09:20:22 +0000
commit2cfd943fe9074c3bfd1c293222d7de381e2f1576 (patch)
tree128b1703009889d3222e0ca646585d0e6d5c5942 /package
parent4802f611cb0ad73f5ac569d94567e5f5ed8024da (diff)
downloadmtk-20170518-2cfd943fe9074c3bfd1c293222d7de381e2f1576.zip
mtk-20170518-2cfd943fe9074c3bfd1c293222d7de381e2f1576.tar.gz
mtk-20170518-2cfd943fe9074c3bfd1c293222d7de381e2f1576.tar.bz2
mac80211: rework gpio chip/button support to build on platforms without CONFIG_GPIOLIB
Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 48938
Diffstat (limited to 'package')
-rw-r--r--package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch (renamed from package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch)160
-rw-r--r--package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch (renamed from package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch)117
2 files changed, 124 insertions, 153 deletions
diff --git a/package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch b/package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch
index 55bb991..f91d85c 100644
--- a/package/kernel/mac80211/patches/549-ath9k_enable_gpio_chip.patch
+++ b/package/kernel/mac80211/patches/548-ath9k_enable_gpio_chip.patch
@@ -6,12 +6,8 @@ Enable access to GPIO chip and its pins for Atheros AR92xx
wireless devices. For now AR9285 and AR9287 are supported.
Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
- ath9k.h | 23 ++++++++++++
- gpio.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- init.c | 2 +
- 3 files changed, 146 insertions(+)
-
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -24,6 +24,7 @@
@@ -22,93 +18,42 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
#include "common.h"
#include "debug.h"
-@@ -817,6 +818,13 @@ void ath_fill_led_pin(struct ath_softc *
- int ath_create_gpio_led(struct ath_softc *sc, int gpio, const char *name,
- const char *trigger, bool active_low);
-
-+/***************/
-+/* GPIO Chip */
-+/***************/
-+
-+void ath9k_register_gpio_chip(struct ath_softc *sc);
-+void ath9k_unregister_gpio_chip(struct ath_softc *sc);
-+
- #else
- static inline void ath_init_leds(struct ath_softc *sc)
- {
-@@ -828,6 +836,14 @@ static inline void ath_deinit_leds(struc
- static inline void ath_fill_led_pin(struct ath_softc *sc)
- {
- }
-+
-+static inline void ath9k_register_gpio_chip(struct ath_softc *sc)
-+{
-+}
-+
-+static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc)
-+{
-+}
- #endif
-
- /************************/
-@@ -963,6 +979,12 @@ struct ath_led {
+@@ -963,6 +964,14 @@ struct ath_led {
struct led_classdev cdev;
};
++#ifdef CONFIG_GPIOLIB
+struct ath9k_gpio_chip {
+ struct ath_softc *sc;
+ char label[32];
+ struct gpio_chip gchip;
+};
++#endif
+
struct ath_softc {
struct ieee80211_hw *hw;
struct device *dev;
-@@ -1017,6 +1039,7 @@ struct ath_softc {
+@@ -1017,6 +1026,9 @@ struct ath_softc {
#ifdef CPTCFG_MAC80211_LEDS
const char *led_default_trigger;
struct list_head leds;
++#ifdef CONFIG_GPIOLIB
+ struct ath9k_gpio_chip *gpiochip;
++#endif
#endif
#ifdef CPTCFG_ATH9K_DEBUGFS
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -22,6 +22,9 @@
- /********************************/
+@@ -16,12 +16,138 @@
- #ifdef CPTCFG_MAC80211_LEDS
+ #include "ath9k.h"
+ #include <linux/ath9k_platform.h>
++#include <linux/gpio.h>
+
-+#include <asm-generic/gpio.h>
++#ifdef CPTCFG_MAC80211_LEDS
+
- static void ath_led_brightness(struct led_classdev *led_cdev,
- enum led_brightness brightness)
- {
-@@ -60,6 +63,10 @@ static int ath_add_led(struct ath_softc
- else
- ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
-
-+ /* If there is GPIO chip configured, reserve LED pin */
-+ if (sc->gpiochip)
-+ gpio_request(sc->gpiochip->gchip.base + gpio->gpio, gpio->name);
-+
- return 0;
- }
-
-@@ -116,6 +123,9 @@ void ath_deinit_leds(struct ath_softc *s
-
- while (!list_empty(&sc->leds)) {
- led = list_first_entry(&sc->leds, struct ath_led, list);
-+ /* If there is GPIO chip configured, free LED pin */
-+ if (sc->gpiochip)
-+ gpio_free(sc->gpiochip->gchip.base + led->gpio->gpio);
- list_del(&led->list);
- ath_led_brightness(&led->cdev, LED_OFF);
- led_classdev_unregister(&led->cdev);
-@@ -186,6 +196,117 @@ void ath_fill_led_pin(struct ath_softc *
- /* LED off, active low */
- ath9k_hw_set_gpio(ah, ah->led_pin, (ah->config.led_active_high) ? 0 : 1);
- }
++#ifdef CONFIG_GPIOLIB
+
+/***************/
+/* GPIO Chip */
@@ -169,7 +114,7 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+}
+
+/* register GPIO chip */
-+void ath9k_register_gpio_chip(struct ath_softc *sc)
++static void ath9k_register_gpio_chip(struct ath_softc *sc)
+{
+ struct ath9k_gpio_chip *gc;
+ u16 ng;
@@ -208,7 +153,7 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+}
+
+/* remove GPIO chip */
-+void ath9k_unregister_gpio_chip(struct ath_softc *sc)
++static void ath9k_unregister_gpio_chip(struct ath_softc *sc)
+{
+ struct ath9k_gpio_chip *gc = sc->gpiochip;
+
@@ -220,24 +165,71 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+ sc->gpiochip = NULL;
+}
+
- #endif
++#else /* CONFIG_GPIOLIB */
++
++static inline void ath9k_register_gpio_chip(struct ath_softc *sc)
++{
++}
++
++static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc)
++{
++}
++
++#endif /* CONFIG_GPIOLIB */
- /*******************/
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -975,6 +975,7 @@ int ath9k_init_device(u16 devid, struct
- goto debug_cleanup;
- }
+ /********************************/
+ /* LED functions */
+ /********************************/
-+ ath9k_register_gpio_chip(sc);
- ath_init_leds(sc);
- ath_start_rfkill_poll(sc);
+-#ifdef CPTCFG_MAC80211_LEDS
+ static void ath_led_brightness(struct led_classdev *led_cdev,
+ enum led_brightness brightness)
+ {
+@@ -60,6 +186,12 @@ static int ath_add_led(struct ath_softc
+ else
+ ath9k_hw_set_gpio(sc->sc_ah, gpio->gpio, gpio->active_low);
-@@ -1022,6 +1023,7 @@ void ath9k_deinit_device(struct ath_soft
++#ifdef CONFIG_GPIOLIB
++ /* If there is GPIO chip configured, reserve LED pin */
++ if (sc->gpiochip)
++ gpio_request(sc->gpiochip->gchip.base + gpio->gpio, gpio->name);
++#endif
++
+ return 0;
+ }
+
+@@ -116,11 +248,17 @@ void ath_deinit_leds(struct ath_softc *s
- wiphy_rfkill_stop_polling(sc->hw->wiphy);
- ath_deinit_leds(sc);
+ while (!list_empty(&sc->leds)) {
+ led = list_first_entry(&sc->leds, struct ath_led, list);
++#ifdef CONFIG_GPIOLIB
++ /* If there is GPIO chip configured, free LED pin */
++ if (sc->gpiochip)
++ gpio_free(sc->gpiochip->gchip.base + led->gpio->gpio);
++#endif
+ list_del(&led->list);
+ ath_led_brightness(&led->cdev, LED_OFF);
+ led_classdev_unregister(&led->cdev);
+ kfree(led);
+ }
+ ath9k_unregister_gpio_chip(sc);
+ }
- ath9k_ps_restore(sc);
+ void ath_init_leds(struct ath_softc *sc)
+@@ -135,6 +273,8 @@ void ath_init_leds(struct ath_softc *sc)
+ if (AR_SREV_9100(sc->sc_ah))
+ return;
++ ath9k_register_gpio_chip(sc);
++
+ if (pdata && pdata->led_name)
+ strncpy(led_name, pdata->led_name, sizeof(led_name));
+ else
+@@ -186,6 +326,7 @@ void ath_fill_led_pin(struct ath_softc *
+ /* LED off, active low */
+ ath9k_hw_set_gpio(ah, ah->led_pin, (ah->config.led_active_high) ? 0 : 1);
+ }
++
+ #endif
+
+ /*******************/
diff --git a/package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch b/package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch
index e3a8cec..0527406 100644
--- a/package/kernel/mac80211/patches/550-ath9k_enable_gpio_buttons.patch
+++ b/package/kernel/mac80211/patches/549-ath9k_enable_gpio_buttons.patch
@@ -6,73 +6,30 @@ 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@openwrt.org>
---
- drivers/net/wireless/ath/ath9k/ath9k.h | 16 ++++++
- drivers/net/wireless/ath/ath9k/gpio.c | 77 +++++++++++++++++++++++++++++++++
- drivers/net/wireless/ath/ath9k/init.c | 2
- include/linux/ath9k_platform.h | 4 +
- 4 files changed, 99 insertions(+)
-
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
-@@ -825,6 +825,13 @@ int ath_create_gpio_led(struct ath_softc
- void ath9k_register_gpio_chip(struct ath_softc *sc);
- void ath9k_unregister_gpio_chip(struct ath_softc *sc);
-
-+/******************/
-+/* GPIO Buttons */
-+/******************/
-+
-+void ath9k_init_buttons(struct ath_softc *sc);
-+void ath9k_deinit_buttons(struct ath_softc *sc);
-+
- #else
- static inline void ath_init_leds(struct ath_softc *sc)
- {
-@@ -844,6 +851,14 @@ static inline void ath9k_register_gpio_c
- static inline void ath9k_unregister_gpio_chip(struct ath_softc *sc)
- {
- }
-+
-+static inline void ath9k_init_buttons(struct ath_softc *sc)
-+{
-+}
-+
-+static inline void ath9k_deinit_buttons(struct ath_softc *sc)
-+{
-+}
- #endif
-
- /************************/
-@@ -1040,6 +1055,7 @@ struct ath_softc {
- const char *led_default_trigger;
+@@ -1028,6 +1028,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
- #ifdef CPTCFG_ATH9K_DEBUGFS
--- a/drivers/net/wireless/ath/ath9k/gpio.c
+++ b/drivers/net/wireless/ath/ath9k/gpio.c
-@@ -24,6 +24,8 @@
- #ifdef CPTCFG_MAC80211_LEDS
-
- #include <asm-generic/gpio.h>
+@@ -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>
- static void ath_led_brightness(struct led_classdev *led_cdev,
- enum led_brightness brightness)
-@@ -159,7 +161,7 @@ void ath_init_leds(struct ath_softc *sc)
- ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
- !sc->sc_ah->config.led_active_high);
-
-- if (!pdata)
-+ if (!pdata || !pdata->leds || !pdata->num_leds)
- return;
+ #ifdef CPTCFG_MAC80211_LEDS
- for (i = 0; i < pdata->num_leds; i++)
-@@ -307,6 +309,63 @@ void ath9k_unregister_gpio_chip(struct a
+@@ -132,6 +134,63 @@ static void ath9k_unregister_gpio_chip(s
sc->gpiochip = NULL;
}
@@ -81,7 +38,7 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+/******************/
+
+/* add GPIO buttons */
-+void ath9k_init_buttons(struct ath_softc *sc)
++static void ath9k_init_buttons(struct ath_softc *sc)
+{
+ struct ath9k_platform_data *pdata = sc->dev->platform_data;
+ struct platform_device *pdev;
@@ -123,7 +80,7 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+}
+
+/* remove GPIO buttons */
-+void ath9k_deinit_buttons(struct ath_softc *sc)
++static void ath9k_deinit_buttons(struct ath_softc *sc)
+{
+ if (!sc->gpiochip || !sc->btnpdev)
+ return;
@@ -133,27 +90,49 @@ Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
+ sc->btnpdev = NULL;
+}
+
- #endif
+ #else /* CONFIG_GPIOLIB */
- /*******************/
---- a/drivers/net/wireless/ath/ath9k/init.c
-+++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -977,6 +977,7 @@ int ath9k_init_device(u16 devid, struct
+ static inline void ath9k_register_gpio_chip(struct ath_softc *sc)
+@@ -142,6 +201,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 */
+
+ /********************************/
+@@ -246,6 +313,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
+@@ -274,6 +342,7 @@ void ath_init_leds(struct ath_softc *sc)
+ return;
ath9k_register_gpio_chip(sc);
- ath_init_leds(sc);
+ ath9k_init_buttons(sc);
- ath_start_rfkill_poll(sc);
- return 0;
-@@ -1022,6 +1023,7 @@ void ath9k_deinit_device(struct ath_soft
- ath9k_ps_wakeup(sc);
+ if (pdata && pdata->led_name)
+ strncpy(led_name, pdata->led_name, sizeof(led_name));
+@@ -289,7 +358,7 @@ void ath_init_leds(struct ath_softc *sc)
+ ath_create_gpio_led(sc, sc->sc_ah->led_pin, led_name, trigger,
+ !sc->sc_ah->config.led_active_high);
- wiphy_rfkill_stop_polling(sc->hw->wiphy);
-+ ath9k_deinit_buttons(sc);
- ath_deinit_leds(sc);
- ath9k_unregister_gpio_chip(sc);
+- if (!pdata)
++ if (!pdata || !pdata->leds || !pdata->num_leds)
+ return;
+ for (i = 0; i < pdata->num_leds; i++)
--- a/include/linux/ath9k_platform.h
+++ b/include/linux/ath9k_platform.h
@@ -46,6 +46,10 @@ struct ath9k_platform_data {