blob: e402ba5e8d2332560dfa6e121e040789b9cde768 [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
Subrata Banikece173c2017-12-14 18:18:34 +05306 * Copyright (C) 2015-2017 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070016 */
17
Lee Leahyb0005132015-05-12 18:19:47 -070018#include <console/console.h>
Barnali Sarkar71464452017-03-31 18:11:49 +053019#include <intelblocks/fast_spi.h>
Subrata Banikece173c2017-12-14 18:18:34 +053020#include <intelblocks/smihandler.h>
Lee Leahyb0005132015-05-12 18:19:47 -070021#include <soc/pm.h>
Lee Leahyb0005132015-05-12 18:19:47 -070022
Subrata Banikece173c2017-12-14 18:18:34 +053023const struct smm_save_state_ops *get_smm_save_state_ops(void)
Lee Leahyb0005132015-05-12 18:19:47 -070024{
Subrata Banikece173c2017-12-14 18:18:34 +053025 return &em64t101_smm_ops;
Lee Leahyb0005132015-05-12 18:19:47 -070026}
27
Subrata Banik261b8932017-12-22 13:41:35 +053028void smihandler_soc_check_illegal_access(uint32_t tco_sts)
Lee Leahyb0005132015-05-12 18:19:47 -070029{
Subrata Banikece173c2017-12-14 18:18:34 +053030 if (!((tco_sts & (1 << 8)) && IS_ENABLED(CONFIG_SPI_FLASH_SMM)
31 && fast_spi_wpd_status()))
32 return;
Lee Leahyb0005132015-05-12 18:19:47 -070033
34 /*
Subrata Banikece173c2017-12-14 18:18:34 +053035 * BWE is RW, so the SMI was caused by a
36 * write to BWE, not by a write to the BIOS
37 *
38 * This is the place where we notice someone
39 * is trying to tinker with the BIOS. We are
40 * trying to be nice and just ignore it. A more
41 * resolute answer would be to power down the
42 * box.
Lee Leahyb0005132015-05-12 18:19:47 -070043 */
Subrata Banikece173c2017-12-14 18:18:34 +053044 printk(BIOS_DEBUG, "Switching back to RO\n");
45 fast_spi_enable_wp();
Lee Leahyb0005132015-05-12 18:19:47 -070046}
47
Furquan Shaikh8f2eadd2017-10-16 22:49:05 -070048/* SMI handlers that should be serviced in SCI mode too. */
Subrata Banik261b8932017-12-22 13:41:35 +053049uint32_t smihandler_soc_get_sci_mask(void)
Lee Leahyb0005132015-05-12 18:19:47 -070050{
Subrata Banikece173c2017-12-14 18:18:34 +053051 uint32_t sci_mask =
52 SMI_HANDLER_SCI_EN(APM_STS_BIT) |
53 SMI_HANDLER_SCI_EN(SMI_ON_SLP_EN_STS_BIT);
Lee Leahyb0005132015-05-12 18:19:47 -070054
Subrata Banikece173c2017-12-14 18:18:34 +053055 return sci_mask;
Lee Leahyb0005132015-05-12 18:19:47 -070056}
Subrata Banikece173c2017-12-14 18:18:34 +053057
58const smi_handler_t southbridge_smi[SMI_STS_BITS] = {
59 [SMI_ON_SLP_EN_STS_BIT] = smihandler_southbridge_sleep,
60 [APM_STS_BIT] = smihandler_southbridge_apmc,
61 [PM1_STS_BIT] = smihandler_southbridge_pm1,
62 [GPE0_STS_BIT] = smihandler_southbridge_gpe0,
63 [GPIO_STS_BIT] = smihandler_southbridge_gpi,
64 [ESPI_SMI_STS_BIT] = smihandler_southbridge_espi,
65 [MCSMI_STS_BIT] = smihandler_southbridge_mc,
66 [TCO_STS_BIT] = smihandler_southbridge_tco,
67 [PERIODIC_STS_BIT] = smihandler_southbridge_periodic,
68 [MONITOR_STS_BIT] = smihandler_southbridge_monitor,
69};