Shaunak Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 1 | /* |
| 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 Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 17 | #include <arch/acpi.h> |
Aaron Durbin | 10d67cb | 2016-09-02 16:56:03 -0500 | [diff] [blame] | 18 | #include <baseboard/variants.h> |
Shaunak Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 19 | #include <cpu/x86/smm.h> |
Aaron Durbin | 1a75560 | 2016-07-14 00:43:11 -0500 | [diff] [blame] | 20 | #include <ec/google/chromeec/smm.h> |
Brandon Breitenstein | 60ce615 | 2017-08-08 15:30:41 -0700 | [diff] [blame] | 21 | #include <intelblocks/smihandler.h> |
Shaunak Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 22 | #include <soc/pm.h> |
Furquan Shaikh | d3d77be | 2016-08-17 16:18:05 -0700 | [diff] [blame] | 23 | #include <soc/gpio.h> |
Aaron Durbin | 114d7c3 | 2016-09-02 15:58:16 -0500 | [diff] [blame] | 24 | #include <variant/ec.h> |
| 25 | #include <variant/gpio.h> |
Shaunak Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 26 | |
Shaunak Saha | 3922cec | 2016-07-24 22:54:13 -0700 | [diff] [blame] | 27 | void 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 Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 33 | void mainboard_smi_sleep(u8 slp_typ) |
| 34 | { |
Aaron Durbin | 10d67cb | 2016-09-02 16:56:03 -0500 | [diff] [blame] | 35 | const struct pad_config *pads; |
| 36 | size_t num; |
| 37 | |
Ben Chan | eeb475c | 2017-11-09 16:53:26 -0800 | [diff] [blame] | 38 | pads = variant_sleep_gpio_table(slp_typ, &num); |
Aaron Durbin | 10d67cb | 2016-09-02 16:56:03 -0500 | [diff] [blame] | 39 | gpio_configure_pads(pads, num); |
Furquan Shaikh | d3d77be | 2016-08-17 16:18:05 -0700 | [diff] [blame] | 40 | |
Aaron Durbin | 1a75560 | 2016-07-14 00:43:11 -0500 | [diff] [blame] | 41 | 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 Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | int mainboard_smi_apmc(u8 apmc) |
| 47 | { |
Aaron Durbin | 1a75560 | 2016-07-14 00:43:11 -0500 | [diff] [blame] | 48 | if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) |
| 49 | chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, |
| 50 | MAINBOARD_EC_SMI_EVENTS); |
Shaunak Saha | 9a6ebda | 2016-07-11 21:04:25 -0700 | [diff] [blame] | 51 | return 0; |
| 52 | } |