aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2012-02-14 05:47:42 -0500
committerLen Brown <len.brown@intel.com>2012-03-22 01:45:03 -0400
commit709585765734e90d9fe0a2dc9c6f4e49eff5c6ec (patch)
tree937a5f1bc23c706f9771e9a4cbbee8bd9b497b02 /drivers/acpi/acpica
parentf99648b1aff8b6158333a06c50d627be3c243a32 (diff)
ACPICA: Split sleep/wake functions into two files
The functions for the original/legacy sleep/wake registers are in hwsleep.c, and the functions for the new extended FADT V5 sleep registers are in hwesleep.c Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/Makefile1
-rw-r--r--drivers/acpi/acpica/achware.h17
-rw-r--r--drivers/acpi/acpica/hwesleep.c251
-rw-r--r--drivers/acpi/acpica/hwsleep.c207
4 files changed, 265 insertions, 211 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index da5518063ef7..793b8cc8e256 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -68,6 +68,7 @@ acpi-y += \
68 68
69acpi-y += \ 69acpi-y += \
70 hwacpi.o \ 70 hwacpi.o \
71 hwesleep.o \
71 hwgpe.o \ 72 hwgpe.o \
72 hwpci.o \ 73 hwpci.o \
73 hwregs.o \ 74 hwregs.o \
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index d3f62a83f454..5de4ec72766d 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -81,22 +81,25 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value);
81acpi_status acpi_hw_clear_acpi_status(void); 81acpi_status acpi_hw_clear_acpi_status(void);
82 82
83/* 83/*
84 * hwsleep - sleep/wake support 84 * hwsleep - sleep/wake support (Legacy sleep registers)
85 */
86acpi_status acpi_hw_legacy_sleep(u8 sleep_state);
87
88acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state);
89
90acpi_status acpi_hw_legacy_wake(u8 sleep_state);
91
92/*
93 * hwesleep - sleep/wake support (Extended FADT-V5 sleep registers)
85 */ 94 */
86void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument); 95void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument);
87 96
88acpi_status acpi_hw_extended_sleep(u8 sleep_state); 97acpi_status acpi_hw_extended_sleep(u8 sleep_state);
89 98
90acpi_status acpi_hw_legacy_sleep(u8 sleep_state);
91
92acpi_status acpi_hw_extended_wake_prep(u8 sleep_state); 99acpi_status acpi_hw_extended_wake_prep(u8 sleep_state);
93 100
94acpi_status acpi_hw_extended_wake(u8 sleep_state); 101acpi_status acpi_hw_extended_wake(u8 sleep_state);
95 102
96acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state);
97
98acpi_status acpi_hw_legacy_wake(u8 sleep_state);
99
100/* 103/*
101 * hwvalid - Port I/O with validation 104 * hwvalid - Port I/O with validation
102 */ 105 */
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
new file mode 100644
index 000000000000..9e44c6c767e6
--- /dev/null
+++ b/drivers/acpi/acpica/hwesleep.c
@@ -0,0 +1,251 @@
1/******************************************************************************
2 *
3 * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the
4 * extended FADT-V5 sleep registers.
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2012, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include "accommon.h"
47#include <linux/module.h>
48
49#define _COMPONENT ACPI_HARDWARE
50ACPI_MODULE_NAME("hwesleep")
51
52static unsigned int gts, bfs;
53module_param(gts, uint, 0644);
54module_param(bfs, uint, 0644);
55MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
56MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_hw_execute_sleep_method
61 *
62 * PARAMETERS: method_name - Pathname of method to execute
63 * integer_argument - Argument to pass to the method
64 *
65 * RETURN: None
66 *
67 * DESCRIPTION: Execute a sleep/wake related method with one integer argument
68 * and no return value.
69 *
70 ******************************************************************************/
71void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument)
72{
73 struct acpi_object_list arg_list;
74 union acpi_object arg;
75 acpi_status status;
76
77 ACPI_FUNCTION_TRACE(hw_execute_sleep_method);
78
79 if (!ACPI_STRCMP(METHOD_NAME__GTS, method_name) && !gts)
80 return_VOID;
81
82 if (!ACPI_STRCMP(METHOD_NAME__BFS, method_name) && !bfs)
83 return_VOID;
84
85 /* One argument, integer_argument; No return value expected */
86
87 arg_list.count = 1;
88 arg_list.pointer = &arg;
89 arg.type = ACPI_TYPE_INTEGER;
90 arg.integer.value = (u64)integer_argument;
91
92 status = acpi_evaluate_object(NULL, method_name, &arg_list, NULL);
93 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
94 ACPI_EXCEPTION((AE_INFO, status, "While executing method %s",
95 method_name));
96 }
97
98 return_VOID;
99}
100
101/*******************************************************************************
102 *
103 * FUNCTION: acpi_hw_extended_sleep
104 *
105 * PARAMETERS: sleep_state - Which sleep state to enter
106 *
107 * RETURN: Status
108 *
109 * DESCRIPTION: Enter a system sleep state via the extended FADT sleep
110 * registers (V5 FADT).
111 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
112 *
113 ******************************************************************************/
114
115acpi_status acpi_hw_extended_sleep(u8 sleep_state)
116{
117 acpi_status status;
118 u8 sleep_type_value;
119 u64 sleep_status;
120
121 ACPI_FUNCTION_TRACE(hw_extended_sleep);
122
123 /* Extended sleep registers must be valid */
124
125 if (!acpi_gbl_FADT.sleep_control.address ||
126 !acpi_gbl_FADT.sleep_status.address) {
127 return_ACPI_STATUS(AE_NOT_EXIST);
128 }
129
130 /* Clear wake status (WAK_STS) */
131
132 status = acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
133 if (ACPI_FAILURE(status)) {
134 return_ACPI_STATUS(status);
135 }
136
137 acpi_gbl_system_awake_and_running = FALSE;
138
139 /* Execute the _GTS method (Going To Sleep) */
140
141 acpi_hw_execute_sleep_method(METHOD_NAME__GTS, sleep_state);
142
143 /* Flush caches, as per ACPI specification */
144
145 ACPI_FLUSH_CPU_CACHE();
146
147 /*
148 * Set the SLP_TYP and SLP_EN bits.
149 *
150 * Note: We only use the first value returned by the \_Sx method
151 * (acpi_gbl_sleep_type_a) - As per ACPI specification.
152 */
153 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
154 "Entering sleep state [S%u]\n", sleep_state));
155
156 sleep_type_value =
157 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
158 ACPI_X_SLEEP_TYPE_MASK);
159
160 status = acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE),
161 &acpi_gbl_FADT.sleep_control);
162 if (ACPI_FAILURE(status)) {
163 return_ACPI_STATUS(status);
164 }
165
166 /* Wait for transition back to Working State */
167
168 do {
169 status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status);
170 if (ACPI_FAILURE(status)) {
171 return_ACPI_STATUS(status);
172 }
173
174 } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS));
175
176 return_ACPI_STATUS(AE_OK);
177}
178
179/*******************************************************************************
180 *
181 * FUNCTION: acpi_hw_extended_wake_prep
182 *
183 * PARAMETERS: sleep_state - Which sleep state we just exited
184 *
185 * RETURN: Status
186 *
187 * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after
188 * a sleep. Called with interrupts ENABLED.
189 *
190 ******************************************************************************/
191
192acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
193{
194 acpi_status status;
195 u8 sleep_type_value;
196
197 ACPI_FUNCTION_TRACE(hw_extended_wake_prep);
198
199 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
200 &acpi_gbl_sleep_type_a,
201 &acpi_gbl_sleep_type_b);
202 if (ACPI_SUCCESS(status)) {
203 sleep_type_value =
204 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
205 ACPI_X_SLEEP_TYPE_MASK);
206
207 (void)acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE),
208 &acpi_gbl_FADT.sleep_control);
209 }
210
211 acpi_hw_execute_sleep_method(METHOD_NAME__BFS, sleep_state);
212 return_ACPI_STATUS(AE_OK);
213}
214
215/*******************************************************************************
216 *
217 * FUNCTION: acpi_hw_extended_wake
218 *
219 * PARAMETERS: sleep_state - Which sleep state we just exited
220 *
221 * RETURN: Status
222 *
223 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
224 * Called with interrupts ENABLED.
225 *
226 ******************************************************************************/
227
228acpi_status acpi_hw_extended_wake(u8 sleep_state)
229{
230 ACPI_FUNCTION_TRACE(hw_extended_wake);
231
232 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
233
234 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
235
236 /* Execute the wake methods */
237
238 acpi_hw_execute_sleep_method(METHOD_NAME__SST, ACPI_SST_WAKING);
239 acpi_hw_execute_sleep_method(METHOD_NAME__WAK, sleep_state);
240
241 /*
242 * Some BIOS code assumes that WAK_STS will be cleared on resume
243 * and use it to determine whether the system is rebooting or
244 * resuming. Clear WAK_STS for compatibility.
245 */
246 (void)acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
247 acpi_gbl_system_awake_and_running = TRUE;
248
249 acpi_hw_execute_sleep_method(METHOD_NAME__SST, ACPI_SST_WORKING);
250 return_ACPI_STATUS(AE_OK);
251}
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index abe65ff4231e..b96d41bbc64e 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -1,6 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 * 2 *
3 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support Functions 3 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
4 * original/legacy sleep/PM registers.
4 * 5 *
5 *****************************************************************************/ 6 *****************************************************************************/
6 7
@@ -49,56 +50,7 @@
49#define _COMPONENT ACPI_HARDWARE 50#define _COMPONENT ACPI_HARDWARE
50ACPI_MODULE_NAME("hwsleep") 51ACPI_MODULE_NAME("hwsleep")
51 52
52static unsigned int gts, bfs; 53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
53module_param(gts, uint, 0644);
54module_param(bfs, uint, 0644);
55MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
56MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
57
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_hw_execute_sleep_method
61 *
62 * PARAMETERS: method_name - Pathname of method to execute
63 * integer_argument - Argument to pass to the method
64 *
65 * RETURN: None
66 *
67 * DESCRIPTION: Execute a sleep/wake related method, with one integer argument
68 * and no return value.
69 *
70 ******************************************************************************/
71void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument)
72{
73 struct acpi_object_list arg_list;
74 union acpi_object arg;
75 acpi_status status;
76
77 ACPI_FUNCTION_TRACE(hw_execute_sleep_method);
78
79 if (!ACPI_STRCMP(METHOD_NAME__GTS, method_name) && !gts)
80 return_VOID;
81
82 if (!ACPI_STRCMP(METHOD_NAME__BFS, method_name) && !bfs)
83 return_VOID;
84
85 /* One argument, integer_argument */
86
87 arg_list.count = 1;
88 arg_list.pointer = &arg;
89 arg.type = ACPI_TYPE_INTEGER;
90 arg.integer.value = (u64)integer_argument;
91
92 status = acpi_evaluate_object(NULL, method_name, &arg_list, NULL);
93 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
94 ACPI_EXCEPTION((AE_INFO, status, "While executing method %s",
95 method_name));
96 }
97
98 return_VOID;
99}
100
101#if (!ACPI_REDUCED_HARDWARE)
102/******************************************************************************* 54/*******************************************************************************
103 * 55 *
104 * FUNCTION: acpi_hw_legacy_sleep 56 * FUNCTION: acpi_hw_legacy_sleep
@@ -111,7 +63,6 @@ void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument)
111 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 63 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
112 * 64 *
113 ******************************************************************************/ 65 ******************************************************************************/
114
115acpi_status acpi_hw_legacy_sleep(u8 sleep_state) 66acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
116{ 67{
117 struct acpi_bit_register_info *sleep_type_reg_info; 68 struct acpi_bit_register_info *sleep_type_reg_info;
@@ -415,155 +366,3 @@ acpi_status acpi_hw_legacy_wake(u8 sleep_state)
415} 366}
416 367
417#endif /* !ACPI_REDUCED_HARDWARE */ 368#endif /* !ACPI_REDUCED_HARDWARE */
418
419/*******************************************************************************
420 *
421 * FUNCTION: acpi_hw_extended_sleep
422 *
423 * PARAMETERS: sleep_state - Which sleep state to enter
424 *
425 * RETURN: Status
426 *
427 * DESCRIPTION: Enter a system sleep state via the extended FADT sleep
428 * registers (V5 FADT).
429 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
430 *
431 ******************************************************************************/
432
433acpi_status acpi_hw_extended_sleep(u8 sleep_state)
434{
435 acpi_status status;
436 u8 sleep_type_value;
437 u64 sleep_status;
438
439 ACPI_FUNCTION_TRACE(hw_extended_sleep);
440
441 /* Extended sleep registers must be valid */
442
443 if (!acpi_gbl_FADT.sleep_control.address ||
444 !acpi_gbl_FADT.sleep_status.address) {
445 return_ACPI_STATUS(AE_NOT_EXIST);
446 }
447
448 /* Clear wake status (WAK_STS) */
449
450 status = acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
451 if (ACPI_FAILURE(status)) {
452 return_ACPI_STATUS(status);
453 }
454
455 acpi_gbl_system_awake_and_running = FALSE;
456
457 /* Execute the _GTS method (Going To Sleep) */
458
459 acpi_hw_execute_sleep_method(METHOD_NAME__GTS, sleep_state);
460
461 /* Flush caches, as per ACPI specification */
462
463 ACPI_FLUSH_CPU_CACHE();
464
465 /*
466 * Set the SLP_TYP and SLP_EN bits.
467 *
468 * Note: We only use the first value returned by the \_Sx method
469 * (acpi_gbl_sleep_type_a) - As per ACPI specification.
470 */
471 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
472 "Entering sleep state [S%u]\n", sleep_state));
473
474 sleep_type_value =
475 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
476 ACPI_X_SLEEP_TYPE_MASK);
477
478 status = acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE),
479 &acpi_gbl_FADT.sleep_control);
480 if (ACPI_FAILURE(status)) {
481 return_ACPI_STATUS(status);
482 }
483
484 /* Wait for transition back to Working State */
485
486 do {
487 status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status);
488 if (ACPI_FAILURE(status)) {
489 return_ACPI_STATUS(status);
490 }
491
492 } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS));
493
494 return_ACPI_STATUS(AE_OK);
495}
496
497/*******************************************************************************
498 *
499 * FUNCTION: acpi_hw_extended_wake_prep
500 *
501 * PARAMETERS: sleep_state - Which sleep state we just exited
502 *
503 * RETURN: Status
504 *
505 * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after
506 * a sleep. Called with interrupts ENABLED.
507 *
508 ******************************************************************************/
509
510acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
511{
512 acpi_status status;
513 u8 sleep_type_value;
514
515 ACPI_FUNCTION_TRACE(hw_extended_wake_prep);
516
517 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
518 &acpi_gbl_sleep_type_a,
519 &acpi_gbl_sleep_type_b);
520 if (ACPI_SUCCESS(status)) {
521 sleep_type_value =
522 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
523 ACPI_X_SLEEP_TYPE_MASK);
524
525 (void)acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE),
526 &acpi_gbl_FADT.sleep_control);
527 }
528
529 acpi_hw_execute_sleep_method(METHOD_NAME__BFS, sleep_state);
530 return_ACPI_STATUS(AE_OK);
531}
532
533/*******************************************************************************
534 *
535 * FUNCTION: acpi_hw_extended_wake
536 *
537 * PARAMETERS: sleep_state - Which sleep state we just exited
538 *
539 * RETURN: Status
540 *
541 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
542 * Called with interrupts ENABLED.
543 *
544 ******************************************************************************/
545
546acpi_status acpi_hw_extended_wake(u8 sleep_state)
547{
548 ACPI_FUNCTION_TRACE(hw_extended_wake);
549
550 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
551
552 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
553
554 /* Execute the wake methods */
555
556 acpi_hw_execute_sleep_method(METHOD_NAME__SST, ACPI_SST_WAKING);
557 acpi_hw_execute_sleep_method(METHOD_NAME__WAK, sleep_state);
558
559 /*
560 * Some BIOS code assumes that WAK_STS will be cleared on resume
561 * and use it to determine whether the system is rebooting or
562 * resuming. Clear WAK_STS for compatibility.
563 */
564 (void)acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
565 acpi_gbl_system_awake_and_running = TRUE;
566
567 acpi_hw_execute_sleep_method(METHOD_NAME__SST, ACPI_SST_WORKING);
568 return_ACPI_STATUS(AE_OK);
569}