Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 2 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <console/console.h> |
| 6 | #include <arch/io.h> |
Kyösti Mälkki | faf20d3 | 2019-08-14 05:41:41 +0300 | [diff] [blame] | 7 | #include <cpu/intel/smm_reloc.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 8 | #include <cpu/x86/smm.h> |
Elyes HAOUAS | a1e22b8 | 2019-03-18 22:49:36 +0100 | [diff] [blame] | 9 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 10 | #include "pch.h" |
| 11 | |
Kyösti Mälkki | faf20d3 | 2019-08-14 05:41:41 +0300 | [diff] [blame] | 12 | void smm_southbridge_clear_state(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 13 | { |
| 14 | u32 smi_en; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 15 | |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 16 | /* Log events from chipset before clearing */ |
Kyösti Mälkki | be5317f | 2019-11-06 12:07:21 +0200 | [diff] [blame] | 17 | if (CONFIG(ELOG)) |
| 18 | pch_log_state(); |
| 19 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 20 | smi_en = inl(get_pmbase() + SMI_EN); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 21 | if (smi_en & APMC_EN) { |
| 22 | printk(BIOS_INFO, "SMI# handler already enabled?\n"); |
| 23 | return; |
| 24 | } |
| 25 | |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 26 | /* Dump and clear status registers */ |
| 27 | clear_smi_status(); |
| 28 | clear_pm1_status(); |
| 29 | clear_tco_status(); |
| 30 | clear_gpe_status(); |
Aaron Durbin | af3158c | 2013-03-27 20:57:28 -0500 | [diff] [blame] | 31 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 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) |
Aaron Durbin | af3158c | 2013-03-27 20:57:28 -0500 | [diff] [blame] | 34 | { |
| 35 | printk(BIOS_DEBUG, "Enabling SMIs.\n"); |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 36 | /* Configure events */ |
Kyösti Mälkki | 0778c86 | 2020-06-10 12:44:03 +0300 | [diff] [blame] | 37 | enable_pm1(pm1_events); |
Duncan Laurie | 467f31d | 2013-03-08 17:00:37 -0800 | [diff] [blame] | 38 | disable_gpe(PME_B0_EN); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 39 | |
| 40 | /* Enable SMI generation: |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 41 | * - 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 Laurie | d5acaaf | 2013-12-17 15:35:51 -0800 | [diff] [blame] | 46 | * - on TCO events |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 47 | */ |
Duncan Laurie | d5acaaf | 2013-12-17 15:35:51 -0800 | [diff] [blame] | 48 | enable_smi(APMC_EN | SLP_SMI_EN | GBL_SMI_EN | EOS); |
Aaron Durbin | 29ffa54 | 2012-12-21 21:21:48 -0600 | [diff] [blame] | 49 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 50 | |
Kyösti Mälkki | 0778c86 | 2020-06-10 12:44:03 +0300 | [diff] [blame] | 51 | void global_smi_enable(void) |
| 52 | { |
| 53 | smm_southbridge_enable(PWRBTN_EN | GBL_EN); |
| 54 | } |