x86, intel_txt: clean up the impact on generic code, unbreak non-x86
[linux-2.6.git] / drivers / acpi / acpica / hwsleep.c
index 26e249e..cc22f9a 100644 (file)
@@ -45,6 +45,7 @@
 #include <acpi/acpi.h>
 #include "accommon.h"
 #include "actables.h"
+#include <linux/tboot.h>
 
 #define _COMPONENT          ACPI_HARDWARE
 ACPI_MODULE_NAME("hwsleep")
@@ -211,6 +212,12 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
 
 ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
 
+static unsigned int gts, bfs;
+module_param(gts, uint, 0644);
+module_param(bfs, uint, 0644);
+MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
+MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_enter_sleep_state
@@ -250,7 +257,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 
        /* Clear wake status */
 
-       status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
+       status =
+           acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
@@ -277,16 +285,18 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
                return_ACPI_STATUS(status);
        }
 
-       /* Execute the _GTS method */
+       if (gts) {
+               /* Execute the _GTS method */
 
-       arg_list.count = 1;
-       arg_list.pointer = &arg;
-       arg.type = ACPI_TYPE_INTEGER;
-       arg.integer.value = sleep_state;
+               arg_list.count = 1;
+               arg_list.pointer = &arg;
+               arg.type = ACPI_TYPE_INTEGER;
+               arg.integer.value = sleep_state;
 
-       status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
-       if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
-               return_ACPI_STATUS(status);
+               status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
+               if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+                       return_ACPI_STATUS(status);
+               }
        }
 
        /* Get current value of PM1A control */
@@ -333,6 +343,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
 
        ACPI_FLUSH_CPU_CACHE();
 
+       tboot_sleep(sleep_state, pm1a_control, pm1b_control);
+
        /* Write #2: Write both SLP_TYP + SLP_EN */
 
        status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
@@ -348,8 +360,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
                 * Wait ten seconds, then try again. This is to get S4/S5 to work on
                 * all machines.
                 *
-                * We wait so long to allow chipsets that poll this reg very slowly to
-                * still read the right value. Ideally, this block would go
+                * We wait so long to allow chipsets that poll this reg very slowly
+                * to still read the right value. Ideally, this block would go
                 * away entirely.
                 */
                acpi_os_stall(10000000);
@@ -365,7 +377,7 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
        /* Wait until we enter sleep state */
 
        do {
-               status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS,
+               status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS,
                                                    &in_value);
                if (ACPI_FAILURE(status)) {
                        return_ACPI_STATUS(status);
@@ -399,7 +411,10 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
 
        ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
 
-       status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
+       /* Clear the wake status bit (PM1) */
+
+       status =
+           acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
@@ -426,12 +441,13 @@ acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
 
        ACPI_FLUSH_CPU_CACHE();
 
-       status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
+       status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
                                    (u32) acpi_gbl_FADT.S4bios_request, 8);
 
        do {
                acpi_os_stall(1000);
-               status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value);
+               status =
+                   acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
                if (ACPI_FAILURE(status)) {
                        return_ACPI_STATUS(status);
                }
@@ -496,12 +512,10 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
 
                        /* Insert the SLP_TYP bits */
 
-                       pm1a_control |=
-                           (acpi_gbl_sleep_type_a << sleep_type_reg_info->
-                            bit_position);
-                       pm1b_control |=
-                           (acpi_gbl_sleep_type_b << sleep_type_reg_info->
-                            bit_position);
+                       pm1a_control |= (acpi_gbl_sleep_type_a <<
+                                        sleep_type_reg_info->bit_position);
+                       pm1b_control |= (acpi_gbl_sleep_type_b <<
+                                        sleep_type_reg_info->bit_position);
 
                        /* Write the control registers and ignore any errors */
 
@@ -510,18 +524,19 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
                }
        }
 
-       /* Execute the _BFS method */
+       if (bfs) {
+               /* Execute the _BFS method */
 
-       arg_list.count = 1;
-       arg_list.pointer = &arg;
-       arg.type = ACPI_TYPE_INTEGER;
-       arg.integer.value = sleep_state;
+               arg_list.count = 1;
+               arg_list.pointer = &arg;
+               arg.type = ACPI_TYPE_INTEGER;
+               arg.integer.value = sleep_state;
 
-       status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
-       if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
-               ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
+               status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
+               if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
+                       ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
+               }
        }
-
        return_ACPI_STATUS(status);
 }
 
@@ -592,19 +607,21 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
         * it to determine whether the system is rebooting or resuming. Clear
         * it for compatibility.
         */
-       acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
+       acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
 
        acpi_gbl_system_awake_and_running = TRUE;
 
        /* Enable power button */
 
        (void)
-           acpi_set_register(acpi_gbl_fixed_event_info
-                             [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1);
+           acpi_write_bit_register(acpi_gbl_fixed_event_info
+                             [ACPI_EVENT_POWER_BUTTON].
+                             enable_register_id, ACPI_ENABLE_EVENT);
 
        (void)
-           acpi_set_register(acpi_gbl_fixed_event_info
-                             [ACPI_EVENT_POWER_BUTTON].status_register_id, 1);
+           acpi_write_bit_register(acpi_gbl_fixed_event_info
+                             [ACPI_EVENT_POWER_BUTTON].
+                             status_register_id, ACPI_CLEAR_STATUS);
 
        arg.integer.value = ACPI_SST_WORKING;
        status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);