Commit 332ff432 authored by Anjaneyulu's avatar Anjaneyulu Committed by Johannes Berg
Browse files

wifi: iwlwifi: Add support for LARI_CONFIG_CHANGE_CMD v10



Add support for enable/disable 320 MHz for Japan and South Korea
by reading WBEM (WiFi Bandwidth Enablement per MCC) variable from
UEFI or ACPI and sending it to the FW.

Signed-off-by: default avatarAnjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240415114847.7946c3befbe1.I453c33f7ea48156ea2a3961f50a9003103fca5a5@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent c60fc06d
Loading
Loading
Loading
Loading
+35 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
 * Copyright (C) 2017 Intel Deutschland GmbH
 * Copyright (C) 2019-2023 Intel Corporation
 * Copyright (C) 2019-2024 Intel Corporation
 */
#include <linux/uuid.h>
#include "iwl-drv.h"
@@ -960,3 +960,37 @@ void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt)
	kfree(data);
}
IWL_EXPORT_SYMBOL(iwl_acpi_get_guid_lock_status);

int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
{
	union acpi_object *wifi_pkg, *data;
	int ret = -ENOENT;
	int tbl_rev;

	data = iwl_acpi_get_object(fwrt->dev, ACPI_WBEM_METHOD);
	if (IS_ERR(data))
		return ret;

	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
					 ACPI_WBEM_WIFI_DATA_SIZE,
					 &tbl_rev);
	if (IS_ERR(wifi_pkg))
		goto out_free;

	if (tbl_rev != IWL_ACPI_WBEM_REVISION) {
		IWL_DEBUG_RADIO(fwrt, "Unsupported ACPI WBEM revision:%d\n",
				tbl_rev);
		goto out_free;
	}

	if (wifi_pkg->package.elements[1].type != ACPI_TYPE_INTEGER)
		goto out_free;

	*value = wifi_pkg->package.elements[1].integer.value &
		 IWL_ACPI_WBEM_REV0_MASK;
	IWL_DEBUG_RADIO(fwrt, "Loaded WBEM config from ACPI\n");
	ret = 0;
out_free:
	kfree(data);
	return ret;
}
+16 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#define ACPI_WTAS_METHOD	"WTAS"
#define ACPI_WPFC_METHOD	"WPFC"
#define ACPI_GLAI_METHOD	"GLAI"
#define ACPI_WBEM_METHOD	"WBEM"

#define ACPI_WIFI_DOMAIN	(0x07)

@@ -67,6 +68,12 @@
#define ACPI_WRDD_WIFI_DATA_SIZE	2
#define ACPI_SPLC_WIFI_DATA_SIZE	2
#define ACPI_ECKV_WIFI_DATA_SIZE	2

/*
 * One element for domain type,
 * and one for enablement of Wi-Fi 320MHz per MCC
 */
#define ACPI_WBEM_WIFI_DATA_SIZE	2
/*
 * One element for domain type,
 * and one for the status
@@ -94,6 +101,9 @@

#define ACPI_DSM_REV 0

#define IWL_ACPI_WBEM_REV0_MASK (BIT(0) | BIT(1))
#define IWL_ACPI_WBEM_REVISION 0

#ifdef CONFIG_ACPI

struct iwl_fw_runtime;
@@ -142,6 +152,7 @@ void iwl_acpi_get_guid_lock_status(struct iwl_fw_runtime *fwrt);
int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt,
		     enum iwl_dsm_funcs func, u32 *value);

int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);
#else /* CONFIG_ACPI */

static inline void *iwl_acpi_get_dsm_object(struct device *dev, int rev,
@@ -205,6 +216,11 @@ static inline int iwl_acpi_get_dsm(struct iwl_fw_runtime *fwrt,
{
	return -ENOENT;
}

static inline int iwl_acpi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
{
	return -ENOENT;
}
#endif /* CONFIG_ACPI */

#endif /* __iwl_fw_acpi__ */
+42 −2
Original line number Diff line number Diff line
@@ -22,8 +22,9 @@ enum iwl_regulatory_and_nvm_subcmd_ids {
	 *	&struct iwl_lari_config_change_cmd_v3,
	 *	&struct iwl_lari_config_change_cmd_v4,
	 *	&struct iwl_lari_config_change_cmd_v5,
	 *	&struct iwl_lari_config_change_cmd_v6 or
	 *	&struct iwl_lari_config_change_cmd_v7
	 *	&struct iwl_lari_config_change_cmd_v6,
	 *	&struct iwl_lari_config_change_cmd_v7 or
	 *	&struct iwl_lari_config_change_cmd
	 */
	LARI_CONFIG_CHANGE = 0x1,

@@ -646,6 +647,45 @@ struct iwl_lari_config_change_cmd_v7 {
/* LARI_CHANGE_CONF_CMD_S_VER_8 */
/* LARI_CHANGE_CONF_CMD_S_VER_9 */

/**
 * struct iwl_lari_config_change_cmd - change LARI configuration
 * @config_bitmap: Bitmap of the config commands. Each bit will trigger a
 *	different predefined FW config operation.
 * @oem_uhb_allow_bitmap: Bitmap of UHB enabled MCC sets.
 * @oem_11ax_allow_bitmap: Bitmap of 11ax allowed MCCs. There are two bits
 *	per country, one to indicate whether to override and the other to
 *	indicate the value to use.
 * @oem_unii4_allow_bitmap: Bitmap of unii4 allowed MCCs.There are two bits
 *	per country, one to indicate whether to override and the other to
 *	indicate allow/disallow unii4 channels.
 *	For LARI cmd version 10 - bits 0:5 are supported.
 * @chan_state_active_bitmap: Bitmap to enable different bands per country
 *	or region.
 *	Each bit represents a country or region, and a band to activate
 *	according to the BIOS definitions.
 *	For LARI cmd version 10 - bits 0:4 are supported.
 * @force_disable_channels_bitmap: Bitmap of disabled bands/channels.
 *	Each bit represents a set of channels in a specific band that should be
 *	disabled
 * @edt_bitmap: Bitmap of energy detection threshold table.
 *	Disable/enable the EDT optimization method for different band.
 * @oem_320mhz_allow_bitmap: 320Mhz bandwidth enablement bitmap per MCC.
 *	bit0: enable 320Mhz in Japan.
 *	bit1: enable 320Mhz in South Korea.
 *	bit 2 - 31: reserved.
 */
struct iwl_lari_config_change_cmd {
	__le32 config_bitmap;
	__le32 oem_uhb_allow_bitmap;
	__le32 oem_11ax_allow_bitmap;
	__le32 oem_unii4_allow_bitmap;
	__le32 chan_state_active_bitmap;
	__le32 force_disable_channels_bitmap;
	__le32 edt_bitmap;
	__le32 oem_320mhz_allow_bitmap;
} __packed;
/* LARI_CHANGE_CONF_CMD_S_VER_10 */

/* Activate UNII-1 (5.2GHz) for World Wide */
#define ACTIVATE_5G2_IN_WW_MASK	BIT(4)

+14 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ IWL_BIOS_TABLE_LOADER_DATA(tas_table, struct iwl_tas_data);
IWL_BIOS_TABLE_LOADER_DATA(pwr_limit, u64);
IWL_BIOS_TABLE_LOADER_DATA(mcc, char);
IWL_BIOS_TABLE_LOADER_DATA(eckv, u32);
IWL_BIOS_TABLE_LOADER_DATA(wbem, u32);


static const struct dmi_system_id dmi_ppag_approved_list[] = {
@@ -496,6 +497,9 @@ static size_t iwl_get_lari_config_cmd_size(u8 cmd_ver)
	size_t cmd_size;

	switch (cmd_ver) {
	case 10:
		cmd_size = sizeof(struct iwl_lari_config_change_cmd);
		break;
	case 9:
	case 8:
	case 7:
@@ -524,7 +528,7 @@ static size_t iwl_get_lari_config_cmd_size(u8 cmd_ver)
}

int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
			 struct iwl_lari_config_change_cmd_v7 *cmd,
			 struct iwl_lari_config_change_cmd *cmd,
			 size_t *cmd_size)
{
	int ret;
@@ -572,13 +576,18 @@ int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
	if (!ret)
		cmd->edt_bitmap = cpu_to_le32(value);

	ret = iwl_bios_get_wbem(fwrt, &value);
	if (!ret)
		cmd->oem_320mhz_allow_bitmap = cpu_to_le32(value);

	if (cmd->config_bitmap ||
	    cmd->oem_uhb_allow_bitmap ||
	    cmd->oem_11ax_allow_bitmap ||
	    cmd->oem_unii4_allow_bitmap ||
	    cmd->chan_state_active_bitmap ||
	    cmd->force_disable_channels_bitmap ||
	    cmd->edt_bitmap) {
	    cmd->edt_bitmap ||
	    cmd->oem_320mhz_allow_bitmap) {
		IWL_DEBUG_RADIO(fwrt,
				"sending LARI_CONFIG_CHANGE, config_bitmap=0x%x, oem_11ax_allow_bitmap=0x%x\n",
				le32_to_cpu(cmd->config_bitmap),
@@ -593,8 +602,9 @@ int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
				le32_to_cpu(cmd->oem_uhb_allow_bitmap),
				le32_to_cpu(cmd->force_disable_channels_bitmap));
		IWL_DEBUG_RADIO(fwrt,
				"sending LARI_CONFIG_CHANGE, edt_bitmap=0x%x\n",
				le32_to_cpu(cmd->edt_bitmap));
				"sending LARI_CONFIG_CHANGE, edt_bitmap=0x%x, oem_320mhz_allow_bitmap=0x%x\n",
				le32_to_cpu(cmd->edt_bitmap),
				le32_to_cpu(cmd->oem_320mhz_allow_bitmap));
	} else {
		return 1;
	}
+2 −1
Original line number Diff line number Diff line
@@ -201,9 +201,10 @@ int iwl_bios_get_pwr_limit(struct iwl_fw_runtime *fwrt,

int iwl_bios_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);
int iwl_bios_get_eckv(struct iwl_fw_runtime *fwrt, u32 *ext_clk);
int iwl_bios_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value);

int iwl_fill_lari_config(struct iwl_fw_runtime *fwrt,
			 struct iwl_lari_config_change_cmd_v7 *cmd,
			 struct iwl_lari_config_change_cmd *cmd,
			 size_t *cmd_size);

int iwl_bios_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
Loading