blob: 27fcb0f0669ef860ef858ffbde046e63fd9f43cb [file] [log] [blame]
Aaron Durbin063c8732013-10-28 11:24:53 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbin063c8732013-10-28 11:24:53 -050014 */
15
16#include <arch/acpi.h>
Aaron Durbin063c8732013-10-28 11:24:53 -050017#include <types.h>
18#include <console/console.h>
19#include <ec/google/chromeec/ec.h>
20#include "ec.h"
21
22void mainboard_ec_init(void)
23{
24 printk(BIOS_DEBUG, "mainboard_ec_init\n");
25 post_code(0xf0);
26
27 /* Restore SCI event mask on resume. */
Kyösti Mälkkic3ed8862014-06-19 19:50:51 +030028 if (acpi_is_wakeup_s3()) {
Aaron Durbin063c8732013-10-28 11:24:53 -050029 google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
30 MAINBOARD_EC_S3_WAKE_EVENTS);
31
32 /* Disable SMI and wake events */
33 google_chromeec_set_smi_mask(0);
34
35 /* Clear pending events */
36 while (google_chromeec_get_event() != 0);
37 google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS);
38 } else {
39 google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS |
40 MAINBOARD_EC_S5_WAKE_EVENTS);
Aaron Durbin3fbf6712013-11-11 14:55:47 -060041 google_chromeec_set_smi_mask(MAINBOARD_EC_SMI_EVENTS);
Aaron Durbin063c8732013-10-28 11:24:53 -050042 }
43
44 /* Clear wake events, these are enabled on entry to sleep */
45 google_chromeec_set_wake_mask(0);
46
47 post_code(0xf1);
48}