Angel Pons | 58c0d32 | 2020-04-05 13:20:46 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 4 | #include <console/console.h> |
| 5 | #include <cpu/x86/smm.h> |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 6 | #include <soc/pm.h> |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 7 | #include <ec/google/chromeec/ec.h> |
Kyösti Mälkki | 923b8ec | 2022-11-29 07:36:44 +0200 | [diff] [blame] | 8 | #include <ec/google/chromeec/smm.h> |
Angel Pons | 52e48b5 | 2021-01-28 17:03:19 +0100 | [diff] [blame] | 9 | #include <southbridge/intel/lynxpoint/lp_gpio.h> |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 10 | #include <soc/iomap.h> |
| 11 | #include <soc/nvs.h> |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 12 | #include "ec.h" |
Matt DeVillier | 45e11aa | 2016-12-18 11:59:58 -0600 | [diff] [blame] | 13 | #include <variant/onboard.h> |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 14 | |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 15 | /* gpi_sts is GPIO 47:32 */ |
| 16 | void mainboard_smi_gpi(u32 gpi_sts) |
| 17 | { |
Kyösti Mälkki | 83faa5d | 2023-01-05 15:39:16 +0200 | [diff] [blame] | 18 | if (gpi_sts & (1 << (EC_SMI_GPI - 32))) |
| 19 | chromeec_smi_process_events(); |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 20 | } |
| 21 | |
Matt DeVillier | 45e11aa | 2016-12-18 11:59:58 -0600 | [diff] [blame] | 22 | static void mainboard_disable_gpios(void) |
| 23 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 24 | #if CONFIG(BOARD_GOOGLE_SAMUS) |
Matt DeVillier | 45e11aa | 2016-12-18 11:59:58 -0600 | [diff] [blame] | 25 | /* Put SSD in reset to prevent leak */ |
| 26 | set_gpio(BOARD_SSD_RESET_GPIO, 0); |
| 27 | /* Disable LTE */ |
| 28 | set_gpio(BOARD_LTE_DISABLE_GPIO, 0); |
| 29 | #else |
| 30 | set_gpio(BOARD_PP3300_CODEC_GPIO, 0); |
| 31 | #endif |
| 32 | /* Prevent leak from standby rail to WLAN rail */ |
| 33 | set_gpio(BOARD_WLAN_DISABLE_GPIO, 0); |
| 34 | } |
| 35 | |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 36 | void mainboard_smi_sleep(u8 slp_typ) |
| 37 | { |
| 38 | /* Disable USB charging if required */ |
| 39 | switch (slp_typ) { |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 40 | case ACPI_S3: |
Kyösti Mälkki | 239abaf | 2020-06-28 12:12:01 +0300 | [diff] [blame] | 41 | if (gnvs->s3u0 == 0) { |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 42 | google_chromeec_set_usb_charge_mode( |
| 43 | 0, USB_CHARGE_MODE_DISABLED); |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 44 | google_chromeec_set_usb_charge_mode( |
| 45 | 1, USB_CHARGE_MODE_DISABLED); |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 46 | } |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 47 | |
Matt DeVillier | 45e11aa | 2016-12-18 11:59:58 -0600 | [diff] [blame] | 48 | mainboard_disable_gpios(); |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 49 | |
| 50 | /* Enable wake events */ |
| 51 | google_chromeec_set_wake_mask(MAINBOARD_EC_S3_WAKE_EVENTS); |
| 52 | break; |
Aaron Durbin | 30b0c7a | 2016-07-13 13:01:13 -0500 | [diff] [blame] | 53 | case ACPI_S5: |
Kyösti Mälkki | 239abaf | 2020-06-28 12:12:01 +0300 | [diff] [blame] | 54 | if (gnvs->s5u0 == 0) { |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 55 | google_chromeec_set_usb_charge_mode( |
| 56 | 0, USB_CHARGE_MODE_DISABLED); |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 57 | google_chromeec_set_usb_charge_mode( |
| 58 | 1, USB_CHARGE_MODE_DISABLED); |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 59 | } |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 60 | |
Matt DeVillier | 45e11aa | 2016-12-18 11:59:58 -0600 | [diff] [blame] | 61 | mainboard_disable_gpios(); |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 62 | |
| 63 | /* Enable wake events */ |
| 64 | google_chromeec_set_wake_mask(MAINBOARD_EC_S5_WAKE_EVENTS); |
| 65 | break; |
| 66 | } |
| 67 | |
| 68 | /* Disable SCI and SMI events */ |
| 69 | google_chromeec_set_smi_mask(0); |
| 70 | google_chromeec_set_sci_mask(0); |
| 71 | |
| 72 | /* Clear pending events that may trigger immediate wake */ |
Rob Barnes | f1ade48 | 2021-06-14 10:22:21 -0600 | [diff] [blame] | 73 | while (google_chromeec_get_event() != EC_HOST_EVENT_NONE) |
Marc Jones | d862121 | 2015-06-09 21:18:38 -0600 | [diff] [blame] | 74 | ; |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 75 | } |
| 76 | |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 77 | int mainboard_smi_apmc(u8 apmc) |
| 78 | { |
Kyösti Mälkki | 923b8ec | 2022-11-29 07:36:44 +0200 | [diff] [blame] | 79 | chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, MAINBOARD_EC_SMI_EVENTS); |
Marc Jones | 07cf24c | 2015-06-09 14:42:55 -0600 | [diff] [blame] | 80 | return 0; |
| 81 | } |