Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * Copyright (C) 2016 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 | |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 17 | #include <console/console.h> |
| 18 | #include <cpu/x86/smm.h> |
| 19 | #include <elog.h> |
| 20 | #include <ec/google/chromeec/smm.h> |
| 21 | #include <soc/iomap.h> |
| 22 | #include <soc/nvs.h> |
| 23 | #include <soc/pm.h> |
| 24 | #include <soc/smm.h> |
| 25 | #include "ec.h" |
Barnali Sarkar | a5b1041 | 2016-11-28 14:53:12 +0530 | [diff] [blame] | 26 | #include <variant/gpio.h> |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 27 | |
| 28 | int mainboard_io_trap_handler(int smif) |
| 29 | { |
| 30 | switch (smif) { |
| 31 | case 0x99: |
| 32 | printk(BIOS_DEBUG, "Sample\n"); |
| 33 | smm_get_gnvs()->smif = 0; |
| 34 | break; |
| 35 | default: |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | /* On success, the IO Trap Handler returns 0 |
| 40 | * On failure, the IO Trap Handler returns a value != 0 |
| 41 | * |
| 42 | * For now, we force the return value to 0 and log all traps to |
| 43 | * see what's going on. |
| 44 | */ |
| 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | void mainboard_smi_gpi_handler(const struct gpi_status *sts) |
| 49 | { |
V Sowmya | 6b78b73 | 2018-01-22 20:23:16 +0530 | [diff] [blame] | 50 | if (IS_ENABLED(CONFIG_BOARD_INTEL_KBLRVP8)) |
| 51 | return; |
| 52 | |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 53 | if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) |
| 54 | if (gpi_status_get(sts, EC_SMI_GPI)) |
| 55 | chromeec_smi_process_events(); |
| 56 | } |
| 57 | |
| 58 | void mainboard_smi_sleep(u8 slp_typ) |
| 59 | { |
| 60 | if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) |
| 61 | if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) |
| 62 | chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS, |
| 63 | MAINBOARD_EC_S5_WAKE_EVENTS); |
| 64 | } |
| 65 | |
| 66 | int mainboard_smi_apmc(u8 apmc) |
| 67 | { |
| 68 | if (IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC)) |
| 69 | chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, |
| 70 | MAINBOARD_EC_SMI_EVENTS); |
| 71 | return 0; |
| 72 | } |