Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 4 | #include <acpi/acpi.h> |
Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 5 | #include <arch/io.h> |
| 6 | #include <console/console.h> |
| 7 | #include "i82371eb.h" |
| 8 | |
Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 9 | /* |
| 10 | * Intel 82371EB (PIIX4E) datasheet, section 7.2.3, page 142 |
| 11 | * |
| 12 | * 0: soft off/suspend to disk S5 |
| 13 | * 1: suspend to ram S3 |
| 14 | * 2: powered on suspend, context lost S2 |
| 15 | * Note: 'context lost' means the CPU restarts at the reset |
| 16 | * vector |
| 17 | * 3: powered on suspend, CPU context lost S1 |
| 18 | * Note: Looks like 'CPU context lost' does _not_ mean the |
| 19 | * CPU restarts at the reset vector. Most likely only |
| 20 | * caches are lost, so both 0x3 and 0x4 map to acpi S1 |
| 21 | * 4: powered on suspend, context maintained S1 |
| 22 | * 5: working (clock control) S0 |
| 23 | * 6: reserved |
| 24 | * 7: reserved |
| 25 | */ |
| 26 | static const u8 acpi_sus_to_slp_typ[8] = { |
| 27 | 5, 3, 2, 1, 1, 0, 0, 0 |
| 28 | }; |
| 29 | |
| 30 | int acpi_get_sleep_type(void) |
| 31 | { |
| 32 | u16 reg, result; |
| 33 | |
| 34 | reg = inw(DEFAULT_PMBASE + PMCNTRL); |
| 35 | result = acpi_sus_to_slp_typ[(reg >> 10) & 7]; |
| 36 | |
| 37 | printk(BIOS_DEBUG, "Wakeup from ACPI sleep type S%d (PMCNTRL=%04x)\n", result, reg); |
| 38 | |
| 39 | return result; |
| 40 | } |