mirror of
https://github.com/torvalds/linux.git
synced 2024-12-19 01:23:20 +00:00
793582ff47
- Update the ACPICA code in the kernel to upstream revision 20230331 including the following changes: * Delete bogus node_array array of pointers from AEST table (Jessica Clarke). * Add support for trace buffer extension in GICC to the ACPI MADT parser (Xiongfeng Wang). * Add missing macro ACPI_FUNCTION_TRACE() for acpi_ns_repair_HID() (Xiongfeng Wang). * Add missing tables to astable (Pedro Falcato). * Add support for 64 bit loong_arch compilation to ACPICA (Huacai Chen). * Add support for ASPT table in disassembler to ACPICA (Jeremi Piotrowski). * Add support for Arm's MPAM ACPI table version 2 (Hesham Almatary). * Update all copyrights/signons in ACPICA to 2023 (Bob Moore). * Add support for ClockInput resource (v6.5) (Niyas Sait). * Add RISC-V INTC interrupt controller definition to the list of supported interrupt controllers for MADT (Sunil V L). * Add structure definitions for the RISC-V RHCT ACPI table (Sunil V L). * Address several cases in which the ACPICA code might lead to undefined behavior (Tamir Duberstein). * Make ACPICA code support flexible arrays properly (Kees Cook). * Check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects() (void0red). * Add os specific support for Zephyr RTOS to ACPICA (Najumon). * Update version to 20230331 (Bob Moore). - Fix evaluating the _PDC ACPI control method when running as Xen dom0 (Roger Pau Monne). - Use platform devices to load ACPI PPC and PCC drivers (Petr Pavlu). - Check for null return of devm_kzalloc() in fch_misc_setup() (Kang Chen). - Log a message if enable_irq_wake() fails for the ACPI SCI (Simon Gaiser). - Initialize the correct IOMMU fwspec while parsing ACPI VIOT (Jean-Philippe Brucker). - Amend indentation and prefix error messages with FW_BUG in the ACPI SPCR parsing code (Andy Shevchenko). - Enable ACPI sysfs support for CCEL records (Kuppuswamy Sathyanarayanan). - Make the APEI error injection code warn on invalid arguments when explicitly indicated by platform (Shuai Xue). - Add CXL error types to the error injection code in APEI (Tony Luck). - Refactor acpi_data_prop_read_single() (Andy Shevchenko). - Fix two issues in the ACPI SBS driver (Armin Wolf). - Replace ternary operator with min_t() in the generic ACPI thermal zone driver (Jiangshan Yi). - Ensure that ACPI notify handlers are not running after removal and clean up code in acpi_sb_notify() (Rafael Wysocki). - Remove register_backlight_delay module option and code and remove quirks for false-positive backlight control support advertised on desktop boards (Hans de Goede). - Replace irqdomain.h include with struct declarations in ACPI headers and update several pieces of code previously including of.h implicitly through those headers (Rob Herring). - Fix acpi_evaluate_dsm_typed() redefinition error (Kiran K). - Update the pm_profile sysfs attribute documentation (Rafael Wysocki). - Add 80862289 ACPI _HID for second PWM controller on Cherry Trail to the ACPI driver for Intel SoCs (Hans de Goede). -----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAmRGvLQSHHJqd0Byand5 c29ja2kubmV0AAoJEILEb/54YlRxoV4P/jxWGAdldtgXORR58lKGbSs6lx/0Y+SF iI7qK88NcbcbWS+a3PqRrisNkjN17rjzajfp28Ue2CXFxzwTViyw6KYELbPJ6N/h /3prem++jKgf7qiueDJG/AyO8N2+Z+yciubhxdMiK1+c1dZM2ycwSyBzJgYocpXn fH+YFPhxE7c8Z8doBrTOZjRuU4SIEKCmxo3c5BbCuyVZkbqCRdQMIDCiBJgLTmbo z4pu9OFhAamB8Cth2QFfRbZWqmuY71Gt54+c4ITPPV2ALlLUYODyHZoSISBJULp3 k0lU/hMCD+i1WRwv+Bb6of7pJPM4Lqp+wOirAtiiibjE9LRxVTNyOUAHLXbx+t2V PN8JKVJVCLaZO6TRELgFIL4nh4aBdOtr4BuaLnClZho9bG68jEkc8grnOZYhFYtM 66BuJBW30rwwGY4N5VSZGzFFR7l2qaHIOSHdq681bxQ3e6erFEeIc5jQVEOKgCqd XWdELVkqf3CnCX0lgonj+AgoeCqOpYdrNcWqMsJ+6OyQRoFhLFltDSPeJm9gHGO7 X+qCQru4ZgEDKexWKpGgH9x8AllDKbh/ApyyumXgsQOsRocVdoNaf+yCBlaaDyqu UYif6hgFYnIxF2Fg1r/POgHDXFobE4iUTHcUU1V2QhuByc4PkN9ljKsHeC2FgVUz JityWRiMABNv =O61K -----END PGP SIGNATURE----- Merge tag 'acpi-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull ACPI updates from Rafael Wysocki: "These update the ACPICA code in the kernel to upstream revision 20230331, fix the ACPI SBS driver and the evaluation of the _PDC method on Xen dom0 in the ACPI processor driver, update the ACPI driver for Intel SoCs and clean up code in multiple places. Specifics: - Update the ACPICA code in the kernel to upstream revision 20230331 including the following changes: * Delete bogus node_array array of pointers from AEST table (Jessica Clarke) * Add support for trace buffer extension in GICC to the ACPI MADT parser (Xiongfeng Wang) * Add missing macro ACPI_FUNCTION_TRACE() for acpi_ns_repair_HID() (Xiongfeng Wang) * Add missing tables to astable (Pedro Falcato) * Add support for 64 bit loong_arch compilation to ACPICA (Huacai Chen) * Add support for ASPT table in disassembler to ACPICA (Jeremi Piotrowski) * Add support for Arm's MPAM ACPI table version 2 (Hesham Almatary) * Update all copyrights/signons in ACPICA to 2023 (Bob Moore) * Add support for ClockInput resource (v6.5) (Niyas Sait) * Add RISC-V INTC interrupt controller definition to the list of supported interrupt controllers for MADT (Sunil V L) * Add structure definitions for the RISC-V RHCT ACPI table (Sunil V L) * Address several cases in which the ACPICA code might lead to undefined behavior (Tamir Duberstein) * Make ACPICA code support flexible arrays properly (Kees Cook) * Check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects() (void0red) * Add os specific support for Zephyr RTOS to ACPICA (Najumon) * Update version to 20230331 (Bob Moore) - Fix evaluating the _PDC ACPI control method when running as Xen dom0 (Roger Pau Monne) - Use platform devices to load ACPI PPC and PCC drivers (Petr Pavlu) - Check for null return of devm_kzalloc() in fch_misc_setup() (Kang Chen) - Log a message if enable_irq_wake() fails for the ACPI SCI (Simon Gaiser) - Initialize the correct IOMMU fwspec while parsing ACPI VIOT (Jean-Philippe Brucker) - Amend indentation and prefix error messages with FW_BUG in the ACPI SPCR parsing code (Andy Shevchenko) - Enable ACPI sysfs support for CCEL records (Kuppuswamy Sathyanarayanan) - Make the APEI error injection code warn on invalid arguments when explicitly indicated by platform (Shuai Xue) - Add CXL error types to the error injection code in APEI (Tony Luck) - Refactor acpi_data_prop_read_single() (Andy Shevchenko) - Fix two issues in the ACPI SBS driver (Armin Wolf) - Replace ternary operator with min_t() in the generic ACPI thermal zone driver (Jiangshan Yi) - Ensure that ACPI notify handlers are not running after removal and clean up code in acpi_sb_notify() (Rafael Wysocki) - Remove register_backlight_delay module option and code and remove quirks for false-positive backlight control support advertised on desktop boards (Hans de Goede) - Replace irqdomain.h include with struct declarations in ACPI headers and update several pieces of code previously including of.h implicitly through those headers (Rob Herring) - Fix acpi_evaluate_dsm_typed() redefinition error (Kiran K) - Update the pm_profile sysfs attribute documentation (Rafael Wysocki) - Add 80862289 ACPI _HID for second PWM controller on Cherry Trail to the ACPI driver for Intel SoCs (Hans de Goede)" * tag 'acpi-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (64 commits) ACPI: LPSS: Add 80862289 ACPI _HID for second PWM controller on Cherry Trail ACPI: bus: Ensure that notify handlers are not running after removal ACPI: bus: Add missing braces to acpi_sb_notify() ACPI: video: Remove desktops without backlight DMI quirks ACPI: video: Remove register_backlight_delay module option and code ACPI: Replace irqdomain.h include with struct declarations fpga: lattice-sysconfig-spi: Add explicit include for of.h tpm: atmel: Add explicit include for of.h virtio-mmio: Add explicit include for of.h pata: ixp4xx: Add explicit include for of.h ata: pata_macio: Add explicit include of irqdomain.h serial: 8250_tegra: Add explicit include for of.h net: rfkill-gpio: Add explicit include for of.h staging: iio: resolver: ad2s1210: Add explicit include for of.h iio: adc: ad7292: Add explicit include for of.h ACPICA: Update version to 20230331 ACPICA: add os specific support for Zephyr RTOS ACPICA: ACPICA: check null return of ACPI_ALLOCATE_ZEROED in acpi_db_display_objects ACPICA: acpi_resource_irq: Replace 1-element arrays with flexible array ACPICA: acpi_madt_oem_data: Fix flexible array member definition ...
319 lines
8.6 KiB
C
319 lines
8.6 KiB
C
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
|
/******************************************************************************
|
|
*
|
|
* Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
|
|
* original/legacy sleep/PM registers.
|
|
*
|
|
* Copyright (C) 2000 - 2023, Intel Corp.
|
|
*
|
|
*****************************************************************************/
|
|
|
|
#include <acpi/acpi.h>
|
|
#include "accommon.h"
|
|
|
|
#define _COMPONENT ACPI_HARDWARE
|
|
ACPI_MODULE_NAME("hwsleep")
|
|
|
|
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
|
|
/*******************************************************************************
|
|
*
|
|
* FUNCTION: acpi_hw_legacy_sleep
|
|
*
|
|
* PARAMETERS: sleep_state - Which sleep state to enter
|
|
*
|
|
* RETURN: Status
|
|
*
|
|
* DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
|
|
* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
|
|
*
|
|
******************************************************************************/
|
|
acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
|
|
{
|
|
struct acpi_bit_register_info *sleep_type_reg_info;
|
|
struct acpi_bit_register_info *sleep_enable_reg_info;
|
|
u32 pm1a_control;
|
|
u32 pm1b_control;
|
|
u32 in_value;
|
|
acpi_status status;
|
|
|
|
ACPI_FUNCTION_TRACE(hw_legacy_sleep);
|
|
|
|
sleep_type_reg_info =
|
|
acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
|
|
sleep_enable_reg_info =
|
|
acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
|
|
|
|
/* Clear wake status */
|
|
|
|
status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
|
|
ACPI_CLEAR_STATUS);
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
/* Disable all GPEs */
|
|
status = acpi_hw_disable_all_gpes();
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
status = acpi_hw_clear_acpi_status();
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
acpi_gbl_system_awake_and_running = FALSE;
|
|
|
|
/* Enable all wakeup GPEs */
|
|
status = acpi_hw_enable_all_wakeup_gpes();
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
/* Get current value of PM1A control */
|
|
|
|
status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
|
|
&pm1a_control);
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INIT,
|
|
"Entering sleep state [S%u]\n", sleep_state));
|
|
|
|
/* Clear the SLP_EN and SLP_TYP fields */
|
|
|
|
pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
|
|
sleep_enable_reg_info->access_bit_mask);
|
|
pm1b_control = pm1a_control;
|
|
|
|
/* Insert the SLP_TYP bits */
|
|
|
|
pm1a_control |=
|
|
(acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
|
|
pm1b_control |=
|
|
(acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
|
|
|
|
/*
|
|
* We split the writes of SLP_TYP and SLP_EN to workaround
|
|
* poorly implemented hardware.
|
|
*/
|
|
|
|
/* Write #1: write the SLP_TYP data to the PM1 Control registers */
|
|
|
|
status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
/* Insert the sleep enable (SLP_EN) bit */
|
|
|
|
pm1a_control |= sleep_enable_reg_info->access_bit_mask;
|
|
pm1b_control |= sleep_enable_reg_info->access_bit_mask;
|
|
|
|
/* Flush caches, as per ACPI specification */
|
|
|
|
if (sleep_state < ACPI_STATE_S4) {
|
|
ACPI_FLUSH_CPU_CACHE();
|
|
}
|
|
|
|
status = acpi_os_enter_sleep(sleep_state, pm1a_control, pm1b_control);
|
|
if (status == AE_CTRL_TERMINATE) {
|
|
return_ACPI_STATUS(AE_OK);
|
|
}
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
/* Write #2: Write both SLP_TYP + SLP_EN */
|
|
|
|
status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
if (sleep_state > ACPI_STATE_S3) {
|
|
/*
|
|
* We wanted to sleep > S3, but it didn't happen (by virtue of the
|
|
* fact that we are still executing!)
|
|
*
|
|
* Wait ten seconds, then try again. This is to get S4/S5 to work on
|
|
* all machines.
|
|
*
|
|
* We wait so long to allow chipsets that poll this reg very slowly
|
|
* to still read the right value. Ideally, this block would go
|
|
* away entirely.
|
|
*/
|
|
acpi_os_stall(10 * ACPI_USEC_PER_SEC);
|
|
|
|
status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
|
|
sleep_enable_reg_info->
|
|
access_bit_mask);
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
}
|
|
|
|
/* Wait for transition back to Working State */
|
|
|
|
do {
|
|
status =
|
|
acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
} while (!in_value);
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
|
}
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* FUNCTION: acpi_hw_legacy_wake_prep
|
|
*
|
|
* PARAMETERS: sleep_state - Which sleep state we just exited
|
|
*
|
|
* RETURN: Status
|
|
*
|
|
* DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
|
|
* sleep.
|
|
* Called with interrupts ENABLED.
|
|
*
|
|
******************************************************************************/
|
|
|
|
acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
|
|
{
|
|
acpi_status status = AE_OK;
|
|
struct acpi_bit_register_info *sleep_type_reg_info;
|
|
struct acpi_bit_register_info *sleep_enable_reg_info;
|
|
u32 pm1a_control;
|
|
u32 pm1b_control;
|
|
|
|
ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
|
|
|
|
/*
|
|
* Set SLP_TYPE and SLP_EN to state S0.
|
|
* This is unclear from the ACPI Spec, but it is required
|
|
* by some machines.
|
|
*/
|
|
if (acpi_gbl_sleep_type_a_s0 != ACPI_SLEEP_TYPE_INVALID) {
|
|
sleep_type_reg_info =
|
|
acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
|
|
sleep_enable_reg_info =
|
|
acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
|
|
|
|
/* Get current value of PM1A control */
|
|
|
|
status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
|
|
&pm1a_control);
|
|
if (ACPI_SUCCESS(status)) {
|
|
|
|
/* Clear the SLP_EN and SLP_TYP fields */
|
|
|
|
pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
|
|
sleep_enable_reg_info->
|
|
access_bit_mask);
|
|
pm1b_control = pm1a_control;
|
|
|
|
/* Insert the SLP_TYP bits */
|
|
|
|
pm1a_control |= (acpi_gbl_sleep_type_a_s0 <<
|
|
sleep_type_reg_info->bit_position);
|
|
pm1b_control |= (acpi_gbl_sleep_type_b_s0 <<
|
|
sleep_type_reg_info->bit_position);
|
|
|
|
/* Write the control registers and ignore any errors */
|
|
|
|
(void)acpi_hw_write_pm1_control(pm1a_control,
|
|
pm1b_control);
|
|
}
|
|
}
|
|
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
/*******************************************************************************
|
|
*
|
|
* FUNCTION: acpi_hw_legacy_wake
|
|
*
|
|
* PARAMETERS: sleep_state - Which sleep state we just exited
|
|
*
|
|
* RETURN: Status
|
|
*
|
|
* DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
|
|
* Called with interrupts ENABLED.
|
|
*
|
|
******************************************************************************/
|
|
|
|
acpi_status acpi_hw_legacy_wake(u8 sleep_state)
|
|
{
|
|
acpi_status status;
|
|
|
|
ACPI_FUNCTION_TRACE(hw_legacy_wake);
|
|
|
|
/* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
|
|
|
|
acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
|
|
acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
|
|
|
|
/*
|
|
* GPEs must be enabled before _WAK is called as GPEs
|
|
* might get fired there
|
|
*
|
|
* Restore the GPEs:
|
|
* 1) Disable all GPEs
|
|
* 2) Enable all runtime GPEs
|
|
*/
|
|
status = acpi_hw_disable_all_gpes();
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
status = acpi_hw_enable_all_runtime_gpes();
|
|
if (ACPI_FAILURE(status)) {
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
/*
|
|
* Now we can execute _WAK, etc. Some machines require that the GPEs
|
|
* are enabled before the wake methods are executed.
|
|
*/
|
|
acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
|
|
|
|
/*
|
|
* Some BIOS code assumes that WAK_STS will be cleared on resume
|
|
* and use it to determine whether the system is rebooting or
|
|
* resuming. Clear WAK_STS for compatibility.
|
|
*/
|
|
(void)acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
|
|
ACPI_CLEAR_STATUS);
|
|
acpi_gbl_system_awake_and_running = TRUE;
|
|
|
|
/* Enable power button */
|
|
|
|
(void)
|
|
acpi_write_bit_register(acpi_gbl_fixed_event_info
|
|
[ACPI_EVENT_POWER_BUTTON].
|
|
enable_register_id, ACPI_ENABLE_EVENT);
|
|
|
|
(void)
|
|
acpi_write_bit_register(acpi_gbl_fixed_event_info
|
|
[ACPI_EVENT_POWER_BUTTON].
|
|
status_register_id, ACPI_CLEAR_STATUS);
|
|
|
|
/* Enable sleep button */
|
|
|
|
(void)
|
|
acpi_write_bit_register(acpi_gbl_fixed_event_info
|
|
[ACPI_EVENT_SLEEP_BUTTON].
|
|
enable_register_id, ACPI_ENABLE_EVENT);
|
|
|
|
(void)
|
|
acpi_write_bit_register(acpi_gbl_fixed_event_info
|
|
[ACPI_EVENT_SLEEP_BUTTON].
|
|
status_register_id, ACPI_CLEAR_STATUS);
|
|
|
|
acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
|
|
return_ACPI_STATUS(status);
|
|
}
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|