2 /******************************************************************************
4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
7 *****************************************************************************/
10 * Copyright (C) 2000, 2001 R. Byron Moore
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #define _COMPONENT ACPI_HARDWARE
32 MODULE_NAME ("hwsleep")
35 /******************************************************************************
37 * FUNCTION: Acpi_set_firmware_waking_vector
39 * PARAMETERS: Physical_address - Physical address of ACPI real mode
42 * RETURN: AE_OK or AE_ERROR
44 * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
46 ******************************************************************************/
49 acpi_set_firmware_waking_vector (
50 ACPI_PHYSICAL_ADDRESS physical_address)
54 /* Make sure that we have an FACS */
57 return (AE_NO_ACPI_TABLES);
62 if (acpi_gbl_FACS->vector_width == 32) {
63 * (u32 *) acpi_gbl_FACS->firmware_waking_vector = (u32) physical_address;
66 *acpi_gbl_FACS->firmware_waking_vector = physical_address;
73 /******************************************************************************
75 * FUNCTION: Acpi_get_firmware_waking_vector
77 * PARAMETERS: *Physical_address - Output buffer where contents of
78 * the Firmware_waking_vector field of
79 * the FACS will be stored.
83 * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
85 ******************************************************************************/
88 acpi_get_firmware_waking_vector (
89 ACPI_PHYSICAL_ADDRESS *physical_address)
93 if (!physical_address) {
94 return (AE_BAD_PARAMETER);
97 /* Make sure that we have an FACS */
100 return (AE_NO_ACPI_TABLES);
105 if (acpi_gbl_FACS->vector_width == 32) {
106 *physical_address = * (u32 *) acpi_gbl_FACS->firmware_waking_vector;
109 *physical_address = *acpi_gbl_FACS->firmware_waking_vector;
115 /******************************************************************************
117 * FUNCTION: Acpi_enter_sleep_state
119 * PARAMETERS: Sleep_state - Which sleep state to enter
123 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
125 ******************************************************************************/
128 acpi_enter_sleep_state (
132 ACPI_OBJECT_LIST arg_list;
140 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
143 status = acpi_hw_obtain_sleep_type_register_data(sleep_state, &type_a, &type_b);
145 if (!ACPI_SUCCESS(status)) {
149 /* run the _PTS and _GTS methods */
150 MEMSET(&arg_list, 0, sizeof(arg_list));
152 arg_list.pointer = &arg;
154 MEMSET(&arg, 0, sizeof(arg));
155 arg.type = ACPI_TYPE_INTEGER;
156 arg.integer.value = sleep_state;
158 acpi_evaluate_object(NULL, "\\_PTS", &arg_list, NULL);
159 acpi_evaluate_object(NULL, "\\_GTS", &arg_list, NULL);
161 /* clear wake status */
162 acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1);
164 PM1_acontrol = (u16) acpi_hw_register_read(ACPI_MTX_LOCK, PM1_CONTROL);
166 /* mask off SLP_EN and SLP_TYP fields */
167 PM1_acontrol &= 0xC3FF;
170 PM1_acontrol |= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK));
172 PM1_bcontrol = PM1_acontrol;
174 /* mask in SLP_TYP */
175 PM1_acontrol |= (type_a << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
176 PM1_bcontrol |= (type_b << acpi_hw_get_bit_shift (SLP_TYPE_X_MASK));
180 acpi_hw_register_write(ACPI_MTX_LOCK, PM1_a_CONTROL, PM1_acontrol);
181 acpi_hw_register_write(ACPI_MTX_LOCK, PM1_b_CONTROL, PM1_bcontrol);
182 acpi_hw_register_write(ACPI_MTX_LOCK, PM1_CONTROL,
183 (1 << acpi_hw_get_bit_shift (SLP_EN_MASK)));