2 * This file is part of the coreboot project.
4 * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <console/console.h>
26 int acpi_get_sleep_type(void);
29 * Intel 82371EB (PIIX4E) datasheet, section 7.2.3, page 142
31 * 0: soft off/suspend to disk S5
32 * 1: suspend to ram S3
33 * 2: powered on suspend, context lost S2
34 * Note: 'context lost' means the CPU restarts at the reset
36 * 3: powered on suspend, CPU context lost S1
37 * Note: Looks like 'CPU context lost' does _not_ mean the
38 * CPU restarts at the reset vector. Most likely only
39 * caches are lost, so both 0x3 and 0x4 map to acpi S1
40 * 4: powered on suspend, context maintained S1
41 * 5: working (clock control) S0
45 static const u8 acpi_sus_to_slp_typ[8] = {
46 5, 3, 2, 1, 1, 0, 0, 0
49 int acpi_get_sleep_type(void)
53 reg = inw(DEFAULT_PMBASE + PMCNTRL);
54 result = acpi_sus_to_slp_typ[(reg >> 10) & 7];
56 printk(BIOS_DEBUG, "Wakeup from ACPI sleep type S%d (PMCNTRL=%04x)\n", result, reg);