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
29 #define _COMPONENT ACPI_HARDWARE
30 MODULE_NAME ("hwsleep")
33 /******************************************************************************
35 * FUNCTION: Acpi_set_firmware_waking_vector
37 * PARAMETERS: Physical_address - Physical address of ACPI real mode
40 * RETURN: AE_OK or AE_ERROR
42 * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
44 ******************************************************************************/
47 acpi_set_firmware_waking_vector (
48 ACPI_PHYSICAL_ADDRESS physical_address
)
52 /* Make sure that we have an FACS */
55 return (AE_NO_ACPI_TABLES
);
60 if (acpi_gbl_FACS
->vector_width
== 32) {
61 * (u32
*) acpi_gbl_FACS
->firmware_waking_vector
= (u32
) physical_address
;
64 *acpi_gbl_FACS
->firmware_waking_vector
= physical_address
;
71 /******************************************************************************
73 * FUNCTION: Acpi_get_firmware_waking_vector
75 * PARAMETERS: *Physical_address - Output buffer where contents of
76 * the Firmware_waking_vector field of
77 * the FACS will be stored.
81 * DESCRIPTION: Access function for d_firmware_waking_vector field in FACS
83 ******************************************************************************/
86 acpi_get_firmware_waking_vector (
87 ACPI_PHYSICAL_ADDRESS
*physical_address
)
91 if (!physical_address
) {
92 return (AE_BAD_PARAMETER
);
95 /* Make sure that we have an FACS */
98 return (AE_NO_ACPI_TABLES
);
103 if (acpi_gbl_FACS
->vector_width
== 32) {
104 *physical_address
= * (u32
*) acpi_gbl_FACS
->firmware_waking_vector
;
107 *physical_address
= *acpi_gbl_FACS
->firmware_waking_vector
;
113 /******************************************************************************
115 * FUNCTION: Acpi_enter_sleep_state
117 * PARAMETERS: Sleep_state - Which sleep state to enter
121 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
123 ******************************************************************************/
126 acpi_enter_sleep_state (
130 ACPI_OBJECT_LIST arg_list
;
138 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
141 status
= acpi_hw_obtain_sleep_type_register_data(sleep_state
, &type_a
, &type_b
);
143 if (!ACPI_SUCCESS(status
)) {
147 /* run the _PTS and _GTS methods */
148 MEMSET(&arg_list
, 0, sizeof(arg_list
));
150 arg_list
.pointer
= &arg
;
152 MEMSET(&arg
, 0, sizeof(arg
));
153 arg
.type
= ACPI_TYPE_INTEGER
;
154 arg
.integer
.value
= sleep_state
;
156 acpi_evaluate_object(NULL
, "\\_PTS", &arg_list
, NULL
);
157 acpi_evaluate_object(NULL
, "\\_GTS", &arg_list
, NULL
);
159 /* clear wake status */
160 acpi_hw_register_bit_access(ACPI_WRITE
, ACPI_MTX_LOCK
, WAK_STS
, 1);
162 PM1_acontrol
= (u16
) acpi_hw_register_read(ACPI_MTX_LOCK
, PM1_CONTROL
);
164 /* mask off SLP_EN and SLP_TYP fields */
165 PM1_acontrol
&= 0xC3FF;
168 PM1_acontrol
|= (1 << acpi_hw_get_bit_shift (SLP_EN_MASK
));
170 PM1_bcontrol
= PM1_acontrol
;
172 /* mask in SLP_TYP */
173 PM1_acontrol
|= (type_a
<< acpi_hw_get_bit_shift (SLP_TYPE_X_MASK
));
174 PM1_bcontrol
|= (type_b
<< acpi_hw_get_bit_shift (SLP_TYPE_X_MASK
));
178 acpi_hw_register_write(ACPI_MTX_LOCK
, PM1_a_CONTROL
, PM1_acontrol
);
179 acpi_hw_register_write(ACPI_MTX_LOCK
, PM1_b_CONTROL
, PM1_bcontrol
);
180 acpi_hw_register_write(ACPI_MTX_LOCK
, PM1_CONTROL
,
181 (1 << acpi_hw_get_bit_shift (SLP_EN_MASK
)));