blob: 2d8bfc821b2197efd681047e0c834e566b0ec25b [file] [log] [blame]
Angel Ponsaf4ecc22020-04-05 13:21:45 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Patrick Georgi04746fc2015-06-05 18:53:43 +02003
Furquan Shaikh76cedd22020-05-02 10:24:23 -07004#include <acpi/acpi.h>
Patrick Georgi04746fc2015-06-05 18:53:43 +02005#include <console/console.h>
6#include <cpu/x86/smm.h>
7#include <soc/pm.h>
Patrick Georgi04746fc2015-06-05 18:53:43 +02008#include <ec/google/chromeec/ec.h>
9#include <soc/gpio.h>
10#include <soc/iomap.h>
11#include <soc/nvs.h>
Matt DeVillier0148fcb2016-12-17 17:13:23 -060012#include "onboard.h"
Patrick Georgi04746fc2015-06-05 18:53:43 +020013
14int mainboard_io_trap_handler(int smif)
15{
16 switch (smif) {
17 case 0x99:
18 printk(BIOS_DEBUG, "Sample\n");
19 smm_get_gnvs()->smif = 0;
20 break;
21 default:
22 return 0;
23 }
24
25 /* On success, the IO Trap Handler returns 0
26 * On failure, the IO Trap Handler returns a value != 0
27 *
28 * For now, we force the return value to 0 and log all traps to
29 * see what's going on.
30 */
31 return 1;
32}
33
34/* gpi_sts is GPIO 47:32 */
35void mainboard_smi_gpi(u32 gpi_sts)
36{
37}
38
39void mainboard_smi_sleep(u8 slp_typ)
40{
41 /* Disable USB charging if required */
42 switch (slp_typ) {
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050043 case ACPI_S3:
Matt DeVillier0148fcb2016-12-17 17:13:23 -060044 set_power_led(LED_BLINK);
45
46 /* Enable DCP mode */
Julius Wernercd49cce2019-03-05 16:53:33 -080047 if (CONFIG(BOARD_GOOGLE_TIDUS)) {
Matt DeVillier0148fcb2016-12-17 17:13:23 -060048 set_gpio(GPIO_USB_CTL_1, 0);
49 }
Patrick Georgi04746fc2015-06-05 18:53:43 +020050 break;
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050051 case ACPI_S5:
Matt DeVillier0148fcb2016-12-17 17:13:23 -060052 set_power_led(LED_OFF);
Patrick Georgi04746fc2015-06-05 18:53:43 +020053 break;
54 }
55}
56
57int mainboard_smi_apmc(u8 apmc)
58{
59 switch (apmc) {
60 case APM_CNT_ACPI_ENABLE:
61 break;
62 case APM_CNT_ACPI_DISABLE:
63 break;
64 }
65 return 0;
66}