1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi_gnvs.h>
4 #include <device/pci_ops.h>
5 #include <console/console.h>
6 #include <cpu/x86/smm.h>
9 #include <southbridge/intel/bd82x6x/pch.h>
10 #include <southbridge/intel/bd82x6x/me.h>
11 #include <northbridge/intel/sandybridge/sandybridge.h>
13 /* Include EC functions */
14 #include <ec/quanta/it8518/ec.h>
17 static u8
mainboard_smi_ec(void)
19 u8 cmd
= ec_it8518_get_event();
22 case EC_SMI_LID_CLOSED
:
23 printk(BIOS_DEBUG
, "LID CLOSED, SHUTDOWN\n");
32 void mainboard_smi_gpi(u32 gpi_sts
)
34 if (gpi_sts
& (1 << EC_SMI_GPI
)) {
35 /* Process all pending events */
36 while (mainboard_smi_ec() != 0);
40 void mainboard_smi_sleep(u8 slp_typ
)
42 bool usb0_disable
= 0, usb1_disable
= 0;
45 * Tell the EC to Enable USB power for S3 if requested.
46 * Bit0 of 0x0D/Bit0 of 0x26
47 * 0/0 All USB port off
48 * 1/0 USB on, all USB port didn't support wake up
49 * 0/1 USB on, yellow port support wake up charge, but may not support
51 * 1/1 USB on, yellow port in AUTO mode and didn't support wake up system.
53 usb_charge_mode_from_gnvs(3, &usb0_disable
, &usb1_disable
);
55 if (!usb0_disable
|| !usb1_disable
) {
56 ec_write(EC_PERIPH_CNTL_3
, ec_read(EC_PERIPH_CNTL_3
) | 0x00);
57 ec_write(EC_USB_S3_EN
, ec_read(EC_USB_S3_EN
) | 0x01);
58 printk(BIOS_DEBUG
, "USB wake from S3 enabled.\n");
61 * If USB charging in suspend is disabled then also disable
62 * the XHCI PME to prevent wake when the port power is cut
63 * after the transition into suspend.
66 pci_update_config32(PCH_XHCI_DEV
, 0x74, ~(1 << 8), 1 << 15);
70 ec_kbc_write_cmd(EC_KBD_CMD_MUTE
);
71 ec_it8518_enable_wake_events();
74 int mainboard_smi_apmc(u8 apmc
)
77 case APM_CNT_FINALIZE
:
78 stout_ec_finalize_smm();
80 case APM_CNT_ACPI_ENABLE
:
82 * TODO(kimarie) Clear all pending events and enable SCI.
84 ec_write_cmd(EC_CMD_NOTIFY_ACPI_ENTER
);
86 case APM_CNT_ACPI_DISABLE
:
88 * TODO(kimarie) Clear all pending events and enable SMI.
90 ec_write_cmd(EC_CMD_NOTIFY_ACPI_EXIT
);