blob: 4aa9f10297e5489ed03e9d1bd1445a8599e54299 [file] [log] [blame]
Kyösti Mälkkie28bd4a2013-09-07 11:38:56 +03001/*
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älkkie28bd4a2013-09-07 11:38:56 +030015 */
16
17#include <arch/io.h>
18#include <timestamp.h>
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070019#include <cpu/x86/tsc.h>
Vladimir Serbinenko55601882014-10-15 20:17:51 +020020#include <console/console.h>
21#include <arch/acpi.h>
22#include "i82801gx.h"
Kyösti Mälkkie28bd4a2013-09-07 11:38:56 +030023
Stefan Reinauer3a6550d2013-08-01 13:31:44 -070024uint64_t get_initial_timestamp(void)
Kyösti Mälkkie28bd4a2013-09-07 11:38:56 +030025{
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 Reinauer3a6550d2013-08-01 13:31:44 -070030 return tsc_to_uint64(base_time);
Kyösti Mälkkie28bd4a2013-09-07 11:38:56 +030031}
Vladimir Serbinenko55601882014-10-15 20:17:51 +020032
33int 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}