Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 15 | #include <arch/acpi.h> |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 16 | #include <baseboard/variant.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 17 | #include <console/console.h> |
| 18 | #include <cpu/x86/smm.h> |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 19 | #include <ec/google/chromeec/smm.h> |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 20 | #include <gpio.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 21 | #include <soc/iomap.h> |
| 22 | #include <soc/nvs.h> |
| 23 | #include <soc/pm.h> |
Kyösti Mälkki | 89d7fd8 | 2019-08-13 07:57:34 +0300 | [diff] [blame] | 24 | #include <intelblocks/smihandler.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 25 | #include "ec.h" |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 26 | #include <variant/gpio.h> |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 27 | |
| 28 | int mainboard_io_trap_handler(int smif) |
| 29 | { |
| 30 | switch (smif) { |
| 31 | case 0x99: |
| 32 | printk(BIOS_DEBUG, "Sample\n"); |
| 33 | smm_get_gnvs()->smif = 0; |
| 34 | break; |
| 35 | default: |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | /* On success, the IO Trap Handler returns 0 |
| 40 | * On failure, the IO Trap Handler returns a value != 0 |
| 41 | * |
| 42 | * For now, we force the return value to 0 and log all traps to |
| 43 | * see what's going on. |
| 44 | */ |
| 45 | return 1; |
| 46 | } |
| 47 | |
Aaron Durbin | 50ed38f | 2015-08-08 01:25:21 -0500 | [diff] [blame] | 48 | void mainboard_smi_gpi_handler(const struct gpi_status *sts) |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 49 | { |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 50 | if (gpi_status_get(sts, EC_SMI_GPI)) |
| 51 | chromeec_smi_process_events(); |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 52 | } |
| 53 | |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 54 | __weak void mainboard_gpio_smi_sleep(void) |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 55 | { |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void mainboard_smi_sleep(u8 slp_typ) |
| 59 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 60 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 61 | chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS, |
| 62 | MAINBOARD_EC_S5_WAKE_EVENTS); |
Aaron Durbin | ce6c356 | 2015-11-11 16:46:27 -0600 | [diff] [blame] | 63 | |
Matt DeVillier | 0b9cfe6 | 2018-06-26 13:07:32 -0500 | [diff] [blame] | 64 | mainboard_gpio_smi_sleep(); |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | int mainboard_smi_apmc(u8 apmc) |
| 68 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 69 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Aaron Durbin | 3969df8 | 2016-07-14 01:09:34 -0500 | [diff] [blame] | 70 | chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, |
| 71 | MAINBOARD_EC_SMI_EVENTS); |
Patrick Georgi | 406313d | 2015-07-20 22:01:32 +0200 | [diff] [blame] | 72 | return 0; |
| 73 | } |