Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <string.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpi.h> |
Elyes HAOUAS | d2b9ec1 | 2018-10-27 09:41:02 +0200 | [diff] [blame] | 6 | #include <arch/cpu.h> |
Elyes HAOUAS | e2d152c | 2019-06-21 07:06:50 +0200 | [diff] [blame] | 7 | #include <commonlib/helpers.h> |
Kyösti Mälkki | c5853e9 | 2020-06-16 12:45:11 +0300 | [diff] [blame] | 8 | #include <cpu/x86/smm.h> |
Kyösti Mälkki | 82e41d8 | 2016-12-11 13:31:17 +0200 | [diff] [blame] | 9 | #include <fallback.h> |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 10 | #include <timestamp.h> |
Kyösti Mälkki | cf0e60f | 2016-06-20 20:40:32 +0300 | [diff] [blame] | 11 | |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 12 | #define WAKEUP_BASE 0x600 |
| 13 | |
Kyösti Mälkki | 7cd2c07 | 2018-06-03 23:04:28 +0300 | [diff] [blame] | 14 | asmlinkage void (*acpi_do_wakeup)(uintptr_t vector) = (void *)WAKEUP_BASE; |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 15 | |
| 16 | extern unsigned char __wakeup; |
| 17 | extern unsigned int __wakeup_size; |
| 18 | |
Kyösti Mälkki | a4c0e1a | 2020-06-18 08:28:12 +0300 | [diff] [blame] | 19 | void __noreturn acpi_resume(void *wake_vec) |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 20 | { |
Kyösti Mälkki | c3c5521 | 2020-06-17 10:34:26 +0300 | [diff] [blame] | 21 | /* Restore GNVS pointer in SMM if found. */ |
| 22 | apm_control(APM_CNT_GNVS_UPDATE); |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 23 | |
| 24 | /* Call mainboard resume handler first, if defined. */ |
| 25 | mainboard_suspend_resume(); |
| 26 | |
Kyösti Mälkki | 561b5cf | 2020-06-18 12:24:06 +0300 | [diff] [blame] | 27 | /* Copy wakeup trampoline in place. */ |
| 28 | memcpy((void *)WAKEUP_BASE, &__wakeup, __wakeup_size); |
| 29 | |
| 30 | set_boot_successful(); |
| 31 | |
| 32 | timestamp_add_now(TS_ACPI_WAKE_JUMP); |
| 33 | |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 34 | post_code(POST_OS_RESUME); |
Kyösti Mälkki | 561b5cf | 2020-06-18 12:24:06 +0300 | [diff] [blame] | 35 | acpi_do_wakeup((uintptr_t)wake_vec); |
Kyösti Mälkki | a4c0e1a | 2020-06-18 08:28:12 +0300 | [diff] [blame] | 36 | |
| 37 | die("Failed the jump to wakeup vector\n"); |
Kyösti Mälkki | d132c99 | 2016-06-18 09:19:18 +0300 | [diff] [blame] | 38 | } |