x86, intel_txt: clean up the impact on generic code, unbreak non-x86
[linux-2.6.git] / drivers / acpi / acpica / hwsleep.c
index 4d14b49..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
@@ -278,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 */
@@ -334,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);
@@ -349,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);
@@ -430,7 +441,7 @@ 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 {
@@ -501,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 */
 
@@ -515,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);
 }