blob: 36cd10acd164c057ec32dde7f80e269926f792fe [file] [log] [blame]
Lee Leahyc4210412015-06-29 11:37:56 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Google Inc.
5 * Copyright (C) 2015 Intel Corporation
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.
Lee Leahyc4210412015-06-29 11:37:56 -070015 */
16
17#include <arch/acpi.h>
18#include <console/console.h>
19#include <ec/google/chromeec/ec.h>
20#include "ec.h"
21
22void mainboard_ec_init(void)
23{
Duncan Laurie74b964e2015-09-04 10:41:02 -070024 printk(BIOS_DEBUG, "mainboard: EC init\n");
Lee Leahyc4210412015-06-29 11:37:56 -070025
Duncan Laurie74b964e2015-09-04 10:41:02 -070026 if (acpi_is_wakeup_s3()) {
Lee Leahyc4210412015-06-29 11:37:56 -070027 google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
28 MAINBOARD_EC_S3_WAKE_EVENTS);
29
30 /* Disable SMI and wake events */
31 google_chromeec_set_smi_mask(0);
32
33 /* Clear pending events */
34 while (google_chromeec_get_event() != 0)
35 ;
Duncan Laurie74b964e2015-09-04 10:41:02 -070036
37 /* Restore SCI event mask */
Lee Leahyc4210412015-06-29 11:37:56 -070038 google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
39 } else {
40 google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
41 MAINBOARD_EC_S5_WAKE_EVENTS);
42 }
43
44 /* Clear wake event mask */
45 google_chromeec_set_wake_mask(0);
Lee Leahyc4210412015-06-29 11:37:56 -070046}