Commit 1843676a authored by Alon Giladi's avatar Alon Giladi Committed by Johannes Berg

wifi: iwlwifi: acpi: support modules with high antenna gain

Starting from version 4 of ANT_GAIN_CMD verification of ppag table
values is done by the FW. Driver has to send the complete table as
it appears in the BIOS. Make this change.
Signed-off-by: default avatarAlon Giladi <alon.giladi@intel.com>
Signed-off-by: default avatarGregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230413213309.a965365e2336.I1081f00ae309d9225d0529fa2da6ba7e34a8bd4f@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 8e5a2636
...@@ -1006,8 +1006,10 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt) ...@@ -1006,8 +1006,10 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
union acpi_object *wifi_pkg, *data, *flags; union acpi_object *wifi_pkg, *data, *flags;
int i, j, ret, tbl_rev, num_sub_bands = 0; int i, j, ret, tbl_rev, num_sub_bands = 0;
int idx = 2; int idx = 2;
u8 cmd_ver;
fwrt->ppag_flags = 0; fwrt->ppag_flags = 0;
fwrt->ppag_table_valid = false;
data = iwl_acpi_get_object(fwrt->dev, ACPI_PPAG_METHOD); data = iwl_acpi_get_object(fwrt->dev, ACPI_PPAG_METHOD);
if (IS_ERR(data)) if (IS_ERR(data))
...@@ -1054,8 +1056,15 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt) ...@@ -1054,8 +1056,15 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
} }
fwrt->ppag_flags = flags->integer.value & ACPI_PPAG_MASK; fwrt->ppag_flags = flags->integer.value & ACPI_PPAG_MASK;
cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
if (!fwrt->ppag_flags) { WIDE_ID(PHY_OPS_GROUP,
PER_PLATFORM_ANT_GAIN_CMD),
IWL_FW_CMD_VER_UNKNOWN);
if (cmd_ver == IWL_FW_CMD_VER_UNKNOWN) {
ret = -EINVAL;
goto out_free;
}
if (!fwrt->ppag_flags && cmd_ver <= 3) {
ret = 0; ret = 0;
goto out_free; goto out_free;
} }
...@@ -1076,21 +1085,22 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt) ...@@ -1076,21 +1085,22 @@ int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
} }
fwrt->ppag_chains[i].subbands[j] = ent->integer.value; fwrt->ppag_chains[i].subbands[j] = ent->integer.value;
/* from ver 4 the fw deals with out of range values */
if (cmd_ver >= 4)
continue;
if ((j == 0 && if ((j == 0 &&
(fwrt->ppag_chains[i].subbands[j] > ACPI_PPAG_MAX_LB || (fwrt->ppag_chains[i].subbands[j] > ACPI_PPAG_MAX_LB ||
fwrt->ppag_chains[i].subbands[j] < ACPI_PPAG_MIN_LB)) || fwrt->ppag_chains[i].subbands[j] < ACPI_PPAG_MIN_LB)) ||
(j != 0 && (j != 0 &&
(fwrt->ppag_chains[i].subbands[j] > ACPI_PPAG_MAX_HB || (fwrt->ppag_chains[i].subbands[j] > ACPI_PPAG_MAX_HB ||
fwrt->ppag_chains[i].subbands[j] < ACPI_PPAG_MIN_HB))) { fwrt->ppag_chains[i].subbands[j] < ACPI_PPAG_MIN_HB))) {
fwrt->ppag_flags = 0;
ret = -EINVAL; ret = -EINVAL;
goto out_free; goto out_free;
} }
} }
} }
fwrt->ppag_table_valid = true;
ret = 0; ret = 0;
out_free: out_free:
...@@ -1116,7 +1126,12 @@ int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *c ...@@ -1116,7 +1126,12 @@ int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *c
"PPAG capability not supported by FW, command not sent.\n"); "PPAG capability not supported by FW, command not sent.\n");
return -EINVAL; return -EINVAL;
} }
if (!fwrt->ppag_flags) {
cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
WIDE_ID(PHY_OPS_GROUP,
PER_PLATFORM_ANT_GAIN_CMD),
IWL_FW_CMD_VER_UNKNOWN);
if (!fwrt->ppag_table_valid || (cmd_ver <= 3 && !fwrt->ppag_flags)) {
IWL_DEBUG_RADIO(fwrt, "PPAG not enabled, command not sent.\n"); IWL_DEBUG_RADIO(fwrt, "PPAG not enabled, command not sent.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1125,9 +1140,7 @@ int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *c ...@@ -1125,9 +1140,7 @@ int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *c
* use v1 to access it. * use v1 to access it.
*/ */
cmd->v1.flags = cpu_to_le32(fwrt->ppag_flags); cmd->v1.flags = cpu_to_le32(fwrt->ppag_flags);
cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
WIDE_ID(PHY_OPS_GROUP, PER_PLATFORM_ANT_GAIN_CMD),
IWL_FW_CMD_VER_UNKNOWN);
if (cmd_ver == 1) { if (cmd_ver == 1) {
num_sub_bands = IWL_NUM_SUB_BANDS_V1; num_sub_bands = IWL_NUM_SUB_BANDS_V1;
gain = cmd->v1.gain[0]; gain = cmd->v1.gain[0];
...@@ -1138,7 +1151,7 @@ int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *c ...@@ -1138,7 +1151,7 @@ int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *c
fwrt->ppag_ver); fwrt->ppag_ver);
cmd->v1.flags &= cpu_to_le32(IWL_PPAG_ETSI_MASK); cmd->v1.flags &= cpu_to_le32(IWL_PPAG_ETSI_MASK);
} }
} else if (cmd_ver == 2 || cmd_ver == 3) { } else if (cmd_ver >= 2 && cmd_ver <= 4) {
num_sub_bands = IWL_NUM_SUB_BANDS_V2; num_sub_bands = IWL_NUM_SUB_BANDS_V2;
gain = cmd->v2.gain[0]; gain = cmd->v2.gain[0];
*cmd_size = sizeof(cmd->v2); *cmd_size = sizeof(cmd->v2);
......
...@@ -165,6 +165,7 @@ struct iwl_fw_runtime { ...@@ -165,6 +165,7 @@ struct iwl_fw_runtime {
struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS]; struct iwl_ppag_chain ppag_chains[IWL_NUM_CHAIN_LIMITS];
u32 ppag_flags; u32 ppag_flags;
u32 ppag_ver; u32 ppag_ver;
bool ppag_table_valid;
struct iwl_sar_offset_mapping_cmd sgom_table; struct iwl_sar_offset_mapping_cmd sgom_table;
bool sgom_enabled; bool sgom_enabled;
u8 reduced_power_flags; u8 reduced_power_flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment