blob: 4cad3223b1d2722cb0fddc8a471707657fb02d72 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01002
3#include <stdint.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07004#include <acpi/acpi.h>
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01005#include <arch/io.h>
6#include <console/console.h>
7#include "i82371eb.h"
8
Tobias Diedrich4e22a3b2010-12-13 22:39:46 +01009/*
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 */
26static const u8 acpi_sus_to_slp_typ[8] = {
27 5, 3, 2, 1, 1, 0, 0, 0
28};
29
30int 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}