Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *                   original/legacy sleep/PM registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 2000 - 2020, Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *****************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <acpi/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "accommon.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #define _COMPONENT          ACPI_HARDWARE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) ACPI_MODULE_NAME("hwsleep")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #if (!ACPI_REDUCED_HARDWARE)	/* Entire module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * FUNCTION:    acpi_hw_legacy_sleep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * PARAMETERS:  sleep_state         - Which sleep state to enter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *              THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	struct acpi_bit_register_info *sleep_type_reg_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct acpi_bit_register_info *sleep_enable_reg_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u32 pm1a_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u32 pm1b_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	u32 in_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	ACPI_FUNCTION_TRACE(hw_legacy_sleep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	sleep_type_reg_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	sleep_enable_reg_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	/* Clear wake status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 					 ACPI_CLEAR_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	/* Disable all GPEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	status = acpi_hw_disable_all_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	status = acpi_hw_clear_acpi_status();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	acpi_gbl_system_awake_and_running = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 /* Enable all wakeup GPEs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	status = acpi_hw_enable_all_wakeup_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	/* Get current value of PM1A control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				       &pm1a_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	ACPI_DEBUG_PRINT((ACPI_DB_INIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			  "Entering sleep state [S%u]\n", sleep_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	/* Clear the SLP_EN and SLP_TYP fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			  sleep_enable_reg_info->access_bit_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	pm1b_control = pm1a_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	/* Insert the SLP_TYP bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	pm1a_control |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	    (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	pm1b_control |=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	    (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 * We split the writes of SLP_TYP and SLP_EN to workaround
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * poorly implemented hardware.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	/* Write #1: write the SLP_TYP data to the PM1 Control registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/* Insert the sleep enable (SLP_EN) bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	pm1a_control |= sleep_enable_reg_info->access_bit_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	pm1b_control |= sleep_enable_reg_info->access_bit_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	/* Flush caches, as per ACPI specification */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	if (sleep_state < ACPI_STATE_S4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		ACPI_FLUSH_CPU_CACHE();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	status = acpi_os_enter_sleep(sleep_state, pm1a_control, pm1b_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (status == AE_CTRL_TERMINATE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	/* Write #2: Write both SLP_TYP + SLP_EN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	if (sleep_state > ACPI_STATE_S3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		 * We wanted to sleep > S3, but it didn't happen (by virtue of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		 * fact that we are still executing!)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		 * Wait ten seconds, then try again. This is to get S4/S5 to work on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		 * all machines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		 * We wait so long to allow chipsets that poll this reg very slowly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		 * to still read the right value. Ideally, this block would go
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		 * away entirely.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		acpi_os_stall(10 * ACPI_USEC_PER_SEC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 						sleep_enable_reg_info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 						access_bit_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/* Wait for transition back to Working State */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		status =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		    acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	} while (!in_value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	return_ACPI_STATUS(AE_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * FUNCTION:    acpi_hw_legacy_wake_prep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  * PARAMETERS:  sleep_state         - Which sleep state we just exited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *              sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  *              Called with interrupts ENABLED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	acpi_status status = AE_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	struct acpi_bit_register_info *sleep_type_reg_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct acpi_bit_register_info *sleep_enable_reg_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	u32 pm1a_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	u32 pm1b_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	 * Set SLP_TYPE and SLP_EN to state S0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	 * This is unclear from the ACPI Spec, but it is required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	 * by some machines.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	if (acpi_gbl_sleep_type_a_s0 != ACPI_SLEEP_TYPE_INVALID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		sleep_type_reg_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		sleep_enable_reg_info =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		    acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		/* Get current value of PM1A control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 					       &pm1a_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		if (ACPI_SUCCESS(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			/* Clear the SLP_EN and SLP_TYP fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 					  sleep_enable_reg_info->
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 					  access_bit_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			pm1b_control = pm1a_control;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 			/* Insert the SLP_TYP bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			pm1a_control |= (acpi_gbl_sleep_type_a_s0 <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 					 sleep_type_reg_info->bit_position);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			pm1b_control |= (acpi_gbl_sleep_type_b_s0 <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 					 sleep_type_reg_info->bit_position);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			/* Write the control registers and ignore any errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			(void)acpi_hw_write_pm1_control(pm1a_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 							pm1b_control);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) /*******************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * FUNCTION:    acpi_hw_legacy_wake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * PARAMETERS:  sleep_state         - Which sleep state we just exited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)  * RETURN:      Status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)  * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)  *              Called with interrupts ENABLED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  ******************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) acpi_status acpi_hw_legacy_wake(u8 sleep_state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	ACPI_FUNCTION_TRACE(hw_legacy_wake);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	/* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	 * GPEs must be enabled before _WAK is called as GPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	 * might get fired there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	 * Restore the GPEs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	 * 1) Disable all GPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	 * 2) Enable all runtime GPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	status = acpi_hw_disable_all_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	status = acpi_hw_enable_all_runtime_gpes();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	 * Now we can execute _WAK, etc. Some machines require that the GPEs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	 * are enabled before the wake methods are executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	 * Some BIOS code assumes that WAK_STS will be cleared on resume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	 * and use it to determine whether the system is rebooting or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * resuming. Clear WAK_STS for compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	(void)acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				      ACPI_CLEAR_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	acpi_gbl_system_awake_and_running = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	/* Enable power button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	    acpi_write_bit_register(acpi_gbl_fixed_event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				    [ACPI_EVENT_POWER_BUTTON].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 				    enable_register_id, ACPI_ENABLE_EVENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	    acpi_write_bit_register(acpi_gbl_fixed_event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 				    [ACPI_EVENT_POWER_BUTTON].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 				    status_register_id, ACPI_CLEAR_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	/* Enable sleep button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	    acpi_write_bit_register(acpi_gbl_fixed_event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 				    [ACPI_EVENT_SLEEP_BUTTON].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 				    enable_register_id, ACPI_ENABLE_EVENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	    acpi_write_bit_register(acpi_gbl_fixed_event_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 				    [ACPI_EVENT_SLEEP_BUTTON].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 				    status_register_id, ACPI_CLEAR_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	return_ACPI_STATUS(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #endif				/* !ACPI_REDUCED_HARDWARE */