summaryrefslogtreecommitdiff
path: root/src/acpi
diff options
context:
space:
mode:
authorTim Van Patten <timvp@google.com>2022-04-13 11:53:20 -0600
committerFelix Held <felix-coreboot@felixheld.de>2022-04-14 22:30:05 +0000
commit3d4665cc71229d0d404035217b6796adc94c9567 (patch)
tree59f07e2ea55ea8c2bed06a81bff0354096d8bb10 /src/acpi
parente9667f4df146ec82511975175fb03287afde4296 (diff)
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 <timvp@google.com> Change-Id: I13aa41766555953b86eded4c72e3b317fe6db5c8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63613 Reviewed-by: Raul Rangel <rrangel@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/acpi')
-rw-r--r--src/acpi/device.c13
1 files changed, 13 insertions, 0 deletions
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) {