#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>
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();
*/
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__ */
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
--- /dev/null
+/*
+ * 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);
+}