Attention is currently required from: Ravindra N. Hello Ravindra N,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/56249
to review the following change.
Change subject: brya: DSM setting enablement for Intel WLAN card ......................................................................
brya: DSM setting enablement for Intel WLAN card
To support worldwide regulatory WLAN feature(Indonesia AX / Ukraine AX / Russia AX), Intel WLAN card has to set DSM setting to meet the regulatory requirement which allows to modify the settings.
BUG=none TEST=Generate SSDT tables and verify the required settings applied
Change-Id: I22411ca8648e89397a2c8dab6ed9041f47c664b8 Signed-off-by: Ravindra N ravindra@intel.corp-partner.google.com --- M src/drivers/wifi/generic/acpi.c M src/mainboard/google/brya/variants/brya0/overridetree.cb 2 files changed, 153 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/56249/1
diff --git a/src/drivers/wifi/generic/acpi.c b/src/drivers/wifi/generic/acpi.c index 3e3b5c1..46d9a42 100644 --- a/src/drivers/wifi/generic/acpi.c +++ b/src/drivers/wifi/generic/acpi.c @@ -7,6 +7,7 @@ #include <device/pci_ids.h> #include <sar.h> #include <wrdd.h> +#include <include/fw_config.h>
#include "chip.h" #include "wifi_private.h" @@ -34,6 +35,143 @@ */ #define WIFI_ACPI_NAME_MAX_LEN 5
+/* Unique ID for the WIFI _DSM. */ +#define ACPI_DSM_OEM_WIFI_UUID "F21202BF-8F78-4DC6-A5B3-1F738E285ADE" + +/* + * Generate ACPI AML code for _DSM method. + * This function takes as input uuid for the device, set of callbacks and + * argument to pass into the callbacks. Callbacks should ensure that Local0 and + * Local1 are left untouched. Use of Local2-Local7 is permitted in callbacks. + */ +void wifi_write_dsm(const char *uuid, void (**callbacks)(void *), + size_t count, void *arg); +void wifi_write_dsm_uuid_arr(struct dsm_uuid *ids, size_t count); +static void wifi_write_dsm_uuid(struct dsm_uuid *id); + +/* + * Function 2 : Supported Indonesia 5.15-5.35 GHz Band + * 00 - Set 5.115-5.35GHz to Disable in Indonesia + * 01 - Set 5.115-5.35GHz to Enable (Passive) in Indonesia + * 02 - Reserved + */ +static void wifi_dsm_indonasia_5Ghz_band_enable(void *arg) +{ + bool band_5ghz_enabled = fw_config_probe(FW_CONFIG(WIFI_INDONESIA_5GHZ_CONFIG, + BAND_5GHZ_ENABLE)); + acpigen_write_to_integer(band_5ghz_enabled, LOCAL0_OP); + acpigen_write_if_lequal_op_int(LOCAL0_OP, 1); + acpigen_write_return_integer(1); + acpigen_write_else(); + acpigen_write_return_integer(0); + acpigen_pop_len(); +} + +/* + * Function 6: 11Ax Control + * Bit 0 - Apply changes to country Ukraine. 11Ax Setting within + * module certification + * 0 - None. Work with Wi-Fi FW/OTP definitions [Default] + * 1 - Apply changes. + * + * Bit 1 - 11Ax Mode. Effective only if Bit 0 set to 1 + * 0 - Disable 11Ax on country Ukraine [Default] + * 1 - Enable 11Ax on country Ukraine + * + * Bit 2 - Apply changes to country Russia. 11Ax Setting within + * module certification + * 0 - None. Work with Wi-Fi FW/OTP definitions [Default] + * 1 - Apply changes. + * + * Bit 3 - 11Ax Mode. Effective only if Bit 2 set to 1 + * 0 - Disable 11Ax on country Russia [Default] + * 1 - Enable 11Ax on country Russia + * + * Bit 31:04 - Reserved + * + */ +static void wifi_dsm_ukrane_russia_11ax_enable(void *arg) +{ + bool dsm_11ax_enabled = fw_config_probe(FW_CONFIG(WIFI_OTP_DEF, + UKR_RUS_OTP_11AX_DEFAULT)); + acpigen_write_to_integer(dsm_11ax_enabled, LOCAL0_OP); + acpigen_write_if_lequal_op_int(LOCAL0_OP, 1); + acpigen_write_return_singleton_buffer(0x0000); + acpigen_pop_len(); + dsm_11ax_enabled = fw_config_probe(FW_CONFIG(WIFI_OTP_DEF, + UKR_OTP_ENB_11AX_ENB)); + acpigen_write_to_integer(dsm_11ax_enabled, LOCAL0_OP); + acpigen_write_if_lequal_op_int(LOCAL0_OP, 1); + acpigen_write_return_singleton_buffer(0x0011); + acpigen_pop_len(); + dsm_11ax_enabled = fw_config_probe(FW_CONFIG(WIFI_OTP_DEF, + UKR_OTP_ENB_11AX_DIS)); + acpigen_write_to_integer(dsm_11ax_enabled, LOCAL0_OP); + acpigen_write_if_lequal_op_int(LOCAL0_OP, 1); + acpigen_write_return_singleton_buffer(0x0010); + acpigen_pop_len(); +} + +static void (*wifi_dsm_callbacks[])(void *) = { + NULL, /* Function 0 */ + NULL, /* Function 1 */ + wifi_dsm_indonasia_5Ghz_band_enable, /* Function 2 */ + NULL, /* Function 3 */ + NULL, /* Function 4 */ + NULL, /* Function 5 */ + wifi_dsm_ukrane_russia_11ax_enable, /* Function 6 */ +}; + +void wifi_write_dsm(const char *uuid, void (**callbacks)(void *), + size_t count, void *arg) +{ + struct dsm_uuid id = DSM_UUID(uuid, callbacks, count, arg); + wifi_write_dsm_uuid_arr(&id, 1); +} + +static void wifi_write_dsm_uuid(struct dsm_uuid *id) +{ + size_t i; + + /* If (LEqual (Local0, ToUUID(uuid))) */ + acpigen_write_if(); + acpigen_emit_byte(LEQUAL_OP); + acpigen_emit_byte(LOCAL0_OP); + acpigen_write_uuid(id->uuid); + + /* ToInteger (Arg2, Local1) */ + acpigen_write_to_integer(ARG2_OP, LOCAL1_OP); + + for (i = 0; i < id->count; i++) { + /* If (LEqual (Local1, i)) */ + acpigen_write_if_lequal_op_int(LOCAL1_OP, i); + + /* Callback to write if handler. */ + if (id->callbacks[i]) + id->callbacks[i](id->arg); + + acpigen_pop_len(); /* If */ + } + + acpigen_pop_len(); /* If (LEqual (Local0, ToUUID(uuid))) */ +} + +void wifi_write_dsm_uuid_arr(struct dsm_uuid *ids, size_t count) +{ + size_t i; + + /* Method (_DSM, 4, Serialized) */ + acpigen_write_method_serialized("_DSM", 0x4) + + /* ToBuffer (Arg0, Local0) */ + acpigen_write_to_buffer(ARG0_OP, LOCAL0_OP); + + for (i = 0; i < count; i++) + wifi_write_dsm_uuid(&ids[i]); + + acpigen_pop_len(); /* Method _DSM */ +} + __weak int get_wifi_sar_limits(struct wifi_sar_limits *sar_limits) { return -1; @@ -183,10 +321,15 @@ static void wifi_ssdt_write_properties(const struct device *dev, const char *scope) { const struct drivers_wifi_generic_config *config = dev->chip_info; - /* Scope */ acpigen_write_scope(scope);
+ /* Call Wifi DSM method */ + wifi_write_dsm(ACPI_DSM_OEM_WIFI_UUID, + wifi_dsm_callbacks, + ARRAY_SIZE(wifi_dsm_callbacks), + NULL); + /* Wake capabilities */ if (config) acpigen_write_PRW(config->wake, ACPI_S3); diff --git a/src/mainboard/google/brya/variants/brya0/overridetree.cb b/src/mainboard/google/brya/variants/brya0/overridetree.cb index d4653bc..25590d7 100644 --- a/src/mainboard/google/brya/variants/brya0/overridetree.cb +++ b/src/mainboard/google/brya/variants/brya0/overridetree.cb @@ -27,6 +27,15 @@ option UFC_USB 0 option UFC_MIPI_5675 1 end + field WIFI_INDONESIA_5GHZ_CONFIG 15 + option BAND_5GHZ_DISABLE 0 + option BAND_5GHZ_ENABLE 1 + end + field WIFI_OTP_DEF 16 17 + option UKR_RUS_OTP_11AX_DEFAULT 0 + option UKR_OTP_ENB_11AX_ENB 1 + option UKR_OTP_ENB_11AX_DIS 2 + end end
chip soc/intel/alderlake