blob: 8a9e2a61f997198c02b958d794bcfff93197d581 [file] [log] [blame]
Patrick Georgi04746fc2015-06-05 18:53:43 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright 2014 Google Inc.
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.
Patrick Georgi04746fc2015-06-05 18:53:43 +020015 */
16
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050017#include <arch/acpi.h>
Patrick Georgi04746fc2015-06-05 18:53:43 +020018#include <console/console.h>
19#include <cpu/x86/smm.h>
20#include <soc/pm.h>
21#include <soc/smm.h>
22#include <elog.h>
23#include <ec/google/chromeec/ec.h>
24#include <soc/gpio.h>
25#include <soc/iomap.h>
26#include <soc/nvs.h>
Matt DeVillier0148fcb2016-12-17 17:13:23 -060027#include "onboard.h"
Patrick Georgi04746fc2015-06-05 18:53:43 +020028
29int mainboard_io_trap_handler(int smif)
30{
31 switch (smif) {
32 case 0x99:
33 printk(BIOS_DEBUG, "Sample\n");
34 smm_get_gnvs()->smif = 0;
35 break;
36 default:
37 return 0;
38 }
39
40 /* On success, the IO Trap Handler returns 0
41 * On failure, the IO Trap Handler returns a value != 0
42 *
43 * For now, we force the return value to 0 and log all traps to
44 * see what's going on.
45 */
46 return 1;
47}
48
49/* gpi_sts is GPIO 47:32 */
50void mainboard_smi_gpi(u32 gpi_sts)
51{
52}
53
54void mainboard_smi_sleep(u8 slp_typ)
55{
56 /* Disable USB charging if required */
57 switch (slp_typ) {
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050058 case ACPI_S3:
Matt DeVillier0148fcb2016-12-17 17:13:23 -060059 set_power_led(LED_BLINK);
60
61 /* Enable DCP mode */
62 if (IS_ENABLED(CONFIG_BOARD_GOOGLE_TIDUS)) {
63 set_gpio(GPIO_USB_CTL_1, 0);
64 }
Patrick Georgi04746fc2015-06-05 18:53:43 +020065 break;
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050066 case ACPI_S5:
Matt DeVillier0148fcb2016-12-17 17:13:23 -060067 set_power_led(LED_OFF);
Patrick Georgi04746fc2015-06-05 18:53:43 +020068 break;
69 }
70}
71
72int mainboard_smi_apmc(u8 apmc)
73{
74 switch (apmc) {
75 case APM_CNT_ACPI_ENABLE:
76 break;
77 case APM_CNT_ACPI_DISABLE:
78 break;
79 }
80 return 0;
81}