Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 1 | /* |
| 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. |
| 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 | |
| 26 | void mainboard_ec_init(void) |
| 27 | { |
Duncan Laurie | 74b964e | 2015-09-04 10:41:02 -0700 | [diff] [blame^] | 28 | printk(BIOS_DEBUG, "mainboard: EC init\n"); |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 29 | |
Duncan Laurie | 74b964e | 2015-09-04 10:41:02 -0700 | [diff] [blame^] | 30 | if (acpi_is_wakeup_s3()) { |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 31 | google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS | |
| 32 | MAINBOARD_EC_S3_WAKE_EVENTS); |
| 33 | |
| 34 | /* Disable SMI and wake events */ |
| 35 | google_chromeec_set_smi_mask(0); |
| 36 | |
| 37 | /* Clear pending events */ |
| 38 | while (google_chromeec_get_event() != 0) |
| 39 | ; |
Duncan Laurie | 74b964e | 2015-09-04 10:41:02 -0700 | [diff] [blame^] | 40 | |
| 41 | /* Restore SCI event mask */ |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 42 | google_chromeec_set_sci_mask(MAINBOARD_EC_SCI_EVENTS); |
| 43 | } else { |
| 44 | google_chromeec_log_events(MAINBOARD_EC_LOG_EVENTS | |
| 45 | MAINBOARD_EC_S5_WAKE_EVENTS); |
| 46 | } |
| 47 | |
| 48 | /* Clear wake event mask */ |
| 49 | google_chromeec_set_wake_mask(0); |
Lee Leahy | c421041 | 2015-06-29 11:37:56 -0700 | [diff] [blame] | 50 | } |