1c1630c05199d92c289eed8f5216805aff5d7b36
[openwrt/staging/pepe2k.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 @@ -71,6 +71,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 @@ -19,6 +19,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 ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
115 --- a/local-symbols
116 +++ b/local-symbols
117 @@ -162,6 +162,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 @@ -26,6 +26,7 @@
128 #include "testmode.h"
129 #include "wmi-ops.h"
130 #include "coredump.h"
131 +#include "leds.h"
132
133 unsigned int ath10k_debug_mask;
134 EXPORT_SYMBOL(ath10k_debug_mask);
135 @@ -65,6 +66,7 @@ static const struct ath10k_hw_params ath
136 .dev_id = QCA988X_2_0_DEVICE_ID,
137 .bus = ATH10K_BUS_PCI,
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 @@ -146,6 +148,7 @@ static const struct ath10k_hw_params ath
144 .dev_id = QCA9887_1_0_DEVICE_ID,
145 .bus = ATH10K_BUS_PCI,
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 @@ -387,6 +390,7 @@ static const struct ath10k_hw_params ath
152 .dev_id = QCA99X0_2_0_DEVICE_ID,
153 .bus = ATH10K_BUS_PCI,
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 @@ -433,6 +437,7 @@ static const struct ath10k_hw_params ath
160 .dev_id = QCA9984_1_0_DEVICE_ID,
161 .bus = ATH10K_BUS_PCI,
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 @@ -486,6 +491,7 @@ static const struct ath10k_hw_params ath
168 .dev_id = QCA9888_2_0_DEVICE_ID,
169 .bus = ATH10K_BUS_PCI,
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 @@ -3231,6 +3237,10 @@ int ath10k_core_start(struct ath10k *ar,
176 goto err_hif_stop;
177 }
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 @@ -3489,9 +3499,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 @@ -3537,6 +3556,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 @@ -14,6 +14,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 @@ -1253,6 +1254,13 @@ struct ath10k {
225 } testmode;
226
227 struct {
228 + struct gpio_led wifi_led;
229 + struct led_classdev cdev;
230 + char label[48];
231 + u32 gpio_state_pin;
232 + } leds;
233 +
234 + struct {
235 /* protected by data_lock */
236 u32 rx_crc_err_drop;
237 u32 fw_crash_counter;
238 --- a/drivers/net/wireless/ath/ath10k/hw.h
239 +++ b/drivers/net/wireless/ath/ath10k/hw.h
240 @@ -519,6 +519,7 @@ struct ath10k_hw_params {
241 const char *name;
242 u32 patch_load_addr;
243 int uart_pin;
244 + int led_pin;
245 u32 otp_exe_param;
246
247 /* Type of hw cycle counter wraparound logic, for more info
248 --- /dev/null
249 +++ b/drivers/net/wireless/ath/ath10k/leds.c
250 @@ -0,0 +1,103 @@
251 +/*
252 + * Copyright (c) 2005-2011 Atheros Communications Inc.
253 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
254 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
255 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
256 + *
257 + * Permission to use, copy, modify, and/or distribute this software for any
258 + * purpose with or without fee is hereby granted, provided that the above
259 + * copyright notice and this permission notice appear in all copies.
260 + *
261 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
262 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
263 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
264 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
265 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
266 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
267 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
268 + */
269 +
270 +#include <linux/leds.h>
271 +
272 +#include "core.h"
273 +#include "wmi.h"
274 +#include "wmi-ops.h"
275 +
276 +#include "leds.h"
277 +
278 +static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
279 + enum led_brightness brightness)
280 +{
281 + struct ath10k *ar = container_of(led_cdev, struct ath10k,
282 + leds.cdev);
283 + struct gpio_led *led = &ar->leds.wifi_led;
284 +
285 + mutex_lock(&ar->conf_mutex);
286 +
287 + if (ar->state != ATH10K_STATE_ON)
288 + goto out;
289 +
290 + ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
291 + ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
292 +
293 +out:
294 + mutex_unlock(&ar->conf_mutex);
295 +
296 + return 0;
297 +}
298 +
299 +int ath10k_leds_start(struct ath10k *ar)
300 +{
301 + if (ar->hw_params.led_pin == 0)
302 + /* leds not supported */
303 + return 0;
304 +
305 + /* under some circumstances, the gpio pin gets reconfigured
306 + * to default state by the firmware, so we need to
307 + * reconfigure it this behaviour has only ben seen on
308 + * QCA9984 and QCA99XX devices so far
309 + */
310 + ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
311 + WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
312 + ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
313 +
314 + return 0;
315 +}
316 +
317 +int ath10k_leds_register(struct ath10k *ar)
318 +{
319 + int ret;
320 +
321 + if (ar->hw_params.led_pin == 0)
322 + /* leds not supported */
323 + return 0;
324 +
325 + snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
326 + wiphy_name(ar->hw->wiphy));
327 + ar->leds.wifi_led.active_low = 1;
328 + ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
329 + ar->leds.wifi_led.name = ar->leds.label;
330 + ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
331 +
332 + ar->leds.cdev.name = ar->leds.label;
333 + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
334 +
335 + /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
336 + ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
337 +
338 + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
339 + if (ret)
340 + return ret;
341 +
342 + return 0;
343 +}
344 +
345 +void ath10k_leds_unregister(struct ath10k *ar)
346 +{
347 + if (ar->hw_params.led_pin == 0)
348 + /* leds not supported */
349 + return;
350 +
351 + led_classdev_unregister(&ar->leds.cdev);
352 +}
353 +
354 --- /dev/null
355 +++ b/drivers/net/wireless/ath/ath10k/leds.h
356 @@ -0,0 +1,41 @@
357 +/*
358 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
359 + *
360 + * Permission to use, copy, modify, and/or distribute this software for any
361 + * purpose with or without fee is hereby granted, provided that the above
362 + * copyright notice and this permission notice appear in all copies.
363 + *
364 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
365 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
366 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
367 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
368 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
369 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
370 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
371 + */
372 +#ifndef _LEDS_H_
373 +#define _LEDS_H_
374 +
375 +#include "core.h"
376 +
377 +#ifdef CPTCFG_ATH10K_LEDS
378 +void ath10k_leds_unregister(struct ath10k *ar);
379 +int ath10k_leds_start(struct ath10k *ar);
380 +int ath10k_leds_register(struct ath10k *ar);
381 +#else
382 +static inline void ath10k_leds_unregister(struct ath10k *ar)
383 +{
384 +}
385 +
386 +static inline int ath10k_leds_start(struct ath10k *ar)
387 +{
388 + return 0;
389 +}
390 +
391 +static inline int ath10k_leds_register(struct ath10k *ar)
392 +{
393 + return 0;
394 +}
395 +
396 +#endif
397 +#endif /* _LEDS_H_ */
398 --- a/drivers/net/wireless/ath/ath10k/mac.c
399 +++ b/drivers/net/wireless/ath/ath10k/mac.c
400 @@ -24,6 +24,7 @@
401 #include "wmi-tlv.h"
402 #include "wmi-ops.h"
403 #include "wow.h"
404 +#include "leds.h"
405
406 /*********/
407 /* Rates */
408 --- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
409 +++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
410 @@ -226,7 +226,10 @@ struct wmi_ops {
411 const struct wmi_bb_timing_cfg_arg *arg);
412 struct sk_buff *(*gen_per_peer_per_tid_cfg)(struct ath10k *ar,
413 const struct wmi_per_peer_per_tid_cfg_arg *arg);
414 + struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num,
415 + u32 input, u32 pull_type, u32 intr_mode);
416
417 + struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set);
418 };
419
420 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
421 @@ -1122,6 +1125,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
422 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
423 }
424
425 +static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num,
426 + u32 input, u32 pull_type, u32 intr_mode)
427 +{
428 + struct sk_buff *skb;
429 +
430 + if (!ar->wmi.ops->gen_gpio_config)
431 + return -EOPNOTSUPP;
432 +
433 + skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode);
434 + if (IS_ERR(skb))
435 + return PTR_ERR(skb);
436 +
437 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid);
438 +}
439 +
440 +static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set)
441 +{
442 + struct sk_buff *skb;
443 +
444 + if (!ar->wmi.ops->gen_gpio_config)
445 + return -EOPNOTSUPP;
446 +
447 + skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set);
448 + if (IS_ERR(skb))
449 + return PTR_ERR(skb);
450 +
451 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
452 +}
453 +
454 static inline int
455 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
456 {
457 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
458 +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
459 @@ -4594,6 +4594,8 @@ static const struct wmi_ops wmi_tlv_ops
460 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
461 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
462 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
463 + /* .gen_gpio_config not implemented */
464 + /* .gen_gpio_output not implemented */
465 };
466
467 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
468 --- a/drivers/net/wireless/ath/ath10k/wmi.c
469 +++ b/drivers/net/wireless/ath/ath10k/wmi.c
470 @@ -7472,6 +7472,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
471 return skb;
472 }
473
474 +static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
475 + u32 gpio_num, u32 input,
476 + u32 pull_type, u32 intr_mode)
477 +{
478 + struct wmi_gpio_config_cmd *cmd;
479 + struct sk_buff *skb;
480 +
481 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
482 + if (!skb)
483 + return ERR_PTR(-ENOMEM);
484 +
485 + cmd = (struct wmi_gpio_config_cmd *)skb->data;
486 + cmd->pull_type = __cpu_to_le32(pull_type);
487 + cmd->gpio_num = __cpu_to_le32(gpio_num);
488 + cmd->input = __cpu_to_le32(input);
489 + cmd->intr_mode = __cpu_to_le32(intr_mode);
490 +
491 + 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",
492 + gpio_num, input, pull_type, intr_mode);
493 +
494 + return skb;
495 +}
496 +
497 +static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
498 + u32 gpio_num, u32 set)
499 +{
500 + struct wmi_gpio_output_cmd *cmd;
501 + struct sk_buff *skb;
502 +
503 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
504 + if (!skb)
505 + return ERR_PTR(-ENOMEM);
506 +
507 + cmd = (struct wmi_gpio_output_cmd *)skb->data;
508 + cmd->gpio_num = __cpu_to_le32(gpio_num);
509 + cmd->set = __cpu_to_le32(set);
510 +
511 + ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
512 + gpio_num, set);
513 +
514 + return skb;
515 +}
516 +
517 static struct sk_buff *
518 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
519 enum wmi_sta_ps_mode psmode)
520 @@ -9160,6 +9203,9 @@ static const struct wmi_ops wmi_ops = {
521 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
522 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
523 .gen_echo = ath10k_wmi_op_gen_echo,
524 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
525 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
526 +
527 /* .gen_bcn_tmpl not implemented */
528 /* .gen_prb_tmpl not implemented */
529 /* .gen_p2p_go_bcn_ie not implemented */
530 @@ -9230,6 +9276,8 @@ static const struct wmi_ops wmi_10_1_ops
531 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
532 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
533 .gen_echo = ath10k_wmi_op_gen_echo,
534 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
535 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
536 /* .gen_bcn_tmpl not implemented */
537 /* .gen_prb_tmpl not implemented */
538 /* .gen_p2p_go_bcn_ie not implemented */
539 @@ -9302,6 +9350,8 @@ static const struct wmi_ops wmi_10_2_ops
540 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
541 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
542 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
543 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
544 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
545 /* .gen_pdev_enable_adaptive_cca not implemented */
546 };
547
548 @@ -9373,6 +9423,8 @@ static const struct wmi_ops wmi_10_2_4_o
549 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
550 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
551 .gen_bb_timing = ath10k_wmi_10_2_4_op_gen_bb_timing,
552 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
553 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
554 /* .gen_bcn_tmpl not implemented */
555 /* .gen_prb_tmpl not implemented */
556 /* .gen_p2p_go_bcn_ie not implemented */
557 @@ -9454,6 +9506,8 @@ static const struct wmi_ops wmi_10_4_ops
558 .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
559 .gen_echo = ath10k_wmi_op_gen_echo,
560 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
561 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
562 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
563 };
564
565 int ath10k_wmi_attach(struct ath10k *ar)
566 --- a/drivers/net/wireless/ath/ath10k/wmi.h
567 +++ b/drivers/net/wireless/ath/ath10k/wmi.h
568 @@ -3030,6 +3030,41 @@ enum wmi_10_4_feature_mask {
569
570 };
571
572 +/* WMI_GPIO_CONFIG_CMDID */
573 +enum {
574 + WMI_GPIO_PULL_NONE,
575 + WMI_GPIO_PULL_UP,
576 + WMI_GPIO_PULL_DOWN,
577 +};
578 +
579 +enum {
580 + WMI_GPIO_INTTYPE_DISABLE,
581 + WMI_GPIO_INTTYPE_RISING_EDGE,
582 + WMI_GPIO_INTTYPE_FALLING_EDGE,
583 + WMI_GPIO_INTTYPE_BOTH_EDGE,
584 + WMI_GPIO_INTTYPE_LEVEL_LOW,
585 + WMI_GPIO_INTTYPE_LEVEL_HIGH
586 +};
587 +
588 +/* WMI_GPIO_CONFIG_CMDID */
589 +struct wmi_gpio_config_cmd {
590 + __le32 gpio_num; /* GPIO number to be setup */
591 + __le32 input; /* 0 - Output/ 1 - Input */
592 + __le32 pull_type; /* Pull type defined above */
593 + __le32 intr_mode; /* Interrupt mode defined above (Input) */
594 +} __packed;
595 +
596 +/* WMI_GPIO_OUTPUT_CMDID */
597 +struct wmi_gpio_output_cmd {
598 + __le32 gpio_num; /* GPIO number to be setup */
599 + __le32 set; /* Set the GPIO pin*/
600 +} __packed;
601 +
602 +/* WMI_GPIO_INPUT_EVENTID */
603 +struct wmi_gpio_input_event {
604 + __le32 gpio_num; /* GPIO number which changed state */
605 +} __packed;
606 +
607 struct wmi_ext_resource_config_10_4_cmd {
608 /* contains enum wmi_host_platform_type */
609 __le32 host_platform_config;