]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
x86: Store and display previous sleep state
authorBin Meng <bmeng.cn@gmail.com>
Fri, 21 Apr 2017 14:24:32 +0000 (07:24 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Wed, 17 May 2017 09:11:46 +0000 (17:11 +0800)
Add one member in the global data to store previous sleep state,
and display the state during boot in print_cpuinfo().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Stefan Roese <sr@denx.de>
arch/x86/cpu/cpu.c
arch/x86/include/asm/acpi_s3.h
arch/x86/include/asm/global_data.h
arch/x86/lib/fsp/fsp_common.c

index 8fa6953588b51537c90dc81aa662b1694f2d208e..7222ec899d08536287100681ac1b076d2140e2c0 100644 (file)
@@ -25,6 +25,7 @@
 #include <errno.h>
 #include <malloc.h>
 #include <syscon.h>
+#include <asm/acpi_s3.h>
 #include <asm/control_regs.h>
 #include <asm/coreboot_tables.h>
 #include <asm/cpu.h>
@@ -179,6 +180,11 @@ int default_print_cpuinfo(void)
               cpu_has_64bit() ? "x86_64" : "x86",
               cpu_vendor_name(gd->arch.x86_vendor), gd->arch.x86_device);
 
+#ifdef CONFIG_HAVE_ACPI_RESUME
+       debug("ACPI previous sleep state: %s\n",
+             acpi_ss_string(gd->arch.prev_sleep_state));
+#endif
+
        return 0;
 }
 
index ec052112f306c5a7b862ad8593f66416d2492894..10cedde39aa1bed5ff036b2747dad5e5afe3010d 100644 (file)
@@ -36,6 +36,19 @@ enum acpi_sleep_state {
        ACPI_S5,
 };
 
+/**
+ * acpi_ss_string() - get ACPI-defined sleep state string
+ *
+ * @pm1_cnt:   ACPI-defined sleep state
+ * @return:    a pointer to the sleep state string.
+ */
+static inline char *acpi_ss_string(enum acpi_sleep_state state)
+{
+       char *ss_string[] = { "S0", "S1", "S2", "S3", "S4", "S5"};
+
+       return ss_string[state];
+}
+
 /**
  * acpi_sleep_from_pm1() - get ACPI-defined sleep state from PM1_CNT register
  *
index 4570bc7a4ad6a94b8b8b3981bca3fb83c5ec8306..7d5efea224ccc93375a2107c5b07ef07067943dc 100644 (file)
@@ -99,6 +99,9 @@ struct arch_global_data {
        u32 high_table_ptr;
        u32 high_table_limit;
 #endif
+#ifdef CONFIG_HAVE_ACPI_RESUME
+       int prev_sleep_state;           /* Previous sleep state */
+#endif
 };
 
 #endif
index cc42cad20bd6dbbc0dc20e8c1e7d4f00fedb89cc..f2d50acbf48baeecad8605ec3472db0aeeb9b029 100644 (file)
@@ -82,6 +82,7 @@ int arch_fsp_init(void)
        int boot_mode = BOOT_FULL_CONFIG;
 #ifdef CONFIG_HAVE_ACPI_RESUME
        int prev_sleep_state = chipset_prev_sleep_state();
+       gd->arch.prev_sleep_state = prev_sleep_state;
 #endif
 
        if (!gd->arch.hob_list) {