refreshes mac80211 + ath10k-ct patches.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
--- /dev/null
+From e2333703373e8b81294da5d1c73c30154f75b082 Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey@gmail.com>
+Date: Fri, 15 Oct 2021 18:56:33 +0200
+Subject: [PATCH] ath10k: fetch (pre-)calibration data via nvmem subsystem
+
+On most embedded ath10k devices (like range extenders,
+routers, accesspoints, ...) the calibration data is
+stored in a easily accessible MTD partitions named
+"ART", "caldata", "calibration", etc...
+
+Since commit 4b361cfa8624 ("mtd: core: add OTP nvmem provider support"):
+MTD partitions and portions of them can be specified
+as potential nvmem-cells which are accessible through
+the nvmem subsystem.
+
+This feature - together with an nvmem cell definition either
+in the platform data or via device-tree allows drivers to get
+the (pre-)calibration data which is required for initializing
+the WIFI.
+
+Tested with Netgear EX6150v2 (IPQ4018)
+
+Cc: Robert Marko <robimarko@gmail.com>
+Cc: Thibaut Varene <hacks@slashdirt.org>
+Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+---
+--- a/ath10k-5.15/core.c
++++ b/ath10k-5.15/core.c
+@@ -13,6 +13,7 @@
+ #include <linux/dmi.h>
+ #include <linux/ctype.h>
+ #include <linux/pm_qos.h>
++#include <linux/nvmem-consumer.h>
+ #include <asm/byteorder.h>
+ #include <linux/ctype.h>
+
+@@ -988,7 +989,8 @@ static int ath10k_core_get_board_id_from
+ }
+
+ if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT ||
+- ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE ||
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_NVMEM)
+ bmi_board_id_param = BMI_PARAM_GET_FLASH_BOARD_ID;
+ else
+ bmi_board_id_param = BMI_PARAM_GET_EEPROM_BOARD_ID;
+@@ -2087,7 +2089,8 @@ static int ath10k_download_and_run_otp(s
+
+ /* As of now pre-cal is valid for 10_4 variants */
+ if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT ||
+- ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE ||
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_NVMEM)
+ bmi_otp_exe_param = BMI_PARAM_FLASH_SECTION_ALL;
+
+ ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, &result);
+@@ -2221,6 +2224,39 @@ struct ath10k_bss_rom_ie {
+ __le32 rom_len;
+ } __packed;
+
++static int ath10k_download_cal_nvmem(struct ath10k *ar, const char *cell_name)
++{
++ struct nvmem_cell *cell;
++ void *buf;
++ size_t len;
++ int ret;
++
++ cell = devm_nvmem_cell_get(ar->dev, cell_name);
++ if (IS_ERR(cell)) {
++ ret = PTR_ERR(cell);
++ return ret;
++ }
++
++ buf = nvmem_cell_read(cell, &len);
++ if (IS_ERR(buf))
++ return PTR_ERR(buf);
++
++ if (ar->hw_params.cal_data_len != len) {
++ kfree(buf);
++ ath10k_warn(ar, "invalid calibration data length in nvmem-cell '%s': %zu != %u\n",
++ cell_name, len, ar->hw_params.cal_data_len);
++ return -EMSGSIZE;
++ }
++
++ ret = ath10k_download_board_data(ar, buf, len);
++ kfree(buf);
++ if (ret)
++ ath10k_warn(ar, "failed to download calibration data from nvmem-cell '%s': %d\n",
++ cell_name, ret);
++
++ return ret;
++}
++
+ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
+ struct ath10k_fw_file *fw_file)
+ {
+@@ -2597,6 +2633,18 @@ static int ath10k_core_pre_cal_download(
+ {
+ int ret;
+
++ ret = ath10k_download_cal_nvmem(ar, "pre-calibration");
++ if (ret == 0) {
++ ar->cal_mode = ATH10K_PRE_CAL_MODE_NVMEM;
++ goto success;
++ } else if (ret == -EPROBE_DEFER) {
++ return ret;
++ }
++
++ ath10k_dbg(ar, ATH10K_DBG_BOOT,
++ "boot did not find a pre-calibration nvmem-cell, try file next: %d\n",
++ ret);
++
+ ret = ath10k_download_cal_file(ar, ar->pre_cal_file);
+ if (ret == 0) {
+ ar->cal_mode = ATH10K_PRE_CAL_MODE_FILE;
+@@ -2663,6 +2711,18 @@ static int ath10k_download_cal_data(stru
+ "pre cal download procedure failed, try cal file: %d\n",
+ ret);
+
++ ret = ath10k_download_cal_nvmem(ar, "calibration");
++ if (ret == 0) {
++ ar->cal_mode = ATH10K_CAL_MODE_NVMEM;
++ goto done;
++ } else if (ret == -EPROBE_DEFER) {
++ return ret;
++ }
++
++ ath10k_dbg(ar, ATH10K_DBG_BOOT,
++ "boot did not find a calibration nvmem-cell, try file next: %d\n",
++ ret);
++
+ ret = ath10k_download_cal_file(ar, ar->cal_file);
+ if (ret == 0) {
+ ar->cal_mode = ATH10K_CAL_MODE_FILE;
+--- a/ath10k-5.15/core.h
++++ b/ath10k-5.15/core.h
+@@ -1109,8 +1109,10 @@ enum ath10k_cal_mode {
+ ATH10K_CAL_MODE_FILE,
+ ATH10K_CAL_MODE_OTP,
+ ATH10K_CAL_MODE_DT,
++ ATH10K_CAL_MODE_NVMEM,
+ ATH10K_PRE_CAL_MODE_FILE,
+ ATH10K_PRE_CAL_MODE_DT,
++ ATH10K_PRE_CAL_MODE_NVMEM,
+ ATH10K_CAL_MODE_EEPROM,
+ };
+
+@@ -1130,10 +1132,14 @@ static inline const char *ath10k_cal_mod
+ return "otp";
+ case ATH10K_CAL_MODE_DT:
+ return "dt";
++ case ATH10K_CAL_MODE_NVMEM:
++ return "nvmem";
+ case ATH10K_PRE_CAL_MODE_FILE:
+ return "pre-cal-file";
+ case ATH10K_PRE_CAL_MODE_DT:
+ return "pre-cal-dt";
++ case ATH10K_PRE_CAL_MODE_NVMEM:
++ return "pre-cal-nvmem";
+ case ATH10K_CAL_MODE_EEPROM:
+ return "eeprom";
+ }
ath10k_core-$(CONFIG_ATH10K_CE) += ce.o
--- a/ath10k-5.15/core.c
+++ b/ath10k-5.15/core.c
-@@ -27,6 +27,7 @@
+@@ -28,6 +28,7 @@
#include "testmode.h"
#include "wmi-ops.h"
#include "coredump.h"
/* Disable ath10k-ct DBGLOG output by default */
unsigned int ath10k_debug_mask = ATH10K_DBG_NO_DBGLOG;
-@@ -69,6 +70,7 @@ static const struct ath10k_hw_params ath
+@@ -70,6 +71,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA988X_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca988x hw2.0",
.patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
-@@ -140,6 +142,7 @@ static const struct ath10k_hw_params ath
+@@ -141,6 +143,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9887_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9887 hw1.0",
.patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
-@@ -351,6 +354,7 @@ static const struct ath10k_hw_params ath
+@@ -352,6 +355,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA99X0_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca99x0 hw2.0",
.patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.otp_exe_param = 0x00000700,
-@@ -392,6 +396,7 @@ static const struct ath10k_hw_params ath
+@@ -393,6 +397,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9984_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.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,
-@@ -440,6 +445,7 @@ static const struct ath10k_hw_params ath
+@@ -441,6 +446,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9888_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9888 hw2.0",
.patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
-@@ -3882,6 +3888,10 @@ int ath10k_core_start(struct ath10k *ar,
+@@ -3942,6 +3948,10 @@ int ath10k_core_start(struct ath10k *ar,
ath10k_wmi_check_apply_board_power_ctl_table(ar);
}
return 0;
err_hif_stop:
-@@ -4143,9 +4153,18 @@ static void ath10k_core_register_work(st
+@@ -4203,9 +4213,18 @@ static void ath10k_core_register_work(st
goto err_spectral_destroy;
}
err_spectral_destroy:
ath10k_spectral_destroy(ar);
err_debug_destroy:
-@@ -4205,6 +4224,8 @@ void ath10k_core_unregister(struct ath10
+@@ -4265,6 +4284,8 @@ void ath10k_core_unregister(struct ath10
if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
return;
#include "htt.h"
#include "htc.h"
-@@ -1571,6 +1572,13 @@ struct ath10k {
+@@ -1577,6 +1578,13 @@ struct ath10k {
} testmode;
struct {
--- a/ath10k-5.15/core.h
+++ b/ath10k-5.15/core.h
-@@ -1686,6 +1686,10 @@ struct ath10k {
+@@ -1692,6 +1692,10 @@ struct ath10k {
u8 csi_data[4096];
u16 csi_data_len;
--- /dev/null
+From e2333703373e8b81294da5d1c73c30154f75b082 Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey@gmail.com>
+Date: Fri, 15 Oct 2021 18:56:33 +0200
+Subject: [PATCH] ath10k: fetch (pre-)calibration data via nvmem subsystem
+
+On most embedded ath10k devices (like range extenders,
+routers, accesspoints, ...) the calibration data is
+stored in a easily accessible MTD partitions named
+"ART", "caldata", "calibration", etc...
+
+Since commit 4b361cfa8624 ("mtd: core: add OTP nvmem provider support"):
+MTD partitions and portions of them can be specified
+as potential nvmem-cells which are accessible through
+the nvmem subsystem.
+
+This feature - together with an nvmem cell definition either
+in the platform data or via device-tree allows drivers to get
+the (pre-)calibration data which is required for initializing
+the WIFI.
+
+Tested with Netgear EX6150v2 (IPQ4018)
+
+Cc: Robert Marko <robimarko@gmail.com>
+Cc: Thibaut Varene <hacks@slashdirt.org>
+Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+---
+--- a/drivers/net/wireless/ath/ath10k/core.c
++++ b/drivers/net/wireless/ath/ath10k/core.c
+@@ -12,6 +12,7 @@
+ #include <linux/dmi.h>
+ #include <linux/ctype.h>
+ #include <linux/pm_qos.h>
++#include <linux/nvmem-consumer.h>
+ #include <asm/byteorder.h>
+
+ #include "core.h"
+@@ -935,7 +936,8 @@ static int ath10k_core_get_board_id_from
+ }
+
+ if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT ||
+- ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE ||
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_NVMEM)
+ bmi_board_id_param = BMI_PARAM_GET_FLASH_BOARD_ID;
+ else
+ bmi_board_id_param = BMI_PARAM_GET_EEPROM_BOARD_ID;
+@@ -1726,7 +1728,8 @@ static int ath10k_download_and_run_otp(s
+
+ /* As of now pre-cal is valid for 10_4 variants */
+ if (ar->cal_mode == ATH10K_PRE_CAL_MODE_DT ||
+- ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE)
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_FILE ||
++ ar->cal_mode == ATH10K_PRE_CAL_MODE_NVMEM)
+ bmi_otp_exe_param = BMI_PARAM_FLASH_SECTION_ALL;
+
+ ret = ath10k_bmi_execute(ar, address, bmi_otp_exe_param, &result);
+@@ -1853,6 +1856,39 @@ out_free:
+ return ret;
+ }
+
++static int ath10k_download_cal_nvmem(struct ath10k *ar, const char *cell_name)
++{
++ struct nvmem_cell *cell;
++ void *buf;
++ size_t len;
++ int ret;
++
++ cell = devm_nvmem_cell_get(ar->dev, cell_name);
++ if (IS_ERR(cell)) {
++ ret = PTR_ERR(cell);
++ return ret;
++ }
++
++ buf = nvmem_cell_read(cell, &len);
++ if (IS_ERR(buf))
++ return PTR_ERR(buf);
++
++ if (ar->hw_params.cal_data_len != len) {
++ kfree(buf);
++ ath10k_warn(ar, "invalid calibration data length in nvmem-cell '%s': %zu != %u\n",
++ cell_name, len, ar->hw_params.cal_data_len);
++ return -EMSGSIZE;
++ }
++
++ ret = ath10k_download_board_data(ar, buf, len);
++ kfree(buf);
++ if (ret)
++ ath10k_warn(ar, "failed to download calibration data from nvmem-cell '%s': %d\n",
++ cell_name, ret);
++
++ return ret;
++}
++
+ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
+ struct ath10k_fw_file *fw_file)
+ {
+@@ -2087,6 +2123,18 @@ static int ath10k_core_pre_cal_download(
+ {
+ int ret;
+
++ ret = ath10k_download_cal_nvmem(ar, "pre-calibration");
++ if (ret == 0) {
++ ar->cal_mode = ATH10K_PRE_CAL_MODE_NVMEM;
++ goto success;
++ } else if (ret == -EPROBE_DEFER) {
++ return ret;
++ }
++
++ ath10k_dbg(ar, ATH10K_DBG_BOOT,
++ "boot did not find a pre-calibration nvmem-cell, try file next: %d\n",
++ ret);
++
+ ret = ath10k_download_cal_file(ar, ar->pre_cal_file);
+ if (ret == 0) {
+ ar->cal_mode = ATH10K_PRE_CAL_MODE_FILE;
+@@ -2153,6 +2201,18 @@ static int ath10k_download_cal_data(stru
+ "pre cal download procedure failed, try cal file: %d\n",
+ ret);
+
++ ret = ath10k_download_cal_nvmem(ar, "calibration");
++ if (ret == 0) {
++ ar->cal_mode = ATH10K_CAL_MODE_NVMEM;
++ goto done;
++ } else if (ret == -EPROBE_DEFER) {
++ return ret;
++ }
++
++ ath10k_dbg(ar, ATH10K_DBG_BOOT,
++ "boot did not find a calibration nvmem-cell, try file next: %d\n",
++ ret);
++
+ ret = ath10k_download_cal_file(ar, ar->cal_file);
+ if (ret == 0) {
+ ar->cal_mode = ATH10K_CAL_MODE_FILE;
+--- a/drivers/net/wireless/ath/ath10k/core.h
++++ b/drivers/net/wireless/ath/ath10k/core.h
+@@ -877,8 +877,10 @@ enum ath10k_cal_mode {
+ ATH10K_CAL_MODE_FILE,
+ ATH10K_CAL_MODE_OTP,
+ ATH10K_CAL_MODE_DT,
++ ATH10K_CAL_MODE_NVMEM,
+ ATH10K_PRE_CAL_MODE_FILE,
+ ATH10K_PRE_CAL_MODE_DT,
++ ATH10K_PRE_CAL_MODE_NVMEM,
+ ATH10K_CAL_MODE_EEPROM,
+ };
+
+@@ -898,10 +900,14 @@ static inline const char *ath10k_cal_mod
+ return "otp";
+ case ATH10K_CAL_MODE_DT:
+ return "dt";
++ case ATH10K_CAL_MODE_NVMEM:
++ return "nvmem";
+ case ATH10K_PRE_CAL_MODE_FILE:
+ return "pre-cal-file";
+ case ATH10K_PRE_CAL_MODE_DT:
+ return "pre-cal-dt";
++ case ATH10K_PRE_CAL_MODE_NVMEM:
++ return "pre-cal-nvmem";
+ case ATH10K_CAL_MODE_EEPROM:
+ return "eeprom";
+ }
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
-@@ -3352,6 +3352,16 @@ int ath10k_core_register(struct ath10k *
+@@ -3412,6 +3412,16 @@ int ath10k_core_register(struct ath10k *
queue_work(ar->workqueue, &ar->register_work);
WCN36XX=
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
-@@ -25,6 +25,7 @@
+@@ -26,6 +26,7 @@
#include "testmode.h"
#include "wmi-ops.h"
#include "coredump.h"
unsigned int ath10k_debug_mask;
EXPORT_SYMBOL(ath10k_debug_mask);
-@@ -61,6 +62,7 @@ static const struct ath10k_hw_params ath
+@@ -62,6 +63,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA988X_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca988x hw2.0",
.patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
-@@ -132,6 +134,7 @@ static const struct ath10k_hw_params ath
+@@ -133,6 +135,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9887_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9887 hw1.0",
.patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
-@@ -343,6 +346,7 @@ static const struct ath10k_hw_params ath
+@@ -344,6 +347,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA99X0_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca99x0 hw2.0",
.patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.otp_exe_param = 0x00000700,
-@@ -384,6 +388,7 @@ static const struct ath10k_hw_params ath
+@@ -385,6 +389,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9984_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.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,
-@@ -432,6 +437,7 @@ static const struct ath10k_hw_params ath
+@@ -433,6 +438,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9888_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9888 hw2.0",
.patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
-@@ -3067,6 +3073,10 @@ int ath10k_core_start(struct ath10k *ar,
+@@ -3127,6 +3133,10 @@ int ath10k_core_start(struct ath10k *ar,
goto err_hif_stop;
}
return 0;
err_hif_stop:
-@@ -3325,9 +3335,18 @@ static void ath10k_core_register_work(st
+@@ -3385,9 +3395,18 @@ static void ath10k_core_register_work(st
goto err_spectral_destroy;
}
err_spectral_destroy:
ath10k_spectral_destroy(ar);
err_debug_destroy:
-@@ -3373,6 +3392,8 @@ void ath10k_core_unregister(struct ath10
+@@ -3433,6 +3452,8 @@ void ath10k_core_unregister(struct ath10
if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
return;
#include "htt.h"
#include "htc.h"
-@@ -1250,6 +1251,13 @@ struct ath10k {
+@@ -1256,6 +1257,13 @@ struct ath10k {
} testmode;
struct {
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
-@@ -1306,6 +1306,10 @@ struct ath10k {
+@@ -1312,6 +1312,10 @@ struct ath10k {
s32 tx_power_2g_limit;
s32 tx_power_5g_limit;
#include <linux/property.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
-@@ -3243,6 +3244,8 @@ static int ath10k_core_probe_fw(struct a
+@@ -3303,6 +3304,8 @@ static int ath10k_core_probe_fw(struct a
device_get_mac_address(ar->dev, ar->mac_addr, sizeof(ar->mac_addr));