Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; version 2 of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | */ |
| 14 | |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 15 | #include <console/console.h> |
| 16 | #include <cpu/x86/smm.h> |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 17 | #include <ec/google/chromeec/smm.h> |
| 18 | #include <soc/iomap.h> |
| 19 | #include <soc/nvs.h> |
| 20 | #include <soc/pm.h> |
Kyösti Mälkki | 89d7fd8 | 2019-08-13 07:57:34 +0300 | [diff] [blame] | 21 | #include <intelblocks/smihandler.h> |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 22 | #include "ec.h" |
Barnali Sarkar | a5b1041 | 2016-11-28 14:53:12 +0530 | [diff] [blame] | 23 | #include <variant/gpio.h> |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 24 | |
| 25 | int mainboard_io_trap_handler(int smif) |
| 26 | { |
| 27 | switch (smif) { |
| 28 | case 0x99: |
| 29 | printk(BIOS_DEBUG, "Sample\n"); |
| 30 | smm_get_gnvs()->smif = 0; |
| 31 | break; |
| 32 | default: |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | /* On success, the IO Trap Handler returns 0 |
| 37 | * On failure, the IO Trap Handler returns a value != 0 |
| 38 | * |
| 39 | * For now, we force the return value to 0 and log all traps to |
| 40 | * see what's going on. |
| 41 | */ |
| 42 | return 1; |
| 43 | } |
| 44 | |
| 45 | void mainboard_smi_gpi_handler(const struct gpi_status *sts) |
| 46 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 47 | if (CONFIG(BOARD_INTEL_KBLRVP8)) |
V Sowmya | 6b78b73 | 2018-01-22 20:23:16 +0530 | [diff] [blame] | 48 | return; |
| 49 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 50 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 51 | if (gpi_status_get(sts, EC_SMI_GPI)) |
| 52 | chromeec_smi_process_events(); |
| 53 | } |
| 54 | |
| 55 | void mainboard_smi_sleep(u8 slp_typ) |
| 56 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 57 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
| 58 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 59 | chromeec_smi_sleep(slp_typ, MAINBOARD_EC_S3_WAKE_EVENTS, |
| 60 | MAINBOARD_EC_S5_WAKE_EVENTS); |
| 61 | } |
| 62 | |
| 63 | int mainboard_smi_apmc(u8 apmc) |
| 64 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 65 | if (CONFIG(EC_GOOGLE_CHROMEEC)) |
Naresh G Solanki | ab5d690 | 2016-10-15 18:13:55 +0530 | [diff] [blame] | 66 | chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, |
| 67 | MAINBOARD_EC_SMI_EVENTS); |
| 68 | return 0; |
| 69 | } |