Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37640 )
Change subject: superio/common: Add more ACPI methods ......................................................................
superio/common: Add more ACPI methods
* Make use of introduced SSDT config mode access. * Provide ACPI functions to safely access SIO config space * Use introduced functions to implement _DIS and _STA in the device
Change-Id: I520b29de925f368cd71ff8f1f58d2d57d72eff8d Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/superio/common/generic.c M src/superio/common/ssdt.c 2 files changed, 104 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/40/37640/1
diff --git a/src/superio/common/generic.c b/src/superio/common/generic.c index 429ee51..2e5bf88 100644 --- a/src/superio/common/generic.c +++ b/src/superio/common/generic.c @@ -153,6 +153,85 @@ acpigen_write_indexfield("INDX", "DATA", i, ARRAY_SIZE(i), FIELD_BYTEACC | FIELD_NOLOCK | FIELD_PRESERVE);
+ const char *mutex = "MTX0"; + + acpigen_write_mutex(mutex, 0); + /* Backup LDN */ + acpigen_write_name_integer("BLDN", 0); + + /* Acquire mutex - Enter config mode */ + acpigen_write_method("AMTX", 1); + { + acpigen_write_acquire(mutex, 0xffff); + + pnp_ssdt_enter_conf_mode(dev, "^INDX", "^DATA"); + + /* Backup LDN */ + acpigen_write_store(); + acpigen_emit_namestring("^LDN"); + acpigen_emit_namestring("^BLDN"); + } + acpigen_pop_len(); /* Method */ + + /* Release mutex - Exit config mode */ + acpigen_write_method("RMTX", 1); + { + /* Restore LDN */ + acpigen_write_store(); + acpigen_emit_namestring("^BLDN"); + acpigen_emit_namestring("^LDN"); + + pnp_ssdt_exit_conf_mode(dev, "^INDX", "^DATA"); + + acpigen_write_release(mutex); + } + acpigen_pop_len(); /* Method */ + + /* Select a LDN */ + acpigen_write_method("SLDN", 1); + { + acpigen_write_store(); + acpigen_emit_byte(ARG0_OP); + acpigen_emit_namestring("^LDN"); + } + acpigen_pop_len(); /* Method */ + + /* Disable a LDN */ + acpigen_write_method("DLDN", 1); + { + acpigen_emit_namestring("AMTX"); + + acpigen_emit_namestring("SLDN"); + acpigen_emit_byte(ARG0_OP); + + acpigen_write_store(); + acpigen_emit_byte(ZERO_OP); + acpigen_emit_namestring("^ACTR"); + + acpigen_emit_namestring("RMTX"); + } + acpigen_pop_len(); /* Method */ + + /* Query LDN enable state. Returns 1 if LDN is enabled. */ + acpigen_write_method("QLDN", 1); + { + acpigen_emit_namestring("AMTX"); + + acpigen_emit_namestring("SLDN"); + acpigen_emit_byte(ARG0_OP); + + acpigen_write_store(); + acpigen_emit_namestring("^ACTR"); + acpigen_emit_byte(LOCAL0_OP); + + acpigen_write_and(LOCAL0_OP, ONE_OP, LOCAL0_OP); + + acpigen_emit_namestring("RMTX"); + + acpigen_write_return_byte(LOCAL0_OP); + } + acpigen_pop_len(); /* Method */ + acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ } diff --git a/src/superio/common/ssdt.c b/src/superio/common/ssdt.c index a919aa5..bc5d394 100644 --- a/src/superio/common/ssdt.c +++ b/src/superio/common/ssdt.c @@ -200,7 +200,24 @@ acpigen_write_name_byte("LDN", ldn); acpigen_write_name_byte("VLDN", vldn);
- acpigen_write_STA(dev->enabled ? 0xf : 0); + acpigen_write_method("_STA", 0); + { + acpigen_write_store(); + acpigen_emit_namestring("^^QLDN"); + acpigen_write_integer(ldn); + acpigen_emit_byte(LOCAL0_OP); + + /* Multiply (Local0, 0xf, Local0) */ + acpigen_emit_byte(MULTIPLY_OP); + acpigen_emit_byte(LOCAL0_OP); + acpigen_write_integer(0xf); + acpigen_emit_byte(LOCAL0_OP); + + acpigen_emit_byte(RETURN_OP); + acpigen_emit_byte(LOCAL0_OP); + + } + acpigen_pop_len(); /* Method */
if (!dev->enabled) { acpigen_pop_len(); /* Device */ @@ -242,6 +259,13 @@ acpigen_write_name_string("_HID", hid); acpigen_write_name_string("_DDN", name_from_hid(hid));
+ acpigen_write_method("_DIS", 0); + { + acpigen_emit_namestring("^^DLDN"); + acpigen_write_integer(ldn); + } + acpigen_pop_len(); /* Method */ + acpigen_pop_len(); /* Device */ acpigen_pop_len(); /* Scope */ }