7b17e111ab486818b294cdfd0be4ddd6fcd04984
[openwrt/staging/lynxis.git] /
1 From: Sebastian Gottschall <s.gottschall@newmedia-net.de>
2
3 Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based
4 chipsets with on chipset connected led's using WMI Firmware API. The LED
5 device will get available named as "ath10k-phyX" at sysfs and can be controlled
6 with various triggers. adds also debugfs interface for gpio control.
7
8 This patch is specific for OpenWRt base, as is use old backported package
9 with old wireless source. Support for QCA9984 is removed and a simbol
10 is added to local-simbol file to export the actually compile the code
11 with the ATH10K_LEDS simbol.
12
13
14 Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
15 Reviewed-by: Steve deRosier <derosier@cal-sierra.com>
16 [kvalo: major reorg and cleanup]
17 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
18 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
19 ---
20
21 v13:
22
23 * only compile tested!
24
25 * fix all checkpatch warnings
26
27 * fix commit log
28
29 * sizeof(struct ath10k_gpiocontrol) -> sizeof(*gpio)
30
31 * unsigned -> unsigned int
32
33 * remove GPIOLIB code, that should be added in a separate patch
34
35 * rename gpio.c to leds.c
36
37 * add leds.h
38
39 * rename some functions:
40
41 ath10k_attach_led() -> ath10k_leds_register()
42 ath10k_unregister_led() -> ath10k_leds_unregister()
43 ath10k_reset_led_pin() -> ath10k_leds_start()
44
45 * call ath10k_leds_unregister() before ath10k_thermal_unregister() to preserve ordering
46
47 * call ath10k_leds_start() only from ath10k_core_start() and not from mac.c
48
49 * rename struct ath10k_gpiocontrol as anonymous function under struct
50 ath10k::leds, no need for memory allocation
51
52 * merge ath10k_add_led() to ath10k_attach_led(), which is it's only caller
53
54 * remove #if IS_ENABLED() checks from most of places, memory savings from those were not worth it
55
56 * Kconfig help text improvement and move it lower in the menu, also don't enable it by default
57
58 * switch to set_brightness_blocking() so that the callback can sleep,
59 then no need to use ath10k_wmi_cmd_send_nowait() and can take mutex
60 to access ar->state
61
62 * don't touch ath10k_wmi_pdev_get_temperature()
63
64 * as QCA6174/QCA9377 are not (yet) supported don't add the command to WMI-TLV interface
65
66 * remove debugfs interface, that should be added in another patch
67
68 * cleanup includes
69
70
71 drivers/net/wireless/ath/ath10k/Kconfig | 10 +++
72 drivers/net/wireless/ath/ath10k/Makefile | 1 +
73 drivers/net/wireless/ath/ath10k/core.c | 22 +++++++
74 drivers/net/wireless/ath/ath10k/core.h | 9 ++-
75 drivers/net/wireless/ath/ath10k/hw.h | 1 +
76 drivers/net/wireless/ath/ath10k/leds.c | 103 ++++++++++++++++++++++++++++++
77 drivers/net/wireless/ath/ath10k/leds.h | 45 +++++++++++++
78 drivers/net/wireless/ath/ath10k/mac.c | 1 +
79 drivers/net/wireless/ath/ath10k/wmi-ops.h | 32 ++++++++++
80 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +
81 drivers/net/wireless/ath/ath10k/wmi.c | 54 ++++++++++++++++
82 drivers/net/wireless/ath/ath10k/wmi.h | 35 ++++++++++
83 12 files changed, 314 insertions(+), 1 deletion(-)
84 create mode 100644 drivers/net/wireless/ath/ath10k/leds.c
85 create mode 100644 drivers/net/wireless/ath/ath10k/leds.h
86 --- a/drivers/net/wireless/ath/ath10k/Kconfig
87 +++ b/drivers/net/wireless/ath/ath10k/Kconfig
88 @@ -56,6 +56,16 @@ config ATH10K_DEBUGFS
89
90 If unsure, say Y to make it easier to debug problems.
91
92 +config ATH10K_LEDS
93 + bool "Atheros ath10k LED support"
94 + depends on ATH10K
95 + select MAC80211_LEDS
96 + select LEDS_CLASS
97 + select NEW_LEDS
98 + default y
99 + ---help---
100 + This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N.
101 +
102 config ATH10K_SPECTRAL
103 bool "Atheros ath10k spectral scan support"
104 depends on ATH10K_DEBUGFS
105 --- a/drivers/net/wireless/ath/ath10k/Makefile
106 +++ b/drivers/net/wireless/ath/ath10k/Makefile
107 @@ -18,6 +18,7 @@ ath10k_core-$(CPTCFG_ATH10K_SPECTRAL) +=
108 ath10k_core-$(CPTCFG_NL80211_TESTMODE) += testmode.o
109 ath10k_core-$(CPTCFG_ATH10K_TRACING) += trace.o
110 ath10k_core-$(CPTCFG_ATH10K_THERMAL) += thermal.o
111 +ath10k_core-$(CPTCFG_ATH10K_LEDS) += leds.o
112 ath10k_core-$(CPTCFG_MAC80211_DEBUGFS) += debugfs_sta.o
113 ath10k_core-$(CONFIG_PM) += wow.o
114
115 --- a/local-symbols
116 +++ b/local-symbols
117 @@ -144,6 +144,7 @@ ATH10K_DEBUG=
118 ATH10K_DEBUGFS=
119 ATH10K_SPECTRAL=
120 ATH10K_THERMAL=
121 +ATH10K_LEDS=
122 ATH10K_TRACING=
123 ATH10K_DFS_CERTIFIED=
124 WCN36XX=
125 --- a/drivers/net/wireless/ath/ath10k/core.c
126 +++ b/drivers/net/wireless/ath/ath10k/core.c
127 @@ -32,6 +32,7 @@
128 #include "htt.h"
129 #include "testmode.h"
130 #include "wmi-ops.h"
131 +#include "leds.h"
132
133 unsigned int ath10k_debug_mask;
134 static unsigned int ath10k_cryptmode_param;
135 @@ -56,6 +57,7 @@ static const struct ath10k_hw_params ath
136 .id = QCA988X_HW_2_0_VERSION,
137 .dev_id = QCA988X_2_0_DEVICE_ID,
138 .name = "qca988x hw2.0",
139 + .led_pin = 1,
140 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
141 .uart_pin = 7,
142 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
143 @@ -80,6 +82,7 @@ static const struct ath10k_hw_params ath
144 .id = QCA9887_HW_1_0_VERSION,
145 .dev_id = QCA9887_1_0_DEVICE_ID,
146 .name = "qca9887 hw1.0",
147 + .led_pin = 1,
148 .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
149 .uart_pin = 7,
150 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
151 @@ -199,6 +202,7 @@ static const struct ath10k_hw_params ath
152 .id = QCA99X0_HW_2_0_DEV_VERSION,
153 .dev_id = QCA99X0_2_0_DEVICE_ID,
154 .name = "qca99x0 hw2.0",
155 + .led_pin = 17,
156 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
157 .uart_pin = 7,
158 .otp_exe_param = 0x00000700,
159 @@ -228,6 +232,7 @@ static const struct ath10k_hw_params ath
160 .id = QCA9984_HW_1_0_DEV_VERSION,
161 .dev_id = QCA9984_1_0_DEVICE_ID,
162 .name = "qca9984/qca9994 hw1.0",
163 + .led_pin = 17,
164 .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
165 .uart_pin = 7,
166 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
167 @@ -262,6 +267,7 @@ static const struct ath10k_hw_params ath
168 .id = QCA9888_HW_2_0_DEV_VERSION,
169 .dev_id = QCA9888_2_0_DEVICE_ID,
170 .name = "qca9888 hw2.0",
171 + .led_pin = 17,
172 .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
173 .uart_pin = 7,
174 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
175 @@ -2254,6 +2260,10 @@ int ath10k_core_start(struct ath10k *ar,
176 if (status)
177 goto err_hif_stop;
178
179 + status = ath10k_leds_start(ar);
180 + if (status)
181 + goto err_hif_stop;
182 +
183 return 0;
184
185 err_hif_stop:
186 @@ -2471,9 +2481,18 @@ static void ath10k_core_register_work(st
187 goto err_spectral_destroy;
188 }
189
190 + status = ath10k_leds_register(ar);
191 + if (status) {
192 + ath10k_err(ar, "could not register leds: %d\n",
193 + status);
194 + goto err_thermal_unregister;
195 + }
196 +
197 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
198 return;
199
200 +err_thermal_unregister:
201 + ath10k_thermal_unregister(ar);
202 err_spectral_destroy:
203 ath10k_spectral_destroy(ar);
204 err_debug_destroy:
205 @@ -2515,6 +2534,8 @@ void ath10k_core_unregister(struct ath10
206 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
207 return;
208
209 + ath10k_leds_unregister(ar);
210 +
211 ath10k_thermal_unregister(ar);
212 /* Stop spectral before unregistering from mac80211 to remove the
213 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
214 --- a/drivers/net/wireless/ath/ath10k/core.h
215 +++ b/drivers/net/wireless/ath/ath10k/core.h
216 @@ -24,6 +24,7 @@
217 #include <linux/pci.h>
218 #include <linux/uuid.h>
219 #include <linux/time.h>
220 +#include <linux/leds.h>
221
222 #include "htt.h"
223 #include "htc.h"
224 @@ -789,7 +790,6 @@ struct ath10k {
225 u32 low_5ghz_chan;
226 u32 high_5ghz_chan;
227 bool ani_enabled;
228 -
229 bool p2p;
230
231 struct {
232 @@ -972,6 +972,13 @@ struct ath10k {
233 } testmode;
234
235 struct {
236 + struct gpio_led wifi_led;
237 + struct led_classdev cdev;
238 + char label[48];
239 + u32 gpio_state_pin;
240 + } leds;
241 +
242 + struct {
243 /* protected by data_lock */
244 u32 fw_crash_counter;
245 u32 fw_warm_reset_counter;
246 --- a/drivers/net/wireless/ath/ath10k/hw.h
247 +++ b/drivers/net/wireless/ath/ath10k/hw.h
248 @@ -490,6 +490,7 @@ struct ath10k_hw_params {
249 const char *name;
250 u32 patch_load_addr;
251 int uart_pin;
252 + int led_pin;
253 u32 otp_exe_param;
254
255 /* Type of hw cycle counter wraparound logic, for more info
256 --- /dev/null
257 +++ b/drivers/net/wireless/ath/ath10k/leds.c
258 @@ -0,0 +1,103 @@
259 +/*
260 + * Copyright (c) 2005-2011 Atheros Communications Inc.
261 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
262 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
263 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
264 + *
265 + * Permission to use, copy, modify, and/or distribute this software for any
266 + * purpose with or without fee is hereby granted, provided that the above
267 + * copyright notice and this permission notice appear in all copies.
268 + *
269 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
270 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
271 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
272 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
273 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
274 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
275 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
276 + */
277 +
278 +#include <linux/leds.h>
279 +
280 +#include "core.h"
281 +#include "wmi.h"
282 +#include "wmi-ops.h"
283 +
284 +#include "leds.h"
285 +
286 +static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
287 + enum led_brightness brightness)
288 +{
289 + struct ath10k *ar = container_of(led_cdev, struct ath10k,
290 + leds.cdev);
291 + struct gpio_led *led = &ar->leds.wifi_led;
292 +
293 + mutex_lock(&ar->conf_mutex);
294 +
295 + if (ar->state != ATH10K_STATE_ON)
296 + goto out;
297 +
298 + ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
299 + ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
300 +
301 +out:
302 + mutex_unlock(&ar->conf_mutex);
303 +
304 + return 0;
305 +}
306 +
307 +int ath10k_leds_start(struct ath10k *ar)
308 +{
309 + if (ar->hw_params.led_pin == 0)
310 + /* leds not supported */
311 + return 0;
312 +
313 + /* under some circumstances, the gpio pin gets reconfigured
314 + * to default state by the firmware, so we need to
315 + * reconfigure it this behaviour has only ben seen on
316 + * QCA9984 and QCA99XX devices so far
317 + */
318 + ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
319 + WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
320 + ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
321 +
322 + return 0;
323 +}
324 +
325 +int ath10k_leds_register(struct ath10k *ar)
326 +{
327 + int ret;
328 +
329 + if (ar->hw_params.led_pin == 0)
330 + /* leds not supported */
331 + return 0;
332 +
333 + snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
334 + wiphy_name(ar->hw->wiphy));
335 + ar->leds.wifi_led.active_low = 1;
336 + ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
337 + ar->leds.wifi_led.name = ar->leds.label;
338 + ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
339 +
340 + ar->leds.cdev.name = ar->leds.label;
341 + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
342 +
343 + /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
344 + ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
345 +
346 + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
347 + if (ret)
348 + return ret;
349 +
350 + return 0;
351 +}
352 +
353 +void ath10k_leds_unregister(struct ath10k *ar)
354 +{
355 + if (ar->hw_params.led_pin == 0)
356 + /* leds not supported */
357 + return;
358 +
359 + led_classdev_unregister(&ar->leds.cdev);
360 +}
361 +
362 --- /dev/null
363 +++ b/drivers/net/wireless/ath/ath10k/leds.h
364 @@ -0,0 +1,41 @@
365 +/*
366 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
367 + *
368 + * Permission to use, copy, modify, and/or distribute this software for any
369 + * purpose with or without fee is hereby granted, provided that the above
370 + * copyright notice and this permission notice appear in all copies.
371 + *
372 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
373 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
374 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
375 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
376 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
377 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
378 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
379 + */
380 +#ifndef _LEDS_H_
381 +#define _LEDS_H_
382 +
383 +#include "core.h"
384 +
385 +#ifdef CPTCFG_ATH10K_LEDS
386 +void ath10k_leds_unregister(struct ath10k *ar);
387 +int ath10k_leds_start(struct ath10k *ar);
388 +int ath10k_leds_register(struct ath10k *ar);
389 +#else
390 +static inline void ath10k_leds_unregister(struct ath10k *ar)
391 +{
392 +}
393 +
394 +static inline int ath10k_leds_start(struct ath10k *ar)
395 +{
396 + return 0;
397 +}
398 +
399 +static inline int ath10k_leds_register(struct ath10k *ar)
400 +{
401 + return 0;
402 +}
403 +
404 +#endif
405 +#endif /* _LEDS_H_ */
406 --- a/drivers/net/wireless/ath/ath10k/mac.c
407 +++ b/drivers/net/wireless/ath/ath10k/mac.c
408 @@ -32,6 +32,7 @@
409 #include "wmi-tlv.h"
410 #include "wmi-ops.h"
411 #include "wow.h"
412 +#include "leds.h"
413
414 /*********/
415 /* Rates */
416 --- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
417 +++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
418 @@ -197,6 +197,10 @@ struct wmi_ops {
419 (struct ath10k *ar,
420 enum wmi_bss_survey_req_type type);
421 struct sk_buff *(*gen_echo)(struct ath10k *ar, u32 value);
422 + struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num,
423 + u32 input, u32 pull_type, u32 intr_mode);
424 +
425 + struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set);
426 };
427
428 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
429 @@ -951,6 +955,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
430 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
431 }
432
433 +static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num,
434 + u32 input, u32 pull_type, u32 intr_mode)
435 +{
436 + struct sk_buff *skb;
437 +
438 + if (!ar->wmi.ops->gen_gpio_config)
439 + return -EOPNOTSUPP;
440 +
441 + skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode);
442 + if (IS_ERR(skb))
443 + return PTR_ERR(skb);
444 +
445 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid);
446 +}
447 +
448 +static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set)
449 +{
450 + struct sk_buff *skb;
451 +
452 + if (!ar->wmi.ops->gen_gpio_config)
453 + return -EOPNOTSUPP;
454 +
455 + skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set);
456 + if (IS_ERR(skb))
457 + return PTR_ERR(skb);
458 +
459 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
460 +}
461 +
462 static inline int
463 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
464 {
465 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
466 +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
467 @@ -3619,6 +3619,8 @@ static const struct wmi_ops wmi_tlv_ops
468 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
469 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
470 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
471 + /* .gen_gpio_config not implemented */
472 + /* .gen_gpio_output not implemented */
473 };
474
475 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
476 --- a/drivers/net/wireless/ath/ath10k/wmi.c
477 +++ b/drivers/net/wireless/ath/ath10k/wmi.c
478 @@ -6580,6 +6580,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
479 return skb;
480 }
481
482 +static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
483 + u32 gpio_num, u32 input,
484 + u32 pull_type, u32 intr_mode)
485 +{
486 + struct wmi_gpio_config_cmd *cmd;
487 + struct sk_buff *skb;
488 +
489 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
490 + if (!skb)
491 + return ERR_PTR(-ENOMEM);
492 +
493 + cmd = (struct wmi_gpio_config_cmd *)skb->data;
494 + cmd->pull_type = __cpu_to_le32(pull_type);
495 + cmd->gpio_num = __cpu_to_le32(gpio_num);
496 + cmd->input = __cpu_to_le32(input);
497 + cmd->intr_mode = __cpu_to_le32(intr_mode);
498 +
499 + 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",
500 + gpio_num, input, pull_type, intr_mode);
501 +
502 + return skb;
503 +}
504 +
505 +static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
506 + u32 gpio_num, u32 set)
507 +{
508 + struct wmi_gpio_output_cmd *cmd;
509 + struct sk_buff *skb;
510 +
511 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
512 + if (!skb)
513 + return ERR_PTR(-ENOMEM);
514 +
515 + cmd = (struct wmi_gpio_output_cmd *)skb->data;
516 + cmd->gpio_num = __cpu_to_le32(gpio_num);
517 + cmd->set = __cpu_to_le32(set);
518 +
519 + ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
520 + gpio_num, set);
521 +
522 + return skb;
523 +}
524 +
525 static struct sk_buff *
526 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
527 enum wmi_sta_ps_mode psmode)
528 @@ -8081,6 +8124,9 @@ static const struct wmi_ops wmi_ops = {
529 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
530 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
531 .gen_echo = ath10k_wmi_op_gen_echo,
532 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
533 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
534 +
535 /* .gen_bcn_tmpl not implemented */
536 /* .gen_prb_tmpl not implemented */
537 /* .gen_p2p_go_bcn_ie not implemented */
538 @@ -8151,6 +8197,8 @@ static const struct wmi_ops wmi_10_1_ops
539 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
540 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
541 .gen_echo = ath10k_wmi_op_gen_echo,
542 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
543 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
544 /* .gen_bcn_tmpl not implemented */
545 /* .gen_prb_tmpl not implemented */
546 /* .gen_p2p_go_bcn_ie not implemented */
547 @@ -8222,6 +8270,8 @@ static const struct wmi_ops wmi_10_2_ops
548 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
549 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
550 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
551 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
552 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
553 /* .gen_pdev_enable_adaptive_cca not implemented */
554 };
555
556 @@ -8292,6 +8342,8 @@ static const struct wmi_ops wmi_10_2_4_o
557 .gen_pdev_enable_adaptive_cca =
558 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
559 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
560 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
561 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
562 /* .gen_bcn_tmpl not implemented */
563 /* .gen_prb_tmpl not implemented */
564 /* .gen_p2p_go_bcn_ie not implemented */
565 @@ -8367,6 +8419,8 @@ static const struct wmi_ops wmi_10_4_ops
566 .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
567 .gen_echo = ath10k_wmi_op_gen_echo,
568 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
569 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
570 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
571 };
572
573 int ath10k_wmi_attach(struct ath10k *ar)
574 --- a/drivers/net/wireless/ath/ath10k/wmi.h
575 +++ b/drivers/net/wireless/ath/ath10k/wmi.h
576 @@ -2899,6 +2899,41 @@ enum wmi_10_4_feature_mask {
577
578 };
579
580 +/* WMI_GPIO_CONFIG_CMDID */
581 +enum {
582 + WMI_GPIO_PULL_NONE,
583 + WMI_GPIO_PULL_UP,
584 + WMI_GPIO_PULL_DOWN,
585 +};
586 +
587 +enum {
588 + WMI_GPIO_INTTYPE_DISABLE,
589 + WMI_GPIO_INTTYPE_RISING_EDGE,
590 + WMI_GPIO_INTTYPE_FALLING_EDGE,
591 + WMI_GPIO_INTTYPE_BOTH_EDGE,
592 + WMI_GPIO_INTTYPE_LEVEL_LOW,
593 + WMI_GPIO_INTTYPE_LEVEL_HIGH
594 +};
595 +
596 +/* WMI_GPIO_CONFIG_CMDID */
597 +struct wmi_gpio_config_cmd {
598 + __le32 gpio_num; /* GPIO number to be setup */
599 + __le32 input; /* 0 - Output/ 1 - Input */
600 + __le32 pull_type; /* Pull type defined above */
601 + __le32 intr_mode; /* Interrupt mode defined above (Input) */
602 +} __packed;
603 +
604 +/* WMI_GPIO_OUTPUT_CMDID */
605 +struct wmi_gpio_output_cmd {
606 + __le32 gpio_num; /* GPIO number to be setup */
607 + __le32 set; /* Set the GPIO pin*/
608 +} __packed;
609 +
610 +/* WMI_GPIO_INPUT_EVENTID */
611 +struct wmi_gpio_input_event {
612 + __le32 gpio_num; /* GPIO number which changed state */
613 +} __packed;
614 +
615 struct wmi_ext_resource_config_10_4_cmd {
616 /* contains enum wmi_host_platform_type */
617 __le32 host_platform_config;