blob: 9ae78793a2671b6715c27c2b543ad3e759e65b5e [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin76c37002012-10-30 09:03:43 -05002
Aaron Durbin76c37002012-10-30 09:03:43 -05003#include <device/device.h>
4#include <device/pci.h>
5#include <console/console.h>
6#include <arch/io.h>
Kyösti Mälkkifaf20d32019-08-14 05:41:41 +03007#include <cpu/intel/smm_reloc.h>
Aaron Durbin76c37002012-10-30 09:03:43 -05008#include <cpu/x86/smm.h>
Elyes HAOUASa1e22b82019-03-18 22:49:36 +01009
Aaron Durbin76c37002012-10-30 09:03:43 -050010#include "pch.h"
11
Kyösti Mälkkifaf20d32019-08-14 05:41:41 +030012void smm_southbridge_clear_state(void)
Aaron Durbin76c37002012-10-30 09:03:43 -050013{
14 u32 smi_en;
Aaron Durbin76c37002012-10-30 09:03:43 -050015
Aaron Durbin29ffa542012-12-21 21:21:48 -060016 /* Log events from chipset before clearing */
Kyösti Mälkkibe5317f2019-11-06 12:07:21 +020017 if (CONFIG(ELOG))
18 pch_log_state();
19
Duncan Laurie467f31d2013-03-08 17:00:37 -080020 smi_en = inl(get_pmbase() + SMI_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -050021 if (smi_en & APMC_EN) {
22 printk(BIOS_INFO, "SMI# handler already enabled?\n");
23 return;
24 }
25
Duncan Laurie467f31d2013-03-08 17:00:37 -080026 /* Dump and clear status registers */
27 clear_smi_status();
28 clear_pm1_status();
29 clear_tco_status();
30 clear_gpe_status();
Aaron Durbinaf3158c2013-03-27 20:57:28 -050031}
Aaron Durbin76c37002012-10-30 09:03:43 -050032
Kyösti Mälkki0778c862020-06-10 12:44:03 +030033static void smm_southbridge_enable(uint16_t pm1_events)
Aaron Durbinaf3158c2013-03-27 20:57:28 -050034{
35 printk(BIOS_DEBUG, "Enabling SMIs.\n");
Duncan Laurie467f31d2013-03-08 17:00:37 -080036 /* Configure events */
Kyösti Mälkki0778c862020-06-10 12:44:03 +030037 enable_pm1(pm1_events);
Duncan Laurie467f31d2013-03-08 17:00:37 -080038 disable_gpe(PME_B0_EN);
Aaron Durbin76c37002012-10-30 09:03:43 -050039
40 /* Enable SMI generation:
Aaron Durbin76c37002012-10-30 09:03:43 -050041 * - on APMC writes (io 0xb2)
42 * - on writes to SLP_EN (sleep states)
43 * - on writes to GBL_RLS (bios commands)
44 * No SMIs:
45 * - on microcontroller writes (io 0x62/0x66)
Duncan Lauried5acaaf2013-12-17 15:35:51 -080046 * - on TCO events
Aaron Durbin76c37002012-10-30 09:03:43 -050047 */
Duncan Lauried5acaaf2013-12-17 15:35:51 -080048 enable_smi(APMC_EN | SLP_SMI_EN | GBL_SMI_EN | EOS);
Aaron Durbin29ffa542012-12-21 21:21:48 -060049}
Aaron Durbin76c37002012-10-30 09:03:43 -050050
Kyösti Mälkki0778c862020-06-10 12:44:03 +030051void global_smi_enable(void)
52{
53 smm_southbridge_enable(PWRBTN_EN | GBL_EN);
54}