blob: bb399e81cac346253a880b466e2bf222c2a6c344 [file] [log] [blame]
Angel Pons80d92382020-04-05 15:47:00 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mariusz Szafranskia4041332017-08-02 17:28:17 +02002
3#include <device/device.h>
4#include <device/pci.h>
5#include <console/console.h>
6#include <arch/io.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02007#include <cpu/x86/smm.h>
Kyösti Mälkkifaf20d32019-08-14 05:41:41 +03008#include <cpu/intel/smm_reloc.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02009
10#include <soc/iomap.h>
11#include <soc/soc_util.h>
12#include <soc/pm.h>
13#include <soc/smm.h>
14
Kyösti Mälkkifaf20d32019-08-14 05:41:41 +030015void smm_southbridge_clear_state(void)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020016{
17 uint32_t smi_en;
18
Mariusz Szafranskia4041332017-08-02 17:28:17 +020019 smi_en = inl((uint16_t)(get_pmbase() + SMI_EN));
20 if (smi_en & APMC_EN) {
21 printk(BIOS_INFO, "SMI# handler already enabled?\n");
22 return;
23 }
24
25 /* Dump and clear status registers */
Patrick Georgiff283712019-01-24 16:03:41 +010026 clear_smi_status();
27 clear_pm1_status();
28 clear_tco_status();
29 clear_gpe_status();
Mariusz Szafranskia4041332017-08-02 17:28:17 +020030 clear_pmc_status();
31}
32
Kyösti Mälkki0778c862020-06-10 12:44:03 +030033static void smm_southbridge_enable(uint16_t pm1_events)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020034{
35
36 printk(BIOS_DEBUG, "Enabling SMIs.\n");
Elyes HAOUAS79ccc692020-02-24 13:43:39 +010037 /* Configure events Disable PCIe wake. */
Kyösti Mälkki0778c862020-06-10 12:44:03 +030038 enable_pm1(pm1_events | PCIEXPWAK_DIS);
Patrick Georgiff283712019-01-24 16:03:41 +010039 disable_gpe(PME_B0_EN);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020040
41 /* Enable SMI generation:
42 * - on APMC writes (io 0xb2)
43 * - on writes to SLP_EN (sleep states)
44 * - on writes to GBL_RLS (bios commands)
45 * No SMIs:
46 * - on TCO events
47 * - on microcontroller writes (io 0x62/0x66)
48 */
Patrick Georgiff283712019-01-24 16:03:41 +010049 enable_smi(APMC_EN | SLP_SMI_EN | GBL_SMI_EN | EOS);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020050}
51
Kyösti Mälkki0778c862020-06-10 12:44:03 +030052void global_smi_enable(void)
53{
54 smm_southbridge_enable(PWRBTN_EN | GBL_EN);
55}