blob: 8fb731a6ca687e09c205d7e2a6edd9a46b0c1910 [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
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; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Duncan Lauriec88c54c2014-04-30 16:36:13 -070014 */
15
16#include <arch/acpi.h>
17#include <cbmem.h>
18#include <console/console.h>
19#include <device/device.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070020#include <stdlib.h>
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +020021#include <string.h>
Julius Werner4ee4bd52014-10-20 13:46:39 -070022#include <soc/nvs.h>
23#include <soc/pm.h>
24#include <soc/ramstage.h>
25#include <soc/intel/broadwell/chip.h>
Duncan Laurie81a4c852015-09-08 16:10:30 -070026#include <soc/intel/common/acpi.h>
Duncan Lauriec88c54c2014-04-30 16:36:13 -070027
Duncan Laurie81a4c852015-09-08 16:10:30 -070028/* Save wake source information for calculating ACPI _SWS values */
29int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0)
Duncan Lauriec88c54c2014-04-30 16:36:13 -070030{
31 struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE);
Duncan Laurie81a4c852015-09-08 16:10:30 -070032 static uint32_t gpe0_sts[GPE0_REG_MAX];
33 int i;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070034
Duncan Laurie81a4c852015-09-08 16:10:30 -070035 *pm1 = ps->pm1_sts & ps->pm1_en;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070036
Duncan Laurie81a4c852015-09-08 16:10:30 -070037 /* Mask off GPE0 status bits that are not enabled */
38 *gpe0 = &gpe0_sts[0];
39 for (i = 0; i < GPE0_REG_MAX; i++)
40 gpe0_sts[i] = ps->gpe0_sts[i] & ps->gpe0_en[i];
Duncan Lauriec88c54c2014-04-30 16:36:13 -070041
Duncan Laurie81a4c852015-09-08 16:10:30 -070042 return GPE0_REG_MAX;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070043}
44
Duncan Lauriec88c54c2014-04-30 16:36:13 -070045static void s3_resume_prepare(void)
46{
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +020047 global_nvs_t *gnvs;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070048
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +020049 gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(global_nvs_t));
50 if (gnvs == NULL)
51 return;
Duncan Lauriec88c54c2014-04-30 16:36:13 -070052
Kyösti Mälkki9e94dbf2015-01-08 20:03:18 +020053 if (!acpi_is_wakeup_s3())
54 memset(gnvs, 0, sizeof(global_nvs_t));
Duncan Lauriec88c54c2014-04-30 16:36:13 -070055}
56
57void broadwell_init_pre_device(void *chip_info)
58{
59 s3_resume_prepare();
60 broadwell_run_reference_code();
61}