mb/google/nissa: Create pujjogatwin variant
[coreboot2.git] / src / mainboard / google / parrot / smihandler.c
blob10341fba9ee7a78944ab4871b8c55e9b2f462227
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi_gnvs.h>
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <halt.h>
7 #include <southbridge/intel/bd82x6x/pch.h>
8 #include <southbridge/intel/bd82x6x/me.h>
9 #include <southbridge/intel/common/pmutil.h>
10 #include <northbridge/intel/sandybridge/sandybridge.h>
11 #include <ec/compal/ene932/ec.h>
12 #include "ec.h"
14 static u8 mainboard_smi_ec(void)
16 u8 src;
18 ec_kbc_write_cmd(0x56);
19 src = ec_kbc_read_ob();
20 printk(BIOS_DEBUG, "%s src: %x\n", __func__, src);
22 switch (src) {
23 case EC_BATTERY_CRITICAL:
24 break;
25 case EC_LID_CLOSE:
26 printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n");
28 /* Go to S5 */
29 poweroff();
30 break;
33 return src;
36 void mainboard_smi_gpi(u32 gpi_sts)
38 if (gpi_sts & (1 << EC_SMI_GPI)) {
39 /* Process all pending events from EC */
40 do {} while (mainboard_smi_ec() != EC_NO_EVENT);
41 } else if (gpi_sts & (1 << EC_LID_GPI)) {
42 printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n");
44 /* Go to S5 */
45 poweroff();
49 void mainboard_smi_sleep(u8 slp_typ)
51 bool usb0_disable = 0, usb1_disable = 0;
53 /* Disable SCI and SMI events */
55 /* Clear pending events that may trigger immediate wake */
57 /* Enable wake events */
59 /* Tell the EC to Disable USB power */
60 usb_charge_mode_from_gnvs(3, &usb0_disable, &usb1_disable);
61 if (usb0_disable && usb1_disable) {
62 ec_kbc_write_cmd(0x45);
63 ec_kbc_write_ib(0xF2);
67 int mainboard_smi_apmc(u8 apmc)
69 switch (apmc) {
70 case APM_CNT_ACPI_ENABLE:
71 /* Clear all pending events */
72 /* EC cmd:59 data:E8 */
73 ec_kbc_write_cmd(0x59);
74 ec_kbc_write_ib(0xE8);
76 /* Set LID GPI to generate SCIs */
77 gpi_route_interrupt(EC_LID_GPI, GPI_IS_SCI);
78 break;
79 case APM_CNT_ACPI_DISABLE:
80 /* Clear all pending events */
81 /* EC cmd:59 data:e9 */
82 ec_kbc_write_cmd(0x59);
83 ec_kbc_write_ib(0xE9);
85 /* Set LID GPI to generate SMIs */
86 gpi_route_interrupt(EC_LID_GPI, GPI_IS_SMI);
87 break;
89 return 0;