blob: 1ff4e3c6d291dd231830604d3bd6a5452b4b4871 [file] [log] [blame]
Angel Pons62079a52020-04-05 13:21:34 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Patrick Georgi406313d2015-07-20 22:01:32 +02003
Aaron Durbin30b0c7a2016-07-13 13:01:13 -05004#include <arch/acpi.h>
Matt DeVillier0b9cfe62018-06-26 13:07:32 -05005#include <baseboard/variant.h>
Patrick Georgi406313d2015-07-20 22:01:32 +02006#include <console/console.h>
7#include <cpu/x86/smm.h>
Aaron Durbin3969df82016-07-14 01:09:34 -05008#include <ec/google/chromeec/smm.h>
Aaron Durbince6c3562015-11-11 16:46:27 -06009#include <gpio.h>
Patrick Georgi406313d2015-07-20 22:01:32 +020010#include <soc/iomap.h>
11#include <soc/nvs.h>
12#include <soc/pm.h>
Kyösti Mälkki89d7fd82019-08-13 07:57:34 +030013#include <intelblocks/smihandler.h>
Patrick Georgi406313d2015-07-20 22:01:32 +020014#include "ec.h"
Matt DeVillier0b9cfe62018-06-26 13:07:32 -050015#include <variant/gpio.h>
Patrick Georgi406313d2015-07-20 22:01:32 +020016
17int 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 Durbin50ed38f2015-08-08 01:25:21 -050037void mainboard_smi_gpi_handler(const struct gpi_status *sts)
Patrick Georgi406313d2015-07-20 22:01:32 +020038{
Aaron Durbin3969df82016-07-14 01:09:34 -050039 if (gpi_status_get(sts, EC_SMI_GPI))
40 chromeec_smi_process_events();
Aaron Durbince6c3562015-11-11 16:46:27 -060041}
42
Matt DeVillier0b9cfe62018-06-26 13:07:32 -050043__weak void mainboard_gpio_smi_sleep(void)
Aaron Durbince6c3562015-11-11 16:46:27 -060044{
Aaron Durbince6c3562015-11-11 16:46:27 -060045}
46
47void mainboard_smi_sleep(u8 slp_typ)
48{
Julius Wernercd49cce2019-03-05 16:53:33 -080049 if (CONFIG(EC_GOOGLE_CHROMEEC))
Aaron Durbin3969df82016-07-14 01:09:34 -050050 chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS,
51 MAINBOARD_EC_S5_WAKE_EVENTS);
Aaron Durbince6c3562015-11-11 16:46:27 -060052
Matt DeVillier0b9cfe62018-06-26 13:07:32 -050053 mainboard_gpio_smi_sleep();
Patrick Georgi406313d2015-07-20 22:01:32 +020054}
55
56int mainboard_smi_apmc(u8 apmc)
57{
Julius Wernercd49cce2019-03-05 16:53:33 -080058 if (CONFIG(EC_GOOGLE_CHROMEEC))
Aaron Durbin3969df82016-07-14 01:09:34 -050059 chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS,
60 MAINBOARD_EC_SMI_EVENTS);
Patrick Georgi406313d2015-07-20 22:01:32 +020061 return 0;
62}