Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 coresystems GmbH |
| 5 | * Copyright 2014 Google Inc. |
| 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. |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 17 | #include <arch/acpi.h> |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 18 | #include <console/console.h> |
| 19 | #include <cpu/x86/smm.h> |
| 20 | #include <soc/pm.h> |
| 21 | #include <soc/smm.h> |
| 22 | #include <elog.h> |
| 23 | #include <ec/google/chromeec/ec.h> |
| 24 | #include <soc/gpio.h> |
| 25 | #include <soc/iomap.h> |
| 26 | #include <soc/nvs.h> |
Matt DeVillier | 0148fcb | 2016-12-17 17:13:23 -0600 | [diff] [blame] | 27 | #include "onboard.h" |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 28 | |
| 29 | int mainboard_io_trap_handler(int smif) |
| 30 | { |
| 31 | switch (smif) { |
| 32 | case 0x99: |
| 33 | printk(BIOS_DEBUG, "Sample\n"); |
| 34 | smm_get_gnvs()->smif = 0; |
| 35 | break; |
| 36 | default: |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | /* On success, the IO Trap Handler returns 0 |
| 41 | * On failure, the IO Trap Handler returns a value != 0 |
| 42 | * |
| 43 | * For now, we force the return value to 0 and log all traps to |
| 44 | * see what's going on. |
| 45 | */ |
| 46 | return 1; |
| 47 | } |
| 48 | |
| 49 | /* gpi_sts is GPIO 47:32 */ |
| 50 | void mainboard_smi_gpi(u32 gpi_sts) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | void mainboard_smi_sleep(u8 slp_typ) |
| 55 | { |
| 56 | /* Disable USB charging if required */ |
| 57 | switch (slp_typ) { |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 58 | case ACPI_S3: |
Matt DeVillier | 0148fcb | 2016-12-17 17:13:23 -0600 | [diff] [blame] | 59 | set_power_led(LED_BLINK); |
| 60 | |
| 61 | /* Enable DCP mode */ |
| 62 | if (IS_ENABLED(CONFIG_BOARD_GOOGLE_TIDUS)) { |
| 63 | set_gpio(GPIO_USB_CTL_1, 0); |
| 64 | } |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 65 | break; |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 66 | case ACPI_S5: |
Matt DeVillier | 0148fcb | 2016-12-17 17:13:23 -0600 | [diff] [blame] | 67 | set_power_led(LED_OFF); |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 68 | break; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | int mainboard_smi_apmc(u8 apmc) |
| 73 | { |
| 74 | switch (apmc) { |
| 75 | case APM_CNT_ACPI_ENABLE: |
| 76 | break; |
| 77 | case APM_CNT_ACPI_DISABLE: |
| 78 | break; |
| 79 | } |
| 80 | return 0; |
| 81 | } |