Angel Pons | 80d9238 | 2020-04-05 15:47:00 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <console/console.h> |
| 6 | #include <arch/io.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 7 | #include <cpu/x86/smm.h> |
Kyösti Mälkki | faf20d3 | 2019-08-14 05:41:41 +0300 | [diff] [blame] | 8 | #include <cpu/intel/smm_reloc.h> |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 9 | |
| 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älkki | faf20d3 | 2019-08-14 05:41:41 +0300 | [diff] [blame] | 15 | void smm_southbridge_clear_state(void) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 16 | { |
| 17 | uint32_t smi_en; |
| 18 | |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 19 | 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 Georgi | ff28371 | 2019-01-24 16:03:41 +0100 | [diff] [blame] | 26 | clear_smi_status(); |
| 27 | clear_pm1_status(); |
| 28 | clear_tco_status(); |
| 29 | clear_gpe_status(); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 30 | clear_pmc_status(); |
| 31 | } |
| 32 | |
Kyösti Mälkki | 0778c86 | 2020-06-10 12:44:03 +0300 | [diff] [blame] | 33 | static void smm_southbridge_enable(uint16_t pm1_events) |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 34 | { |
| 35 | |
| 36 | printk(BIOS_DEBUG, "Enabling SMIs.\n"); |
Elyes HAOUAS | 79ccc69 | 2020-02-24 13:43:39 +0100 | [diff] [blame] | 37 | /* Configure events Disable PCIe wake. */ |
Kyösti Mälkki | 0778c86 | 2020-06-10 12:44:03 +0300 | [diff] [blame] | 38 | enable_pm1(pm1_events | PCIEXPWAK_DIS); |
Patrick Georgi | ff28371 | 2019-01-24 16:03:41 +0100 | [diff] [blame] | 39 | disable_gpe(PME_B0_EN); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 40 | |
| 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 Georgi | ff28371 | 2019-01-24 16:03:41 +0100 | [diff] [blame] | 49 | enable_smi(APMC_EN | SLP_SMI_EN | GBL_SMI_EN | EOS); |
Mariusz Szafranski | a404133 | 2017-08-02 17:28:17 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Kyösti Mälkki | 0778c86 | 2020-06-10 12:44:03 +0300 | [diff] [blame] | 52 | void global_smi_enable(void) |
| 53 | { |
| 54 | smm_southbridge_enable(PWRBTN_EN | GBL_EN); |
| 55 | } |