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