This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_hw_legacy_wake_prep
- acpi_hw_legacy_wake
1
2
3
4
5
6
7
8
9
10
11 #include <acpi/acpi.h>
12 #include "accommon.h"
13
14 #define _COMPONENT ACPI_HARDWARE
15 ACPI_MODULE_NAME("hwsleep")
16
17 #if (!ACPI_REDUCED_HARDWARE)
18
19
20
21
22
23
24
25
26
27
28
29
30 acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
31 {
32 struct acpi_bit_register_info *sleep_type_reg_info;
33 struct acpi_bit_register_info *sleep_enable_reg_info;
34 u32 pm1a_control;
35 u32 pm1b_control;
36 u32 in_value;
37 acpi_status status;
38
39 ACPI_FUNCTION_TRACE(hw_legacy_sleep);
40
41 sleep_type_reg_info =
42 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
43 sleep_enable_reg_info =
44 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
45
46
47
48 status = acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
49 ACPI_CLEAR_STATUS);
50 if (ACPI_FAILURE(status)) {
51 return_ACPI_STATUS(status);
52 }
53
54
55 status = acpi_hw_disable_all_gpes();
56 if (ACPI_FAILURE(status)) {
57 return_ACPI_STATUS(status);
58 }
59 status = acpi_hw_clear_acpi_status();
60 if (ACPI_FAILURE(status)) {
61 return_ACPI_STATUS(status);
62 }
63 acpi_gbl_system_awake_and_running = FALSE;
64
65
66 status = acpi_hw_enable_all_wakeup_gpes();
67 if (ACPI_FAILURE(status)) {
68 return_ACPI_STATUS(status);
69 }
70
71
72
73 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
74 &pm1a_control);
75 if (ACPI_FAILURE(status)) {
76 return_ACPI_STATUS(status);
77 }
78 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
79 "Entering sleep state [S%u]\n", sleep_state));
80
81
82
83 pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
84 sleep_enable_reg_info->access_bit_mask);
85 pm1b_control = pm1a_control;
86
87
88
89 pm1a_control |=
90 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
91 pm1b_control |=
92 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
93
94
95
96
97
98
99
100
101 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
102 if (ACPI_FAILURE(status)) {
103 return_ACPI_STATUS(status);
104 }
105
106
107
108 pm1a_control |= sleep_enable_reg_info->access_bit_mask;
109 pm1b_control |= sleep_enable_reg_info->access_bit_mask;
110
111
112
113 ACPI_FLUSH_CPU_CACHE();
114
115 status = acpi_os_enter_sleep(sleep_state, pm1a_control, pm1b_control);
116 if (status == AE_CTRL_TERMINATE) {
117 return_ACPI_STATUS(AE_OK);
118 }
119 if (ACPI_FAILURE(status)) {
120 return_ACPI_STATUS(status);
121 }
122
123
124
125 status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
126 if (ACPI_FAILURE(status)) {
127 return_ACPI_STATUS(status);
128 }
129
130 if (sleep_state > ACPI_STATE_S3) {
131
132
133
134
135
136
137
138
139
140
141
142 acpi_os_stall(10 * ACPI_USEC_PER_SEC);
143
144 status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
145 sleep_enable_reg_info->
146 access_bit_mask);
147 if (ACPI_FAILURE(status)) {
148 return_ACPI_STATUS(status);
149 }
150 }
151
152
153
154 do {
155 status =
156 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
157 if (ACPI_FAILURE(status)) {
158 return_ACPI_STATUS(status);
159 }
160
161 } while (!in_value);
162
163 return_ACPI_STATUS(AE_OK);
164 }
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180 acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
181 {
182 acpi_status status;
183 struct acpi_bit_register_info *sleep_type_reg_info;
184 struct acpi_bit_register_info *sleep_enable_reg_info;
185 u32 pm1a_control;
186 u32 pm1b_control;
187
188 ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
189
190
191
192
193
194
195 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
196 &acpi_gbl_sleep_type_a,
197 &acpi_gbl_sleep_type_b);
198 if (ACPI_SUCCESS(status)) {
199 sleep_type_reg_info =
200 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
201 sleep_enable_reg_info =
202 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
203
204
205
206 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
207 &pm1a_control);
208 if (ACPI_SUCCESS(status)) {
209
210
211
212 pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
213 sleep_enable_reg_info->
214 access_bit_mask);
215 pm1b_control = pm1a_control;
216
217
218
219 pm1a_control |= (acpi_gbl_sleep_type_a <<
220 sleep_type_reg_info->bit_position);
221 pm1b_control |= (acpi_gbl_sleep_type_b <<
222 sleep_type_reg_info->bit_position);
223
224
225
226 (void)acpi_hw_write_pm1_control(pm1a_control,
227 pm1b_control);
228 }
229 }
230
231 return_ACPI_STATUS(status);
232 }
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247 acpi_status acpi_hw_legacy_wake(u8 sleep_state)
248 {
249 acpi_status status;
250
251 ACPI_FUNCTION_TRACE(hw_legacy_wake);
252
253
254
255 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
256 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
257
258
259
260
261
262
263
264
265
266 status = acpi_hw_disable_all_gpes();
267 if (ACPI_FAILURE(status)) {
268 return_ACPI_STATUS(status);
269 }
270
271 status = acpi_hw_enable_all_runtime_gpes();
272 if (ACPI_FAILURE(status)) {
273 return_ACPI_STATUS(status);
274 }
275
276
277
278
279
280 acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
281
282
283
284
285
286
287 (void)acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS,
288 ACPI_CLEAR_STATUS);
289 acpi_gbl_system_awake_and_running = TRUE;
290
291
292
293 (void)
294 acpi_write_bit_register(acpi_gbl_fixed_event_info
295 [ACPI_EVENT_POWER_BUTTON].
296 enable_register_id, ACPI_ENABLE_EVENT);
297
298 (void)
299 acpi_write_bit_register(acpi_gbl_fixed_event_info
300 [ACPI_EVENT_POWER_BUTTON].
301 status_register_id, ACPI_CLEAR_STATUS);
302
303 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
304 return_ACPI_STATUS(status);
305 }
306
307 #endif