aboutsummaryrefslogtreecommitdiffstats
path: root/docs
Commit message (Expand)AuthorAgeFilesLines
* Add documentation for passphrase option.Felix Fietkau2009-09-241-0/+8
* implement doth (802.11h) and wmm (802.11e) options for broadcom as well; upda...Jo-Philipp Wich2009-09-221-0/+10
* configure the IPv6 from /etc/config/network and remove 6scripts's prefix opti...Florian Fainelli2009-07-051-3/+0
* add a short note on how to use OpenWrt for daily work, covering the use of qu...Florian Fainelli2009-06-283-0/+115
* comment and fix some parts of the documentation, thanks to Harsh TrivediFlorian Fainelli2009-06-083-5/+37
* a couple of small fixes in the Wireless documentationFlorian Fainelli2009-05-221-12/+25
* build: update svn url from https:// to svn://Andy Boyett2009-05-201-1/+1
* get rid of $Id$ - it has never helped us and it has broken too many patches ;)Felix Fietkau2009-04-171-3/+0
* document a little bit more the rationale of the 6bridge scriptFlorian Fainelli2009-04-021-0/+2
* allow mac80211 devices to be configured to do 802.11s, requires iwFlorian Fainelli2009-02-261-1/+9
* wireless.tex: update docs to reflect txpower moveAndy Boyett2009-01-311-2/+6
* document the BUILDONLY optionFelix Fietkau2009-01-131-0/+3
* Make the doc slightly more complete and add notes on how to add a new target ...Florian Fainelli2009-01-064-3/+173
* hostapd,madwifi: rename agmode option to hwmode. 11a and 11g aren't the only ...Andy Boyett2008-12-311-4/+4
* build.tex: fix formatting of example in build environments sectionAndy Boyett2008-12-301-1/+1
* update wireless documentation to reflect broadcom config changesJo-Philipp Wich2008-11-161-10/+16
* Document how to build binary ipkgsFlorian Fainelli2008-09-301-0/+53
* Document madwifi specific diversity and antenna settings (#3889Florian Fainelli2008-09-271-0/+8
* Add 802.1x client configuration support and corresponding documentation (#2069)Florian Fainelli2008-08-111-0/+33
* Support encrypted WDS connections (#2463)Florian Fainelli2008-08-091-1/+62
* add script for managing 'build environments' (.config+files/), including docu...Felix Fietkau2008-08-061-0/+57
* cosmetic fix for docs/ prereq checkFelix Fietkau2008-08-061-1/+1
* Update wireless documentationFlorian Fainelli2008-07-261-6/+29
* Document a bit more about IPv6 configurationFlorian Fainelli2008-07-211-2/+19
* fix a small dep bug in the docs/ dirFelix Fietkau2008-06-091-1/+2
* Fix docs build from a clean checkout, closes #2975Andy Boyett2008-01-071-1/+2
* Trivial patch to correct typos and spelling errors in OpenWRT documentation.\...Florian Fainelli2008-01-062-11/+11
* document the feeds systemFelix Fietkau2007-12-281-6/+8
* update build directory pathsFelix Fietkau2007-12-281-10/+10
* update target namesFelix Fietkau2007-12-281-5/+5
* remove some obsolete stuffFelix Fietkau2007-12-281-6/+0
* remove old 'Submitting patches' textFelix Fietkau2007-12-281-15/+0
* add SubmittingPatches document to docs/Felix Fietkau2007-12-283-1/+56
* START is no longer optional for /etc/rc.common based init scriptsFelix Fietkau2007-12-281-2/+1
* document Build/UninstallDevFelix Fietkau2007-12-281-0/+6
* document Build/InstallDevFelix Fietkau2007-12-281-0/+13
* add .gitignore for docs/Felix Fietkau2007-12-281-0/+15
* Allow specifying static IPv6 gateways (#2710)Florian Fainelli2007-11-161-0/+1
* Document the IPv6 connectivity with OpenWrt.Florian Fainelli2007-10-262-1/+47
* apply latex style patch posted on openwrt-devel@listsFelix Fietkau2007-09-292-7/+11
* Fix the option dns usages (#2174)Florian Fainelli2007-08-061-0/+2
* document config_foreach, close #2162Felix Fietkau2007-08-041-0/+19
* fix a few overfull hboxes, remove some redundant stuffFelix Fietkau2007-08-043-20/+12
* wifi docs: fix a few typos and inconsistencies, add examplesFelix Fietkau2007-08-041-14/+68
* Add some more documentationFlorian Fainelli2007-08-033-0/+65
* Fix a typo in the agmode selectionFlorian Fainelli2007-08-011-2/+2
* fix a typoFelix Fietkau2007-07-271-1/+1
* fix docs compile targetsFelix Fietkau2007-07-101-1/+3
* Add a paragraph on how to package kernel modulesFlorian Fainelli2007-03-241-1/+54
* Fix some mistakes and typosFlorian Fainelli2007-03-241-10/+9
'>557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
From: Sebastian Gottschall <s.gottschall@newmedia-net.de>

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.

This patch is specific for OpenWRt base, as is use old backported package
with old wireless source. Support for QCA9984 is removed and a simbol
is added to local-simbol file to export the actually compile the code 
with the ATH10K_LEDS simbol.


Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Reviewed-by: Steve deRosier <derosier@cal-sierra.com>
[kvalo: major reorg and cleanup]
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---

v13:

* only compile tested!

* fix all checkpatch warnings

* fix commit log

* sizeof(struct ath10k_gpiocontrol) -> sizeof(*gpio)

* unsigned -> unsigned int

* remove GPIOLIB code, that should be added in a separate patch

* rename gpio.c to leds.c

* add leds.h

* rename some functions:

  ath10k_attach_led() -> ath10k_leds_register()
  ath10k_unregister_led() -> ath10k_leds_unregister()
  ath10k_reset_led_pin() -> ath10k_leds_start()

* call ath10k_leds_unregister() before ath10k_thermal_unregister() to preserve ordering

* call ath10k_leds_start() only from ath10k_core_start() and not from mac.c

* rename struct ath10k_gpiocontrol as anonymous function under struct
  ath10k::leds, no need for memory allocation

* merge ath10k_add_led() to ath10k_attach_led(), which is it's only caller

* remove #if IS_ENABLED() checks from most of places, memory savings from those were not worth it

* Kconfig help text improvement and move it lower in the menu, also don't enable it by default

* switch to set_brightness_blocking() so that the callback can sleep,
  then no need to use ath10k_wmi_cmd_send_nowait() and can take mutex
  to access ar->state

* don't touch ath10k_wmi_pdev_get_temperature()

* as QCA6174/QCA9377 are not (yet) supported don't add the command to WMI-TLV interface

* remove debugfs interface, that should be added in another patch

* cleanup includes


 drivers/net/wireless/ath/ath10k/Kconfig   |  10 +++
 drivers/net/wireless/ath/ath10k/Makefile  |   1 +
 drivers/net/wireless/ath/ath10k/core.c    |  22 +++++++
 drivers/net/wireless/ath/ath10k/core.h    |   9 ++-
 drivers/net/wireless/ath/ath10k/hw.h      |   1 +
 drivers/net/wireless/ath/ath10k/leds.c    | 103 ++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/leds.h    |  45 +++++++++++++
 drivers/net/wireless/ath/ath10k/mac.c     |   1 +
 drivers/net/wireless/ath/ath10k/wmi-ops.h |  32 ++++++++++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c |   2 +
 drivers/net/wireless/ath/ath10k/wmi.c     |  54 ++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h     |  35 ++++++++++
 12 files changed, 314 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/wireless/ath/ath10k/leds.c
 create mode 100644 drivers/net/wireless/ath/ath10k/leds.h
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Kconfig
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/Kconfig
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Kconfig
@@ -69,6 +69,16 @@ config ATH10K_DEBUGFS
 
 	  If unsure, say Y to make it easier to debug problems.
 
+config ATH10K_LEDS
+	bool "Atheros ath10k LED support"
+	depends on ATH10K
+	select MAC80211_LEDS
+	select LEDS_CLASS
+	select NEW_LEDS
+	default y
+	---help---
+	  This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N.
+
 config ATH10K_SPECTRAL
 	bool "Atheros ath10k spectral scan support"
 	depends on ATH10K_DEBUGFS
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Makefile
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/Makefile
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Makefile
@@ -19,6 +19,7 @@ ath10k_core-$(CPTCFG_ATH10K_SPECTRAL) +=
 ath10k_core-$(CPTCFG_NL80211_TESTMODE) += testmode.o
 ath10k_core-$(CPTCFG_ATH10K_TRACING) += trace.o
 ath10k_core-$(CPTCFG_ATH10K_THERMAL) += thermal.o
+ath10k_core-$(CPTCFG_ATH10K_LEDS) += leds.o
 ath10k_core-$(CPTCFG_MAC80211_DEBUGFS) += debugfs_sta.o
 ath10k_core-$(CONFIG_PM) += wow.o
 ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
Index: backports-v4.18-rc7/local-symbols
===================================================================
--- backports-v4.18-rc7.orig/local-symbols
+++ backports-v4.18-rc7/local-symbols
@@ -147,6 +147,7 @@ ATH10K_DEBUG=
 ATH10K_DEBUGFS=
 ATH10K_SPECTRAL=
 ATH10K_THERMAL=
+ATH10K_LEDS=
 ATH10K_TRACING=
 ATH10K_DFS_CERTIFIED=
 WCN36XX=
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.c
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/core.c
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.c
@@ -34,6 +34,7 @@
 #include "testmode.h"
 #include "wmi-ops.h"
 #include "coredump.h"
+#include "leds.h"
 
 unsigned int ath10k_debug_mask;
 static unsigned int ath10k_cryptmode_param;
@@ -66,6 +67,7 @@ static const struct ath10k_hw_params ath
 		.id = QCA988X_HW_2_0_VERSION,
 		.dev_id = QCA988X_2_0_DEVICE_ID,
 		.name = "qca988x hw2.0",
+		.led_pin = 1,
 		.patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
 		.uart_pin = 7,
 		.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -129,6 +131,7 @@ static const struct ath10k_hw_params ath
 		.id = QCA9887_HW_1_0_VERSION,
 		.dev_id = QCA9887_1_0_DEVICE_ID,
 		.name = "qca9887 hw1.0",
+		.led_pin = 1,
 		.patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
 		.uart_pin = 7,
 		.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -288,6 +291,7 @@ static const struct ath10k_hw_params ath
 		.id = QCA99X0_HW_2_0_DEV_VERSION,
 		.dev_id = QCA99X0_2_0_DEVICE_ID,
 		.name = "qca99x0 hw2.0",
+		.led_pin = 17,
 		.patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
 		.uart_pin = 7,
 		.otp_exe_param = 0x00000700,
@@ -325,6 +329,7 @@ static const struct ath10k_hw_params ath
 		.id = QCA9984_HW_1_0_DEV_VERSION,
 		.dev_id = QCA9984_1_0_DEVICE_ID,
 		.name = "qca9984/qca9994 hw1.0",
+		.led_pin = 17,
 		.patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
 		.uart_pin = 7,
 		.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -367,6 +372,7 @@ static const struct ath10k_hw_params ath
 		.id = QCA9888_HW_2_0_DEV_VERSION,
 		.dev_id = QCA9888_2_0_DEVICE_ID,
 		.name = "qca9888 hw2.0",
+		.led_pin = 17,
 		.patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
 		.uart_pin = 7,
 		.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -2428,6 +2434,10 @@ int ath10k_core_start(struct ath10k *ar,
 	if (status)
 		goto err_hif_stop;
 
+	status = ath10k_leds_start(ar);
+	if (status)
+		goto err_hif_stop;
+
 	return 0;
 
 err_hif_stop:
@@ -2682,9 +2692,18 @@ static void ath10k_core_register_work(st
 		goto err_spectral_destroy;
 	}
 
+	status = ath10k_leds_register(ar);
+	if (status) {
+		ath10k_err(ar, "could not register leds: %d\n",
+			   status);
+		goto err_thermal_unregister;
+	}
+
 	set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
 	return;
 
+err_thermal_unregister:
+	ath10k_thermal_unregister(ar);
 err_spectral_destroy:
 	ath10k_spectral_destroy(ar);
 err_debug_destroy:
@@ -2728,6 +2747,8 @@ void ath10k_core_unregister(struct ath10
 	if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
 		return;
 
+	ath10k_leds_unregister(ar);
+
 	ath10k_thermal_unregister(ar);
 	/* Stop spectral before unregistering from mac80211 to remove the
 	 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.h
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/core.h
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.h
@@ -25,6 +25,7 @@
 #include <linux/pci.h>
 #include <linux/uuid.h>
 #include <linux/time.h>
+#include <linux/leds.h>
 
 #include "htt.h"
 #include "htc.h"
@@ -902,7 +903,6 @@ struct ath10k {
 	u32 low_5ghz_chan;
 	u32 high_5ghz_chan;
 	bool ani_enabled;
-
 	bool p2p;
 
 	struct {
@@ -1093,6 +1093,13 @@ struct ath10k {
 	} testmode;
 
 	struct {
+		struct gpio_led wifi_led;
+		struct led_classdev cdev;
+		char label[48];
+		u32 gpio_state_pin;
+	} leds;
+
+	struct {
 		/* protected by data_lock */
 		u32 fw_crash_counter;
 		u32 fw_warm_reset_counter;
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/hw.h
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/hw.h
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/hw.h
@@ -504,6 +504,7 @@ struct ath10k_hw_params {
 	const char *name;
 	u32 patch_load_addr;
 	int uart_pin;
+	int led_pin;
 	u32 otp_exe_param;
 
 	/* Type of hw cycle counter wraparound logic, for more info
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.c
===================================================================
--- /dev/null
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2005-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/leds.h>
+
+#include "core.h"
+#include "wmi.h"
+#include "wmi-ops.h"
+
+#include "leds.h"
+
+static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
+					       enum led_brightness brightness)
+{
+	struct ath10k *ar = container_of(led_cdev, struct ath10k,
+					 leds.cdev);
+	struct gpio_led *led = &ar->leds.wifi_led;
+
+	mutex_lock(&ar->conf_mutex);
+
+	if (ar->state != ATH10K_STATE_ON)
+		goto out;
+
+	ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
+	ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
+
+out:
+	mutex_unlock(&ar->conf_mutex);
+
+	return 0;
+}
+
+int ath10k_leds_start(struct ath10k *ar)
+{
+	if (ar->hw_params.led_pin == 0)
+		/* leds not supported */
+		return 0;
+
+	/* 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_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
+			       WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
+	ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
+
+	return 0;
+}
+
+int ath10k_leds_register(struct ath10k *ar)
+{
+	int ret;
+
+	if (ar->hw_params.led_pin == 0)
+		/* leds not supported */
+		return 0;
+
+	snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
+		 wiphy_name(ar->hw->wiphy));
+	ar->leds.wifi_led.active_low = 1;
+	ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
+	ar->leds.wifi_led.name = ar->leds.label;
+	ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
+
+	ar->leds.cdev.name = ar->leds.label;
+	ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
+
+	/* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
+	ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
+
+	ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+void ath10k_leds_unregister(struct ath10k *ar)
+{
+	if (ar->hw_params.led_pin == 0)
+		/* leds not supported */
+		return;
+
+	led_classdev_unregister(&ar->leds.cdev);
+}
+
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.h
===================================================================
--- /dev/null
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef _LEDS_H_
+#define _LEDS_H_
+
+#include "core.h"
+
+#ifdef CPTCFG_ATH10K_LEDS
+void ath10k_leds_unregister(struct ath10k *ar);
+int ath10k_leds_start(struct ath10k *ar);
+int ath10k_leds_register(struct ath10k *ar);
+#else
+static inline void ath10k_leds_unregister(struct ath10k *ar)
+{
+}
+
+static inline int ath10k_leds_start(struct ath10k *ar)
+{
+	return 0;
+}
+
+static inline int ath10k_leds_register(struct ath10k *ar)
+{
+	return 0;
+}
+
+#endif
+#endif /* _LEDS_H_ */
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/mac.c
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/mac.c
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/mac.c
@@ -33,6 +33,7 @@
 #include "wmi-tlv.h"
 #include "wmi-ops.h"
 #include "wow.h"
+#include "leds.h"
 
 /*********/
 /* Rates */
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-ops.h
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi-ops.h
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-ops.h
@@ -214,7 +214,10 @@ struct wmi_ops {
 	struct sk_buff *(*gen_echo)(struct ath10k *ar, u32 value);
 	struct sk_buff *(*gen_pdev_get_tpc_table_cmdid)(struct ath10k *ar,
 							u32 param);
+	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);
@@ -1042,6 +1045,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
 	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(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(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
+}
+
 static inline int
 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
 {
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-tlv.c
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -3909,6 +3909,8 @@ static const struct wmi_ops wmi_tlv_ops
 	.gen_echo = ath10k_wmi_tlv_op_gen_echo,
 	.gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
 	.gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
+	/* .gen_gpio_config not implemented */
+	/* .gen_gpio_output not implemented */
 };
 
 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.c
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi.c
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.c
@@ -7115,6 +7115,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
 	return skb;
 }
 
+static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
+						     u32 gpio_num, u32 input,
+						     u32 pull_type, u32 intr_mode)
+{
+	struct wmi_gpio_config_cmd *cmd;
+	struct sk_buff *skb;
+
+	skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
+	if (!skb)
+		return ERR_PTR(-ENOMEM);
+
+	cmd = (struct wmi_gpio_config_cmd *)skb->data;
+	cmd->pull_type = __cpu_to_le32(pull_type);
+	cmd->gpio_num = __cpu_to_le32(gpio_num);
+	cmd->input = __cpu_to_le32(input);
+	cmd->intr_mode = __cpu_to_le32(intr_mode);
+
+	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_config gpio_num 0x%08x input 0x%08x pull_type 0x%08x intr_mode 0x%08x\n",
+		   gpio_num, input, pull_type, intr_mode);
+
+	return skb;
+}
+
+static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
+						     u32 gpio_num, u32 set)
+{
+	struct wmi_gpio_output_cmd *cmd;
+	struct sk_buff *skb;
+
+	skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
+	if (!skb)
+		return ERR_PTR(-ENOMEM);
+
+	cmd = (struct wmi_gpio_output_cmd *)skb->data;
+	cmd->gpio_num = __cpu_to_le32(gpio_num);
+	cmd->set = __cpu_to_le32(set);
+
+	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
+		   gpio_num, set);
+
+	return skb;
+}
+
 static struct sk_buff *
 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
 			     enum wmi_sta_ps_mode psmode)
@@ -8726,6 +8769,9 @@ static const struct wmi_ops wmi_ops = {
 	.fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
 	.get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
 	.gen_echo = ath10k_wmi_op_gen_echo,
+	.gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
+	.gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
+
 	/* .gen_bcn_tmpl not implemented */
 	/* .gen_prb_tmpl not implemented */
 	/* .gen_p2p_go_bcn_ie not implemented */
@@ -8796,6 +8842,8 @@ static const struct wmi_ops wmi_10_1_ops
 	.fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
 	.get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
 	.gen_echo = ath10k_wmi_op_gen_echo,
+	.gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
+	.gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
 	/* .gen_bcn_tmpl not implemented */
 	/* .gen_prb_tmpl not implemented */
 	/* .gen_p2p_go_bcn_ie not implemented */
@@ -8867,6 +8915,8 @@ static const struct wmi_ops wmi_10_2_ops
 	.gen_delba_send = ath10k_wmi_op_gen_delba_send,
 	.fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
 	.get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
+	.gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
+	.gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
 	/* .gen_pdev_enable_adaptive_cca not implemented */
 };
 
@@ -8937,6 +8987,8 @@ static const struct wmi_ops wmi_10_2_4_o
 	.gen_pdev_enable_adaptive_cca =
 		ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
 	.get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
+	.gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
+	.gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
 	/* .gen_bcn_tmpl not implemented */
 	/* .gen_prb_tmpl not implemented */
 	/* .gen_p2p_go_bcn_ie not implemented */
@@ -9016,6 +9068,8 @@ static const struct wmi_ops wmi_10_4_ops
 	.gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
 	.gen_echo = ath10k_wmi_op_gen_echo,
 	.gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
+	.gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
+	.gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
 };
 
 int ath10k_wmi_attach(struct ath10k *ar)
Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.h
===================================================================
--- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi.h
+++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.h
@@ -2941,6 +2941,41 @@ 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;