blob: 6bc519078acbfa7738ef17fd482a2c1e62bc66e0 [file] [log] [blame]
Shaunak Saha9a6ebda2016-07-11 21:04:25 -07001/*
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
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050017#include <arch/acpi.h>
Aaron Durbin10d67cb2016-09-02 16:56:03 -050018#include <baseboard/variants.h>
Shaunak Saha9a6ebda2016-07-11 21:04:25 -070019#include <cpu/x86/smm.h>
Aaron Durbin1a755602016-07-14 00:43:11 -050020#include <ec/google/chromeec/smm.h>
Brandon Breitenstein60ce6152017-08-08 15:30:41 -070021#include <intelblocks/smihandler.h>
Shaunak Saha9a6ebda2016-07-11 21:04:25 -070022#include <soc/pm.h>
Furquan Shaikhd3d77be2016-08-17 16:18:05 -070023#include <soc/gpio.h>
Aaron Durbin114d7c32016-09-02 15:58:16 -050024#include <variant/ec.h>
25#include <variant/gpio.h>
Shaunak Saha9a6ebda2016-07-11 21:04:25 -070026
Shaunak Saha3922cec2016-07-24 22:54:13 -070027void mainboard_smi_gpi_handler(const struct gpi_status *sts)
28{
29 if (gpi_status_get(sts, EC_SMI_GPI))
30 chromeec_smi_process_events();
31}
32
Shaunak Saha9a6ebda2016-07-11 21:04:25 -070033void mainboard_smi_sleep(u8 slp_typ)
34{
Aaron Durbin10d67cb2016-09-02 16:56:03 -050035 const struct pad_config *pads;
36 size_t num;
37
Ben Chaneeb475c2017-11-09 16:53:26 -080038 pads = variant_sleep_gpio_table(slp_typ, &num);
Aaron Durbin10d67cb2016-09-02 16:56:03 -050039 gpio_configure_pads(pads, num);
Furquan Shaikhd3d77be2016-08-17 16:18:05 -070040
Aaron Durbin1a755602016-07-14 00:43:11 -050041 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
42 chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS,
43 MAINBOARD_EC_S5_WAKE_EVENTS);
Shaunak Saha9a6ebda2016-07-11 21:04:25 -070044}
45
46int mainboard_smi_apmc(u8 apmc)
47{
Aaron Durbin1a755602016-07-14 00:43:11 -050048 if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC))
49 chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS,
50 MAINBOARD_EC_SMI_EVENTS);
Shaunak Saha9a6ebda2016-07-11 21:04:25 -070051 return 0;
52}