Commit 669761e8 authored by Miri Korenblit's avatar Miri Korenblit Committed by Johannes Berg
Browse files

wifi: iwlwifi: read WRDD table from UEFI



Try to read the WRDD 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_mcc() 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.

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.5d52eeb109f7.I4d81700a7ae7fe2dfee14e363de358be59de7823@changeid


Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 4dde4ff0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -326,17 +326,18 @@ int iwl_acpi_get_tas_table(struct iwl_fw_runtime *fwrt,
	return ret;
}

int iwl_acpi_get_mcc(struct device *dev, char *mcc)
int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
{
	union acpi_object *wifi_pkg, *data;
	u32 mcc_val;
	int ret, tbl_rev;

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

	wifi_pkg = iwl_acpi_get_wifi_pkg(dev, data, ACPI_WRDD_WIFI_DATA_SIZE,
	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
					 ACPI_WRDD_WIFI_DATA_SIZE,
					 &tbl_rev);
	if (IS_ERR(wifi_pkg)) {
		ret = PTR_ERR(wifi_pkg);
@@ -360,7 +361,6 @@ int iwl_acpi_get_mcc(struct device *dev, char *mcc)
	kfree(data);
	return ret;
}
IWL_EXPORT_SYMBOL(iwl_acpi_get_mcc);

int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit)
{
+3 −3
Original line number Diff line number Diff line
@@ -149,12 +149,12 @@ int iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func,
/**
 * iwl_acpi_get_mcc - read MCC from ACPI, if available
 *
 * @dev: the struct device
 * @fwrt: the fw runtime struct
 * @mcc: output buffer (3 bytes) that will get the MCC
 *
 * This function tries to read the current MCC from ACPI if available.
 */
int iwl_acpi_get_mcc(struct device *dev, char *mcc);
int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc);

int iwl_acpi_get_pwr_limit(struct iwl_fw_runtime *fwrt, u64 *dflt_pwr_limit);

@@ -207,7 +207,7 @@ static inline int iwl_acpi_get_dsm_u32(struct device *dev, int rev, int func,
	return -ENOENT;
}

static inline int iwl_acpi_get_mcc(struct device *dev, char *mcc)
static inline int iwl_acpi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
{
	return -ENOENT;
}
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ IWL_BIOS_TABLE_LOADER(wgds_table);
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);


static const struct dmi_system_id dmi_ppag_approved_list[] = {
+2 −0
Original line number Diff line number Diff line
@@ -139,4 +139,6 @@ int iwl_bios_get_tas_table(struct iwl_fw_runtime *fwrt,

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);
#endif /* __fw_regulatory_h__ */
+31 −0
Original line number Diff line number Diff line
@@ -621,3 +621,34 @@ int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
	kfree(data);
	return ret;
}

int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
{
	struct uefi_cnv_var_wrdd *data;
	int ret = 0;

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

	if (data->revision != IWL_UEFI_WRDD_REVISION) {
		ret = -EINVAL;
		IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WRDD revision:%d\n",
				data->revision);
		goto out;
	}

	if (data->mcc != UEFI_MCC_CHINA) {
		ret = -EINVAL;
		IWL_DEBUG_RADIO(fwrt, "UEFI WRDD is supported only for CN\n");
		goto out;
	}

	mcc[0] = (data->mcc >> 8) & 0xff;
	mcc[1] = data->mcc & 0xff;
	mcc[2] = '\0';
out:
	kfree(data);
	return ret;
}
Loading