/* SPDX-License-Identifier: GPL-2.0-or-later */ #include #include #include #include #define LPI_S0_HELPER_UUID "c4eb40a0-6cd2-11e2-bcfd-0800200c9a66" #define SYSTEM_POWER_MANAGEMENT_HID "INT33A1" #define SYSTEM_POWER_MANAGEMENT_CID "PNP0D80" #define EC_S0IX_HOOK "\\_SB.PCI0.LPCB.EC0.S0IX" #define MAINBOARD_HOOK "\\_SB.MS0X" #define ENABLE_PM_BITS_HOOK "\\_SB.PCI0.EGPM" #define RESTORE_PM_BITS_HOOK "\\_SB.PCI0.RGPM" #define LPI_STATES_ALL 0xff #define MIN_DEVICE_STATE ACPI_DEVICE_SLEEP_D0 #define PEPD_SCOPE "\\_SB.PCI0" /* * For now there is only one disabled non-existent device, because Windows * expects at least one device and crashes without it with a bluescreen * (`INTERNAL_POWER_ERROR`). Returning an empty package does not work. */ static void lpi_get_constraints(void *unused) { /* * Return (Package() { * Package() { "\NULL", 0, * Package() { 0, * Package() { 0xff, 0 }}}}) */ acpigen_emit_byte(RETURN_OP); acpigen_write_package(1); { acpigen_write_package(3); { acpigen_emit_namestring("\\NULL"); acpigen_write_integer(0); /* device disabled */ acpigen_write_package(2); { acpigen_write_integer(0); /* revision */ acpigen_write_package(2); { acpigen_write_integer(LPI_STATES_ALL); acpigen_write_integer(MIN_DEVICE_STATE); } acpigen_write_package_end(); } acpigen_write_package_end(); } acpigen_write_package_end(); } acpigen_write_package_end(); } static void lpi_s0ix_entry(void *unused) { /* Inform the EC */ acpigen_write_if_cond_ref_of(EC_S0IX_HOOK); acpigen_emit_namestring(EC_S0IX_HOOK); acpigen_write_integer(1); acpigen_write_if_end(); /* Provide a board level S0ix hook */ acpigen_write_if_cond_ref_of(MAINBOARD_HOOK); acpigen_emit_namestring(MAINBOARD_HOOK); acpigen_write_integer(1); acpigen_write_if_end(); /* Save the current PM bits then enable GPIO PM with MISCCFG_GPIO_PM_CONFIG_BITS */ acpigen_write_if_cond_ref_of(ENABLE_PM_BITS_HOOK); acpigen_emit_namestring(ENABLE_PM_BITS_HOOK); acpigen_write_if_end(); } static void lpi_s0ix_exit(void *unused) { /* Inform the EC */ acpigen_write_if_cond_ref_of(EC_S0IX_HOOK); acpigen_emit_namestring(EC_S0IX_HOOK); acpigen_write_integer(0); acpigen_write_if_end(); /* Provide a board level S0ix hook */ acpigen_write_if_cond_ref_of(MAINBOARD_HOOK); acpigen_emit_namestring(MAINBOARD_HOOK); acpigen_write_integer(0); acpigen_write_if_end(); /* Restore GPIO all Community PM */ acpigen_write_if_cond_ref_of(RESTORE_PM_BITS_HOOK); acpigen_emit_namestring(RESTORE_PM_BITS_HOOK); acpigen_write_if_end(); } static void (*lpi_s0_helpers[])(void *) = { NULL, /* enumerate functions (autogenerated) */ lpi_get_constraints, /* get device constraints */ NULL, /* get crash dump device */ NULL, /* display off notify */ NULL, /* display on notify */ lpi_s0ix_entry, /* s0ix entry */ lpi_s0ix_exit, /* s0ix exit */ }; void generate_acpi_power_engine(void) { acpigen_write_scope(PEPD_SCOPE); acpigen_write_device("PEPD"); acpigen_write_name_string("_HID", SYSTEM_POWER_MANAGEMENT_HID); acpigen_write_name("_CID"); acpigen_emit_eisaid(SYSTEM_POWER_MANAGEMENT_CID); acpigen_write_dsm(LPI_S0_HELPER_UUID, lpi_s0_helpers, ARRAY_SIZE(lpi_s0_helpers), NULL); acpigen_write_device_end(); acpigen_write_scope_end(); printk(BIOS_INFO, PEPD_SCOPE ".PEPD: Intel Power Engine Plug-in\n"); }