mac80211: ath10k: replace LEDs patch with upstream patch

LEDs support for ath10k has finally merged upstream hence replace it
with the upstream version.

Link: https://github.com/openwrt/openwrt/pull/15735
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
Christian Marangi 2024-06-17 18:23:44 +02:00
parent 70088a7e4c
commit 6b71ab630a
No known key found for this signature in database
GPG Key ID: AC001D09ADBFEAD7
3 changed files with 160 additions and 145 deletions

View File

@ -1,103 +1,52 @@
From: Sebastian Gottschall <s.gottschall@newmedia-net.de>
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984 based
chipsets with on chipset connected led's using WMI Firmware API. The LED
device will get available named as "ath10k-phyX" at sysfs and can be controlled
with various triggers. adds also debugfs interface for gpio control.
This patch is specific for OpenWRt base, as is use old backported package
with old wireless source. Support for QCA9984 is removed and a simbol
is added to local-simbol file to export the actually compile the code
with the ATH10K_LEDS simbol.
From 8e1debd82466a3fe711784ab37e6b54e56011267 Mon Sep 17 00:00:00 2001
From: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Date: Mon, 13 May 2024 17:22:25 +0300
Subject: [PATCH] wifi: ath10k: add LED and GPIO controlling support for
various chipsets
Adds LED and GPIO Control support for 988x, 9887, 9888, 99x0, 9984
based chipsets with on chipset connected led's using WMI Firmware API.
The LED device will get available named as "ath10k-phyX" at sysfs and
can be controlled with various triggers.
Adds also debugfs interface for gpio control.
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
Reviewed-by: Steve deRosier <derosier@cal-sierra.com>
[kvalo: major reorg and cleanup]
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
[ansuel: rebase and small cleanup]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20230611080505.17393-1-ansuelsmth@gmail.com
---
v13:
* only compile tested!
* fix all checkpatch warnings
* fix commit log
* sizeof(struct ath10k_gpiocontrol) -> sizeof(*gpio)
* unsigned -> unsigned int
* remove GPIOLIB code, that should be added in a separate patch
* rename gpio.c to leds.c
* add leds.h
* rename some functions:
ath10k_attach_led() -> ath10k_leds_register()
ath10k_unregister_led() -> ath10k_leds_unregister()
ath10k_reset_led_pin() -> ath10k_leds_start()
* call ath10k_leds_unregister() before ath10k_thermal_unregister() to preserve ordering
* call ath10k_leds_start() only from ath10k_core_start() and not from mac.c
* rename struct ath10k_gpiocontrol as anonymous function under struct
ath10k::leds, no need for memory allocation
* merge ath10k_add_led() to ath10k_attach_led(), which is it's only caller
* remove #if IS_ENABLED() checks from most of places, memory savings from those were not worth it
* Kconfig help text improvement and move it lower in the menu, also don't enable it by default
* switch to set_brightness_blocking() so that the callback can sleep,
then no need to use ath10k_wmi_cmd_send_nowait() and can take mutex
to access ar->state
* don't touch ath10k_wmi_pdev_get_temperature()
* as QCA6174/QCA9377 are not (yet) supported don't add the command to WMI-TLV interface
* remove debugfs interface, that should be added in another patch
* cleanup includes
drivers/net/wireless/ath/ath10k/Kconfig | 10 +++
drivers/net/wireless/ath/ath10k/Makefile | 1 +
drivers/net/wireless/ath/ath10k/core.c | 22 +++++++
drivers/net/wireless/ath/ath10k/core.h | 9 ++-
drivers/net/wireless/ath/ath10k/hw.h | 1 +
drivers/net/wireless/ath/ath10k/leds.c | 103 ++++++++++++++++++++++++++++++
drivers/net/wireless/ath/ath10k/leds.h | 45 +++++++++++++
drivers/net/wireless/ath/ath10k/mac.c | 1 +
drivers/net/wireless/ath/ath10k/wmi-ops.h | 32 ++++++++++
drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +
drivers/net/wireless/ath/ath10k/wmi.c | 54 ++++++++++++++++
drivers/net/wireless/ath/ath10k/wmi.h | 35 ++++++++++
12 files changed, 314 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/Kconfig | 6 ++
drivers/net/wireless/ath/ath10k/Makefile | 1 +
drivers/net/wireless/ath/ath10k/core.c | 32 ++++++++
drivers/net/wireless/ath/ath10k/core.h | 8 ++
drivers/net/wireless/ath/ath10k/hw.h | 1 +
drivers/net/wireless/ath/ath10k/leds.c | 90 +++++++++++++++++++++++
drivers/net/wireless/ath/ath10k/leds.h | 34 +++++++++
drivers/net/wireless/ath/ath10k/mac.c | 1 +
drivers/net/wireless/ath/ath10k/wmi-ops.h | 32 ++++++++
drivers/net/wireless/ath/ath10k/wmi-tlv.c | 2 +
drivers/net/wireless/ath/ath10k/wmi.c | 54 ++++++++++++++
drivers/net/wireless/ath/ath10k/wmi.h | 35 +++++++++
12 files changed, 296 insertions(+)
create mode 100644 drivers/net/wireless/ath/ath10k/leds.c
create mode 100644 drivers/net/wireless/ath/ath10k/leds.h
--- a/drivers/net/wireless/ath/ath10k/Kconfig
+++ b/drivers/net/wireless/ath/ath10k/Kconfig
@@ -72,6 +72,16 @@ config ATH10K_DEBUGFS
@@ -72,6 +72,12 @@ config ATH10K_DEBUGFS
If unsure, say Y to make it easier to debug problems.
+config ATH10K_LEDS
+ bool "Atheros ath10k LED support"
+ bool
+ depends on ATH10K
+ select MAC80211_LEDS
+ select LEDS_CLASS
+ select NEW_LEDS
+ depends on LEDS_CLASS=y || LEDS_CLASS=MAC80211
+ default y
+ ---help---
+ This option is necessary, if you want LED support for chipset connected led pins. If unsure, say N.
+
config ATH10K_SPECTRAL
bool "Atheros ath10k spectral scan support"
@ -132,47 +81,135 @@ v13:
unsigned int ath10k_debug_mask;
EXPORT_SYMBOL(ath10k_debug_mask);
@@ -65,6 +66,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA988X_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
@@ -67,6 +68,7 @@ static const struct ath10k_hw_params ath
.name = "qca988x hw2.0",
+ .led_pin = 1,
.patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -146,6 +148,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9887_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9887 hw1.0",
+ .led_pin = 1,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
@@ -107,6 +109,7 @@ static const struct ath10k_hw_params ath
.name = "qca988x hw2.0 ubiquiti",
.patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
+ .led_pin = 0,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
@@ -148,6 +151,7 @@ static const struct ath10k_hw_params ath
.name = "qca9887 hw1.0",
.patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
+ .led_pin = 1,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -387,6 +390,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA99X0_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
@@ -189,6 +193,7 @@ static const struct ath10k_hw_params ath
.name = "qca6174 hw3.2 sdio",
.patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
.uart_pin = 19,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -225,6 +230,7 @@ static const struct ath10k_hw_params ath
.name = "qca6164 hw2.1",
.patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
.uart_pin = 6,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -265,6 +271,7 @@ static const struct ath10k_hw_params ath
.name = "qca6174 hw2.1",
.patch_load_addr = QCA6174_HW_2_1_PATCH_LOAD_ADDR,
.uart_pin = 6,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -305,6 +312,7 @@ static const struct ath10k_hw_params ath
.name = "qca6174 hw3.0",
.patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
.uart_pin = 6,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -345,6 +353,7 @@ static const struct ath10k_hw_params ath
.name = "qca6174 hw3.2",
.patch_load_addr = QCA6174_HW_3_0_PATCH_LOAD_ADDR,
.uart_pin = 6,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -389,6 +398,7 @@ static const struct ath10k_hw_params ath
.name = "qca99x0 hw2.0",
+ .led_pin = 17,
.patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.otp_exe_param = 0x00000700,
@@ -433,6 +437,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9984_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9984/qca9994 hw1.0",
+ .led_pin = 17,
.otp_exe_param = 0x00000700,
.continuous_frag_desc = true,
.cck_rate_map_rev2 = true,
@@ -435,6 +445,7 @@ static const struct ath10k_hw_params ath
.name = "qca9984/qca9994 hw1.0",
.patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -486,6 +491,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9888_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9888 hw2.0",
+ .led_pin = 17,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
.otp_exe_param = 0x00000700,
.continuous_frag_desc = true,
@@ -488,6 +499,7 @@ static const struct ath10k_hw_params ath
.name = "qca9888 hw2.0",
.patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
+ .led_pin = 17,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -3222,6 +3228,10 @@ int ath10k_core_start(struct ath10k *ar,
.otp_exe_param = 0x00000700,
.continuous_frag_desc = true,
@@ -538,6 +550,7 @@ static const struct ath10k_hw_params ath
.name = "qca9377 hw1.0",
.patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 6,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -578,6 +591,7 @@ static const struct ath10k_hw_params ath
.name = "qca9377 hw1.1",
.patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 6,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -620,6 +634,7 @@ static const struct ath10k_hw_params ath
.name = "qca9377 hw1.1 sdio",
.patch_load_addr = QCA9377_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 19,
+ .led_pin = 0,
.otp_exe_param = 0,
.channel_counters_freq_hz = 88000,
.max_probe_resp_desc_thres = 0,
@@ -653,6 +668,7 @@ static const struct ath10k_hw_params ath
.name = "qca4019 hw1.0",
.patch_load_addr = QCA4019_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
+ .led_pin = 0,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
.otp_exe_param = 0x0010000,
.continuous_frag_desc = true,
@@ -698,6 +714,7 @@ static const struct ath10k_hw_params ath
.dev_id = 0,
.bus = ATH10K_BUS_SNOC,
.name = "wcn3990 hw1.0",
+ .led_pin = 0,
.continuous_frag_desc = true,
.tx_chain_mask = 0x7,
.rx_chain_mask = 0x7,
@@ -3222,6 +3239,10 @@ int ath10k_core_start(struct ath10k *ar,
goto err_hif_stop;
}
@ -183,7 +220,7 @@ v13:
return 0;
err_hif_stop:
@@ -3480,9 +3490,18 @@ static void ath10k_core_register_work(st
@@ -3480,9 +3501,18 @@ static void ath10k_core_register_work(st
goto err_spectral_destroy;
}
@ -202,7 +239,7 @@ v13:
err_spectral_destroy:
ath10k_spectral_destroy(ar);
err_debug_destroy:
@@ -3528,6 +3547,8 @@ void ath10k_core_unregister(struct ath10
@@ -3528,6 +3558,8 @@ void ath10k_core_unregister(struct ath10
if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
return;
@ -247,24 +284,13 @@ v13:
/* Type of hw cycle counter wraparound logic, for more info
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/leds.c
@@ -0,0 +1,103 @@
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: ISC
+/*
+ * Copyright (c) 2005-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ */
+
+#include <linux/leds.h>
@ -331,8 +357,6 @@ v13:
+
+ ar->leds.cdev.name = ar->leds.label;
+ ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
+
+ /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
+ ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
+
+ ret = led_classdev_register(wiphy_dev(ar->hw->wiphy), &ar->leds.cdev);
@ -353,22 +377,15 @@ v13:
+
--- /dev/null
+++ b/drivers/net/wireless/ath/ath10k/leds.h
@@ -0,0 +1,41 @@
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * Copyright (c) 2005-2011 Atheros Communications Inc.
+ * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
+ * Copyright (c) 2018 Sebastian Gottschall <s.gottschall@dd-wrt.com>
+ * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ */
+
+#ifndef _LEDS_H_
+#define _LEDS_H_
+
@ -569,7 +586,7 @@ v13:
};
+/* WMI_GPIO_CONFIG_CMDID */
+/* WMI_GPIO_CPTCFG_CMDID */
+enum {
+ WMI_GPIO_PULL_NONE,
+ WMI_GPIO_PULL_UP,
@ -585,7 +602,7 @@ v13:
+ WMI_GPIO_INTTYPE_LEVEL_HIGH
+};
+
+/* WMI_GPIO_CONFIG_CMDID */
+/* WMI_GPIO_CPTCFG_CMDID */
+struct wmi_gpio_config_cmd {
+ __le32 gpio_num; /* GPIO number to be setup */
+ __le32 input; /* 0 - Output/ 1 - Input */

View File

@ -29,12 +29,10 @@ Signed-off-by: Mathias Kresin <dev@kresin.me>
};
--- a/drivers/net/wireless/ath/ath10k/leds.c
+++ b/drivers/net/wireless/ath/ath10k/leds.c
@@ -81,9 +81,7 @@ int ath10k_leds_register(struct ath10k *
@@ -70,7 +70,7 @@ int ath10k_leds_register(struct ath10k *
ar->leds.cdev.name = ar->leds.label;
ar->leds.cdev.brightness_set_blocking = ath10k_leds_set_brightness_blocking;
-
- /* FIXME: this assignment doesn't make sense as it's NULL, remove it? */
- ar->leds.cdev.default_trigger = ar->leds.wifi_led.default_trigger;
+ ar->leds.cdev.default_trigger = ar->led_default_trigger;

View File

@ -26,7 +26,7 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
#include <linux/property.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
@@ -3398,6 +3399,8 @@ static int ath10k_core_probe_fw(struct a
@@ -3409,6 +3410,8 @@ static int ath10k_core_probe_fw(struct a
device_get_mac_address(ar->dev, ar->mac_addr);