a9eb38e57642dc3029170695bf97f8155ff93af0
[openwrt/staging/ldir.git] /
1 From 8e1debd82466a3fe711784ab37e6b54e56011267 Mon Sep 17 00:00:00 2001
2 From: Sebastian Gottschall <s.gottschall@dd-wrt.com>
3 Date: Mon, 13 May 2024 17:22:25 +0300
4 Subject: [PATCH] wifi: ath10k: add LED and GPIO controlling support for
5 various chipsets
6
7 Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984
8 based chipsets with on chipset connected led's using WMI Firmware API.
9 The LED device will get available named as "ath10k-phyX" at sysfs and
10 can be controlled with various triggers.
11 Adds also debugfs interface for gpio control.
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 [ansuel: rebase and small cleanup]
18 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
19 Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
20 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
21 Link: https://msgid.link/20230611080505.17393-1-ansuelsmth@gmail.com
22 ---
23 drivers/net/wireless/ath/ath10k/Kconfig | 6 ++
24 drivers/net/wireless/ath/ath10k/Makefile | 1 +
25 drivers/net/wireless/ath/ath10k/core.c | 32 ++++++++
26 drivers/net/wireless/ath/ath10k/core.h | 8 ++
27 drivers/net/wireless/ath/ath10k/hw.h | 1 +
28 drivers/net/wireless/ath/ath10k/leds.c | 90 +++++++++++++++++++++++
29 drivers/net/wireless/ath/ath10k/leds.h | 34 +++++++++
30 drivers/net/wireless/ath/ath10k/mac.c | 1 +
31 drivers/net/wireless/ath/ath10k/wmi-ops.h | 32 ++++++++
32 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +
33 drivers/net/wireless/ath/ath10k/wmi.c | 54 ++++++++++++++
34 drivers/net/wireless/ath/ath10k/wmi.h | 35 +++++++++
35 12 files changed, 296 insertions(+)
36 create mode 100644 drivers/net/wireless/ath/ath10k/leds.c
37 create mode 100644 drivers/net/wireless/ath/ath10k/leds.h
38
39 --- a/drivers/net/wireless/ath/ath10k/Kconfig
40 +++ b/drivers/net/wireless/ath/ath10k/Kconfig
41 @@ -73,6 +73,12 @@ config ATH10K_DEBUGFS
42
43 If unsure, say Y to make it easier to debug problems.
44
45 +config ATH10K_LEDS
46 + bool
47 + depends on ATH10K
48 + depends on LEDS_CLASS=y || LEDS_CLASS=MAC80211
49 + default y
50 +
51 config ATH10K_SPECTRAL
52 bool "Atheros ath10k spectral scan support"
53 depends on ATH10K_DEBUGFS
54 --- a/drivers/net/wireless/ath/ath10k/Makefile
55 +++ b/drivers/net/wireless/ath/ath10k/Makefile
56 @@ -19,6 +19,7 @@ ath10k_core-$(CPTCFG_ATH10K_SPECTRAL) +=
57 ath10k_core-$(CPTCFG_NL80211_TESTMODE) += testmode.o
58 ath10k_core-$(CPTCFG_ATH10K_TRACING) += trace.o
59 ath10k_core-$(CPTCFG_ATH10K_THERMAL) += thermal.o
60 +ath10k_core-$(CPTCFG_ATH10K_LEDS) += leds.o
61 ath10k_core-$(CPTCFG_MAC80211_DEBUGFS) += debugfs_sta.o
62 ath10k_core-$(CONFIG_PM) += wow.o
63 ath10k_core-$(CONFIG_DEV_COREDUMP) += coredump.o
64 --- a/local-symbols
65 +++ b/local-symbols
66 @@ -154,6 +154,7 @@ ATH10K_DEBUG=
67 ATH10K_DEBUGFS=
68 ATH10K_SPECTRAL=
69 ATH10K_THERMAL=
70 +ATH10K_LEDS=
71 ATH10K_TRACING=
72 ATH10K_DFS_CERTIFIED=
73 WCN36XX=
74 --- a/drivers/net/wireless/ath/ath10k/core.c
75 +++ b/drivers/net/wireless/ath/ath10k/core.c
76 @@ -27,6 +27,7 @@
77 #include "testmode.h"
78 #include "wmi-ops.h"
79 #include "coredump.h"
80 +#include "leds.h"
81
82 unsigned int ath10k_debug_mask;
83 EXPORT_SYMBOL(ath10k_debug_mask);
84 @@ -68,6 +69,7 @@ static const struct ath10k_hw_params ath
85 .name = "qca988x hw2.0",
86 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
87 .uart_pin = 7,
88 + .led_pin = 1,
89 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
90 .otp_exe_param = 0,
91 .channel_counters_freq_hz = 88000,
92 @@ -109,6 +111,7 @@ static const struct ath10k_hw_params ath
93 .name = "qca988x hw2.0 ubiquiti",
94 .patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
95 .uart_pin = 7,
96 + .led_pin = 0,
97 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
98 .otp_exe_param = 0,
99 .channel_counters_freq_hz = 88000,
100 @@ -151,6 +154,7 @@ static const struct ath10k_hw_params ath
101 .name = "qca9887 hw1.0",
102 .patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
103 .uart_pin = 7,
104 + .led_pin = 1,
105 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
106 .otp_exe_param = 0,
107 .channel_counters_freq_hz = 88000,
108 @@ -193,6 +197,7 @@ static const struct ath10k_hw_params ath
109 .name = "qca6174 hw3.2 sdio",
110 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
111 .uart_pin = 19,
112 + .led_pin = 0,
113 .otp_exe_param = 0,
114 .channel_counters_freq_hz = 88000,
115 .max_probe_resp_desc_thres = 0,
116 @@ -230,6 +235,7 @@ static const struct ath10k_hw_params ath
117 .name = "qca6164 hw2.1",
118 .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
119 .uart_pin = 6,
120 + .led_pin = 0,
121 .otp_exe_param = 0,
122 .channel_counters_freq_hz = 88000,
123 .max_probe_resp_desc_thres = 0,
124 @@ -271,6 +277,7 @@ static const struct ath10k_hw_params ath
125 .name = "qca6174 hw2.1",
126 .patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
127 .uart_pin = 6,
128 + .led_pin = 0,
129 .otp_exe_param = 0,
130 .channel_counters_freq_hz = 88000,
131 .max_probe_resp_desc_thres = 0,
132 @@ -312,6 +319,7 @@ static const struct ath10k_hw_params ath
133 .name = "qca6174 hw3.0",
134 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
135 .uart_pin = 6,
136 + .led_pin = 0,
137 .otp_exe_param = 0,
138 .channel_counters_freq_hz = 88000,
139 .max_probe_resp_desc_thres = 0,
140 @@ -353,6 +361,7 @@ static const struct ath10k_hw_params ath
141 .name = "qca6174 hw3.2",
142 .patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
143 .uart_pin = 6,
144 + .led_pin = 0,
145 .otp_exe_param = 0,
146 .channel_counters_freq_hz = 88000,
147 .max_probe_resp_desc_thres = 0,
148 @@ -398,6 +407,7 @@ static const struct ath10k_hw_params ath
149 .name = "qca99x0 hw2.0",
150 .patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
151 .uart_pin = 7,
152 + .led_pin = 17,
153 .otp_exe_param = 0x00000700,
154 .continuous_frag_desc = true,
155 .cck_rate_map_rev2 = true,
156 @@ -445,6 +455,7 @@ static const struct ath10k_hw_params ath
157 .name = "qca9984/qca9994 hw1.0",
158 .patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
159 .uart_pin = 7,
160 + .led_pin = 17,
161 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
162 .otp_exe_param = 0x00000700,
163 .continuous_frag_desc = true,
164 @@ -499,6 +510,7 @@ static const struct ath10k_hw_params ath
165 .name = "qca9888 hw2.0",
166 .patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
167 .uart_pin = 7,
168 + .led_pin = 17,
169 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
170 .otp_exe_param = 0x00000700,
171 .continuous_frag_desc = true,
172 @@ -550,6 +562,7 @@ static const struct ath10k_hw_params ath
173 .name = "qca9377 hw1.0",
174 .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
175 .uart_pin = 6,
176 + .led_pin = 0,
177 .otp_exe_param = 0,
178 .channel_counters_freq_hz = 88000,
179 .max_probe_resp_desc_thres = 0,
180 @@ -591,6 +604,7 @@ static const struct ath10k_hw_params ath
181 .name = "qca9377 hw1.1",
182 .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
183 .uart_pin = 6,
184 + .led_pin = 0,
185 .otp_exe_param = 0,
186 .channel_counters_freq_hz = 88000,
187 .max_probe_resp_desc_thres = 0,
188 @@ -634,6 +648,7 @@ static const struct ath10k_hw_params ath
189 .name = "qca9377 hw1.1 sdio",
190 .patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
191 .uart_pin = 19,
192 + .led_pin = 0,
193 .otp_exe_param = 0,
194 .channel_counters_freq_hz = 88000,
195 .max_probe_resp_desc_thres = 0,
196 @@ -668,6 +683,7 @@ static const struct ath10k_hw_params ath
197 .name = "qca4019 hw1.0",
198 .patch_load_addr = QCA4019_HW_1_0_PATCH_LOAD_ADDR,
199 .uart_pin = 7,
200 + .led_pin = 0,
201 .cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
202 .otp_exe_param = 0x0010000,
203 .continuous_frag_desc = true,
204 @@ -714,6 +730,7 @@ static const struct ath10k_hw_params ath
205 .dev_id = 0,
206 .bus = ATH10K_BUS_SNOC,
207 .name = "wcn3990 hw1.0",
208 + .led_pin = 0,
209 .continuous_frag_desc = true,
210 .tx_chain_mask = 0x7,
211 .rx_chain_mask = 0x7,
212 @@ -3242,6 +3259,10 @@ int ath10k_core_start(struct ath10k *ar,
213 goto err_hif_stop;
214 }
215
216 + status = ath10k_leds_start(ar);
217 + if (status)
218 + goto err_hif_stop;
219 +
220 return 0;
221
222 err_hif_stop:
223 @@ -3500,9 +3521,18 @@ static void ath10k_core_register_work(st
224 goto err_spectral_destroy;
225 }
226
227 + status = ath10k_leds_register(ar);
228 + if (status) {
229 + ath10k_err(ar, "could not register leds: %d\n",
230 + status);
231 + goto err_thermal_unregister;
232 + }
233 +
234 set_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags);
235 return;
236
237 +err_thermal_unregister:
238 + ath10k_thermal_unregister(ar);
239 err_spectral_destroy:
240 ath10k_spectral_destroy(ar);
241 err_debug_destroy:
242 @@ -3548,6 +3578,8 @@ void ath10k_core_unregister(struct ath10
243 if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
244 return;
245
246 + ath10k_leds_unregister(ar);
247 +
248 ath10k_thermal_unregister(ar);
249 /* Stop spectral before unregistering from mac80211 to remove the
250 * relayfs debugfs file cleanly. Otherwise the parent debugfs tree
251 --- a/drivers/net/wireless/ath/ath10k/core.h
252 +++ b/drivers/net/wireless/ath/ath10k/core.h
253 @@ -15,6 +15,7 @@
254 #include <linux/pci.h>
255 #include <linux/uuid.h>
256 #include <linux/time.h>
257 +#include <linux/leds.h>
258
259 #include "htt.h"
260 #include "htc.h"
261 @@ -1257,6 +1258,13 @@ struct ath10k {
262 } testmode;
263
264 struct {
265 + struct gpio_led wifi_led;
266 + struct led_classdev cdev;
267 + char label[48];
268 + u32 gpio_state_pin;
269 + } leds;
270 +
271 + struct {
272 /* protected by data_lock */
273 u32 rx_crc_err_drop;
274 u32 fw_crash_counter;
275 --- a/drivers/net/wireless/ath/ath10k/hw.h
276 +++ b/drivers/net/wireless/ath/ath10k/hw.h
277 @@ -521,6 +521,7 @@ struct ath10k_hw_params {
278 const char *name;
279 u32 patch_load_addr;
280 int uart_pin;
281 + int led_pin;
282 u32 otp_exe_param;
283
284 /* Type of hw cycle counter wraparound logic, for more info
285 --- /dev/null
286 +++ b/drivers/net/wireless/ath/ath10k/leds.c
287 @@ -0,0 +1,90 @@
288 +// SPDX-License-Identifier: ISC
289 +/*
290 + * Copyright (c) 2005-2011 Atheros Communications Inc.
291 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
292 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
293 + * Copyright (c) 2018 The Linux Foundation. All rights reserved.
294 + */
295 +
296 +#include <linux/leds.h>
297 +
298 +#include "core.h"
299 +#include "wmi.h"
300 +#include "wmi-ops.h"
301 +
302 +#include "leds.h"
303 +
304 +static int ath10k_leds_set_brightness_blocking(struct led_classdev *led_cdev,
305 + enum led_brightness brightness)
306 +{
307 + struct ath10k *ar = container_of(led_cdev, struct ath10k,
308 + leds.cdev);
309 + struct gpio_led *led = &ar->leds.wifi_led;
310 +
311 + mutex_lock(&ar->conf_mutex);
312 +
313 + if (ar->state != ATH10K_STATE_ON)
314 + goto out;
315 +
316 + ar->leds.gpio_state_pin = (brightness != LED_OFF) ^ led->active_low;
317 + ath10k_wmi_gpio_output(ar, led->gpio, ar->leds.gpio_state_pin);
318 +
319 +out:
320 + mutex_unlock(&ar->conf_mutex);
321 +
322 + return 0;
323 +}
324 +
325 +int ath10k_leds_start(struct ath10k *ar)
326 +{
327 + if (ar->hw_params.led_pin == 0)
328 + /* leds not supported */
329 + return 0;
330 +
331 + /* under some circumstances, the gpio pin gets reconfigured
332 + * to default state by the firmware, so we need to
333 + * reconfigure it this behaviour has only ben seen on
334 + * QCA9984 and QCA99XX devices so far
335 + */
336 + ath10k_wmi_gpio_config(ar, ar->hw_params.led_pin, 0,
337 + WMI_GPIO_PULL_NONE, WMI_GPIO_INTTYPE_DISABLE);
338 + ath10k_wmi_gpio_output(ar, ar->hw_params.led_pin, 1);
339 +
340 + return 0;
341 +}
342 +
343 +int ath10k_leds_register(struct ath10k *ar)
344 +{
345 + int ret;
346 +
347 + if (ar->hw_params.led_pin == 0)
348 + /* leds not supported */
349 + return 0;
350 +
351 + snprintf(ar->leds.label, sizeof(ar->leds.label), "ath10k-%s",
352 + wiphy_name(ar->hw->wiphy));
353 + ar->leds.wifi_led.active_low = 1;
354 + ar->leds.wifi_led.gpio = ar->hw_params.led_pin;
355 + ar->leds.wifi_led.name = ar->leds.label;
356 + ar->leds.wifi_led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
357 +
358 + ar->leds.cdev.name = ar->leds.label;
359 + ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
360 + ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
361 +
362 + ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
363 + if (ret)
364 + return ret;
365 +
366 + return 0;
367 +}
368 +
369 +void ath10k_leds_unregister(struct ath10k *ar)
370 +{
371 + if (ar->hw_params.led_pin == 0)
372 + /* leds not supported */
373 + return;
374 +
375 + led_classdev_unregister(&ar->leds.cdev);
376 +}
377 +
378 --- /dev/null
379 +++ b/drivers/net/wireless/ath/ath10k/leds.h
380 @@ -0,0 +1,34 @@
381 +/* SPDX-License-Identifier: ISC */
382 +/*
383 + * Copyright (c) 2005-2011 Atheros Communications Inc.
384 + * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
385 + * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
386 + * Copyright (c) 2018 The Linux Foundation. All rights reserved.
387 + */
388 +
389 +#ifndef _LEDS_H_
390 +#define _LEDS_H_
391 +
392 +#include "core.h"
393 +
394 +#ifdef CPTCFG_ATH10K_LEDS
395 +void ath10k_leds_unregister(struct ath10k *ar);
396 +int ath10k_leds_start(struct ath10k *ar);
397 +int ath10k_leds_register(struct ath10k *ar);
398 +#else
399 +static inline void ath10k_leds_unregister(struct ath10k *ar)
400 +{
401 +}
402 +
403 +static inline int ath10k_leds_start(struct ath10k *ar)
404 +{
405 + return 0;
406 +}
407 +
408 +static inline int ath10k_leds_register(struct ath10k *ar)
409 +{
410 + return 0;
411 +}
412 +
413 +#endif
414 +#endif /* _LEDS_H_ */
415 --- a/drivers/net/wireless/ath/ath10k/mac.c
416 +++ b/drivers/net/wireless/ath/ath10k/mac.c
417 @@ -25,6 +25,7 @@
418 #include "wmi-tlv.h"
419 #include "wmi-ops.h"
420 #include "wow.h"
421 +#include "leds.h"
422
423 /*********/
424 /* Rates */
425 --- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
426 +++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
427 @@ -226,7 +226,10 @@ struct wmi_ops {
428 const struct wmi_bb_timing_cfg_arg *arg);
429 struct sk_buff *(*gen_per_peer_per_tid_cfg)(struct ath10k *ar,
430 const struct wmi_per_peer_per_tid_cfg_arg *arg);
431 + struct sk_buff *(*gen_gpio_config)(struct ath10k *ar, u32 gpio_num,
432 + u32 input, u32 pull_type, u32 intr_mode);
433
434 + struct sk_buff *(*gen_gpio_output)(struct ath10k *ar, u32 gpio_num, u32 set);
435 };
436
437 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id);
438 @@ -1122,6 +1125,35 @@ ath10k_wmi_force_fw_hang(struct ath10k *
439 return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->force_fw_hang_cmdid);
440 }
441
442 +static inline int ath10k_wmi_gpio_config(struct ath10k *ar, u32 gpio_num,
443 + u32 input, u32 pull_type, u32 intr_mode)
444 +{
445 + struct sk_buff *skb;
446 +
447 + if (!ar->wmi.ops->gen_gpio_config)
448 + return -EOPNOTSUPP;
449 +
450 + skb = ar->wmi.ops->gen_gpio_config(ar, gpio_num, input, pull_type, intr_mode);
451 + if (IS_ERR(skb))
452 + return PTR_ERR(skb);
453 +
454 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_config_cmdid);
455 +}
456 +
457 +static inline int ath10k_wmi_gpio_output(struct ath10k *ar, u32 gpio_num, u32 set)
458 +{
459 + struct sk_buff *skb;
460 +
461 + if (!ar->wmi.ops->gen_gpio_config)
462 + return -EOPNOTSUPP;
463 +
464 + skb = ar->wmi.ops->gen_gpio_output(ar, gpio_num, set);
465 + if (IS_ERR(skb))
466 + return PTR_ERR(skb);
467 +
468 + return ath10k_wmi_cmd_send(ar, skb, ar->wmi.cmd->gpio_output_cmdid);
469 +}
470 +
471 static inline int
472 ath10k_wmi_dbglog_cfg(struct ath10k *ar, u64 module_enable, u32 log_level)
473 {
474 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
475 +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
476 @@ -4606,6 +4606,8 @@ static const struct wmi_ops wmi_tlv_ops
477 .gen_echo = ath10k_wmi_tlv_op_gen_echo,
478 .gen_vdev_spectral_conf = ath10k_wmi_tlv_op_gen_vdev_spectral_conf,
479 .gen_vdev_spectral_enable = ath10k_wmi_tlv_op_gen_vdev_spectral_enable,
480 + /* .gen_gpio_config not implemented */
481 + /* .gen_gpio_output not implemented */
482 };
483
484 static const struct wmi_peer_flags_map wmi_tlv_peer_flags_map = {
485 --- a/drivers/net/wireless/ath/ath10k/wmi.c
486 +++ b/drivers/net/wireless/ath/ath10k/wmi.c
487 @@ -7493,6 +7493,49 @@ ath10k_wmi_op_gen_peer_set_param(struct
488 return skb;
489 }
490
491 +static struct sk_buff *ath10k_wmi_op_gen_gpio_config(struct ath10k *ar,
492 + u32 gpio_num, u32 input,
493 + u32 pull_type, u32 intr_mode)
494 +{
495 + struct wmi_gpio_config_cmd *cmd;
496 + struct sk_buff *skb;
497 +
498 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
499 + if (!skb)
500 + return ERR_PTR(-ENOMEM);
501 +
502 + cmd = (struct wmi_gpio_config_cmd *)skb->data;
503 + cmd->pull_type = __cpu_to_le32(pull_type);
504 + cmd->gpio_num = __cpu_to_le32(gpio_num);
505 + cmd->input = __cpu_to_le32(input);
506 + cmd->intr_mode = __cpu_to_le32(intr_mode);
507 +
508 + 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",
509 + gpio_num, input, pull_type, intr_mode);
510 +
511 + return skb;
512 +}
513 +
514 +static struct sk_buff *ath10k_wmi_op_gen_gpio_output(struct ath10k *ar,
515 + u32 gpio_num, u32 set)
516 +{
517 + struct wmi_gpio_output_cmd *cmd;
518 + struct sk_buff *skb;
519 +
520 + skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
521 + if (!skb)
522 + return ERR_PTR(-ENOMEM);
523 +
524 + cmd = (struct wmi_gpio_output_cmd *)skb->data;
525 + cmd->gpio_num = __cpu_to_le32(gpio_num);
526 + cmd->set = __cpu_to_le32(set);
527 +
528 + ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi gpio_output gpio_num 0x%08x set 0x%08x\n",
529 + gpio_num, set);
530 +
531 + return skb;
532 +}
533 +
534 static struct sk_buff *
535 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
536 enum wmi_sta_ps_mode psmode)
537 @@ -9157,6 +9200,9 @@ static const struct wmi_ops wmi_ops = {
538 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
539 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
540 .gen_echo = ath10k_wmi_op_gen_echo,
541 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
542 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
543 +
544 /* .gen_bcn_tmpl not implemented */
545 /* .gen_prb_tmpl not implemented */
546 /* .gen_p2p_go_bcn_ie not implemented */
547 @@ -9227,6 +9273,8 @@ static const struct wmi_ops wmi_10_1_ops
548 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
549 .get_vdev_subtype = ath10k_wmi_op_get_vdev_subtype,
550 .gen_echo = ath10k_wmi_op_gen_echo,
551 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
552 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
553 /* .gen_bcn_tmpl not implemented */
554 /* .gen_prb_tmpl not implemented */
555 /* .gen_p2p_go_bcn_ie not implemented */
556 @@ -9299,6 +9347,8 @@ static const struct wmi_ops wmi_10_2_ops
557 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
558 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
559 .get_vdev_subtype = ath10k_wmi_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_pdev_enable_adaptive_cca not implemented */
563 };
564
565 @@ -9370,6 +9420,8 @@ static const struct wmi_ops wmi_10_2_4_o
566 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
567 .get_vdev_subtype = ath10k_wmi_10_2_4_op_get_vdev_subtype,
568 .gen_bb_timing = ath10k_wmi_10_2_4_op_gen_bb_timing,
569 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
570 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
571 /* .gen_bcn_tmpl not implemented */
572 /* .gen_prb_tmpl not implemented */
573 /* .gen_p2p_go_bcn_ie not implemented */
574 @@ -9451,6 +9503,8 @@ static const struct wmi_ops wmi_10_4_ops
575 .gen_pdev_bss_chan_info_req = ath10k_wmi_10_2_op_gen_pdev_bss_chan_info,
576 .gen_echo = ath10k_wmi_op_gen_echo,
577 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
578 + .gen_gpio_config = ath10k_wmi_op_gen_gpio_config,
579 + .gen_gpio_output = ath10k_wmi_op_gen_gpio_output,
580 };
581
582 int ath10k_wmi_attach(struct ath10k *ar)
583 --- a/drivers/net/wireless/ath/ath10k/wmi.h
584 +++ b/drivers/net/wireless/ath/ath10k/wmi.h
585 @@ -3034,6 +3034,41 @@ enum wmi_10_4_feature_mask {
586
587 };
588
589 +/* WMI_GPIO_CPTCFG_CMDID */
590 +enum {
591 + WMI_GPIO_PULL_NONE,
592 + WMI_GPIO_PULL_UP,
593 + WMI_GPIO_PULL_DOWN,
594 +};
595 +
596 +enum {
597 + WMI_GPIO_INTTYPE_DISABLE,
598 + WMI_GPIO_INTTYPE_RISING_EDGE,
599 + WMI_GPIO_INTTYPE_FALLING_EDGE,
600 + WMI_GPIO_INTTYPE_BOTH_EDGE,
601 + WMI_GPIO_INTTYPE_LEVEL_LOW,
602 + WMI_GPIO_INTTYPE_LEVEL_HIGH
603 +};
604 +
605 +/* WMI_GPIO_CPTCFG_CMDID */
606 +struct wmi_gpio_config_cmd {
607 + __le32 gpio_num; /* GPIO number to be setup */
608 + __le32 input; /* 0 - Output/ 1 - Input */
609 + __le32 pull_type; /* Pull type defined above */
610 + __le32 intr_mode; /* Interrupt mode defined above (Input) */
611 +} __packed;
612 +
613 +/* WMI_GPIO_OUTPUT_CMDID */
614 +struct wmi_gpio_output_cmd {
615 + __le32 gpio_num; /* GPIO number to be setup */
616 + __le32 set; /* Set the GPIO pin*/
617 +} __packed;
618 +
619 +/* WMI_GPIO_INPUT_EVENTID */
620 +struct wmi_gpio_input_event {
621 + __le32 gpio_num; /* GPIO number which changed state */
622 +} __packed;
623 +
624 struct wmi_ext_resource_config_10_4_cmd {
625 /* contains enum wmi_host_platform_type */
626 __le32 host_platform_config;