Rev 1498 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
1 | /****************************************************************************** |
1 | /****************************************************************************** |
2 | * |
2 | * |
3 | * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface |
3 | * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface |
4 | * |
4 | * |
5 | *****************************************************************************/ |
5 | *****************************************************************************/ |
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
17 | * rights. You may have additional license terms from the party that provided |
17 | * rights. You may have additional license terms from the party that provided |
18 | * you this software, covering your right to use that party's intellectual |
18 | * you this software, covering your right to use that party's intellectual |
19 | * property rights. |
19 | * property rights. |
20 | * |
20 | * |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
22 | * copy of the source code appearing in this file ("Covered Code") an |
22 | * copy of the source code appearing in this file ("Covered Code") an |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
25 | * make derivatives, distribute, use and display any portion of the Covered |
25 | * make derivatives, distribute, use and display any portion of the Covered |
26 | * Code in any form, with the right to sublicense such rights; and |
26 | * Code in any form, with the right to sublicense such rights; and |
27 | * |
27 | * |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
29 | * license (with the right to sublicense), under only those claims of Intel |
29 | * license (with the right to sublicense), under only those claims of Intel |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
32 | * solely to the minimum extent necessary to exercise the above copyright |
32 | * solely to the minimum extent necessary to exercise the above copyright |
33 | * license, and in no event shall the patent license extend to any additions |
33 | * license, and in no event shall the patent license extend to any additions |
34 | * to or modifications of the Original Intel Code. No other license or right |
34 | * to or modifications of the Original Intel Code. No other license or right |
35 | * is granted directly or by implication, estoppel or otherwise; |
35 | * is granted directly or by implication, estoppel or otherwise; |
36 | * |
36 | * |
37 | * The above copyright and patent license is granted only if the following |
37 | * The above copyright and patent license is granted only if the following |
38 | * conditions are met: |
38 | * conditions are met: |
39 | * |
39 | * |
40 | * 3. Conditions |
40 | * 3. Conditions |
41 | * |
41 | * |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
43 | * Redistribution of source code of any substantial portion of the Covered |
43 | * Redistribution of source code of any substantial portion of the Covered |
44 | * Code or modification with rights to further distribute source must include |
44 | * Code or modification with rights to further distribute source must include |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
48 | * contain a file documenting the changes Licensee made to create that Covered |
48 | * contain a file documenting the changes Licensee made to create that Covered |
49 | * Code and the date of any change. Licensee must include in that file the |
49 | * Code and the date of any change. Licensee must include in that file the |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
51 | * must include a prominent statement that the modification is derived, |
51 | * must include a prominent statement that the modification is derived, |
52 | * directly or indirectly, from Original Intel Code. |
52 | * directly or indirectly, from Original Intel Code. |
53 | * |
53 | * |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
55 | * Redistribution of source code of any substantial portion of the Covered |
55 | * Redistribution of source code of any substantial portion of the Covered |
56 | * Code or modification without rights to further distribute source must |
56 | * Code or modification without rights to further distribute source must |
57 | * include the following Disclaimer and Export Compliance provision in the |
57 | * include the following Disclaimer and Export Compliance provision in the |
58 | * documentation and/or other materials provided with distribution. In |
58 | * documentation and/or other materials provided with distribution. In |
59 | * addition, Licensee may not authorize further sublicense of source of any |
59 | * addition, Licensee may not authorize further sublicense of source of any |
60 | * portion of the Covered Code, and must include terms to the effect that the |
60 | * portion of the Covered Code, and must include terms to the effect that the |
61 | * license from Licensee to its licensee is limited to the intellectual |
61 | * license from Licensee to its licensee is limited to the intellectual |
62 | * property embodied in the software Licensee provides to its licensee, and |
62 | * property embodied in the software Licensee provides to its licensee, and |
63 | * not to intellectual property embodied in modifications its licensee may |
63 | * not to intellectual property embodied in modifications its licensee may |
64 | * make. |
64 | * make. |
65 | * |
65 | * |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
67 | * substantial portion of the Covered Code or modification must reproduce the |
67 | * substantial portion of the Covered Code or modification must reproduce the |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
69 | * provision in the documentation and/or other materials provided with the |
69 | * provision in the documentation and/or other materials provided with the |
70 | * distribution. |
70 | * distribution. |
71 | * |
71 | * |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
73 | * Intel Code. |
73 | * Intel Code. |
74 | * |
74 | * |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
77 | * other dealings in products derived from or relating to the Covered Code |
77 | * other dealings in products derived from or relating to the Covered Code |
78 | * without prior written authorization from Intel. |
78 | * without prior written authorization from Intel. |
79 | * |
79 | * |
80 | * 4. Disclaimer and Export Compliance |
80 | * 4. Disclaimer and Export Compliance |
81 | * |
81 | * |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
88 | * PARTICULAR PURPOSE. |
88 | * PARTICULAR PURPOSE. |
89 | * |
89 | * |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
97 | * LIMITED REMEDY. |
97 | * LIMITED REMEDY. |
98 | * |
98 | * |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
100 | * software or system incorporating such software without first obtaining any |
100 | * software or system incorporating such software without first obtaining any |
101 | * required license or other approval from the U. S. Department of Commerce or |
101 | * required license or other approval from the U. S. Department of Commerce or |
102 | * any other agency or department of the United States Government. In the |
102 | * any other agency or department of the United States Government. In the |
103 | * event Licensee exports any such software from the United States or |
103 | * event Licensee exports any such software from the United States or |
104 | * re-exports any such software from a foreign destination, Licensee shall |
104 | * re-exports any such software from a foreign destination, Licensee shall |
105 | * ensure that the distribution and export/re-export of the software is in |
105 | * ensure that the distribution and export/re-export of the software is in |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
109 | * software, or service, directly or indirectly, to any country for which the |
109 | * software, or service, directly or indirectly, to any country for which the |
110 | * United States government or any agency thereof requires an export license, |
110 | * United States government or any agency thereof requires an export license, |
111 | * other governmental approval, or letter of assurance, without first obtaining |
111 | * other governmental approval, or letter of assurance, without first obtaining |
112 | * such license, approval or letter. |
112 | * such license, approval or letter. |
113 | * |
113 | * |
114 | *****************************************************************************/ |
114 | *****************************************************************************/ |
115 | 115 | ||
116 | #include "acpi.h" |
116 | #include "acpi.h" |
117 | #include "accommon.h" |
117 | #include "accommon.h" |
118 | 118 | ||
119 | #define _COMPONENT ACPI_HARDWARE |
119 | #define _COMPONENT ACPI_HARDWARE |
120 | ACPI_MODULE_NAME ("hwsleep") |
120 | ACPI_MODULE_NAME ("hwsleep") |
121 | 121 | ||
122 | 122 | ||
123 | /******************************************************************************* |
123 | /******************************************************************************* |
124 | * |
124 | * |
125 | * FUNCTION: AcpiSetFirmwareWakingVector |
125 | * FUNCTION: AcpiSetFirmwareWakingVector |
126 | * |
126 | * |
127 | * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode |
127 | * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode |
128 | * entry point. |
128 | * entry point. |
129 | * |
129 | * |
130 | * RETURN: Status |
130 | * RETURN: Status |
131 | * |
131 | * |
132 | * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS |
132 | * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS |
133 | * |
133 | * |
134 | ******************************************************************************/ |
134 | ******************************************************************************/ |
135 | 135 | ||
136 | ACPI_STATUS |
136 | ACPI_STATUS |
137 | AcpiSetFirmwareWakingVector ( |
137 | AcpiSetFirmwareWakingVector ( |
138 | UINT32 PhysicalAddress) |
138 | UINT32 PhysicalAddress) |
139 | { |
139 | { |
140 | ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); |
140 | ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); |
141 | 141 | ||
142 | 142 | ||
143 | /* Set the 32-bit vector */ |
143 | /* Set the 32-bit vector */ |
144 | 144 | ||
145 | AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; |
145 | AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; |
146 | 146 | ||
147 | /* Clear the 64-bit vector if it exists */ |
147 | /* Clear the 64-bit vector if it exists */ |
148 | 148 | ||
149 | if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) |
149 | if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) |
150 | { |
150 | { |
151 | AcpiGbl_FACS->XFirmwareWakingVector = 0; |
151 | AcpiGbl_FACS->XFirmwareWakingVector = 0; |
152 | } |
152 | } |
153 | 153 | ||
154 | return_ACPI_STATUS (AE_OK); |
154 | return_ACPI_STATUS (AE_OK); |
155 | } |
155 | } |
156 | 156 | ||
157 | ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) |
157 | ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) |
158 | 158 | ||
159 | 159 | ||
160 | #if ACPI_MACHINE_WIDTH == 64 |
160 | #if ACPI_MACHINE_WIDTH == 64 |
161 | /******************************************************************************* |
161 | /******************************************************************************* |
162 | * |
162 | * |
163 | * FUNCTION: AcpiSetFirmwareWakingVector64 |
163 | * FUNCTION: AcpiSetFirmwareWakingVector64 |
164 | * |
164 | * |
165 | * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected |
165 | * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected |
166 | * mode entry point. |
166 | * mode entry point. |
167 | * |
167 | * |
168 | * RETURN: Status |
168 | * RETURN: Status |
169 | * |
169 | * |
170 | * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if |
170 | * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if |
171 | * it exists in the table. This function is intended for use with |
171 | * it exists in the table. This function is intended for use with |
172 | * 64-bit host operating systems. |
172 | * 64-bit host operating systems. |
173 | * |
173 | * |
174 | ******************************************************************************/ |
174 | ******************************************************************************/ |
175 | 175 | ||
176 | ACPI_STATUS |
176 | ACPI_STATUS |
177 | AcpiSetFirmwareWakingVector64 ( |
177 | AcpiSetFirmwareWakingVector64 ( |
178 | UINT64 PhysicalAddress) |
178 | UINT64 PhysicalAddress) |
179 | { |
179 | { |
180 | ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); |
180 | ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); |
181 | 181 | ||
182 | 182 | ||
183 | /* Determine if the 64-bit vector actually exists */ |
183 | /* Determine if the 64-bit vector actually exists */ |
184 | 184 | ||
185 | if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) |
185 | if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) |
186 | { |
186 | { |
187 | return_ACPI_STATUS (AE_NOT_EXIST); |
187 | return_ACPI_STATUS (AE_NOT_EXIST); |
188 | } |
188 | } |
189 | 189 | ||
190 | /* Clear 32-bit vector, set the 64-bit X_ vector */ |
190 | /* Clear 32-bit vector, set the 64-bit X_ vector */ |
191 | 191 | ||
192 | AcpiGbl_FACS->FirmwareWakingVector = 0; |
192 | AcpiGbl_FACS->FirmwareWakingVector = 0; |
193 | AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; |
193 | AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; |
194 | return_ACPI_STATUS (AE_OK); |
194 | return_ACPI_STATUS (AE_OK); |
195 | } |
195 | } |
196 | 196 | ||
197 | ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) |
197 | ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) |
198 | #endif |
198 | #endif |
199 | 199 | ||
200 | /******************************************************************************* |
200 | /******************************************************************************* |
201 | * |
201 | * |
202 | * FUNCTION: AcpiEnterSleepStatePrep |
202 | * FUNCTION: AcpiEnterSleepStatePrep |
203 | * |
203 | * |
204 | * PARAMETERS: SleepState - Which sleep state to enter |
204 | * PARAMETERS: SleepState - Which sleep state to enter |
205 | * |
205 | * |
206 | * RETURN: Status |
206 | * RETURN: Status |
207 | * |
207 | * |
208 | * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) |
208 | * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) |
209 | * This function must execute with interrupts enabled. |
209 | * This function must execute with interrupts enabled. |
210 | * We break sleeping into 2 stages so that OSPM can handle |
210 | * We break sleeping into 2 stages so that OSPM can handle |
211 | * various OS-specific tasks between the two steps. |
211 | * various OS-specific tasks between the two steps. |
212 | * |
212 | * |
213 | ******************************************************************************/ |
213 | ******************************************************************************/ |
214 | 214 | ||
215 | ACPI_STATUS |
215 | ACPI_STATUS |
216 | AcpiEnterSleepStatePrep ( |
216 | AcpiEnterSleepStatePrep ( |
217 | UINT8 SleepState) |
217 | UINT8 SleepState) |
218 | { |
218 | { |
219 | ACPI_STATUS Status; |
219 | ACPI_STATUS Status; |
220 | ACPI_OBJECT_LIST ArgList; |
220 | ACPI_OBJECT_LIST ArgList; |
221 | ACPI_OBJECT Arg; |
221 | ACPI_OBJECT Arg; |
222 | 222 | ||
223 | 223 | ||
224 | ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); |
224 | ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); |
225 | 225 | ||
226 | 226 | ||
227 | /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ |
227 | /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ |
228 | 228 | ||
229 | Status = AcpiGetSleepTypeData (SleepState, |
229 | Status = AcpiGetSleepTypeData (SleepState, |
230 | &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); |
230 | &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); |
231 | if (ACPI_FAILURE (Status)) |
231 | if (ACPI_FAILURE (Status)) |
232 | { |
232 | { |
233 | return_ACPI_STATUS (Status); |
233 | return_ACPI_STATUS (Status); |
234 | } |
234 | } |
235 | 235 | ||
236 | /* Execute the _PTS method (Prepare To Sleep) */ |
236 | /* Execute the _PTS method (Prepare To Sleep) */ |
237 | 237 | ||
238 | ArgList.Count = 1; |
238 | ArgList.Count = 1; |
239 | ArgList.Pointer = &Arg; |
239 | ArgList.Pointer = &Arg; |
240 | Arg.Type = ACPI_TYPE_INTEGER; |
240 | Arg.Type = ACPI_TYPE_INTEGER; |
241 | Arg.Integer.Value = SleepState; |
241 | Arg.Integer.Value = SleepState; |
242 | 242 | ||
243 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL); |
243 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL); |
244 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
244 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
245 | { |
245 | { |
246 | return_ACPI_STATUS (Status); |
246 | return_ACPI_STATUS (Status); |
247 | } |
247 | } |
248 | 248 | ||
249 | /* Setup the argument to the _SST method (System STatus) */ |
249 | /* Setup the argument to the _SST method (System STatus) */ |
250 | 250 | ||
251 | switch (SleepState) |
251 | switch (SleepState) |
252 | { |
252 | { |
253 | case ACPI_STATE_S0: |
253 | case ACPI_STATE_S0: |
254 | Arg.Integer.Value = ACPI_SST_WORKING; |
254 | Arg.Integer.Value = ACPI_SST_WORKING; |
255 | break; |
255 | break; |
256 | 256 | ||
257 | case ACPI_STATE_S1: |
257 | case ACPI_STATE_S1: |
258 | case ACPI_STATE_S2: |
258 | case ACPI_STATE_S2: |
259 | case ACPI_STATE_S3: |
259 | case ACPI_STATE_S3: |
260 | Arg.Integer.Value = ACPI_SST_SLEEPING; |
260 | Arg.Integer.Value = ACPI_SST_SLEEPING; |
261 | break; |
261 | break; |
262 | 262 | ||
263 | case ACPI_STATE_S4: |
263 | case ACPI_STATE_S4: |
264 | Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT; |
264 | Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT; |
265 | break; |
265 | break; |
266 | 266 | ||
267 | default: |
267 | default: |
268 | Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ |
268 | Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ |
269 | break; |
269 | break; |
270 | } |
270 | } |
271 | 271 | ||
272 | /* |
272 | /* |
273 | * Set the system indicators to show the desired sleep state. |
273 | * Set the system indicators to show the desired sleep state. |
274 | * _SST is an optional method (return no error if not found) |
274 | * _SST is an optional method (return no error if not found) |
275 | */ |
275 | */ |
276 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); |
276 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); |
277 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
277 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
278 | { |
278 | { |
279 | ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST")); |
279 | ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST")); |
280 | } |
280 | } |
281 | 281 | ||
282 | return_ACPI_STATUS (AE_OK); |
282 | return_ACPI_STATUS (AE_OK); |
283 | } |
283 | } |
284 | 284 | ||
285 | ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) |
285 | ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) |
286 | 286 | ||
287 | 287 | ||
288 | /******************************************************************************* |
288 | /******************************************************************************* |
289 | * |
289 | * |
290 | * FUNCTION: AcpiEnterSleepState |
290 | * FUNCTION: AcpiEnterSleepState |
291 | * |
291 | * |
292 | * PARAMETERS: SleepState - Which sleep state to enter |
292 | * PARAMETERS: SleepState - Which sleep state to enter |
293 | * |
293 | * |
294 | * RETURN: Status |
294 | * RETURN: Status |
295 | * |
295 | * |
296 | * DESCRIPTION: Enter a system sleep state |
296 | * DESCRIPTION: Enter a system sleep state |
297 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
297 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
298 | * |
298 | * |
299 | ******************************************************************************/ |
299 | ******************************************************************************/ |
300 | 300 | ||
301 | ACPI_STATUS |
301 | ACPI_STATUS |
302 | AcpiEnterSleepState ( |
302 | AcpiEnterSleepState ( |
303 | UINT8 SleepState) |
303 | UINT8 SleepState) |
304 | { |
304 | { |
305 | UINT32 Pm1aControl; |
305 | UINT32 Pm1aControl; |
306 | UINT32 Pm1bControl; |
306 | UINT32 Pm1bControl; |
307 | ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; |
307 | ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; |
308 | ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; |
308 | ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; |
309 | UINT32 InValue; |
309 | UINT32 InValue; |
310 | ACPI_OBJECT_LIST ArgList; |
310 | ACPI_OBJECT_LIST ArgList; |
311 | ACPI_OBJECT Arg; |
311 | ACPI_OBJECT Arg; |
312 | ACPI_STATUS Status; |
312 | ACPI_STATUS Status; |
313 | 313 | ||
314 | 314 | ||
315 | ACPI_FUNCTION_TRACE (AcpiEnterSleepState); |
315 | ACPI_FUNCTION_TRACE (AcpiEnterSleepState); |
316 | 316 | ||
317 | 317 | ||
318 | if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || |
318 | if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || |
319 | (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) |
319 | (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) |
320 | { |
320 | { |
321 | ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", |
321 | ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", |
322 | AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); |
322 | AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); |
323 | return_ACPI_STATUS (AE_AML_OPERAND_VALUE); |
323 | return_ACPI_STATUS (AE_AML_OPERAND_VALUE); |
324 | } |
324 | } |
325 | 325 | ||
326 | SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); |
326 | SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); |
327 | SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); |
327 | SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); |
328 | 328 | ||
329 | /* Clear wake status */ |
329 | /* Clear wake status */ |
330 | 330 | ||
331 | Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
331 | Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
332 | if (ACPI_FAILURE (Status)) |
332 | if (ACPI_FAILURE (Status)) |
333 | { |
333 | { |
334 | return_ACPI_STATUS (Status); |
334 | return_ACPI_STATUS (Status); |
335 | } |
335 | } |
336 | 336 | ||
337 | /* Clear all fixed and general purpose status bits */ |
337 | /* Clear all fixed and general purpose status bits */ |
338 | 338 | ||
339 | Status = AcpiHwClearAcpiStatus (); |
339 | Status = AcpiHwClearAcpiStatus (); |
340 | if (ACPI_FAILURE (Status)) |
340 | if (ACPI_FAILURE (Status)) |
341 | { |
341 | { |
342 | return_ACPI_STATUS (Status); |
342 | return_ACPI_STATUS (Status); |
343 | } |
343 | } |
344 | 344 | ||
345 | if (SleepState != ACPI_STATE_S5) |
345 | if (SleepState != ACPI_STATE_S5) |
346 | { |
346 | { |
347 | /* |
347 | /* |
348 | * Disable BM arbitration. This feature is contained within an |
348 | * Disable BM arbitration. This feature is contained within an |
349 | * optional register (PM2 Control), so ignore a BAD_ADDRESS |
349 | * optional register (PM2 Control), so ignore a BAD_ADDRESS |
350 | * exception. |
350 | * exception. |
351 | */ |
351 | */ |
352 | Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); |
352 | Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); |
353 | if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) |
353 | if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) |
354 | { |
354 | { |
355 | return_ACPI_STATUS (Status); |
355 | return_ACPI_STATUS (Status); |
356 | } |
356 | } |
357 | } |
357 | } |
358 | 358 | ||
359 | /* |
359 | /* |
360 | * 1) Disable/Clear all GPEs |
360 | * 1) Disable/Clear all GPEs |
361 | * 2) Enable all wakeup GPEs |
361 | * 2) Enable all wakeup GPEs |
362 | */ |
362 | */ |
363 | Status = AcpiHwDisableAllGpes (); |
363 | Status = AcpiHwDisableAllGpes (); |
364 | if (ACPI_FAILURE (Status)) |
364 | if (ACPI_FAILURE (Status)) |
365 | { |
365 | { |
366 | return_ACPI_STATUS (Status); |
366 | return_ACPI_STATUS (Status); |
367 | } |
367 | } |
368 | AcpiGbl_SystemAwakeAndRunning = FALSE; |
368 | AcpiGbl_SystemAwakeAndRunning = FALSE; |
369 | 369 | ||
370 | Status = AcpiHwEnableAllWakeupGpes (); |
370 | Status = AcpiHwEnableAllWakeupGpes (); |
371 | if (ACPI_FAILURE (Status)) |
371 | if (ACPI_FAILURE (Status)) |
372 | { |
372 | { |
373 | return_ACPI_STATUS (Status); |
373 | return_ACPI_STATUS (Status); |
374 | } |
374 | } |
375 | 375 | ||
376 | /* Execute the _GTS method (Going To Sleep) */ |
376 | /* Execute the _GTS method (Going To Sleep) */ |
377 | 377 | ||
378 | ArgList.Count = 1; |
378 | ArgList.Count = 1; |
379 | ArgList.Pointer = &Arg; |
379 | ArgList.Pointer = &Arg; |
380 | Arg.Type = ACPI_TYPE_INTEGER; |
380 | Arg.Type = ACPI_TYPE_INTEGER; |
381 | Arg.Integer.Value = SleepState; |
381 | Arg.Integer.Value = SleepState; |
382 | 382 | ||
383 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL); |
383 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL); |
384 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
384 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
385 | { |
385 | { |
386 | return_ACPI_STATUS (Status); |
386 | return_ACPI_STATUS (Status); |
387 | } |
387 | } |
388 | 388 | ||
389 | /* Get current value of PM1A control */ |
389 | /* Get current value of PM1A control */ |
390 | 390 | ||
391 | Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, |
391 | Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, |
392 | &Pm1aControl); |
392 | &Pm1aControl); |
393 | if (ACPI_FAILURE (Status)) |
393 | if (ACPI_FAILURE (Status)) |
394 | { |
394 | { |
395 | return_ACPI_STATUS (Status); |
395 | return_ACPI_STATUS (Status); |
396 | } |
396 | } |
397 | ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
397 | ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
398 | "Entering sleep state [S%u]\n", SleepState)); |
398 | "Entering sleep state [S%u]\n", SleepState)); |
399 | 399 | ||
400 | /* Clear the SLP_EN and SLP_TYP fields */ |
400 | /* Clear the SLP_EN and SLP_TYP fields */ |
401 | 401 | ||
402 | Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | |
402 | Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | |
403 | SleepEnableRegInfo->AccessBitMask); |
403 | SleepEnableRegInfo->AccessBitMask); |
404 | Pm1bControl = Pm1aControl; |
404 | Pm1bControl = Pm1aControl; |
405 | 405 | ||
406 | /* Insert the SLP_TYP bits */ |
406 | /* Insert the SLP_TYP bits */ |
407 | 407 | ||
408 | Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); |
408 | Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); |
409 | Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); |
409 | Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); |
410 | 410 | ||
411 | /* |
411 | /* |
412 | * We split the writes of SLP_TYP and SLP_EN to workaround |
412 | * We split the writes of SLP_TYP and SLP_EN to workaround |
413 | * poorly implemented hardware. |
413 | * poorly implemented hardware. |
414 | */ |
414 | */ |
415 | 415 | ||
416 | /* Write #1: write the SLP_TYP data to the PM1 Control registers */ |
416 | /* Write #1: write the SLP_TYP data to the PM1 Control registers */ |
417 | 417 | ||
418 | Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); |
418 | Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); |
419 | if (ACPI_FAILURE (Status)) |
419 | if (ACPI_FAILURE (Status)) |
420 | { |
420 | { |
421 | return_ACPI_STATUS (Status); |
421 | return_ACPI_STATUS (Status); |
422 | } |
422 | } |
423 | 423 | ||
424 | /* Insert the sleep enable (SLP_EN) bit */ |
424 | /* Insert the sleep enable (SLP_EN) bit */ |
425 | 425 | ||
426 | Pm1aControl |= SleepEnableRegInfo->AccessBitMask; |
426 | Pm1aControl |= SleepEnableRegInfo->AccessBitMask; |
427 | Pm1bControl |= SleepEnableRegInfo->AccessBitMask; |
427 | Pm1bControl |= SleepEnableRegInfo->AccessBitMask; |
428 | 428 | ||
429 | /* Flush caches, as per ACPI specification */ |
429 | /* Flush caches, as per ACPI specification */ |
430 | 430 | ||
431 | ACPI_FLUSH_CPU_CACHE (); |
431 | ACPI_FLUSH_CPU_CACHE (); |
432 | 432 | ||
433 | /* Write #2: Write both SLP_TYP + SLP_EN */ |
433 | /* Write #2: Write both SLP_TYP + SLP_EN */ |
434 | 434 | ||
435 | Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); |
435 | Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); |
436 | if (ACPI_FAILURE (Status)) |
436 | if (ACPI_FAILURE (Status)) |
437 | { |
437 | { |
438 | return_ACPI_STATUS (Status); |
438 | return_ACPI_STATUS (Status); |
439 | } |
439 | } |
440 | 440 | ||
441 | if (SleepState > ACPI_STATE_S3) |
441 | if (SleepState > ACPI_STATE_S3) |
442 | { |
442 | { |
443 | /* |
443 | /* |
444 | * We wanted to sleep > S3, but it didn't happen (by virtue of the |
444 | * We wanted to sleep > S3, but it didn't happen (by virtue of the |
445 | * fact that we are still executing!) |
445 | * fact that we are still executing!) |
446 | * |
446 | * |
447 | * Wait ten seconds, then try again. This is to get S4/S5 to work on |
447 | * Wait ten seconds, then try again. This is to get S4/S5 to work on |
448 | * all machines. |
448 | * all machines. |
449 | * |
449 | * |
450 | * We wait so long to allow chipsets that poll this reg very slowly |
450 | * We wait so long to allow chipsets that poll this reg very slowly |
451 | * to still read the right value. Ideally, this block would go |
451 | * to still read the right value. Ideally, this block would go |
452 | * away entirely. |
452 | * away entirely. |
453 | */ |
453 | */ |
454 | AcpiOsStall (10000000); |
454 | AcpiOsStall (10000000); |
455 | 455 | ||
456 | Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, |
456 | Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, |
457 | SleepEnableRegInfo->AccessBitMask); |
457 | SleepEnableRegInfo->AccessBitMask); |
458 | if (ACPI_FAILURE (Status)) |
458 | if (ACPI_FAILURE (Status)) |
459 | { |
459 | { |
460 | return_ACPI_STATUS (Status); |
460 | return_ACPI_STATUS (Status); |
461 | } |
461 | } |
462 | } |
462 | } |
463 | 463 | ||
464 | /* Wait until we enter sleep state */ |
464 | /* Wait until we enter sleep state */ |
465 | 465 | ||
466 | do |
466 | do |
467 | { |
467 | { |
468 | Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); |
468 | Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); |
469 | if (ACPI_FAILURE (Status)) |
469 | if (ACPI_FAILURE (Status)) |
470 | { |
470 | { |
471 | return_ACPI_STATUS (Status); |
471 | return_ACPI_STATUS (Status); |
472 | } |
472 | } |
473 | 473 | ||
474 | /* Spin until we wake */ |
474 | /* Spin until we wake */ |
475 | 475 | ||
476 | } while (!InValue); |
476 | } while (!InValue); |
477 | 477 | ||
478 | return_ACPI_STATUS (AE_OK); |
478 | return_ACPI_STATUS (AE_OK); |
479 | } |
479 | } |
480 | 480 | ||
481 | ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) |
481 | ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) |
482 | 482 | ||
483 | 483 | ||
484 | /******************************************************************************* |
484 | /******************************************************************************* |
485 | * |
485 | * |
486 | * FUNCTION: AcpiEnterSleepStateS4bios |
486 | * FUNCTION: AcpiEnterSleepStateS4bios |
487 | * |
487 | * |
488 | * PARAMETERS: None |
488 | * PARAMETERS: None |
489 | * |
489 | * |
490 | * RETURN: Status |
490 | * RETURN: Status |
491 | * |
491 | * |
492 | * DESCRIPTION: Perform a S4 bios request. |
492 | * DESCRIPTION: Perform a S4 bios request. |
493 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
493 | * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED |
494 | * |
494 | * |
495 | ******************************************************************************/ |
495 | ******************************************************************************/ |
496 | 496 | ||
497 | ACPI_STATUS |
497 | ACPI_STATUS |
498 | AcpiEnterSleepStateS4bios ( |
498 | AcpiEnterSleepStateS4bios ( |
499 | void) |
499 | void) |
500 | { |
500 | { |
501 | UINT32 InValue; |
501 | UINT32 InValue; |
502 | ACPI_STATUS Status; |
502 | ACPI_STATUS Status; |
503 | 503 | ||
504 | 504 | ||
505 | ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); |
505 | ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); |
506 | 506 | ||
507 | 507 | ||
508 | /* Clear the wake status bit (PM1) */ |
508 | /* Clear the wake status bit (PM1) */ |
509 | 509 | ||
510 | Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
510 | Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
511 | if (ACPI_FAILURE (Status)) |
511 | if (ACPI_FAILURE (Status)) |
512 | { |
512 | { |
513 | return_ACPI_STATUS (Status); |
513 | return_ACPI_STATUS (Status); |
514 | } |
514 | } |
515 | 515 | ||
516 | Status = AcpiHwClearAcpiStatus (); |
516 | Status = AcpiHwClearAcpiStatus (); |
517 | if (ACPI_FAILURE (Status)) |
517 | if (ACPI_FAILURE (Status)) |
518 | { |
518 | { |
519 | return_ACPI_STATUS (Status); |
519 | return_ACPI_STATUS (Status); |
520 | } |
520 | } |
521 | 521 | ||
522 | /* |
522 | /* |
523 | * 1) Disable/Clear all GPEs |
523 | * 1) Disable/Clear all GPEs |
524 | * 2) Enable all wakeup GPEs |
524 | * 2) Enable all wakeup GPEs |
525 | */ |
525 | */ |
526 | Status = AcpiHwDisableAllGpes (); |
526 | Status = AcpiHwDisableAllGpes (); |
527 | if (ACPI_FAILURE (Status)) |
527 | if (ACPI_FAILURE (Status)) |
528 | { |
528 | { |
529 | return_ACPI_STATUS (Status); |
529 | return_ACPI_STATUS (Status); |
530 | } |
530 | } |
531 | AcpiGbl_SystemAwakeAndRunning = FALSE; |
531 | AcpiGbl_SystemAwakeAndRunning = FALSE; |
532 | 532 | ||
533 | Status = AcpiHwEnableAllWakeupGpes (); |
533 | Status = AcpiHwEnableAllWakeupGpes (); |
534 | if (ACPI_FAILURE (Status)) |
534 | if (ACPI_FAILURE (Status)) |
535 | { |
535 | { |
536 | return_ACPI_STATUS (Status); |
536 | return_ACPI_STATUS (Status); |
537 | } |
537 | } |
538 | 538 | ||
539 | ACPI_FLUSH_CPU_CACHE (); |
539 | ACPI_FLUSH_CPU_CACHE (); |
540 | 540 | ||
541 | Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, |
541 | Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, |
542 | (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); |
542 | (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); |
543 | 543 | ||
544 | do { |
544 | do { |
545 | AcpiOsStall(1000); |
545 | AcpiOsStall(1000); |
546 | Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); |
546 | Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); |
547 | if (ACPI_FAILURE (Status)) |
547 | if (ACPI_FAILURE (Status)) |
548 | { |
548 | { |
549 | return_ACPI_STATUS (Status); |
549 | return_ACPI_STATUS (Status); |
550 | } |
550 | } |
551 | } while (!InValue); |
551 | } while (!InValue); |
552 | 552 | ||
553 | return_ACPI_STATUS (AE_OK); |
553 | return_ACPI_STATUS (AE_OK); |
554 | } |
554 | } |
555 | 555 | ||
556 | ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) |
556 | ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) |
557 | 557 | ||
558 | 558 | ||
559 | /******************************************************************************* |
559 | /******************************************************************************* |
560 | * |
560 | * |
561 | * FUNCTION: AcpiLeaveSleepState |
561 | * FUNCTION: AcpiLeaveSleepState |
562 | * |
562 | * |
563 | * PARAMETERS: SleepState - Which sleep state we just exited |
563 | * PARAMETERS: SleepState - Which sleep state we just exited |
564 | * |
564 | * |
565 | * RETURN: Status |
565 | * RETURN: Status |
566 | * |
566 | * |
567 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep |
567 | * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep |
568 | * Called with interrupts ENABLED. |
568 | * Called with interrupts ENABLED. |
569 | * |
569 | * |
570 | ******************************************************************************/ |
570 | ******************************************************************************/ |
571 | 571 | ||
572 | ACPI_STATUS |
572 | ACPI_STATUS |
573 | AcpiLeaveSleepState ( |
573 | AcpiLeaveSleepState ( |
574 | UINT8 SleepState) |
574 | UINT8 SleepState) |
575 | { |
575 | { |
576 | ACPI_OBJECT_LIST ArgList; |
576 | ACPI_OBJECT_LIST ArgList; |
577 | ACPI_OBJECT Arg; |
577 | ACPI_OBJECT Arg; |
578 | ACPI_STATUS Status; |
578 | ACPI_STATUS Status; |
579 | ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; |
579 | ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; |
580 | ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; |
580 | ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; |
581 | UINT32 Pm1aControl; |
581 | UINT32 Pm1aControl; |
582 | UINT32 Pm1bControl; |
582 | UINT32 Pm1bControl; |
583 | 583 | ||
584 | 584 | ||
585 | ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); |
585 | ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); |
586 | 586 | ||
587 | 587 | ||
588 | /* |
588 | /* |
589 | * Set SLP_TYPE and SLP_EN to state S0. |
589 | * Set SLP_TYPE and SLP_EN to state S0. |
590 | * This is unclear from the ACPI Spec, but it is required |
590 | * This is unclear from the ACPI Spec, but it is required |
591 | * by some machines. |
591 | * by some machines. |
592 | */ |
592 | */ |
593 | Status = AcpiGetSleepTypeData (ACPI_STATE_S0, |
593 | Status = AcpiGetSleepTypeData (ACPI_STATE_S0, |
594 | &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); |
594 | &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); |
595 | if (ACPI_SUCCESS (Status)) |
595 | if (ACPI_SUCCESS (Status)) |
596 | { |
596 | { |
597 | SleepTypeRegInfo = |
597 | SleepTypeRegInfo = |
598 | AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); |
598 | AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); |
599 | SleepEnableRegInfo = |
599 | SleepEnableRegInfo = |
600 | AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); |
600 | AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); |
601 | 601 | ||
602 | /* Get current value of PM1A control */ |
602 | /* Get current value of PM1A control */ |
603 | 603 | ||
604 | Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, |
604 | Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, |
605 | &Pm1aControl); |
605 | &Pm1aControl); |
606 | if (ACPI_SUCCESS (Status)) |
606 | if (ACPI_SUCCESS (Status)) |
607 | { |
607 | { |
608 | /* Clear the SLP_EN and SLP_TYP fields */ |
608 | /* Clear the SLP_EN and SLP_TYP fields */ |
609 | 609 | ||
610 | Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | |
610 | Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | |
611 | SleepEnableRegInfo->AccessBitMask); |
611 | SleepEnableRegInfo->AccessBitMask); |
612 | Pm1bControl = Pm1aControl; |
612 | Pm1bControl = Pm1aControl; |
613 | 613 | ||
614 | /* Insert the SLP_TYP bits */ |
614 | /* Insert the SLP_TYP bits */ |
615 | 615 | ||
616 | Pm1aControl |= (AcpiGbl_SleepTypeA << |
616 | Pm1aControl |= (AcpiGbl_SleepTypeA << |
617 | SleepTypeRegInfo->BitPosition); |
617 | SleepTypeRegInfo->BitPosition); |
618 | Pm1bControl |= (AcpiGbl_SleepTypeB << |
618 | Pm1bControl |= (AcpiGbl_SleepTypeB << |
619 | SleepTypeRegInfo->BitPosition); |
619 | SleepTypeRegInfo->BitPosition); |
620 | 620 | ||
621 | /* Write the control registers and ignore any errors */ |
621 | /* Write the control registers and ignore any errors */ |
622 | 622 | ||
623 | (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); |
623 | (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); |
624 | } |
624 | } |
625 | } |
625 | } |
626 | 626 | ||
627 | /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ |
627 | /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ |
628 | 628 | ||
629 | AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; |
629 | AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; |
630 | 630 | ||
631 | /* Setup parameter object */ |
631 | /* Setup parameter object */ |
632 | 632 | ||
633 | ArgList.Count = 1; |
633 | ArgList.Count = 1; |
634 | ArgList.Pointer = &Arg; |
634 | ArgList.Pointer = &Arg; |
635 | Arg.Type = ACPI_TYPE_INTEGER; |
635 | Arg.Type = ACPI_TYPE_INTEGER; |
636 | 636 | ||
637 | /* Ignore any errors from these methods */ |
637 | /* Ignore any errors from these methods */ |
638 | 638 | ||
639 | Arg.Integer.Value = ACPI_SST_WAKING; |
639 | Arg.Integer.Value = ACPI_SST_WAKING; |
640 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); |
640 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); |
641 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
641 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
642 | { |
642 | { |
643 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); |
643 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); |
644 | } |
644 | } |
645 | 645 | ||
646 | Arg.Integer.Value = SleepState; |
646 | Arg.Integer.Value = SleepState; |
647 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); |
647 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); |
648 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
648 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
649 | { |
649 | { |
650 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS")); |
650 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS")); |
651 | } |
651 | } |
652 | 652 | ||
653 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); |
653 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); |
654 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
654 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
655 | { |
655 | { |
656 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK")); |
656 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK")); |
657 | } |
657 | } |
658 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ |
658 | /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ |
659 | 659 | ||
660 | /* |
660 | /* |
661 | * Restore the GPEs: |
661 | * Restore the GPEs: |
662 | * 1) Disable/Clear all GPEs |
662 | * 1) Disable/Clear all GPEs |
663 | * 2) Enable all runtime GPEs |
663 | * 2) Enable all runtime GPEs |
664 | */ |
664 | */ |
665 | Status = AcpiHwDisableAllGpes (); |
665 | Status = AcpiHwDisableAllGpes (); |
666 | if (ACPI_FAILURE (Status)) |
666 | if (ACPI_FAILURE (Status)) |
667 | { |
667 | { |
668 | return_ACPI_STATUS (Status); |
668 | return_ACPI_STATUS (Status); |
669 | } |
669 | } |
670 | AcpiGbl_SystemAwakeAndRunning = TRUE; |
670 | AcpiGbl_SystemAwakeAndRunning = TRUE; |
671 | 671 | ||
672 | Status = AcpiHwEnableAllRuntimeGpes (); |
672 | Status = AcpiHwEnableAllRuntimeGpes (); |
673 | if (ACPI_FAILURE (Status)) |
673 | if (ACPI_FAILURE (Status)) |
674 | { |
674 | { |
675 | return_ACPI_STATUS (Status); |
675 | return_ACPI_STATUS (Status); |
676 | } |
676 | } |
677 | 677 | ||
678 | /* Enable power button */ |
678 | /* Enable power button */ |
679 | 679 | ||
680 | (void) AcpiWriteBitRegister( |
680 | (void) AcpiWriteBitRegister( |
681 | AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, |
681 | AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, |
682 | ACPI_ENABLE_EVENT); |
682 | ACPI_ENABLE_EVENT); |
683 | 683 | ||
684 | (void) AcpiWriteBitRegister( |
684 | (void) AcpiWriteBitRegister( |
685 | AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, |
685 | AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, |
686 | ACPI_CLEAR_STATUS); |
686 | ACPI_CLEAR_STATUS); |
687 | 687 | ||
688 | /* |
688 | /* |
689 | * Enable BM arbitration. This feature is contained within an |
689 | * Enable BM arbitration. This feature is contained within an |
690 | * optional register (PM2 Control), so ignore a BAD_ADDRESS |
690 | * optional register (PM2 Control), so ignore a BAD_ADDRESS |
691 | * exception. |
691 | * exception. |
692 | */ |
692 | */ |
693 | Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); |
693 | Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); |
694 | if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) |
694 | if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) |
695 | { |
695 | { |
696 | return_ACPI_STATUS (Status); |
696 | return_ACPI_STATUS (Status); |
697 | } |
697 | } |
698 | 698 | ||
699 | Arg.Integer.Value = ACPI_SST_WORKING; |
699 | Arg.Integer.Value = ACPI_SST_WORKING; |
700 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); |
700 | Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); |
701 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
701 | if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
702 | { |
702 | { |
703 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); |
703 | ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); |
704 | } |
704 | } |
705 | 705 | ||
706 | return_ACPI_STATUS (Status); |
706 | return_ACPI_STATUS (Status); |
707 | } |
707 | } |
708 | 708 | ||
709 | ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) |
709 | ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) |
710 | >< |
710 | >< |
711 | > |
711 | > |
712 | >< |
712 | >< |
713 | >><>><>>=> |
713 | >><>><>>=> |