blob: 60e80d365fb12a32de2f5dbe9df7f4fd7d5ab2c2 [file] [log] [blame]
Lee Leahy5cb9dda2015-05-01 10:34:54 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 Google Inc.
5 * Copyright (C) 2015 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 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc.
19 */
20
21#include <arch/acpi.h>
22#include <console/console.h>
23#include <ec/google/chromeec/ec.h>
24#include "ec.h"
25#include <vendorcode/google/chromeos/chromeos.h>
26#include <types.h>
27
28void mainboard_ec_init(void)
29{
30 printk(BIOS_DEBUG, "mainboard_ec_init\n");
31 post_code(0xf0);
32
33#if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)
34 /* Restore SCI event mask on resume. */
35 if (acpi_slp_type == 3) {
36 google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
37 MAINBOARD_EC_S3_WAKE_EVENTS);
38
39 /* Disable SMI and wake events */
40 google_chromeec_set_smi_mask(0);
41
42 /* Clear pending events */
43 while (google_chromeec_get_event() != 0)
44 ;
45 /*
46 * Set SCI mask.OS may not generate the SMI event to
47 * set this on S3 resume
48 */
49 google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
50 } else {
51 google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
52 MAINBOARD_EC_S5_WAKE_EVENTS);
53 }
54
55 /* Clear wake event mask */
56 google_chromeec_set_wake_mask(0);
57#endif
58 post_code(0xf1);
59}