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