]> git.sur5r.net Git - u-boot/commitdiff
x86: acpi: Resume OS if resume vector is found
authorBin Meng <bmeng.cn@gmail.com>
Fri, 21 Apr 2017 14:24:37 +0000 (07:24 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Wed, 17 May 2017 09:11:46 +0000 (17:11 +0800)
In an S3 resume path, U-Boot does everything like a cold boot except
in the last_stage_init() it jumps to the OS resume vector.

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/lib/Makefile
arch/x86/lib/acpi_s3.c [new file with mode: 0644]

index 7222ec899d08536287100681ac1b076d2140e2c0..f686ad49c99298b0ae2e86aba9fdf1835345ca88 100644 (file)
@@ -26,6 +26,7 @@
 #include <malloc.h>
 #include <syscon.h>
 #include <asm/acpi_s3.h>
+#include <asm/acpi_table.h>
 #include <asm/control_regs.h>
 #include <asm/coreboot_tables.h>
 #include <asm/cpu.h>
@@ -204,6 +205,13 @@ __weak void board_final_cleanup(void)
 
 int last_stage_init(void)
 {
+#if CONFIG_HAVE_ACPI_RESUME
+       void *wake_vector = acpi_find_wakeup_vector();
+
+       if (wake_vector != NULL && gd->arch.prev_sleep_state == ACPI_S3)
+               acpi_resume(wake_vector);
+#endif
+
        write_tables();
 
        board_final_cleanup();
index a06466c01e5d6efc28f9db07367a496a65b60095..b8d14f470d2fd4be503fc62bc8b78067a037fd31 100644 (file)
@@ -99,6 +99,16 @@ enum acpi_sleep_state chipset_prev_sleep_state(void);
  */
 void chipset_clear_sleep_state(void);
 
+/**
+ * acpi_resume() - Do ACPI S3 resume
+ *
+ * This calls U-Boot wake up assembly stub and jumps to OS's wake up vector.
+ *
+ * @wake_vec:  OS wake up vector
+ * @return:    Never returns
+ */
+void acpi_resume(void *wake_vec);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_ACPI_S3_H__ */
index d1ad37af64861779132bd561bcd01137fd251116..21f59a04857a8dd927ee9527f21290040f62154e 100644 (file)
@@ -37,6 +37,7 @@ obj-$(CONFIG_INTEL_MID) += scu.o
 obj-y  += sections.o
 obj-y += sfi.o
 obj-y  += string.o
+obj-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.o
 ifndef CONFIG_QEMU
 obj-$(CONFIG_GENERATE_ACPI_TABLE) += acpi_table.o
 endif
diff --git a/arch/x86/lib/acpi_s3.c b/arch/x86/lib/acpi_s3.c
new file mode 100644 (file)
index 0000000..f679c06
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/acpi_s3.h>
+#include <asm/post.h>
+
+static void asmlinkage (*acpi_do_wakeup)(void *vector) = (void *)WAKEUP_BASE;
+
+static void acpi_jump_to_wakeup(void *vector)
+{
+       /* Copy wakeup trampoline in place */
+       memcpy((void *)WAKEUP_BASE, __wakeup, __wakeup_size);
+
+       printf("Jumping to OS waking vector %p\n", vector);
+       acpi_do_wakeup(vector);
+}
+
+void acpi_resume(void *wake_vec)
+{
+       post_code(POST_OS_RESUME);
+       acpi_jump_to_wakeup(wake_vec);
+}