Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de> |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <stdint.h> |
Kyösti Mälkki | 78c5d58 | 2015-01-09 23:48:47 +0200 | [diff] [blame] | 18 | #include <arch/acpi.h> |
Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 19 | #include <arch/io.h> |
| 20 | #include <console/console.h> |
| 21 | #include "i82371eb.h" |
| 22 | |
Tobias Diedrich | 4e22a3b | 2010-12-13 22:39:46 +0100 | [diff] [blame] | 23 | /* |
| 24 | * Intel 82371EB (PIIX4E) datasheet, section 7.2.3, page 142 |
| 25 | * |
| 26 | * 0: soft off/suspend to disk S5 |
| 27 | * 1: suspend to ram S3 |
| 28 | * 2: powered on suspend, context lost S2 |
| 29 | * Note: 'context lost' means the CPU restarts at the reset |
| 30 | * vector |
| 31 | * 3: powered on suspend, CPU context lost S1 |
| 32 | * Note: Looks like 'CPU context lost' does _not_ mean the |
| 33 | * CPU restarts at the reset vector. Most likely only |
| 34 | * caches are lost, so both 0x3 and 0x4 map to acpi S1 |
| 35 | * 4: powered on suspend, context maintained S1 |
| 36 | * 5: working (clock control) S0 |
| 37 | * 6: reserved |
| 38 | * 7: reserved |
| 39 | */ |
| 40 | static const u8 acpi_sus_to_slp_typ[8] = { |
| 41 | 5, 3, 2, 1, 1, 0, 0, 0 |
| 42 | }; |
| 43 | |
| 44 | int acpi_get_sleep_type(void) |
| 45 | { |
| 46 | u16 reg, result; |
| 47 | |
| 48 | reg = inw(DEFAULT_PMBASE + PMCNTRL); |
| 49 | result = acpi_sus_to_slp_typ[(reg >> 10) & 7]; |
| 50 | |
| 51 | printk(BIOS_DEBUG, "Wakeup from ACPI sleep type S%d (PMCNTRL=%04x)\n", result, reg); |
| 52 | |
| 53 | return result; |
| 54 | } |