blob: 0fc3588020de4174894f0ca66bcc9b50c97031a0 [file] [log] [blame]
Angel Pons58c0d322020-04-05 13:20:46 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marc Jones07cf24c2015-06-09 14:42:55 -06002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi.h>
Marc Jones07cf24c2015-06-09 14:42:55 -06004#include <console/console.h>
5#include <cpu/x86/smm.h>
Marc Jonesd8621212015-06-09 21:18:38 -06006#include <soc/pm.h>
Marc Jones07cf24c2015-06-09 14:42:55 -06007#include <ec/google/chromeec/ec.h>
Kyösti Mälkki923b8ec2022-11-29 07:36:44 +02008#include <ec/google/chromeec/smm.h>
Angel Pons52e48b52021-01-28 17:03:19 +01009#include <southbridge/intel/lynxpoint/lp_gpio.h>
Marc Jonesd8621212015-06-09 21:18:38 -060010#include <soc/iomap.h>
Marc Jones07cf24c2015-06-09 14:42:55 -060011#include "ec.h"
Matt DeVillier45e11aa2016-12-18 11:59:58 -060012#include <variant/onboard.h>
Marc Jonesd8621212015-06-09 21:18:38 -060013
Marc Jones07cf24c2015-06-09 14:42:55 -060014/* gpi_sts is GPIO 47:32 */
15void mainboard_smi_gpi(u32 gpi_sts)
16{
Kyösti Mälkki83faa5d2023-01-05 15:39:16 +020017 if (gpi_sts & (1 << (EC_SMI_GPI - 32)))
18 chromeec_smi_process_events();
Marc Jones07cf24c2015-06-09 14:42:55 -060019}
20
Matt DeVillier45e11aa2016-12-18 11:59:58 -060021static void mainboard_disable_gpios(void)
22{
Julius Wernercd49cce2019-03-05 16:53:33 -080023#if CONFIG(BOARD_GOOGLE_SAMUS)
Matt DeVillier45e11aa2016-12-18 11:59:58 -060024 /* Put SSD in reset to prevent leak */
25 set_gpio(BOARD_SSD_RESET_GPIO, 0);
26 /* Disable LTE */
27 set_gpio(BOARD_LTE_DISABLE_GPIO, 0);
28#else
29 set_gpio(BOARD_PP3300_CODEC_GPIO, 0);
30#endif
31 /* Prevent leak from standby rail to WLAN rail */
32 set_gpio(BOARD_WLAN_DISABLE_GPIO, 0);
33}
34
Marc Jones07cf24c2015-06-09 14:42:55 -060035void mainboard_smi_sleep(u8 slp_typ)
36{
37 /* Disable USB charging if required */
Kyösti Mälkki027f86e2022-12-02 15:30:10 +020038 /* NOTE: Setting of usb0 _may_ also control usb1 here. */
39 chromeec_set_usb_charge_mode(slp_typ);
40
Marc Jones07cf24c2015-06-09 14:42:55 -060041 switch (slp_typ) {
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050042 case ACPI_S3:
Matt DeVillier45e11aa2016-12-18 11:59:58 -060043 mainboard_disable_gpios();
Marc Jones07cf24c2015-06-09 14:42:55 -060044
45 /* Enable wake events */
46 google_chromeec_set_wake_mask(MAINBOARD_EC_S3_WAKE_EVENTS);
47 break;
Aaron Durbin30b0c7a2016-07-13 13:01:13 -050048 case ACPI_S5:
Matt DeVillier45e11aa2016-12-18 11:59:58 -060049 mainboard_disable_gpios();
Marc Jones07cf24c2015-06-09 14:42:55 -060050
51 /* Enable wake events */
52 google_chromeec_set_wake_mask(MAINBOARD_EC_S5_WAKE_EVENTS);
53 break;
54 }
55
56 /* Disable SCI and SMI events */
57 google_chromeec_set_smi_mask(0);
58 google_chromeec_set_sci_mask(0);
59
60 /* Clear pending events that may trigger immediate wake */
Rob Barnesf1ade482021-06-14 10:22:21 -060061 while (google_chromeec_get_event() != EC_HOST_EVENT_NONE)
Marc Jonesd8621212015-06-09 21:18:38 -060062 ;
Marc Jones07cf24c2015-06-09 14:42:55 -060063}
64
Marc Jones07cf24c2015-06-09 14:42:55 -060065int mainboard_smi_apmc(u8 apmc)
66{
Kyösti Mälkki923b8ec2022-11-29 07:36:44 +020067 chromeec_smi_apmc(apmc, MAINBOARD_EC_SCI_EVENTS, MAINBOARD_EC_SMI_EVENTS);
Marc Jones07cf24c2015-06-09 14:42:55 -060068 return 0;
69}