Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 1 | /* |
| 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 Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/acpi.h> |
| 17 | #include <cbmem.h> |
| 18 | #include <console/console.h> |
| 19 | #include <device/device.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 20 | #include <stdlib.h> |
Kyösti Mälkki | 9e94dbf | 2015-01-08 20:03:18 +0200 | [diff] [blame] | 21 | #include <string.h> |
Julius Werner | 4ee4bd5 | 2014-10-20 13:46:39 -0700 | [diff] [blame] | 22 | #include <soc/nvs.h> |
| 23 | #include <soc/pm.h> |
| 24 | #include <soc/ramstage.h> |
| 25 | #include <soc/intel/broadwell/chip.h> |
Duncan Laurie | 81a4c85 | 2015-09-08 16:10:30 -0700 | [diff] [blame] | 26 | #include <soc/intel/common/acpi.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 27 | |
Duncan Laurie | 81a4c85 | 2015-09-08 16:10:30 -0700 | [diff] [blame] | 28 | /* Save wake source information for calculating ACPI _SWS values */ |
| 29 | int soc_fill_acpi_wake(uint32_t *pm1, uint32_t **gpe0) |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 30 | { |
| 31 | struct chipset_power_state *ps = cbmem_find(CBMEM_ID_POWER_STATE); |
Duncan Laurie | 81a4c85 | 2015-09-08 16:10:30 -0700 | [diff] [blame] | 32 | static uint32_t gpe0_sts[GPE0_REG_MAX]; |
| 33 | int i; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 34 | |
Duncan Laurie | 81a4c85 | 2015-09-08 16:10:30 -0700 | [diff] [blame] | 35 | *pm1 = ps->pm1_sts & ps->pm1_en; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 36 | |
Duncan Laurie | 81a4c85 | 2015-09-08 16:10:30 -0700 | [diff] [blame] | 37 | /* 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 Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 41 | |
Duncan Laurie | 81a4c85 | 2015-09-08 16:10:30 -0700 | [diff] [blame] | 42 | return GPE0_REG_MAX; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 45 | static void s3_resume_prepare(void) |
| 46 | { |
Kyösti Mälkki | 9e94dbf | 2015-01-08 20:03:18 +0200 | [diff] [blame] | 47 | global_nvs_t *gnvs; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 48 | |
Kyösti Mälkki | 9e94dbf | 2015-01-08 20:03:18 +0200 | [diff] [blame] | 49 | gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, sizeof(global_nvs_t)); |
| 50 | if (gnvs == NULL) |
| 51 | return; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 52 | |
Kyösti Mälkki | 9e94dbf | 2015-01-08 20:03:18 +0200 | [diff] [blame] | 53 | if (!acpi_is_wakeup_s3()) |
| 54 | memset(gnvs, 0, sizeof(global_nvs_t)); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | void broadwell_init_pre_device(void *chip_info) |
| 58 | { |
| 59 | s3_resume_prepare(); |
| 60 | broadwell_run_reference_code(); |
| 61 | } |