blob: 9ecc43aaffde66ce3b061870b177bbda467e9267 [file] [log] [blame]
Naresh G Solankiab5d6902016-10-15 18:13:55 +05301/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2016 Intel Corp.
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.
15 */
16
17#include <arch/acpi.h>
18#include <arch/io.h>
19#include <console/console.h>
20#include <cpu/x86/smm.h>
21#include <elog.h>
22#include <ec/google/chromeec/smm.h>
23#include <soc/iomap.h>
24#include <soc/nvs.h>
25#include <soc/pm.h>
26#include <soc/smm.h>
27#include "ec.h"
Barnali Sarkara5b10412016-11-28 14:53:12 +053028#include <variant/gpio.h>
Naresh G Solankiab5d6902016-10-15 18:13:55 +053029
30int mainboard_io_trap_handler(int smif)
31{
32 switch (smif) {
33 case 0x99:
34 printk(BIOS_DEBUG, "Sample\n");
35 smm_get_gnvs()->smif = 0;
36 break;
37 default:
38 return 0;
39 }
40
41 /* On success, the IO Trap Handler returns 0
42 * On failure, the IO Trap Handler returns a value != 0
43 *
44 * For now, we force the return value to 0 and log all traps to
45 * see what's going on.
46 */
47 return 1;
48}
49
50void mainboard_smi_gpi_handler(const struct gpi_status *sts)
51{
52 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
53 if (gpi_status_get(sts, EC_SMI_GPI))
54 chromeec_smi_process_events();
55}
56
57void mainboard_smi_sleep(u8 slp_typ)
58{
59 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
60 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
61 chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS,
62 MAINBOARD_EC_S5_WAKE_EVENTS);
63}
64
65int mainboard_smi_apmc(u8 apmc)
66{
67 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
68 chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS,
69 MAINBOARD_EC_SMI_EVENTS);
70 return 0;
71}