aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2012-02-14 05:57:13 -0500
committerLen Brown <len.brown@intel.com>2012-03-22 01:45:05 -0400
commit72a8887a356076dfa39bd6691c52446f90a50480 (patch)
tree6cdf2e3f228b8482273029066554d57c7095a405 /drivers
parent709585765734e90d9fe0a2dc9c6f4e49eff5c6ec (diff)
ACPICA: Add table-driven dispatch for sleep/wake functions
Simplifies the code, especially the compile-time ACPI_REDUCED_HARDWARE option. 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')
-rw-r--r--drivers/acpi/acpica/acmacros.h6
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c136
2 files changed, 88 insertions, 54 deletions
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index ef338a96f5b2..f119f473f71a 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -516,6 +516,12 @@
516 516
517#endif /* ACPI_DEBUG_OUTPUT */ 517#endif /* ACPI_DEBUG_OUTPUT */
518 518
519#if (!ACPI_REDUCED_HARDWARE)
520#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr
521#else
522#define ACPI_HW_OPTIONAL_FUNCTION(addr) NULL
523#endif
524
519/* 525/*
520 * Some code only gets executed when the debugger is built in. 526 * Some code only gets executed when the debugger is built in.
521 * Note that this is entirely independent of whether the 527 * Note that this is entirely independent of whether the
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
index ff2055804809..b711f97c9a87 100644
--- a/drivers/acpi/acpica/hwxfsleep.c
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -48,6 +48,34 @@
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwxfsleep") 49ACPI_MODULE_NAME("hwxfsleep")
50 50
51/* Local prototypes */
52static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id);
53
54/*
55 * Dispatch table used to efficiently branch to the various sleep
56 * functions.
57 */
58#define ACPI_SLEEP_FUNCTION 0
59#define ACPI_WAKE_PREP_FUNCTION 1
60#define ACPI_WAKE_FUNCTION 2
61
62/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
63
64static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
65 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
66 acpi_hw_extended_sleep},
67 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
68 acpi_hw_extended_wake_prep},
69 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
70};
71
72/*
73 * These functions are removed for the ACPI_REDUCED_HARDWARE case:
74 * acpi_set_firmware_waking_vector
75 * acpi_set_firmware_waking_vector64
76 * acpi_enter_sleep_state_s4bios
77 */
78
51#if (!ACPI_REDUCED_HARDWARE) 79#if (!ACPI_REDUCED_HARDWARE)
52/******************************************************************************* 80/*******************************************************************************
53 * 81 *
@@ -61,6 +89,7 @@ ACPI_MODULE_NAME("hwxfsleep")
61 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS 89 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
62 * 90 *
63 ******************************************************************************/ 91 ******************************************************************************/
92
64acpi_status acpi_set_firmware_waking_vector(u32 physical_address) 93acpi_status acpi_set_firmware_waking_vector(u32 physical_address)
65{ 94{
66 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); 95 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
@@ -193,18 +222,65 @@ ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
193#endif /* !ACPI_REDUCED_HARDWARE */ 222#endif /* !ACPI_REDUCED_HARDWARE */
194/******************************************************************************* 223/*******************************************************************************
195 * 224 *
225 * FUNCTION: acpi_hw_sleep_dispatch
226 *
227 * PARAMETERS: sleep_state - Which sleep state to enter/exit
228 * function_id - Sleep, wake_prep, or Wake
229 *
230 * RETURN: Status from the invoked sleep handling function.
231 *
232 * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling
233 * function.
234 *
235 ******************************************************************************/
236static acpi_status acpi_hw_sleep_dispatch(u8 sleep_state, u32 function_id)
237{
238 acpi_status status;
239 struct acpi_sleep_functions *sleep_functions =
240 &acpi_sleep_dispatch[function_id];
241
242#if (!ACPI_REDUCED_HARDWARE)
243
244 /*
245 * If the Hardware Reduced flag is set (from the FADT), we must
246 * use the extended sleep registers
247 */
248 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
249 status = sleep_functions->extended_function(sleep_state);
250 } else {
251 /* Legacy sleep */
252
253 status = sleep_functions->legacy_function(sleep_state);
254 }
255
256 return (status);
257
258#else
259 /*
260 * For the case where reduced-hardware-only code is being generated,
261 * we know that only the extended sleep registers are available
262 */
263 status = sleep_functions->extended_function(sleep_state);
264 return (status);
265
266#endif /* !ACPI_REDUCED_HARDWARE */
267}
268
269/*******************************************************************************
270 *
196 * FUNCTION: acpi_enter_sleep_state_prep 271 * FUNCTION: acpi_enter_sleep_state_prep
197 * 272 *
198 * PARAMETERS: sleep_state - Which sleep state to enter 273 * PARAMETERS: sleep_state - Which sleep state to enter
199 * 274 *
200 * RETURN: Status 275 * RETURN: Status
201 * 276 *
202 * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) 277 * DESCRIPTION: Prepare to enter a system sleep state.
203 * This function must execute with interrupts enabled. 278 * This function must execute with interrupts enabled.
204 * We break sleeping into 2 stages so that OSPM can handle 279 * We break sleeping into 2 stages so that OSPM can handle
205 * various OS-specific tasks between the two steps. 280 * various OS-specific tasks between the two steps.
206 * 281 *
207 ******************************************************************************/ 282 ******************************************************************************/
283
208acpi_status acpi_enter_sleep_state_prep(u8 sleep_state) 284acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
209{ 285{
210 acpi_status status; 286 acpi_status status;
@@ -291,23 +367,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
291 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); 367 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
292 return_ACPI_STATUS(AE_AML_OPERAND_VALUE); 368 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
293 } 369 }
294#if (!ACPI_REDUCED_HARDWARE)
295
296 /* If Hardware Reduced flag is set, must use the extended sleep registers */
297
298 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
299 status = acpi_hw_extended_sleep(sleep_state);
300 } else {
301 /* Legacy sleep */
302
303 status = acpi_hw_legacy_sleep(sleep_state);
304 }
305
306#else
307 status = acpi_hw_extended_sleep(sleep_state);
308
309#endif /* !ACPI_REDUCED_HARDWARE */
310 370
371 status = acpi_hw_sleep_dispatch(sleep_state, ACPI_SLEEP_FUNCTION);
311 return_ACPI_STATUS(status); 372 return_ACPI_STATUS(status);
312} 373}
313 374
@@ -330,26 +391,9 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
330{ 391{
331 acpi_status status; 392 acpi_status status;
332 393
333 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); 394 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
334
335
336#if (!ACPI_REDUCED_HARDWARE)
337
338 /* If Hardware Reduced flag is set, must use the extended sleep registers */
339
340 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
341 status = acpi_hw_extended_wake_prep(sleep_state);
342 } else {
343 /* Legacy sleep */
344
345 status = acpi_hw_legacy_wake_prep(sleep_state);
346 }
347#else
348 status = acpi_hw_extended_wake_prep(sleep_state);
349
350#endif /* !ACPI_REDUCED_HARDWARE */
351
352 395
396 status = acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_PREP_FUNCTION);
353 return_ACPI_STATUS(status); 397 return_ACPI_STATUS(status);
354} 398}
355 399
@@ -359,7 +403,7 @@ ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state_prep)
359 * 403 *
360 * FUNCTION: acpi_leave_sleep_state 404 * FUNCTION: acpi_leave_sleep_state
361 * 405 *
362 * PARAMETERS: sleep_state - Which sleep state we just exited 406 * PARAMETERS: sleep_state - Which sleep state we are exiting
363 * 407 *
364 * RETURN: Status 408 * RETURN: Status
365 * 409 *
@@ -374,23 +418,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
374 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); 418 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
375 419
376 420
377#if (!ACPI_REDUCED_HARDWARE) 421 status = acpi_hw_sleep_dispatch(sleep_state, ACPI_WAKE_FUNCTION);
378
379 /* If Hardware Reduced flag is set, must use the extended sleep registers */
380
381 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
382 status = acpi_hw_extended_wake(sleep_state);
383 } else {
384 /* Legacy sleep */
385
386 status = acpi_hw_legacy_wake(sleep_state);
387 }
388
389#else
390 status = acpi_hw_extended_wake(sleep_state);
391
392#endif /* !ACPI_REDUCED_HARDWARE */
393
394 return_ACPI_STATUS(status); 422 return_ACPI_STATUS(status);
395} 423}
396 424