0be3ffdcff3f6c37ecb0fce5d01200e66c320b2e
[openwrt/staging/jow.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.
10 Reworked to use ath10k-ct custom source
11
12
13 Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
14 Reviewed-by: Steve deRosier <derosier@cal-sierra.com>
15 [kvalo: major reorg and cleanup]
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
18 ---
19
20 v13:
21
22 * only compile tested!
23
24 * fix all checkpatch warnings
25
26 * fix commit log
27
28 * sizeof(struct ath10k_gpiocontrol) -> sizeof(*gpio)
29
30 * unsigned -> unsigned int
31
32 * remove GPIOLIB code, that should be added in a separate patch
33
34 * rename gpio.c to leds.c
35
36 * add leds.h
37
38 * rename some functions:
39
40 ath10k_attach_led() -> ath10k_leds_register()
41 ath10k_unregister_led() -> ath10k_leds_unregister()
42 ath10k_reset_led_pin() -> ath10k_leds_start()
43
44 * call ath10k_leds_unregister() before ath10k_thermal_unregister() to preserve ordering
45
46 * call ath10k_leds_start() only from ath10k_core_start() and not from mac.c
47
48 * rename struct ath10k_gpiocontrol as anonymous function under struct
49 ath10k::leds, no need for memory allocation
50
51 * merge ath10k_add_led() to ath10k_attach_led(), which is it's only caller
52
53 * remove #if IS_ENABLED() checks from most of places, memory savings from those were not worth it
54
55 * Kconfig help text improvement and move it lower in the menu, also don't enable it by default
56
57 * switch to set_brightness_blocking() so that the callback can sleep,
58 then no need to use ath10k_wmi_cmd_send_nowait() and can take mutex
59 to access ar->state
60
61 * don't touch ath10k_wmi_pdev_get_temperature()
62
63 * as QCA6174/QCA9377 are not (yet) supported don't add the command to WMI-TLV interface
64
65 * remove debugfs interface, that should be added in another patch
66
67 * cleanup includes
68
69
70 ath10k-4.16/Kconfig | 10 +++
71 ath10k-4.16/Makefile | 1 +
72 ath10k-4.16/core.c | 22 +++++++
73 ath10k-4.16/core.h | 9 ++-
74 ath10k-4.16/hw.h | 1 +
75 ath10k-4.16/leds.c | 103 ++++++++++++++++++++++++++++++
76 ath10k-4.16/leds.h | 45 +++++++++++++
77 ath10k-4.16/mac.c | 1 +
78 ath10k-4.16/wmi-ops.h | 32 ++++++++++
79 ath10k-4.16/wmi-tlv.c | 2 +
80 ath10k-4.16/wmi.c | 54 ++++++++++++++++
81 ath10k-4.16/wmi.h | 35 ++++++++++
82 12 files changed, 314 insertions(+), 1 deletion(-)
83 create mode 100644 ath10k-4.16/leds.c
84 create mode 100644 ath10k-4.16/leds.h
85 --- a/ath10k-4.16/Kconfig
86 +++ b/ath10k-4.16/Kconfig
87 @@ -60,6 +60,16 @@ config ATH10K_SPECTRAL
88 ---help---
89 Say Y to enable access to the FFT/spectral data via debugfs.
90
91 +config ATH10K_LEDS
92 + bool "Atheros ath10k LED support"
93 + depends on ATH10K
94 + select MAC80211_LEDS
95 + select LEDS_CLASS
96 + select NEW_LEDS
97 + default y
98 + ---help---
99 + This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N.
100 +
101 config ATH10K_TRACING
102 bool "Atheros ath10k tracing support"
103 depends on ATH10K
104 --- a/ath10k-4.16/Makefile
105 +++ b/ath10k-4.16/Makefile
106 @@ -19,6 +19,7 @@ ath10k_core-$(CONFIG_ATH10K_SPECTRAL) +=
107 ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o
108 ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o
109 ath10k_core-$(CONFIG_THERMAL) += thermal.o
110 +ath10k_core-$(CONFIG_ATH10K_LEDS) += leds.o
111 ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o
112 ath10k_core-$(CONFIG_PM) += wow.o
113 ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
114 --- a/ath10k-4.16/core.c
115 +++ b/ath10k-4.16/core.c
116 @@ -34,6 +34,7 @@
117 #include "testmode.h"
118 #include "wmi-ops.h"
119 #include "coredump.h"
120 +#include "leds.h"
121
122 /* Disable ath10k-ct DBGLOG output by default */
123 unsigned int ath10k_debug_mask = ATH10K_DBG_NO_DBGLOG;
124 @@ -73,6 +74,7 @@ static const struct ath10k_hw_params ath
125 .id = QCA988X_HW_2_0_VERSION,
126 .dev_id = QCA988X_2_0_DEVICE_ID,
127 .name = "qca988x hw2.0",
128 + .led_pin = 1,
129 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
130 .uart_pin = 7,
131 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
132 @@ -131,6 +133,7 @@ static const struct ath10k_hw_params ath
133 .id = QCA9887_HW_1_0_VERSION,
134 .dev_id = QCA9887_1_0_DEVICE_ID,
135 .name = "qca9887 hw1.0",
136 + .led_pin = 1,
137 .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
138 .uart_pin = 7,
139 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
140 @@ -275,6 +278,7 @@ static const struct ath10k_hw_params ath
141 .id = QCA99X0_HW_2_0_DEV_VERSION,
142 .dev_id = QCA99X0_2_0_DEVICE_ID,
143 .name = "qca99x0 hw2.0",
144 + .led_pin = 17,
145 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
146 .uart_pin = 7,
147 .otp_exe_param = 0x00000700,
148 @@ -309,6 +313,7 @@ static const struct ath10k_hw_params ath
149 .id = QCA9984_HW_1_0_DEV_VERSION,
150 .dev_id = QCA9984_1_0_DEVICE_ID,
151 .name = "qca9984/qca9994 hw1.0",
152 + .led_pin = 17,
153 .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
154 .uart_pin = 7,
155 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
156 @@ -348,6 +353,7 @@ static const struct ath10k_hw_params ath
157 .id = QCA9888_HW_2_0_DEV_VERSION,
158 .dev_id = QCA9888_2_0_DEVICE_ID,
159 .name = "qca9888 hw2.0",
160 + .led_pin = 17,
161 .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
162 .uart_pin = 7,
163 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
164 @@ -3040,6 +3046,10 @@ int ath10k_core_start(struct ath10k *ar,
165 ar->eeprom_overrides.rc_txbf_probe);
166 }
167
168 + status = ath10k_leds_start(ar);
169 + if (status)
170 + goto err_hif_stop;
171 +
172 return 0;
173
174 err_hif_stop:
175 @@ -3286,9 +3296,18 @@ static void ath10k_core_register_work(st
176 goto err_spectral_destroy;
177 }
178
179 + status = ath10k_leds_register(ar);
180 + if (status) {
181 + ath10k_err(ar, "could not register leds: %d\n",
182 + status);
183 + goto err_thermal_unregister;
184 + }
185 +
186 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
187 return;
188
189 +err_thermal_unregister:
190 + ath10k_thermal_unregister(ar);
191 err_spectral_destroy:
192 ath10k_spectral_destroy(ar);
193 err_debug_destroy:
194 @@ -3346,6 +3365,8 @@ void ath10k_core_unregister(struct ath10
195 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
196 return;
197
198 + ath10k_leds_unregister(ar);
199 +
200 ath10k_thermal_unregister(ar);
201 /* Stop spectral before unregistering from mac80211 to remove the
202 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
203 --- a/ath10k-4.16/core.h
204 +++ b/ath10k-4.16/core.h
205 @@ -24,6 +24,7 @@
206 #include <linux/pci.h>
207 #include <linux/uuid.h>
208 #include <linux/time.h>
209 +#include <linux/leds.h>
210
211 #include "htt.h"
212 #include "htc.h"
213 @@ -1245,6 +1246,13 @@ struct ath10k {
214 } testmode;
215
216 struct {
217 + struct gpio_led wifi_led;
218 + struct led_classdev cdev;
219 + char label[48];
220 + u32 gpio_state_pin;
221 + } leds;
222 +
223 + struct {
224 /* protected by data_lock */
225 u32 fw_crash_counter;
226 u32 fw_warm_reset_counter;
227 --- a/ath10k-4.16/hw.h
228 +++ b/ath10k-4.16/hw.h
229 @@ -499,6 +499,7 @@ struct ath10k_hw_params {
230 const char *name;
231 u32 patch_load_addr;
232 int uart_pin;
233 + int led_pin;
234 u32 otp_exe_param;
235
236 /* Type of hw cycle counter wraparound logic, for more info
237 --- /dev/null
238 +++ b/ath10k-4.16/leds.c
239 @@ -0,0 +1,103 @@
240 +/*
241 + * Copyright (c) 2005-2011 Atheros Communications Inc.
242 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
243 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
244 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
245 + *
246 + * Permission to use, copy, modify, and/or distribute this software for any
247 + * purpose with or without fee is hereby granted, provided that the above
248 + * copyright notice and this permission notice appear in all copies.
249 + *
250 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
251 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
252 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
253 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
254 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
255 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
256 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
257 + */
258 +
259 +#include <linux/leds.h>
260 +
261 +#include "core.h"
262 +#include "wmi.h"
263 +#include "wmi-ops.h"
264 +
265 +#include "leds.h"
266 +
267 +static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
268 + enum led_brightness brightness)
269 +{
270 + struct ath10k *ar = container_of(led_cdev, struct ath10k,
271 + leds.cdev);
272 + struct gpio_led *led = &ar->leds.wifi_led;
273 +
274 + mutex_lock(&ar->conf_mutex);
275 +
276 + if (ar->state != ATH10K_STATE_ON)
277 + goto out;
278 +
279 + ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
280 + ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
281 +
282 +out:
283 + mutex_unlock(&ar->conf_mutex);
284 +
285 + return 0;
286 +}
287 +
288 +int ath10k_leds_start(struct ath10k *ar)
289 +{
290 + if (ar->hw_params.led_pin == 0)
291 + /* leds not supported */
292 + return 0;
293 +
294 + /* under some circumstances, the gpio pin gets reconfigured
295 + * to default state by the firmware, so we need to
296 + * reconfigure it this behaviour has only ben seen on
297 + * QCA9984 and QCA99XX devices so far
298 + */
299 + ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
300 + WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
301 + ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
302 +
303 + return 0;
304 +}
305 +
306 +int ath10k_leds_register(struct ath10k *ar)
307 +{
308 + int ret;
309 +
310 + if (ar->hw_params.led_pin == 0)
311 + /* leds not supported */
312 + return 0;
313 +
314 + snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
315 + wiphy_name(ar->hw->wiphy));
316 + ar->leds.wifi_led.active_low = 1;
317 + ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
318 + ar->leds.wifi_led.name = ar->leds.label;
319 + ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
320 +
321 + ar->leds.cdev.name = ar->leds.label;
322 + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
323 +
324 + /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
325 + ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
326 +
327 + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
328 + if (ret)
329 + return ret;
330 +
331 + return 0;
332 +}
333 +
334 +void ath10k_leds_unregister(struct ath10k *ar)
335 +{
336 + if (ar->hw_params.led_pin == 0)
337 + /* leds not supported */
338 + return;
339 +
340 + led_classdev_unregister(&ar->leds.cdev);
341 +}
342 +
343 --- /dev/null
344 +++ b/ath10k-4.16/leds.h
345 @@ -0,0 +1,41 @@
346 +/*
347 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
348 + *
349 + * Permission to use, copy, modify, and/or distribute this software for any
350 + * purpose with or without fee is hereby granted, provided that the above
351 + * copyright notice and this permission notice appear in all copies.
352 + *
353 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
354 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
355 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
356 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
357 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
358 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
359 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
360 + */
361 +#ifndef _LEDS_H_
362 +#define _LEDS_H_
363 +
364 +#include "core.h"
365 +
366 +#ifdef CONFIG_ATH10K_LEDS
367 +void ath10k_leds_unregister(struct ath10k *ar);
368 +int ath10k_leds_start(struct ath10k *ar);
369 +int ath10k_leds_register(struct ath10k *ar);
370 +#else
371 +static inline void ath10k_leds_unregister(struct ath10k *ar)
372 +{
373 +}
374 +
375 +static inline int ath10k_leds_start(struct ath10k *ar)
376 +{
377 + return 0;
378 +}
379 +
380 +static inline int ath10k_leds_register(struct ath10k *ar)
381 +{
382 + return 0;
383 +}
384 +
385 +#endif
386 +#endif /* _LEDS_H_ */
387 --- a/ath10k-4.16/mac.c
388 +++ b/ath10k-4.16/mac.c
389 @@ -33,6 +33,7 @@
390 #include "wmi-tlv.h"
391 #include "wmi-ops.h"
392 #include "wow.h"
393 +#include "leds.h"
394
395 /*********/
396 /* Rates */
397 --- a/ath10k-4.16/wmi-ops.h
398 +++ b/ath10k-4.16/wmi-ops.h
399 @@ -199,6 +199,9 @@ struct wmi_ops {
400 (struct ath10k *ar,
401 enum wmi_bss_survey_req_type type);
402 struct sk_buff *(*gen_echo)(struct ath10k *ar, u32 value);
403 + struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num,
404 + u32 input, u32 pull_type, u32 intr_mode);
405 + struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set);
406 };
407
408 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
409 @@ -975,6 +978,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
410 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
411 }
412
413 +static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num,
414 + u32 input, u32 pull_type, u32 intr_mode)
415 +{
416 + struct sk_buff *skb;
417 +
418 + if (!ar->wmi.ops->gen_gpio_config)
419 + return -EOPNOTSUPP;
420 +
421 + skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode);
422 + if (IS_ERR(skb))
423 + return PTR_ERR(skb);
424 +
425 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid);
426 +}
427 +
428 +static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set)
429 +{
430 + struct sk_buff *skb;
431 +
432 + if (!ar->wmi.ops->gen_gpio_config)
433 + return -EOPNOTSUPP;
434 +
435 + skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set);
436 + if (IS_ERR(skb))
437 + return PTR_ERR(skb);
438 +
439 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
440 +}
441 +
442 static inline int
443 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
444 {
445 --- a/ath10k-4.16/wmi-tlv.c
446 +++ b/ath10k-4.16/wmi-tlv.c
447 @@ -3729,6 +3729,8 @@ static const struct wmi_ops wmi_tlv_ops
448 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
449 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
450 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
451 + /* .gen_gpio_config not implemented */
452 + /* .gen_gpio_output not implemented */
453 };
454
455 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
456 --- a/ath10k-4.16/wmi.c
457 +++ b/ath10k-4.16/wmi.c
458 @@ -7325,6 +7325,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
459 return skb;
460 }
461
462 +static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
463 + u32 gpio_num, u32 input,
464 + u32 pull_type, u32 intr_mode)
465 +{
466 + struct wmi_gpio_config_cmd *cmd;
467 + struct sk_buff *skb;
468 +
469 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
470 + if (!skb)
471 + return ERR_PTR(-ENOMEM);
472 +
473 + cmd = (struct wmi_gpio_config_cmd *)skb->data;
474 + cmd->pull_type = __cpu_to_le32(pull_type);
475 + cmd->gpio_num = __cpu_to_le32(gpio_num);
476 + cmd->input = __cpu_to_le32(input);
477 + cmd->intr_mode = __cpu_to_le32(intr_mode);
478 +
479 + 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",
480 + gpio_num, input, pull_type, intr_mode);
481 +
482 + return skb;
483 +}
484 +
485 +static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
486 + u32 gpio_num, u32 set)
487 +{
488 + struct wmi_gpio_output_cmd *cmd;
489 + struct sk_buff *skb;
490 +
491 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
492 + if (!skb)
493 + return ERR_PTR(-ENOMEM);
494 +
495 + cmd = (struct wmi_gpio_output_cmd *)skb->data;
496 + cmd->gpio_num = __cpu_to_le32(gpio_num);
497 + cmd->set = __cpu_to_le32(set);
498 +
499 + ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
500 + gpio_num, set);
501 +
502 + return skb;
503 +}
504 +
505 static struct sk_buff *
506 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
507 enum wmi_sta_ps_mode psmode)
508 @@ -8940,6 +8983,9 @@ static const struct wmi_ops wmi_ops = {
509 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
510 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
511 .gen_echo = ath10k_wmi_op_gen_echo,
512 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
513 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
514 +
515 /* .gen_bcn_tmpl not implemented */
516 /* .gen_prb_tmpl not implemented */
517 /* .gen_p2p_go_bcn_ie not implemented */
518 @@ -9010,6 +9056,8 @@ static const struct wmi_ops wmi_10_1_ops
519 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
520 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
521 .gen_echo = ath10k_wmi_op_gen_echo,
522 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
523 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
524 /* .gen_bcn_tmpl not implemented */
525 /* .gen_prb_tmpl not implemented */
526 /* .gen_p2p_go_bcn_ie not implemented */
527 @@ -9087,6 +9135,8 @@ static const struct wmi_ops wmi_10_2_ops
528 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
529 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
530 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
531 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
532 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
533 /* .gen_pdev_enable_adaptive_cca not implemented */
534 };
535
536 @@ -9157,6 +9207,8 @@ static const struct wmi_ops wmi_10_2_4_o
537 .gen_pdev_enable_adaptive_cca =
538 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
539 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
540 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
541 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
542 /* .gen_bcn_tmpl not implemented */
543 /* .gen_prb_tmpl not implemented */
544 /* .gen_p2p_go_bcn_ie not implemented */
545 @@ -9233,6 +9285,8 @@ static const struct wmi_ops wmi_10_4_ops
546 .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
547 .gen_echo = ath10k_wmi_op_gen_echo,
548 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
549 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
550 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
551 };
552
553 int ath10k_wmi_attach(struct ath10k *ar)
554 --- a/ath10k-4.16/wmi.h
555 +++ b/ath10k-4.16/wmi.h
556 @@ -3000,6 +3000,41 @@ enum wmi_10_4_feature_mask {
557
558 };
559
560 +/* WMI_GPIO_CONFIG_CMDID */
561 +enum {
562 + WMI_GPIO_PULL_NONE,
563 + WMI_GPIO_PULL_UP,
564 + WMI_GPIO_PULL_DOWN,
565 +};
566 +
567 +enum {
568 + WMI_GPIO_INTTYPE_DISABLE,
569 + WMI_GPIO_INTTYPE_RISING_EDGE,
570 + WMI_GPIO_INTTYPE_FALLING_EDGE,
571 + WMI_GPIO_INTTYPE_BOTH_EDGE,
572 + WMI_GPIO_INTTYPE_LEVEL_LOW,
573 + WMI_GPIO_INTTYPE_LEVEL_HIGH
574 +};
575 +
576 +/* WMI_GPIO_CONFIG_CMDID */
577 +struct wmi_gpio_config_cmd {
578 + __le32 gpio_num; /* GPIO number to be setup */
579 + __le32 input; /* 0 - Output/ 1 - Input */
580 + __le32 pull_type; /* Pull type defined above */
581 + __le32 intr_mode; /* Interrupt mode defined above (Input) */
582 +} __packed;
583 +
584 +/* WMI_GPIO_OUTPUT_CMDID */
585 +struct wmi_gpio_output_cmd {
586 + __le32 gpio_num; /* GPIO number to be setup */
587 + __le32 set; /* Set the GPIO pin*/
588 +} __packed;
589 +
590 +/* WMI_GPIO_INPUT_EVENTID */
591 +struct wmi_gpio_input_event {
592 + __le32 gpio_num; /* GPIO number which changed state */
593 +} __packed;
594 +
595 struct wmi_ext_resource_config_10_4_cmd {
596 /* contains enum wmi_host_platform_type */
597 __le32 host_platform_config;
598 --- a/ath10k-4.19/Kconfig
599 +++ b/ath10k-4.19/Kconfig
600 @@ -64,6 +64,16 @@ config ATH10K_DEBUGFS
601
602 If unsure, say Y to make it easier to debug problems.
603
604 +config ATH10K_LEDS
605 + bool "Atheros ath10k LED support"
606 + depends on ATH10K
607 + select MAC80211_LEDS
608 + select LEDS_CLASS
609 + select NEW_LEDS
610 + default y
611 + ---help---
612 + This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N.
613 +
614 config ATH10K_SPECTRAL
615 bool "Atheros ath10k spectral scan support"
616 depends on ATH10K_DEBUGFS
617 --- a/ath10k-4.19/Makefile
618 +++ b/ath10k-4.19/Makefile
619 @@ -19,6 +19,7 @@ ath10k_core-$(CONFIG_ATH10K_SPECTRAL) +=
620 ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o
621 ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o
622 ath10k_core-$(CONFIG_THERMAL) += thermal.o
623 +ath10k_core-$(CONFIG_ATH10K_LEDS) += leds.o
624 ath10k_core-$(CONFIG_MAC80211_DEBUGFS) += debugfs_sta.o
625 ath10k_core-$(CONFIG_PM) += wow.o
626 ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
627 --- a/ath10k-4.19/core.c
628 +++ b/ath10k-4.19/core.c
629 @@ -35,6 +35,7 @@
630 #include "testmode.h"
631 #include "wmi-ops.h"
632 #include "coredump.h"
633 +#include "leds.h"
634
635 /* Disable ath10k-ct DBGLOG output by default */
636 unsigned int ath10k_debug_mask = ATH10K_DBG_NO_DBGLOG;
637 @@ -72,6 +73,7 @@ static const struct ath10k_hw_params ath
638 .id = QCA988X_HW_2_0_VERSION,
639 .dev_id = QCA988X_2_0_DEVICE_ID,
640 .name = "qca988x hw2.0",
641 + .led_pin = 1,
642 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
643 .uart_pin = 7,
644 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
645 @@ -137,6 +139,7 @@ static const struct ath10k_hw_params ath
646 .id = QCA9887_HW_1_0_VERSION,
647 .dev_id = QCA9887_1_0_DEVICE_ID,
648 .name = "qca9887 hw1.0",
649 + .led_pin = 1,
650 .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
651 .uart_pin = 7,
652 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
653 @@ -301,6 +304,7 @@ static const struct ath10k_hw_params ath
654 .id = QCA99X0_HW_2_0_DEV_VERSION,
655 .dev_id = QCA99X0_2_0_DEVICE_ID,
656 .name = "qca99x0 hw2.0",
657 + .led_pin = 17,
658 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
659 .uart_pin = 7,
660 .otp_exe_param = 0x00000700,
661 @@ -339,6 +343,7 @@ static const struct ath10k_hw_params ath
662 .id = QCA9984_HW_1_0_DEV_VERSION,
663 .dev_id = QCA9984_1_0_DEVICE_ID,
664 .name = "qca9984/qca9994 hw1.0",
665 + .led_pin = 17,
666 .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
667 .uart_pin = 7,
668 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
669 @@ -382,6 +387,7 @@ static const struct ath10k_hw_params ath
670 .id = QCA9888_HW_2_0_DEV_VERSION,
671 .dev_id = QCA9888_2_0_DEVICE_ID,
672 .name = "qca9888 hw2.0",
673 + .led_pin = 17,
674 .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
675 .uart_pin = 7,
676 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
677 @@ -3102,6 +3108,10 @@ int ath10k_core_start(struct ath10k *ar,
678 ar->eeprom_overrides.rc_txbf_probe);
679 }
680
681 + status = ath10k_leds_start(ar);
682 + if (status)
683 + goto err_hif_stop;
684 +
685 return 0;
686
687 err_hif_stop:
688 @@ -3356,9 +3366,18 @@ static void ath10k_core_register_work(st
689 goto err_spectral_destroy;
690 }
691
692 + status = ath10k_leds_register(ar);
693 + if (status) {
694 + ath10k_err(ar, "could not register leds: %d\n",
695 + status);
696 + goto err_thermal_unregister;
697 + }
698 +
699 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
700 return;
701
702 +err_thermal_unregister:
703 + ath10k_thermal_unregister(ar);
704 err_spectral_destroy:
705 ath10k_spectral_destroy(ar);
706 err_debug_destroy:
707 @@ -3416,6 +3435,8 @@ void ath10k_core_unregister(struct ath10
708 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
709 return;
710
711 + ath10k_leds_unregister(ar);
712 +
713 ath10k_thermal_unregister(ar);
714 /* Stop spectral before unregistering from mac80211 to remove the
715 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
716 --- a/ath10k-4.19/core.h
717 +++ b/ath10k-4.19/core.h
718 @@ -25,6 +25,7 @@
719 #include <linux/pci.h>
720 #include <linux/uuid.h>
721 #include <linux/time.h>
722 +#include <linux/leds.h>
723
724 #include "htt.h"
725 #include "htc.h"
726 @@ -1106,7 +1107,6 @@ struct ath10k {
727 u32 low_5ghz_chan;
728 u32 high_5ghz_chan;
729 bool ani_enabled;
730 -
731 bool p2p;
732 bool ct_all_pkts_htt; /* CT firmware only: native-wifi for all pkts */
733
734 @@ -1355,6 +1355,13 @@ struct ath10k {
735 } testmode;
736
737 struct {
738 + struct gpio_led wifi_led;
739 + struct led_classdev cdev;
740 + char label[48];
741 + u32 gpio_state_pin;
742 + } leds;
743 +
744 + struct {
745 /* protected by data_lock */
746 u32 fw_crash_counter;
747 u32 fw_warm_reset_counter;
748 --- a/ath10k-4.19/hw.h
749 +++ b/ath10k-4.19/hw.h
750 @@ -508,6 +508,7 @@ struct ath10k_hw_params {
751 const char *name;
752 u32 patch_load_addr;
753 int uart_pin;
754 + int led_pin;
755 u32 otp_exe_param;
756
757 /* Type of hw cycle counter wraparound logic, for more info
758 --- /dev/null
759 +++ b/ath10k-4.19/leds.c
760 @@ -0,0 +1,103 @@
761 +/*
762 + * Copyright (c) 2005-2011 Atheros Communications Inc.
763 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
764 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
765 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
766 + *
767 + * Permission to use, copy, modify, and/or distribute this software for any
768 + * purpose with or without fee is hereby granted, provided that the above
769 + * copyright notice and this permission notice appear in all copies.
770 + *
771 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
772 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
773 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
774 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
775 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
776 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
777 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
778 + */
779 +
780 +#include <linux/leds.h>
781 +
782 +#include "core.h"
783 +#include "wmi.h"
784 +#include "wmi-ops.h"
785 +
786 +#include "leds.h"
787 +
788 +static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
789 + enum led_brightness brightness)
790 +{
791 + struct ath10k *ar = container_of(led_cdev, struct ath10k,
792 + leds.cdev);
793 + struct gpio_led *led = &ar->leds.wifi_led;
794 +
795 + mutex_lock(&ar->conf_mutex);
796 +
797 + if (ar->state != ATH10K_STATE_ON)
798 + goto out;
799 +
800 + ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
801 + ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
802 +
803 +out:
804 + mutex_unlock(&ar->conf_mutex);
805 +
806 + return 0;
807 +}
808 +
809 +int ath10k_leds_start(struct ath10k *ar)
810 +{
811 + if (ar->hw_params.led_pin == 0)
812 + /* leds not supported */
813 + return 0;
814 +
815 + /* under some circumstances, the gpio pin gets reconfigured
816 + * to default state by the firmware, so we need to
817 + * reconfigure it this behaviour has only ben seen on
818 + * QCA9984 and QCA99XX devices so far
819 + */
820 + ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
821 + WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
822 + ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
823 +
824 + return 0;
825 +}
826 +
827 +int ath10k_leds_register(struct ath10k *ar)
828 +{
829 + int ret;
830 +
831 + if (ar->hw_params.led_pin == 0)
832 + /* leds not supported */
833 + return 0;
834 +
835 + snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
836 + wiphy_name(ar->hw->wiphy));
837 + ar->leds.wifi_led.active_low = 1;
838 + ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
839 + ar->leds.wifi_led.name = ar->leds.label;
840 + ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
841 +
842 + ar->leds.cdev.name = ar->leds.label;
843 + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
844 +
845 + /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
846 + ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
847 +
848 + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
849 + if (ret)
850 + return ret;
851 +
852 + return 0;
853 +}
854 +
855 +void ath10k_leds_unregister(struct ath10k *ar)
856 +{
857 + if (ar->hw_params.led_pin == 0)
858 + /* leds not supported */
859 + return;
860 +
861 + led_classdev_unregister(&ar->leds.cdev);
862 +}
863 +
864 --- /dev/null
865 +++ b/ath10k-4.19/leds.h
866 @@ -0,0 +1,41 @@
867 +/*
868 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
869 + *
870 + * Permission to use, copy, modify, and/or distribute this software for any
871 + * purpose with or without fee is hereby granted, provided that the above
872 + * copyright notice and this permission notice appear in all copies.
873 + *
874 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
875 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
876 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
877 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
878 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
879 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
880 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
881 + */
882 +#ifndef _LEDS_H_
883 +#define _LEDS_H_
884 +
885 +#include "core.h"
886 +
887 +#ifdef CONFIG_ATH10K_LEDS
888 +void ath10k_leds_unregister(struct ath10k *ar);
889 +int ath10k_leds_start(struct ath10k *ar);
890 +int ath10k_leds_register(struct ath10k *ar);
891 +#else
892 +static inline void ath10k_leds_unregister(struct ath10k *ar)
893 +{
894 +}
895 +
896 +static inline int ath10k_leds_start(struct ath10k *ar)
897 +{
898 + return 0;
899 +}
900 +
901 +static inline int ath10k_leds_register(struct ath10k *ar)
902 +{
903 + return 0;
904 +}
905 +
906 +#endif
907 +#endif /* _LEDS_H_ */
908 --- a/ath10k-4.19/mac.c
909 +++ b/ath10k-4.19/mac.c
910 @@ -34,6 +34,7 @@
911 #include "wmi-tlv.h"
912 #include "wmi-ops.h"
913 #include "wow.h"
914 +#include "leds.h"
915
916 /*********/
917 /* Rates */
918 --- a/ath10k-4.19/wmi-ops.h
919 +++ b/ath10k-4.19/wmi-ops.h
920 @@ -218,7 +218,10 @@ struct wmi_ops {
921 struct sk_buff *(*gen_echo)(struct ath10k *ar, u32 value);
922 struct sk_buff *(*gen_pdev_get_tpc_table_cmdid)(struct ath10k *ar,
923 u32 param);
924 + struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num,
925 + u32 input, u32 pull_type, u32 intr_mode);
926
927 + struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set);
928 };
929
930 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
931 @@ -1071,6 +1074,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
932 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
933 }
934
935 +static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num,
936 + u32 input, u32 pull_type, u32 intr_mode)
937 +{
938 + struct sk_buff *skb;
939 +
940 + if (!ar->wmi.ops->gen_gpio_config)
941 + return -EOPNOTSUPP;
942 +
943 + skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode);
944 + if (IS_ERR(skb))
945 + return PTR_ERR(skb);
946 +
947 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid);
948 +}
949 +
950 +static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set)
951 +{
952 + struct sk_buff *skb;
953 +
954 + if (!ar->wmi.ops->gen_gpio_config)
955 + return -EOPNOTSUPP;
956 +
957 + skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set);
958 + if (IS_ERR(skb))
959 + return PTR_ERR(skb);
960 +
961 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
962 +}
963 +
964 static inline int
965 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
966 {
967 --- a/ath10k-4.19/wmi-tlv.c
968 +++ b/ath10k-4.19/wmi-tlv.c
969 @@ -3976,6 +3976,8 @@ static const struct wmi_ops wmi_tlv_ops
970 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
971 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
972 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
973 + /* .gen_gpio_config not implemented */
974 + /* .gen_gpio_output not implemented */
975 };
976
977 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
978 --- a/ath10k-4.19/wmi.c
979 +++ b/ath10k-4.19/wmi.c
980 @@ -7844,6 +7844,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
981 return skb;
982 }
983
984 +static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
985 + u32 gpio_num, u32 input,
986 + u32 pull_type, u32 intr_mode)
987 +{
988 + struct wmi_gpio_config_cmd *cmd;
989 + struct sk_buff *skb;
990 +
991 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
992 + if (!skb)
993 + return ERR_PTR(-ENOMEM);
994 +
995 + cmd = (struct wmi_gpio_config_cmd *)skb->data;
996 + cmd->pull_type = __cpu_to_le32(pull_type);
997 + cmd->gpio_num = __cpu_to_le32(gpio_num);
998 + cmd->input = __cpu_to_le32(input);
999 + cmd->intr_mode = __cpu_to_le32(intr_mode);
1000 +
1001 + 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",
1002 + gpio_num, input, pull_type, intr_mode);
1003 +
1004 + return skb;
1005 +}
1006 +
1007 +static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
1008 + u32 gpio_num, u32 set)
1009 +{
1010 + struct wmi_gpio_output_cmd *cmd;
1011 + struct sk_buff *skb;
1012 +
1013 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
1014 + if (!skb)
1015 + return ERR_PTR(-ENOMEM);
1016 +
1017 + cmd = (struct wmi_gpio_output_cmd *)skb->data;
1018 + cmd->gpio_num = __cpu_to_le32(gpio_num);
1019 + cmd->set = __cpu_to_le32(set);
1020 +
1021 + ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
1022 + gpio_num, set);
1023 +
1024 + return skb;
1025 +}
1026 +
1027 static struct sk_buff *
1028 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
1029 enum wmi_sta_ps_mode psmode)
1030 @@ -9568,6 +9611,9 @@ static const struct wmi_ops wmi_ops = {
1031 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
1032 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
1033 .gen_echo = ath10k_wmi_op_gen_echo,
1034 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
1035 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
1036 +
1037 /* .gen_bcn_tmpl not implemented */
1038 /* .gen_prb_tmpl not implemented */
1039 /* .gen_p2p_go_bcn_ie not implemented */
1040 @@ -9638,6 +9684,8 @@ static const struct wmi_ops wmi_10_1_ops
1041 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
1042 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
1043 .gen_echo = ath10k_wmi_op_gen_echo,
1044 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
1045 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
1046 /* .gen_bcn_tmpl not implemented */
1047 /* .gen_prb_tmpl not implemented */
1048 /* .gen_p2p_go_bcn_ie not implemented */
1049 @@ -9715,6 +9763,8 @@ static const struct wmi_ops wmi_10_2_ops
1050 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
1051 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
1052 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
1053 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
1054 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
1055 /* .gen_pdev_enable_adaptive_cca not implemented */
1056 };
1057
1058 @@ -9785,6 +9835,8 @@ static const struct wmi_ops wmi_10_2_4_o
1059 .gen_pdev_enable_adaptive_cca =
1060 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
1061 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
1062 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
1063 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
1064 /* .gen_bcn_tmpl not implemented */
1065 /* .gen_prb_tmpl not implemented */
1066 /* .gen_p2p_go_bcn_ie not implemented */
1067 @@ -9865,6 +9917,8 @@ static const struct wmi_ops wmi_10_4_ops
1068 .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
1069 .gen_echo = ath10k_wmi_op_gen_echo,
1070 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
1071 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
1072 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
1073 };
1074
1075 int ath10k_wmi_attach(struct ath10k *ar)
1076 --- a/ath10k-4.19/wmi.h
1077 +++ b/ath10k-4.19/wmi.h
1078 @@ -3038,6 +3038,41 @@ enum wmi_10_4_feature_mask {
1079
1080 };
1081
1082 +/* WMI_GPIO_CONFIG_CMDID */
1083 +enum {
1084 + WMI_GPIO_PULL_NONE,
1085 + WMI_GPIO_PULL_UP,
1086 + WMI_GPIO_PULL_DOWN,
1087 +};
1088 +
1089 +enum {
1090 + WMI_GPIO_INTTYPE_DISABLE,
1091 + WMI_GPIO_INTTYPE_RISING_EDGE,
1092 + WMI_GPIO_INTTYPE_FALLING_EDGE,
1093 + WMI_GPIO_INTTYPE_BOTH_EDGE,
1094 + WMI_GPIO_INTTYPE_LEVEL_LOW,
1095 + WMI_GPIO_INTTYPE_LEVEL_HIGH
1096 +};
1097 +
1098 +/* WMI_GPIO_CONFIG_CMDID */
1099 +struct wmi_gpio_config_cmd {
1100 + __le32 gpio_num; /* GPIO number to be setup */
1101 + __le32 input; /* 0 - Output/ 1 - Input */
1102 + __le32 pull_type; /* Pull type defined above */
1103 + __le32 intr_mode; /* Interrupt mode defined above (Input) */
1104 +} __packed;
1105 +
1106 +/* WMI_GPIO_OUTPUT_CMDID */
1107 +struct wmi_gpio_output_cmd {
1108 + __le32 gpio_num; /* GPIO number to be setup */
1109 + __le32 set; /* Set the GPIO pin*/
1110 +} __packed;
1111 +
1112 +/* WMI_GPIO_INPUT_EVENTID */
1113 +struct wmi_gpio_input_event {
1114 + __le32 gpio_num; /* GPIO number which changed state */
1115 +} __packed;
1116 +
1117 struct wmi_ext_resource_config_10_4_cmd {
1118 /* contains enum wmi_host_platform_type */
1119 __le32 host_platform_config;