Arthur Heymans | 4111465 | 2017-04-12 00:10:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 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. |
| 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <timestamp.h> |
| 19 | #include <cpu/x86/tsc.h> |
| 20 | #include <console/console.h> |
| 21 | #include <arch/acpi.h> |
| 22 | #include "i82801jx.h" |
| 23 | |
| 24 | uint64_t get_initial_timestamp(void) |
| 25 | { |
| 26 | tsc_t base_time = { |
| 27 | .lo = pci_read_config32(PCI_DEV(0, 0x00, 0), 0xdc), |
| 28 | .hi = pci_read_config32(PCI_DEV(0, 0x1f, 2), 0xd0) |
| 29 | }; |
| 30 | return tsc_to_uint64(base_time); |
| 31 | } |
| 32 | |
| 33 | int southbridge_detect_s3_resume(void) |
| 34 | { |
| 35 | u32 reg32; |
| 36 | |
| 37 | /* Read PM1_CNT */ |
| 38 | reg32 = inl(DEFAULT_PMBASE + 0x04); |
| 39 | printk(BIOS_DEBUG, "PM1_CNT: %08x\n", reg32); |
| 40 | if (((reg32 >> 10) & 7) == 5) { |
| 41 | if (!acpi_s3_resume_allowed()) { |
| 42 | printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n"); |
| 43 | } else { |
| 44 | printk(BIOS_DEBUG, "Resume from S3 detected.\n"); |
| 45 | /* Clear SLP_TYPE. This will break stage2 but |
| 46 | * we care for that when we get there. |
| 47 | */ |
| 48 | outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04); |
| 49 | return 1; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return 0; |
| 54 | } |