blob: c68741b2e9dd55618cee0225d5bac0cf7c824c1d [file] [log] [blame]
Angel Ponsd28443e2020-04-05 13:22:44 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06004#include <console/console.h>
5#include <cpu/x86/smm.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -06006#include <southbridge/intel/lynxpoint/pch.h>
7#include <southbridge/intel/common/gpio.h>
8#include <southbridge/intel/lynxpoint/me.h>
9#include <northbridge/intel/haswell/haswell.h>
10#include <cpu/intel/haswell/haswell.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060011
12/* Include EC functions */
13#include <ec/google/chromeec/ec.h>
Kyösti Mälkki923b8ec2022-11-29 07:36:44 +020014#include <ec/google/chromeec/smm.h>
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060015#include "ec.h"
16
17/* Codec enable: GPIO45 */
18#define GPIO_PP3300_CODEC_EN 45
19/* GPIO46 controls the WLAN_DISABLE_L signal. */
20#define GPIO_WLAN_DISABLE_L 46
21#define GPIO_LTE_DISABLE_L 59
22
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060023/* gpi_sts is GPIO 47:32 */
24void mainboard_smi_gpi(u32 gpi_sts)
25{
Kyösti Mälkki83faa5d2023-01-05 15:39:16 +020026 if (gpi_sts & (1 << (EC_SMI_GPI - 32)))
27 chromeec_smi_process_events();
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060028}
29
30void mainboard_smi_sleep(u8 slp_typ)
31{
32 /* Disable USB charging if required */
Kyösti Mälkki027f86e2022-12-02 15:30:10 +020033 chromeec_set_usb_charge_mode(slp_typ);
34
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060035 switch (slp_typ) {
36 case ACPI_S3:
Kyösti Mälkki28a7d9b2023-01-05 18:05:11 +020037 case ACPI_S4:
38 case ACPI_S5:
39 /* Prevent leak from standby rail to WLAN rail in S3/S4/S5. */
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060040 set_gpio(GPIO_WLAN_DISABLE_L, 0);
41 set_gpio(GPIO_PP3300_CODEC_EN, 0);
42 /* Disable LTE */
43 set_gpio(GPIO_LTE_DISABLE_L, 0);
Kyösti Mälkki28a7d9b2023-01-05 18:05:11 +020044 break;
45 }
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060046
Kyösti Mälkki28a7d9b2023-01-05 18:05:11 +020047 switch (slp_typ) {
48 case ACPI_S3:
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060049 /* Enable wake events */
50 google_chromeec_set_wake_mask(MAINBOARD_EC_S3_WAKE_EVENTS);
51 break;
52 case ACPI_S4:
53 case ACPI_S5:
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060054 /* Enable wake events */
55 google_chromeec_set_wake_mask(MAINBOARD_EC_S5_WAKE_EVENTS);
56 break;
57 }
58
59 /* Disable SCI and SMI events */
60 google_chromeec_set_smi_mask(0);
61 google_chromeec_set_sci_mask(0);
62
63 /* Clear pending events that may trigger immediate wake */
Rob Barnesf1ade482021-06-14 10:22:21 -060064 while (google_chromeec_get_event() != EC_HOST_EVENT_NONE)
65 ;
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060066}
67
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060068int mainboard_smi_apmc(u8 apmc)
69{
Kyösti Mälkki923b8ec2022-11-29 07:36:44 +020070 chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, MAINBOARD_EC_SMI_EVENTS);
Matt DeVillierc12e5ae2016-11-27 02:19:02 -060071 return 0;
72}