blob: 1673cd0df16b1e359c64c10cdd7600156229b8b8 [file] [log] [blame]
Naresh G Solankiab5d6902016-10-15 18:13:55 +05301/*
2 * This file is part of the coreboot project.
3 *
Naresh G Solankiab5d6902016-10-15 18:13:55 +05304 *
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.
13 */
14
Naresh G Solankiab5d6902016-10-15 18:13:55 +053015#include <console/console.h>
16#include <cpu/x86/smm.h>
Naresh G Solankiab5d6902016-10-15 18:13:55 +053017#include <ec/google/chromeec/smm.h>
18#include <soc/iomap.h>
19#include <soc/nvs.h>
20#include <soc/pm.h>
Kyösti Mälkki89d7fd82019-08-13 07:57:34 +030021#include <intelblocks/smihandler.h>
Naresh G Solankiab5d6902016-10-15 18:13:55 +053022#include "ec.h"
Barnali Sarkara5b10412016-11-28 14:53:12 +053023#include <variant/gpio.h>
Naresh G Solankiab5d6902016-10-15 18:13:55 +053024
25int mainboard_io_trap_handler(int smif)
26{
27 switch (smif) {
28 case 0x99:
29 printk(BIOS_DEBUG, "Sample\n");
30 smm_get_gnvs()->smif = 0;
31 break;
32 default:
33 return 0;
34 }
35
36 /* On success, the IO Trap Handler returns 0
37 * On failure, the IO Trap Handler returns a value != 0
38 *
39 * For now, we force the return value to 0 and log all traps to
40 * see what's going on.
41 */
42 return 1;
43}
44
45void mainboard_smi_gpi_handler(const struct gpi_status *sts)
46{
Julius Wernercd49cce2019-03-05 16:53:33 -080047 if (CONFIG(BOARD_INTEL_KBLRVP8))
V Sowmya6b78b732018-01-22 20:23:16 +053048 return;
49
Julius Wernercd49cce2019-03-05 16:53:33 -080050 if (CONFIG(EC_GOOGLE_CHROMEEC))
Naresh G Solankiab5d6902016-10-15 18:13:55 +053051 if (gpi_status_get(sts, EC_SMI_GPI))
52 chromeec_smi_process_events();
53}
54
55void mainboard_smi_sleep(u8 slp_typ)
56{
Julius Wernercd49cce2019-03-05 16:53:33 -080057 if (CONFIG(EC_GOOGLE_CHROMEEC))
58 if (CONFIG(EC_GOOGLE_CHROMEEC))
Naresh G Solankiab5d6902016-10-15 18:13:55 +053059 chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS,
60 MAINBOARD_EC_S5_WAKE_EVENTS);
61}
62
63int mainboard_smi_apmc(u8 apmc)
64{
Julius Wernercd49cce2019-03-05 16:53:33 -080065 if (CONFIG(EC_GOOGLE_CHROMEEC))
Naresh G Solankiab5d6902016-10-15 18:13:55 +053066 chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS,
67 MAINBOARD_EC_SMI_EVENTS);
68 return 0;
69}