Commit 20935f3e authored by Miri Korenblit's avatar Miri Korenblit Committed by Johannes Berg
Browse files

wifi: iwlwifi: read ECKV table from UEFI



Try to read the ECKV table from UEFI first,
and if the WIFI UEFI tables are unlocked or the
table doesn't exist - try to read it from ACPI.

Change iwl_acpi_get_eckv() to receive fwrt as argument so
it will be the same as all iwl_acpi_get_x() functions,
so it could  be generated by the macro.

While at it - move the reading of ECKV to INIT stage. There is no
reason to read it each time we load the FW.

Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Reviewed-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://msgid.link/20240201155157.d4937cc00727.I36e5fc7f7850229b9b377c80b5203aa47137c97c@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 669761e8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -386,16 +386,17 @@ int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit)
	return ret;
}

int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk)
int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
{
	union acpi_object *wifi_pkg, *data;
	int ret, tbl_rev;

	data = iwl_acpi_get_object(dev, ACPI_ECKV_METHOD);
	data = iwl_acpi_get_object(fwrt->dev, ACPI_ECKV_METHOD);
	if (IS_ERR(data))
		return PTR_ERR(data);

	wifi_pkg = iwl_acpi_get_wifi_pkg(dev, data, ACPI_ECKV_WIFI_DATA_SIZE,
	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
					 ACPI_ECKV_WIFI_DATA_SIZE,
					 &tbl_rev);
	if (IS_ERR(wifi_pkg)) {
		ret = PTR_ERR(wifi_pkg);
@@ -416,7 +417,6 @@ int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk)
	kfree(data);
	return ret;
}
IWL_EXPORT_SYMBOL(iwl_acpi_get_eckv);

static int iwl_acpi_sar_set_profile(union acpi_object *table,
				    struct iwl_sar_profile *profile,
+3 −3
Original line number Diff line number Diff line
@@ -161,13 +161,13 @@ int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit);
/*
 * iwl_acpi_get_eckv - read external clock validation from ACPI, if available
 *
 * @dev: the struct device
 * @fwrt: the fw runtime struct
 * @extl_clk: output var (2 bytes) that will get the clk indication.
 *
 * This function tries to read the external clock indication
 * from ACPI if available.
 */
int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk);
int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk);

int iwl_acpi_get_wrds_table(struct iwl_fw_runtime *fwrt);

@@ -219,7 +219,7 @@ static inline int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
	return 0;
}

static inline int iwl_acpi_get_eckv(struct device *dev, u32 *extl_clk)
static inline int iwl_acpi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
{
	return -ENOENT;
}
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ IWL_BIOS_TABLE_LOADER(ppag_table);
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);


static const struct dmi_system_id dmi_ppag_approved_list[] = {
+1 −0
Original line number Diff line number Diff line
@@ -141,4 +141,5 @@ int iwl_bios_get_pwr_limit(struct iwl_fw_runtime *fwrt,
			   u64 *dflt_pwr_limit);

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);
#endif /* __fw_regulatory_h__ */
+22 −0
Original line number Diff line number Diff line
@@ -652,3 +652,25 @@ int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
	kfree(data);
	return ret;
}

int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
{
	struct uefi_cnv_var_eckv *data;
	int ret = 0;

	data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_ECKV_NAME,
					      "ECKV", sizeof(*data), NULL);
	if (IS_ERR(data))
		return -EINVAL;

	if (data->revision != IWL_UEFI_ECKV_REVISION) {
		ret = -EINVAL;
		IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WRDD revision:%d\n",
				data->revision);
		goto out;
	}
	*extl_clk = data->ext_clock_valid;
out:
	kfree(data);
	return ret;
}
Loading