Angel Pons | 62079a5 | 2020-04-05 13:21:34 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 3 | |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 4 | #include <arch/acpi.h> |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 5 | #include <baseboard/variant.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 6 | #include <console/console.h> |
| 7 | #include <cpu/x86/smm.h> |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 8 | #include <ec/google/chromeec/smm.h> |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 9 | #include <gpio.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 10 | #include <soc/iomap.h> |
| 11 | #include <soc/nvs.h> |
| 12 | #include <soc/pm.h> |
Kyösti Mälkki | 89d7fd8 | 2019-08-13 07:57:34 +0300 | [diff] [blame] | 13 | #include <intelblocks/smihandler.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 14 | #include "ec.h" |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 15 | #include <variant/gpio.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 16 | |
| 17 | int mainboard_io_trap_handler(int smif) |
| 18 | { |
| 19 | switch (smif) { |
| 20 | case 0x99: |
| 21 | printk(BIOS_DEBUG, "Sample\n"); |
| 22 | smm_get_gnvs()->smif = 0; |
| 23 | break; |
| 24 | default: |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | /* On success, the IO Trap Handler returns 0 |
| 29 | * On failure, the IO Trap Handler returns a value != 0 |
| 30 | * |
| 31 | * For now, we force the return value to 0 and log all traps to |
| 32 | * see what's going on. |
| 33 | */ |
| 34 | return 1; |
| 35 | } |
| 36 | |
Aaron Durbin | 50ed38f | 2015-08-08 01:25:21 -0500 | [diff] [blame] | 37 | void mainboard_smi_gpi_handler(const struct gpi_status *sts) |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 38 | { |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 39 | if (gpi_status_get(sts, EC_SMI_GPI)) |
| 40 | chromeec_smi_process_events(); |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 41 | } |
| 42 | |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 43 | __weak void mainboard_gpio_smi_sleep(void) |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 44 | { |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | void mainboard_smi_sleep(u8 slp_typ) |
| 48 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 49 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 50 | chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS, |
| 51 | MAINBOARD_EC_S5_WAKE_EVENTS); |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 52 | |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 53 | mainboard_gpio_smi_sleep(); |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | int mainboard_smi_apmc(u8 apmc) |
| 57 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 58 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 59 | chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, |
| 60 | MAINBOARD_EC_SMI_EVENTS); |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 61 | return 0; |
| 62 | } |