Attention is currently required from: Lance Zhao, Tim Wawrzynczak. Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/55027 )
Change subject: acpi/device: Add ability to generate proper _STA for PowerResource ......................................................................
acpi/device: Add ability to generate proper _STA for PowerResource
acpi_device_add_power_res currently generates a `_STA` method hardcoded to ON. This change enables the ability to generate a `_STA` method that queries the status of the GPIOs to determine if the power resource is ON or OFF.
The acpigen_write_power_res_STA method was copied from soc/intel/common/block/pcie/rtd3.c:pcie_rtd3_acpi_method_status. I also added support for checking the stop_gpio.
BUG=b:184617186 TEST=Dump SSDT table for guybrush
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: I91410556db002c620fd9aaa99981457808da93a5 --- M src/acpi/device.c M src/include/acpi/acpi_device.h 2 files changed, 40 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/27/55027/1
diff --git a/src/acpi/device.c b/src/acpi/device.c index 5d4d9be..dfbab3e 100644 --- a/src/acpi/device.c +++ b/src/acpi/device.c @@ -598,6 +598,35 @@ acpi_device_fill_len(desc_length); }
+static void acpigen_write_power_res_STA(const struct acpi_power_res_params *params) +{ + const struct acpi_gpio *gpio; + + acpigen_write_method("_STA", 0); + + /* Use enable GPIO for status if provided, otherwise reset GPIO, and finally stop */ + if (params->enable_gpio->pin_count) + gpio = params->enable_gpio; + else if (params->reset_gpio->pin_count) + gpio = params->reset_gpio; + else + gpio = params->stop_gpio; + + /* Read current GPIO value into Local0. */ + acpigen_get_tx_gpio(gpio); + + /* Ensure check works for both active low and active high GPIOs. */ + acpigen_write_store_int_to_op(gpio->active_low, LOCAL1_OP); + + acpigen_write_if_lequal_op_op(LOCAL0_OP, LOCAL1_OP); + acpigen_write_return_op(ZERO_OP); + acpigen_write_else(); + acpigen_write_return_op(ONE_OP); + acpigen_pop_len(); /* Else */ + + acpigen_pop_len(); /* Method */ +} + /* PowerResource() with Enable and/or Reset control */ void acpi_device_add_power_res(const struct acpi_power_res_params *params) { @@ -613,8 +642,12 @@ acpigen_write_power_res("PRIC", 0, 0, power_res_dev_states, ARRAY_SIZE(power_res_dev_states));
- /* Method (_STA, 0, NotSerialized) { Return (0x1) } */ - acpigen_write_STA(0x1); + if (params->enable_status) { + acpigen_write_power_res_STA(params); + } else { + /* Method (_STA, 0, NotSerialized) { Return (0x1) } */ + acpigen_write_STA(0x1); + }
/* Method (_ON, 0, Serialized) */ acpigen_write_method_serialized("_ON", 0); diff --git a/src/include/acpi/acpi_device.h b/src/include/acpi/acpi_device.h index 301f9b0..da936aa 100644 --- a/src/include/acpi/acpi_device.h +++ b/src/include/acpi/acpi_device.h @@ -456,6 +456,11 @@ * (_OFF method delay) */ unsigned int stop_off_delay_ms; + + /* Write a _STA method that checks the state of the GPIOs. Otherwise + * the _STA method will always return _ON. + */ + bool enable_status; };
/*