From 3d4665cc71229d0d404035217b6796adc94c9567 Mon Sep 17 00:00:00 2001 From: Tim Van Patten Date: Wed, 13 Apr 2022 11:53:20 -0600 Subject: src/acpi/device: Early return in _ON if device already enabled If the device has enabled `use_gpio_for_status`, then call the `_STA` method in `_ON` to determine if the device is already enabled. If it is already enabled, return early to skip re-enabling the device and performing the associated sleep. This change is necessary since the Linux kernel does not call `_STA` before calling `_ON`. BRANCH=None BUG=b:225022810 TEST=Dump SSDT table for guybrush Signed-off-by: Tim Van Patten Change-Id: I13aa41766555953b86eded4c72e3b317fe6db5c8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63613 Reviewed-by: Raul Rangel Tested-by: build bot (Jenkins) --- src/acpi/device.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/acpi/device.c b/src/acpi/device.c index 1df179bad6..2b085b61a6 100644 --- a/src/acpi/device.c +++ b/src/acpi/device.c @@ -670,6 +670,19 @@ void acpi_device_add_power_res(const struct acpi_power_res_params *params) /* Method (_ON, 0, Serialized) */ acpigen_write_method_serialized("_ON", 0); + /* Call _STA and early return if the device is already enabled, since the Linux + kernel doesn't check the device status before calling _ON. This avoids + unnecessary delays while booting. */ + if (params->use_gpio_for_status) { + /* Local0 = _STA () */ + acpigen_write_store(); + acpigen_emit_namestring("_STA"); + acpigen_emit_byte(LOCAL0_OP); + /* If (( Local0 == ACPI_POWER_RESOURCE_STATUS_ON_OP)) */ + acpigen_write_if_lequal_op_op(LOCAL0_OP, ACPI_POWER_RESOURCE_STATUS_ON_OP); + acpigen_write_return_op(ZERO_OP); + acpigen_write_if_end(); + } if (reset_gpio) acpigen_enable_tx_gpio(params->reset_gpio); if (enable_gpio) { -- cgit v1.2.3