ath10k: add LED and GPIO controlling support for various chipsets
PATCH v9 1/1 ath10k: add LED and GPIO controlling support for various chipsets
From: Sebastian Gottschall <[email protected]>
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based chipsets with on chipset connected led's using WMI Firmware API.
The LED device will get available named as "ath10k-phyX" at sysfs and can be controlled with various triggers. adds also debugfs interface for gpio control.
v2 add correct gpio count per chipset and remove IPQ4019 support since this chipset does not make use of specific gpios) v5 fix compiling without LED_CLASS and GPIOLIB support, fix also error by kbuild test robot which does not occur in standard builds. curious v6 correct return values and fix comment style v7 fix ath10k_unregister_led for compiling without LED_CLASS v8 fix various code design issues reported by reviewers v9 move led and led code to separate sourcefile (gpio.c) --- drivers/net/wireless/ath/ath10k/Kconfig | 3 + drivers/net/wireless/ath/ath10k/Makefile | 1 + drivers/net/wireless/ath/ath10k/core.c | 28 ++++- drivers/net/wireless/ath/ath10k/core.h | 33 ++++- drivers/net/wireless/ath/ath10k/debug.c | 142 ++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/gpio.c | 196 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/hw.h | 2 + drivers/net/wireless/ath/ath10k/mac.c | 5 + drivers/net/wireless/ath/ath10k/wmi-ops.h | 36 +++++- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 65 ++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 46 +++++++ drivers/net/wireless/ath/ath10k/wmi.h | 36 ++++++ 12 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 drivers/net/wireless/ath/ath10k/gpio.c
drivers/net/wireless/ath/ath10k/Kconfig +3 -0
@@ -2,6 +2,9 @@ config ATH10K tristate "Atheros 802.11ac wireless cards support" depends on MAC80211 && HAS_DMA select ATH_COMMON + select MAC80211_LEDS + select LEDS_CLASS + select NEW_LEDS select CRC32 select WANT_DEV_COREDUMP ---help---
drivers/net/wireless/ath/ath10k/Makefile +1 -0
@@ -20,6 +20,7 @@ ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o ath10k_core-$(CONFIG_THERMAL) += thermal.o ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o +ath10k_core-y += gpio.o ath10k_core-$(CONFIG_PM) += wow.o ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
drivers/net/wireless/ath/ath10k/core.c +27 -1
@@ -21,6 +21,10 @@#include <linux/dmi.h> #include <linux/ctype.h> #include <asm/byteorder.h> +#include <linux/leds.h> +#include <linux/platform_device.h> +#include <linux/version.h> +#include "core.h" #include "mac.h"
@@ -65,6 +69,8 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .id = QCA988X_HW_2_0_VERSION, .dev_id = QCA988X_2_0_DEVICE_ID, .name = "qca988x hw2.0", + .led_pin = 1, + .gpio_count = 24, .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -94,6 +100,8 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .id = QCA988X_HW_2_0_VERSION, .dev_id = QCA988X_2_0_DEVICE_ID_UBNT, .name = "qca988x hw2.0 ubiquiti", + .led_pin = 1, + .gpio_count = 24, .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -123,6 +131,8 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .id = QCA9887_HW_1_0_VERSION, .dev_id = QCA9887_1_0_DEVICE_ID, .name = "qca9887 hw1.0", + .led_pin = 1, + .gpio_count = 24, .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -267,6 +277,8 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .id = QCA99X0_HW_2_0_DEV_VERSION, .dev_id = QCA99X0_2_0_DEVICE_ID, .name = "qca99x0 hw2.0", + .led_pin = 17, + .gpio_count = 35, .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .otp_exe_param = 0x00000700,
@@ -301,6 +313,8 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .id = QCA9984_HW_1_0_DEV_VERSION, .dev_id = QCA9984_1_0_DEVICE_ID, .name = "qca9984/qca9994 hw1.0", + .led_pin = 17, + .gpio_count = 35, .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -340,6 +354,8 @@ static const struct ath10k_hw_params ath10k_hw_params_list[] = { .id = QCA9888_HW_2_0_DEV_VERSION, .dev_id = QCA9888_2_0_DEVICE_ID, .name = "qca9888 hw2.0", + .led_pin = 17, + .gpio_count = 35, .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR, .uart_pin = 7, .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -2372,8 +2388,15 @@ int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode,if (status) goto err_hif_stop; -return 0 ; + + status =ath10k_attach_led (ar); +if (status) + goto err_no_led; +ath10k_attach_gpio (ar); + +err_no_led: +return 0 ; err_hif_stop:ath10k_hif_stop (ar); err_htt_rx_detach:
@@ -2673,6 +2696,9 @@ void ath10k_core_unregister(struct ath10k *ar)ath10k_core_free_board_files (ar);ath10k_debug_unregister (ar); + +ath10k_unregister_gpio_chip (ar); +ath10k_unregister_led (ar); }EXPORT_SYMBOL (ath10k_core_unregister);
drivers/net/wireless/ath/ath10k/core.h +32 -1
@@ -25,6 +25,8 @@#include <linux/pci.h> #include <linux/uuid.h> #include <linux/time.h> +#include <linux/gpio.h> +#include <linux/leds.h> #include "htt.h" #include "htc.h"
@@ -812,6 +814,35 @@ struct ath10k_per_peer_tx_stats {u32 reserved2; }; +struct ath10k_gpiocontrol { +struct ath10k *ar; + +/* since we have no gpio read method, these are the state variables for debugfs. */ +u32 gpio_set_num; +u32 gpio_num; +u32 gpio_input; +u32 gpio_pull_type; +u32 gpio_intr_mode; +u32 gpio_set; + +#if IS_ENABLED (CONFIG_GPIOLIB ) +struct gpio_chip gchip; +#endif /* CONFIG_GPIOLIB */ +struct gpio_led wifi_led; +struct led_classdev cdev; +char label[48 ]; +u32 gpio_state_dir;/* same as for debugfs, but for gpiochip implementation */ +u32 gpio_state_pin; +}; + +void ath10k_unregister_led (struct ath10k *ar); +void ath10k_reset_led_pin (struct ath10k *ar); +int ath10k_attach_led (struct ath10k *ar); +#if IS_ENABLED (CONFIG_GPIOLIB ) +void ath10k_unregister_gpio_chip (struct ath10k *ar); +int ath10k_attach_gpio (struct ath10k *ar); +#endif +struct ath10k {struct ath_common ath_common;struct ieee80211_hw *hw;
@@ -840,7 +871,7 @@ struct ath10k {u32 low_5ghz_chan;u32 high_5ghz_chan;bool ani_enabled; - +struct ath10k_gpiocontrol *gpio;bool p2p;struct {
drivers/net/wireless/ath/ath10k/debug.c +142 -0
160 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/gpio.c new file +196 -0
196 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/hw.h +2 -0
@@ -495,6 +495,8 @@ struct ath10k_hw_params {const char *name;u32 patch_load_addr;int uart_pin; +int led_pin;/* 1 for peregrine, 17 for beeliner */ +int gpio_count;/* 24 for peregrine, 35 for beeliner */ u32 otp_exe_param;/* Type of hw cycle counter wraparound logic, for more info
drivers/net/wireless/ath/ath10k/mac.c +5 -0
@@ -4601,6 +4601,11 @@ static int ath10k_start(struct ieee80211_hw *hw)switch (ar->state) {case ATH10K_STATE_OFF : ar->state =ATH10K_STATE_ON ; +/* +* under some circumstances, the gpio pin gets reconfigured to default state by the firmware, so we need to reconfigure it +* this behaviour has only ben seen on QCA9984 and QCA99XX devices so far +*/ +ath10k_reset_led_pin (ar);break ;case ATH10K_STATE_RESTARTING : ar->state =ATH10K_STATE_RESTARTED ;
drivers/net/wireless/ath/ath10k/wmi-ops.h +35 -1
@@ -197,8 +197,13 @@ struct wmi_ops { (struct ath10k *ar, enum wmi_bss_survey_req_type type);struct sk_buff *(*gen_echo)(struct ath10k *ar,u32 value); + +struct sk_buff *(*gen_gpio_config)(struct ath10k *ar,u32 gpio_num,u32 input,u32 pull_type,u32 intr_mode); + +struct sk_buff *(*gen_gpio_output)(struct ath10k *ar,u32 gpio_num,u32 set); }; +int ath10k_wmi_cmd_send (struct ath10k *ar,struct sk_buff *skb,u32 cmd_id); static inline int
@@ -957,6 +962,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *ar,return ath10k_wmi_cmd_send (ar, skb, ar->wmi.cmd->force_fw_hang_cmdid); } +static inline int +ath10k_wmi_gpio_config (struct ath10k *ar,u32 gpio_num,u32 input,u32 pull_type,u32 intr_mode) +{ +struct sk_buff *skb; + +if (!ar->wmi.ops->gen_gpio_config) +return -EOPNOTSUPP ; + + skb = ar->wmi.ops->gen_gpio_config (ar, gpio_num, input, pull_type, intr_mode); +if (IS_ERR (skb)) +return PTR_ERR (skb); + +return ath10k_wmi_cmd_send_nowait (ar, skb, ar->wmi.cmd->gpio_config_cmdid); +} + +static inline int +ath10k_wmi_gpio_output (struct ath10k *ar,u32 gpio_num,u32 set) +{ +struct sk_buff *skb; + +if (!ar->wmi.ops->gen_gpio_config) +return -EOPNOTSUPP ; + + skb = ar->wmi.ops->gen_gpio_output (ar, gpio_num, set); +if (IS_ERR (skb)) +return PTR_ERR (skb); + +return ath10k_wmi_cmd_send_nowait (ar, skb, ar->wmi.cmd->gpio_output_cmdid); +}static inline int ath10k_wmi_dbglog_cfg (struct ath10k *ar,u64 module_enable,u32 log_level)
@@ -1034,7 +1068,7 @@ ath10k_wmi_pdev_get_temperature(struct ath10k *ar)if (IS_ERR (skb))return PTR_ERR (skb); -return ath10k_wmi_cmd_send (ar, skb, +return ath10k_wmi_cmd_send_nowait (ar, skb, ar->wmi.cmd->pdev_get_temperature_cmdid); }
drivers/net/wireless/ath/ath10k/wmi-tlv.c +65 -0
77 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/wmi.c +46 -0
82 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/wmi.h +36 -0
@@ -2906,6 +2906,42 @@ enum wmi_10_4_feature_mask { }; +/* WMI_GPIO_CONFIG_CMDID */ +enum { +WMI_GPIO_PULL_NONE , +WMI_GPIO_PULL_UP , +WMI_GPIO_PULL_DOWN , +}; + +enum { +WMI_GPIO_INTTYPE_DISABLE , +WMI_GPIO_INTTYPE_RISING_EDGE , +WMI_GPIO_INTTYPE_FALLING_EDGE , +WMI_GPIO_INTTYPE_BOTH_EDGE , +WMI_GPIO_INTTYPE_LEVEL_LOW , +WMI_GPIO_INTTYPE_LEVEL_HIGH +}; + +/* WMI_GPIO_CONFIG_CMDID */ +struct wmi_gpio_config_cmd { +__le32 gpio_num;/* GPIO number to be setup */ +__le32 input;/* 0 - Output/ 1 - Input */ +__le32 pull_type;/* Pull type defined above */ +__le32 intr_mode;/* Interrupt mode defined above (Input) */ +} __packed; + +/* WMI_GPIO_OUTPUT_CMDID */ +struct wmi_gpio_output_cmd { +__le32 gpio_num;/* GPIO number to be setup */ +__le32 set;/* Set the GPIO pin*/ +} __packed; + +/* WMI_GPIO_INPUT_EVENTID */ +struct wmi_gpio_input_event { +__le32 gpio_num;/* GPIO number which changed state */ +} __packed; + +struct wmi_ext_resource_config_10_4_cmd {/* contains enum wmi_host_platform_type */ __le32 host_platform_config;
Signature · 1 line
2.14.1
Quoted 36 lines · On Thu, Feb 22, 2018 at 3:15 AM, <[email protected]> wrote:
From: Sebastian Gottschall <[email protected]>
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based chipsets with on chipset connected led's using WMI Firmware API.
The LED device will get available named as "ath10k-phyX" at sysfs and can be controlled with various triggers. adds also debugfs interface for gpio control.Signed-off-by Sebastian Gottschall <[email protected]>v2 add correct gpio count per chipset and remove IPQ4019 support since this chipset does not make use of specific gpios) v5 fix compiling without LED_CLASS and GPIOLIB support, fix also error by kbuild test robot which does not occur in standard builds. curious v6 correct return values and fix comment style v7 fix ath10k_unregister_led for compiling without LED_CLASS v8 fix various code design issues reported by reviewers v9 move led and led code to separate sourcefile (gpio.c) --- drivers/net/wireless/ath/ath10k/Kconfig | 3 + drivers/net/wireless/ath/ath10k/Makefile | 1 + drivers/net/wireless/ath/ath10k/core.c | 28 ++++- drivers/net/wireless/ath/ath10k/core.h | 33 ++++- drivers/net/wireless/ath/ath10k/debug.c | 142 ++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/gpio.c | 196 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/hw.h | 2 + drivers/net/wireless/ath/ath10k/mac.c | 5 + drivers/net/wireless/ath/ath10k/wmi-ops.h | 36 +++++- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 65 ++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 46 +++++++ drivers/net/wireless/ath/ath10k/wmi.h | 36 ++++++ 12 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 drivers/net/wireless/ath/ath10k/gpio.cdrivers/net/wireless/ath/ath10k/Kconfig +0
-0
drivers/net/wireless/ath/ath10k/Kconfig config ATH10K · line 10
Quoted 9 lines
drivers/net/wireless/ath/ath10k/Kconfig +3
-0@@ -2,6 +2,9 @@ config ATH10K tristate "Atheros 802.11ac wireless cards support" depends on MAC80211 && HAS_DMA select ATH_COMMON + select MAC80211_LEDS + select LEDS_CLASS + select NEW_LEDS select CRC32 select WANT_DEV_COREDUMP ---help---
Pure question: do we require LEDS, or is this an option? I assumed all along it was an optional thing - ie if GPIOs and/or LEDs were configured, we added this code. And if not optional, then what happens if we are on a platform that can't support LEDS_CLASS or NEW_LEDS, assuming there is such a thing?
drivers/net/wireless/ath/ath10k/Makefile ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o · line 26
Quoted 12 lines
drivers/net/wireless/ath/ath10k/Makefile +1
-0@@ -20,6 +20,7 @@ ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o ath10k_core-$(CONFIG_THERMAL) += thermal.o ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o +ath10k_core-y += gpio.o ath10k_core-$(CONFIG_PM) += wow.o ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
I'd expect it would be something like ath10k_core-$(CONFIG_GPIO) += gpoi.o. Maybe I'm mistaken.
(Note, I didn't look up the actual config option name, I'm guessing. Assume I wrote something reasonable for my example.)
I only ask the above two questions, not because I think it's wrong, but because I don't quite know the intention and it makes me wonder.
Other than those questions, which are optional as the code looks correct to me, the rest of it looks fine to me.
- Steve
Am 22.02.2018 um 23:17 schrieb Steve deRosier:
Quoted 43 lines · On Thu, Feb 22, 2018 at 3:15 AM, <[email protected]> wrote:
Quoted 42 lines
From: Sebastian Gottschall <[email protected]>
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based chipsets with on chipset connected led's using WMI Firmware API.
The LED device will get available named as "ath10k-phyX" at sysfs and can be controlled with various triggers. adds also debugfs interface for gpio control.Signed-off-by Sebastian Gottschall <[email protected]>v2 add correct gpio count per chipset and remove IPQ4019 support since this chipset does not make use of specific gpios) v5 fix compiling without LED_CLASS and GPIOLIB support, fix also error by kbuild test robot which does not occur in standard builds. curious v6 correct return values and fix comment style v7 fix ath10k_unregister_led for compiling without LED_CLASS v8 fix various code design issues reported by reviewers v9 move led and led code to separate sourcefile (gpio.c) --- drivers/net/wireless/ath/ath10k/Kconfig | 3 + drivers/net/wireless/ath/ath10k/Makefile | 1 + drivers/net/wireless/ath/ath10k/core.c | 28 ++++- drivers/net/wireless/ath/ath10k/core.h | 33 ++++- drivers/net/wireless/ath/ath10k/debug.c | 142 ++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/gpio.c | 196 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/hw.h | 2 + drivers/net/wireless/ath/ath10k/mac.c | 5 + drivers/net/wireless/ath/ath10k/wmi-ops.h | 36 +++++- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 65 ++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 46 +++++++ drivers/net/wireless/ath/ath10k/wmi.h | 36 ++++++ 12 files changed, 590 insertions(+), 3 deletions(-)create mode 100644
drivers/net/wireless/ath/ath10k/gpio.cdrivers/net/wireless/ath/ath10k/Kconfig +3
-0@@ -2,6 +2,9 @@ config ATH10K tristate "Atheros 802.11ac wireless cards support" depends on MAC80211 && HAS_DMA select ATH_COMMON + select MAC80211_LEDS + select LEDS_CLASS + select NEW_LEDS
Quoted 8 lines
drivers/net/wireless/ath/ath10k/Kconfig config ATH10K · line 10
Quoted 3 lines
drivers/net/wireless/ath/ath10k/Kconfig +0
-0select CRC32 select WANT_DEV_COREDUMP ---help---Pure question: do we require LEDS, or is this an option? I assumed all along it was an optional thing - ie if GPIOs and/or LEDs were configured, we added this code. And if not optional, then what happens if we are on a platform that can't support
LEDS_CLASSorNEW_LEDS, assuming there is such a thing?
i took this behaviour from ath9k/ath5k, both driver auto select MAC80211_LEDS and LEDS_CLASS (by the way MAC80211_LEDS auto selects LEDS_CLASS too). only chipsets which are known to have preconfigured leds are used and led will only turn on if you enable it in sysfs by assigning a trigger to the led.
for sure this can be removed from the Kconfig. it will compile without it as well. so this is optional. i just added it since all other drivers behave in the same way.
in addition. LEDS_CLASS / NEW_LEDS is a kernel api, not a driver. so all platforms to support LEDS_CLASS. just enabling LEDS_CLASS will not cause any platform specific dependency.
Quoted 16 lines
Quoted 7 lines
drivers/net/wireless/ath/ath10k/Makefile +0
-0drivers/net/wireless/ath/ath10k/Makefile ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o · line 26
Quoted 7 lines
drivers/net/wireless/ath/ath10k/Makefile +1
-0@@ -20,6 +20,7 @@ ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o ath10k_core-$(CONFIG_THERMAL) += thermal.o ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o +ath10k_core-y += gpio.o ath10k_core-$(CONFIG_PM) += wow.o ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.oI'd expect it would be something like
ath10k_core-$(CONFIG_GPIO) += gpoi.o. Maybe I'm mistaken.
gpio.c contains the MAC80211_LEDS code and has a guard for GPIOLIB inside. it can be compiled even if GPIOLIB is disabled in system. (which is indeed platform specific) and leds are still supported without gpio support since it does contain a led only driver and a separate gpio driver.
i suggest more somelike like
ath10k_core-$(ATH10K_LEDS) += gpio.o
if you want it totally optional which requires some other small changes as well (mainly renaming some ifdefs)
Quoted 8 lines
(Note, I didn't look up the actual config option name, I'm guessing. Assume I wrote something reasonable for my example.)
I only ask the above two questions, not because I think it's wrong, but because I don't quite know the intention and it makes me wonder.
Other than those questions, which are optional as the code looks correct to me, the rest of it looks fine to me.
i fully understand your concerns, i just followed other drivers behaviour. for sure its more sane to make it optional and to compile it out of not required. but then i suggest todo the same in ath5k and ath9k
Quoted 5 lines
Reviewed-by Steve deRosier <[email protected]>- Steve
Signature · 11 lines
Mit freundlichen Grüssen / Regards Sebastian Gottschall / CTO NewMedia-NET GmbH - DD-WRT Firmensitz: Stubenwaldallee 21a, 64625 Bensheim Registergericht: Amtsgericht Darmstadt, HRB 25473 Geschäftsführer: Peter Steinhäuser, Christian Scheele http://www.dd-wrt.com email: [email protected] Tel.: +496251-582650 / Fax: +496251-5826565
Hi Sebastian,
Quoted 111 lines · Sebastian Gottschall
Am 22.02.2018 um 23:17 schrieb Steve deRosier:
Quoted 52 lines · On Thu, Feb 22, 2018 at 3:15 AM, <[email protected]> wrote:
Quoted 50 lines
From: Sebastian Gottschall <[email protected]>
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based chipsets with on chipset connected led's
using WMI Firmware API.
The LED device will get available named as "ath10k-phyX" at sysfs and can be controlled with various triggers.
adds also debugfs interface for gpio control.Signed-off-by Sebastian Gottschall <[email protected]>v2 add correct gpio count per chipset and remove IPQ4019 support since this chipset does not make use of specific gpios)
v5 fix compiling withoutLED_CLASSand GPIOLIB support, fix also error by kbuild test robot which does not occur in standard builds. curiousv6 correct return values and fix comment style v7 fix ath10k_unregister_led for compiling without LED_CLASS v8 fix various code design issues reported by reviewers v9 move led and led code to separate sourcefile (gpio.c) --- drivers/net/wireless/ath/ath10k/Kconfig | 3 + drivers/net/wireless/ath/ath10k/Makefile | 1 + drivers/net/wireless/ath/ath10k/core.c | 28 ++++- drivers/net/wireless/ath/ath10k/core.h | 33 ++++- drivers/net/wireless/ath/ath10k/debug.c | 142 ++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/gpio.c | 196 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/hw.h | 2 + drivers/net/wireless/ath/ath10k/mac.c | 5 + drivers/net/wireless/ath/ath10k/wmi-ops.h | 36 +++++- drivers/net/wireless/ath/ath10k/wmi-tlv.c | 65 ++++++++++ drivers/net/wireless/ath/ath10k/wmi.c | 46 +++++++ drivers/net/wireless/ath/ath10k/wmi.h | 36 ++++++ 12 files changed, 590 insertions(+), 3 deletions(-)create mode 100644
drivers/net/wireless/ath/ath10k/gpio.cdrivers/net/wireless/ath/ath10k/Kconfig +3
-0@@ -2,6 +2,9 @@ config ATH10K tristate "Atheros 802.11ac wireless cards support" depends on MAC80211 && HAS_DMA select ATH_COMMON + select MAC80211_LEDS + select LEDS_CLASS + select NEW_LEDS select CRC32Quoted 8 lines
drivers/net/wireless/ath/ath10k/Kconfig config ATH10K · line 10
Quoted 2 lines
drivers/net/wireless/ath/ath10k/Kconfig +0
-0select WANT_DEV_COREDUMP ---help---Pure question: do we require LEDS, or is this an option? I assumed all along it was an optional thing - ie if GPIOs and/or LEDs were configured, we added this code. And if not optional, then what happens if we are on a platform that can't support
LEDS_CLASSorNEW_LEDS, assuming there is such a thing?i took this behaviour from ath9k/ath5k, both driver auto select
MAC80211_LEDSandLEDS_CLASS(by the wayMAC80211_LEDSauto selectsLEDS_CLASStoo). only chipsets which are known to have preconfigured leds are used
and led will only turn on if you enable it in sysfs by assigning a trigger to the led.
for sure this can be removed from theKconfig. it will compile without it as well. so this is optional. i just added it since all other drivers behave in the same way.
in addition.LEDS_CLASS/NEW_LEDSis a kernel api, not a driver. so all platforms to supportLEDS_CLASS. just enablingLEDS_CLASSwill not cause any platform specific dependency.Quoted 18 lines
Quoted 9 lines
drivers/net/wireless/ath/ath10k/Makefile +0
-0drivers/net/wireless/ath/ath10k/Makefile ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o · line 26
Quoted 7 lines
drivers/net/wireless/ath/ath10k/Makefile +1
-0@@ -20,6 +20,7 @@ ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o ath10k_core-$(CONFIG_THERMAL) += thermal.o ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o +ath10k_core-y += gpio.o ath10k_core-$(CONFIG_PM) += wow.o ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.oI'd expect it would be something like
ath10k_core-$(CONFIG_GPIO) += gpoi.o. Maybe I'm mistaken.
gpio.ccontains theMAC80211_LEDScode and has a guard for GPIOLIB inside. it can be compiled even if GPIOLIB is disabled in system. (which is indeed platform specific)
and leds are still supported without gpio support since it does contain a led only driver and a separate gpio driver.
i suggest more somelike likeath10k_core-$(ATH10K_LEDS) += gpio.o
if you want it totally optional which requires some other small changes as well (mainly renaming some ifdefs)
Quoted 6 lines
(Note, I didn't look up the actual config option name, I'm guessing. Assume I wrote something reasonable for my example.)
I only ask the above two questions, not because I think it's wrong, but because I don't quite know the intention and it makes me wonder.
Quoted 8 lines
Quoted 2 lines
Other than those questions, which are optional as the code looks correct to me, the rest of it looks fine to me.
i fully understand your concerns, i just followed other drivers behaviour. for sure its more sane to make it optional and to compile it out of not required.
but then i suggest todo the same in ath5k and ath9k
Your explanation is fine with me. Consistency with other drivers makes perfect sense. And I happen to agree with your thought, that it should be fixed in the other drivers. But that doesn't seem like it should have to be done right now. Thanks for explaining.
I think this is good to go as long as no one else has issues with it.
Quoted 3 lines
Quoted 3 lines
Reviewed-by Steve deRosier <[email protected]>
Thanks,
- Steve
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Sebastian,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on v4.16-rc2 next-20180223]
[cannot apply to ath6kl/ath-next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/s-gottschall-dd-wrt-com/ath10k-add-LED-and-GPIO-controlling-support-for-various-chipsets/20180224-185406 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/net/wireless/ath/ath10k/gpio.c:84:5: sparse: symbol 'ath10k_register_gpio_chip' was not declared. Should it be
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build bot[RFC PATCH] ath10k: ath10k_register_gpio_chip() can be static
In reply to [email protected]Fixes: 35b91f175b35 ("ath10k: add LED and GPIO controlling support for various chipsets")
--- gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/gpio.c +1 -1
@@ -81,7 +81,7 @@ static void ath10k_gpio_pin_set(struct gpio_chip *chip, unsigned offset, }/* register GPIO chip */ -int ath10k_register_gpio_chip (struct ath10k *ar) +static int ath10k_register_gpio_chip (struct ath10k *ar) {struct ath10k_gpiocontrol *gpio = ar->gpio;