Kyösti Mälkki | e28bd4a | 2013-09-07 11:38:56 +0300 | [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. |
Kyösti Mälkki | e28bd4a | 2013-09-07 11:38:56 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <timestamp.h> |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 19 | #include <cpu/x86/tsc.h> |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | #include <arch/acpi.h> |
| 22 | #include "i82801gx.h" |
Kyösti Mälkki | e28bd4a | 2013-09-07 11:38:56 +0300 | [diff] [blame] | 23 | |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 24 | uint64_t get_initial_timestamp(void) |
Kyösti Mälkki | e28bd4a | 2013-09-07 11:38:56 +0300 | [diff] [blame] | 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 | }; |
Stefan Reinauer | 3a6550d | 2013-08-01 13:31:44 -0700 | [diff] [blame] | 30 | return tsc_to_uint64(base_time); |
Kyösti Mälkki | e28bd4a | 2013-09-07 11:38:56 +0300 | [diff] [blame] | 31 | } |
Vladimir Serbinenko | 5560188 | 2014-10-15 20:17:51 +0200 | [diff] [blame] | 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.\n"); |
| 43 | /* Clear SLP_TYPE. This will break stage2 but |
| 44 | * we care for that when we get there. |
| 45 | */ |
| 46 | outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04); |
| 47 | return 1; |
| 48 | } else { |
| 49 | printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n"); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return 0; |
| 54 | } |