e59d45d50807254afe23dbc7d3bc882af13e49a5
[openwrt/staging/ansuel.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 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Kconfig
87 ===================================================================
88 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/Kconfig
89 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Kconfig
90 @@ -69,6 +69,16 @@ config ATH10K_DEBUGFS
91
92 If unsure, say Y to make it easier to debug problems.
93
94 +config ATH10K_LEDS
95 + bool "Atheros ath10k LED support"
96 + depends on ATH10K
97 + select MAC80211_LEDS
98 + select LEDS_CLASS
99 + select NEW_LEDS
100 + default y
101 + ---help---
102 + This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N.
103 +
104 config ATH10K_SPECTRAL
105 bool "Atheros ath10k spectral scan support"
106 depends on ATH10K_DEBUGFS
107 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Makefile
108 ===================================================================
109 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/Makefile
110 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/Makefile
111 @@ -19,6 +19,7 @@ ath10k_core-$(CPTCFG_ATH10K_SPECTRAL) +=
112 ath10k_core-$(CPTCFG_NL80211_TESTMODE) += testmode.o
113 ath10k_core-$(CPTCFG_ATH10K_TRACING) += trace.o
114 ath10k_core-$(CPTCFG_ATH10K_THERMAL) += thermal.o
115 +ath10k_core-$(CPTCFG_ATH10K_LEDS) += leds.o
116 ath10k_core-$(CPTCFG_MAC80211_DEBUGFS) += debugfs_sta.o
117 ath10k_core-$(CONFIG_PM) += wow.o
118 ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
119 Index: backports-v4.18-rc7/local-symbols
120 ===================================================================
121 --- backports-v4.18-rc7.orig/local-symbols
122 +++ backports-v4.18-rc7/local-symbols
123 @@ -147,6 +147,7 @@ ATH10K_DEBUG=
124 ATH10K_DEBUGFS=
125 ATH10K_SPECTRAL=
126 ATH10K_THERMAL=
127 +ATH10K_LEDS=
128 ATH10K_TRACING=
129 ATH10K_DFS_CERTIFIED=
130 WCN36XX=
131 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.c
132 ===================================================================
133 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/core.c
134 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.c
135 @@ -34,6 +34,7 @@
136 #include "testmode.h"
137 #include "wmi-ops.h"
138 #include "coredump.h"
139 +#include "leds.h"
140
141 unsigned int ath10k_debug_mask;
142 static unsigned int ath10k_cryptmode_param;
143 @@ -66,6 +67,7 @@ static const struct ath10k_hw_params ath
144 .id = QCA988X_HW_2_0_VERSION,
145 .dev_id = QCA988X_2_0_DEVICE_ID,
146 .name = "qca988x hw2.0",
147 + .led_pin = 1,
148 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
149 .uart_pin = 7,
150 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
151 @@ -129,6 +131,7 @@ static const struct ath10k_hw_params ath
152 .id = QCA9887_HW_1_0_VERSION,
153 .dev_id = QCA9887_1_0_DEVICE_ID,
154 .name = "qca9887 hw1.0",
155 + .led_pin = 1,
156 .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
157 .uart_pin = 7,
158 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
159 @@ -288,6 +291,7 @@ static const struct ath10k_hw_params ath
160 .id = QCA99X0_HW_2_0_DEV_VERSION,
161 .dev_id = QCA99X0_2_0_DEVICE_ID,
162 .name = "qca99x0 hw2.0",
163 + .led_pin = 17,
164 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
165 .uart_pin = 7,
166 .otp_exe_param = 0x00000700,
167 @@ -325,6 +329,7 @@ static const struct ath10k_hw_params ath
168 .id = QCA9984_HW_1_0_DEV_VERSION,
169 .dev_id = QCA9984_1_0_DEVICE_ID,
170 .name = "qca9984/qca9994 hw1.0",
171 + .led_pin = 17,
172 .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
173 .uart_pin = 7,
174 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
175 @@ -367,6 +372,7 @@ static const struct ath10k_hw_params ath
176 .id = QCA9888_HW_2_0_DEV_VERSION,
177 .dev_id = QCA9888_2_0_DEVICE_ID,
178 .name = "qca9888 hw2.0",
179 + .led_pin = 17,
180 .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
181 .uart_pin = 7,
182 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
183 @@ -2428,6 +2434,10 @@ int ath10k_core_start(struct ath10k *ar,
184 if (status)
185 goto err_hif_stop;
186
187 + status = ath10k_leds_start(ar);
188 + if (status)
189 + goto err_hif_stop;
190 +
191 return 0;
192
193 err_hif_stop:
194 @@ -2682,9 +2692,18 @@ static void ath10k_core_register_work(st
195 goto err_spectral_destroy;
196 }
197
198 + status = ath10k_leds_register(ar);
199 + if (status) {
200 + ath10k_err(ar, "could not register leds: %d\n",
201 + status);
202 + goto err_thermal_unregister;
203 + }
204 +
205 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
206 return;
207
208 +err_thermal_unregister:
209 + ath10k_thermal_unregister(ar);
210 err_spectral_destroy:
211 ath10k_spectral_destroy(ar);
212 err_debug_destroy:
213 @@ -2728,6 +2747,8 @@ void ath10k_core_unregister(struct ath10
214 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
215 return;
216
217 + ath10k_leds_unregister(ar);
218 +
219 ath10k_thermal_unregister(ar);
220 /* Stop spectral before unregistering from mac80211 to remove the
221 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
222 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.h
223 ===================================================================
224 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/core.h
225 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/core.h
226 @@ -25,6 +25,7 @@
227 #include <linux/pci.h>
228 #include <linux/uuid.h>
229 #include <linux/time.h>
230 +#include <linux/leds.h>
231
232 #include "htt.h"
233 #include "htc.h"
234 @@ -902,7 +903,6 @@ struct ath10k {
235 u32 low_5ghz_chan;
236 u32 high_5ghz_chan;
237 bool ani_enabled;
238 -
239 bool p2p;
240
241 struct {
242 @@ -1093,6 +1093,13 @@ struct ath10k {
243 } testmode;
244
245 struct {
246 + struct gpio_led wifi_led;
247 + struct led_classdev cdev;
248 + char label[48];
249 + u32 gpio_state_pin;
250 + } leds;
251 +
252 + struct {
253 /* protected by data_lock */
254 u32 fw_crash_counter;
255 u32 fw_warm_reset_counter;
256 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/hw.h
257 ===================================================================
258 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/hw.h
259 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/hw.h
260 @@ -504,6 +504,7 @@ struct ath10k_hw_params {
261 const char *name;
262 u32 patch_load_addr;
263 int uart_pin;
264 + int led_pin;
265 u32 otp_exe_param;
266
267 /* Type of hw cycle counter wraparound logic, for more info
268 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.c
269 ===================================================================
270 --- /dev/null
271 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.c
272 @@ -0,0 +1,103 @@
273 +/*
274 + * Copyright (c) 2005-2011 Atheros Communications Inc.
275 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
276 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
277 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
278 + *
279 + * Permission to use, copy, modify, and/or distribute this software for any
280 + * purpose with or without fee is hereby granted, provided that the above
281 + * copyright notice and this permission notice appear in all copies.
282 + *
283 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
284 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
285 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
286 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
287 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
288 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
289 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
290 + */
291 +
292 +#include <linux/leds.h>
293 +
294 +#include "core.h"
295 +#include "wmi.h"
296 +#include "wmi-ops.h"
297 +
298 +#include "leds.h"
299 +
300 +static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
301 + enum led_brightness brightness)
302 +{
303 + struct ath10k *ar = container_of(led_cdev, struct ath10k,
304 + leds.cdev);
305 + struct gpio_led *led = &ar->leds.wifi_led;
306 +
307 + mutex_lock(&ar->conf_mutex);
308 +
309 + if (ar->state != ATH10K_STATE_ON)
310 + goto out;
311 +
312 + ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
313 + ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
314 +
315 +out:
316 + mutex_unlock(&ar->conf_mutex);
317 +
318 + return 0;
319 +}
320 +
321 +int ath10k_leds_start(struct ath10k *ar)
322 +{
323 + if (ar->hw_params.led_pin == 0)
324 + /* leds not supported */
325 + return 0;
326 +
327 + /* under some circumstances, the gpio pin gets reconfigured
328 + * to default state by the firmware, so we need to
329 + * reconfigure it this behaviour has only ben seen on
330 + * QCA9984 and QCA99XX devices so far
331 + */
332 + ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
333 + WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
334 + ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
335 +
336 + return 0;
337 +}
338 +
339 +int ath10k_leds_register(struct ath10k *ar)
340 +{
341 + int ret;
342 +
343 + if (ar->hw_params.led_pin == 0)
344 + /* leds not supported */
345 + return 0;
346 +
347 + snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
348 + wiphy_name(ar->hw->wiphy));
349 + ar->leds.wifi_led.active_low = 1;
350 + ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
351 + ar->leds.wifi_led.name = ar->leds.label;
352 + ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
353 +
354 + ar->leds.cdev.name = ar->leds.label;
355 + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
356 +
357 + /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
358 + ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
359 +
360 + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
361 + if (ret)
362 + return ret;
363 +
364 + return 0;
365 +}
366 +
367 +void ath10k_leds_unregister(struct ath10k *ar)
368 +{
369 + if (ar->hw_params.led_pin == 0)
370 + /* leds not supported */
371 + return;
372 +
373 + led_classdev_unregister(&ar->leds.cdev);
374 +}
375 +
376 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.h
377 ===================================================================
378 --- /dev/null
379 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/leds.h
380 @@ -0,0 +1,41 @@
381 +/*
382 + * Copyright (c) 2018, The Linux Foundation. All rights reserved.
383 + *
384 + * Permission to use, copy, modify, and/or distribute this software for any
385 + * purpose with or without fee is hereby granted, provided that the above
386 + * copyright notice and this permission notice appear in all copies.
387 + *
388 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
389 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
390 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
391 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
392 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
393 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
394 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
395 + */
396 +#ifndef _LEDS_H_
397 +#define _LEDS_H_
398 +
399 +#include "core.h"
400 +
401 +#ifdef CPTCFG_ATH10K_LEDS
402 +void ath10k_leds_unregister(struct ath10k *ar);
403 +int ath10k_leds_start(struct ath10k *ar);
404 +int ath10k_leds_register(struct ath10k *ar);
405 +#else
406 +static inline void ath10k_leds_unregister(struct ath10k *ar)
407 +{
408 +}
409 +
410 +static inline int ath10k_leds_start(struct ath10k *ar)
411 +{
412 + return 0;
413 +}
414 +
415 +static inline int ath10k_leds_register(struct ath10k *ar)
416 +{
417 + return 0;
418 +}
419 +
420 +#endif
421 +#endif /* _LEDS_H_ */
422 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/mac.c
423 ===================================================================
424 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/mac.c
425 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/mac.c
426 @@ -33,6 +33,7 @@
427 #include "wmi-tlv.h"
428 #include "wmi-ops.h"
429 #include "wow.h"
430 +#include "leds.h"
431
432 /*********/
433 /* Rates */
434 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-ops.h
435 ===================================================================
436 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi-ops.h
437 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-ops.h
438 @@ -214,7 +214,10 @@ struct wmi_ops {
439 struct sk_buff *(*gen_echo)(struct ath10k *ar, u32 value);
440 struct sk_buff *(*gen_pdev_get_tpc_table_cmdid)(struct ath10k *ar,
441 u32 param);
442 + struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num,
443 + u32 input, u32 pull_type, u32 intr_mode);
444
445 + struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set);
446 };
447
448 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
449 @@ -1042,6 +1045,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
450 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
451 }
452
453 +static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num,
454 + u32 input, u32 pull_type, u32 intr_mode)
455 +{
456 + struct sk_buff *skb;
457 +
458 + if (!ar->wmi.ops->gen_gpio_config)
459 + return -EOPNOTSUPP;
460 +
461 + skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode);
462 + if (IS_ERR(skb))
463 + return PTR_ERR(skb);
464 +
465 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid);
466 +}
467 +
468 +static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set)
469 +{
470 + struct sk_buff *skb;
471 +
472 + if (!ar->wmi.ops->gen_gpio_config)
473 + return -EOPNOTSUPP;
474 +
475 + skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set);
476 + if (IS_ERR(skb))
477 + return PTR_ERR(skb);
478 +
479 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
480 +}
481 +
482 static inline int
483 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
484 {
485 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-tlv.c
486 ===================================================================
487 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi-tlv.c
488 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi-tlv.c
489 @@ -3909,6 +3909,8 @@ static const struct wmi_ops wmi_tlv_ops
490 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
491 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
492 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
493 + /* .gen_gpio_config not implemented */
494 + /* .gen_gpio_output not implemented */
495 };
496
497 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
498 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.c
499 ===================================================================
500 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi.c
501 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.c
502 @@ -7115,6 +7115,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
503 return skb;
504 }
505
506 +static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
507 + u32 gpio_num, u32 input,
508 + u32 pull_type, u32 intr_mode)
509 +{
510 + struct wmi_gpio_config_cmd *cmd;
511 + struct sk_buff *skb;
512 +
513 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
514 + if (!skb)
515 + return ERR_PTR(-ENOMEM);
516 +
517 + cmd = (struct wmi_gpio_config_cmd *)skb->data;
518 + cmd->pull_type = __cpu_to_le32(pull_type);
519 + cmd->gpio_num = __cpu_to_le32(gpio_num);
520 + cmd->input = __cpu_to_le32(input);
521 + cmd->intr_mode = __cpu_to_le32(intr_mode);
522 +
523 + 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",
524 + gpio_num, input, pull_type, intr_mode);
525 +
526 + return skb;
527 +}
528 +
529 +static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
530 + u32 gpio_num, u32 set)
531 +{
532 + struct wmi_gpio_output_cmd *cmd;
533 + struct sk_buff *skb;
534 +
535 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
536 + if (!skb)
537 + return ERR_PTR(-ENOMEM);
538 +
539 + cmd = (struct wmi_gpio_output_cmd *)skb->data;
540 + cmd->gpio_num = __cpu_to_le32(gpio_num);
541 + cmd->set = __cpu_to_le32(set);
542 +
543 + ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
544 + gpio_num, set);
545 +
546 + return skb;
547 +}
548 +
549 static struct sk_buff *
550 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
551 enum wmi_sta_ps_mode psmode)
552 @@ -8726,6 +8769,9 @@ static const struct wmi_ops wmi_ops = {
553 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
554 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
555 .gen_echo = ath10k_wmi_op_gen_echo,
556 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
557 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
558 +
559 /* .gen_bcn_tmpl not implemented */
560 /* .gen_prb_tmpl not implemented */
561 /* .gen_p2p_go_bcn_ie not implemented */
562 @@ -8796,6 +8842,8 @@ static const struct wmi_ops wmi_10_1_ops
563 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
564 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
565 .gen_echo = ath10k_wmi_op_gen_echo,
566 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
567 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
568 /* .gen_bcn_tmpl not implemented */
569 /* .gen_prb_tmpl not implemented */
570 /* .gen_p2p_go_bcn_ie not implemented */
571 @@ -8867,6 +8915,8 @@ static const struct wmi_ops wmi_10_2_ops
572 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
573 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
574 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
575 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
576 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
577 /* .gen_pdev_enable_adaptive_cca not implemented */
578 };
579
580 @@ -8937,6 +8987,8 @@ static const struct wmi_ops wmi_10_2_4_o
581 .gen_pdev_enable_adaptive_cca =
582 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
583 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
584 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
585 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
586 /* .gen_bcn_tmpl not implemented */
587 /* .gen_prb_tmpl not implemented */
588 /* .gen_p2p_go_bcn_ie not implemented */
589 @@ -9016,6 +9068,8 @@ static const struct wmi_ops wmi_10_4_ops
590 .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
591 .gen_echo = ath10k_wmi_op_gen_echo,
592 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
593 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
594 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
595 };
596
597 int ath10k_wmi_attach(struct ath10k *ar)
598 Index: backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.h
599 ===================================================================
600 --- backports-v4.18-rc7.orig/drivers/net/wireless/ath/ath10k/wmi.h
601 +++ backports-v4.18-rc7/drivers/net/wireless/ath/ath10k/wmi.h
602 @@ -2941,6 +2941,41 @@ enum wmi_10_4_feature_mask {
603
604 };
605
606 +/* WMI_GPIO_CONFIG_CMDID */
607 +enum {
608 + WMI_GPIO_PULL_NONE,
609 + WMI_GPIO_PULL_UP,
610 + WMI_GPIO_PULL_DOWN,
611 +};
612 +
613 +enum {
614 + WMI_GPIO_INTTYPE_DISABLE,
615 + WMI_GPIO_INTTYPE_RISING_EDGE,
616 + WMI_GPIO_INTTYPE_FALLING_EDGE,
617 + WMI_GPIO_INTTYPE_BOTH_EDGE,
618 + WMI_GPIO_INTTYPE_LEVEL_LOW,
619 + WMI_GPIO_INTTYPE_LEVEL_HIGH
620 +};
621 +
622 +/* WMI_GPIO_CONFIG_CMDID */
623 +struct wmi_gpio_config_cmd {
624 + __le32 gpio_num; /* GPIO number to be setup */
625 + __le32 input; /* 0 - Output/ 1 - Input */
626 + __le32 pull_type; /* Pull type defined above */
627 + __le32 intr_mode; /* Interrupt mode defined above (Input) */
628 +} __packed;
629 +
630 +/* WMI_GPIO_OUTPUT_CMDID */
631 +struct wmi_gpio_output_cmd {
632 + __le32 gpio_num; /* GPIO number to be setup */
633 + __le32 set; /* Set the GPIO pin*/
634 +} __packed;
635 +
636 +/* WMI_GPIO_INPUT_EVENTID */
637 +struct wmi_gpio_input_event {
638 + __le32 gpio_num; /* GPIO number which changed state */
639 +} __packed;
640 +
641 struct wmi_ext_resource_config_10_4_cmd {
642 /* contains enum wmi_host_platform_type */
643 __le32 host_platform_config;