blob: 7963dac3136bc6ae465123af56cc06c72c52dbc5 [file] [log] [blame]
Angel Pons54c54722020-04-05 13:20:54 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -08002
Kyösti Mälkki027f86e2022-12-02 15:30:10 +02003#include <acpi/acpi_gnvs.h>
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -08004#include <console/console.h>
5#include <cpu/x86/smm.h>
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -08006#include <southbridge/intel/bd82x6x/pch.h>
7#include <southbridge/intel/bd82x6x/me.h>
8#include <northbridge/intel/sandybridge/sandybridge.h>
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -08009
10/* Include EC functions */
11#include <ec/quanta/ene_kb3940q/ec.h>
12#include "ec.h"
13
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080014void mainboard_smi_sleep(u8 slp_typ)
15{
Kyösti Mälkki027f86e2022-12-02 15:30:10 +020016 bool usb0_disable = 0, usb1_disable = 0;
17
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080018 /* Tell the EC to Enable USB power for S3 if requested */
Kyösti Mälkki027f86e2022-12-02 15:30:10 +020019 usb_charge_mode_from_gnvs(3, &usb0_disable, &usb1_disable);
20 if (!usb0_disable || !usb1_disable)
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080021 ec_mem_write(EC_EC_PSW, ec_mem_read(EC_EC_PSW) | EC_PSW_USB);
22
23 /* Disable wake on USB, LAN & RTC */
24 /* Enable Wake from Keyboard */
25 if ((slp_typ == 4) || (slp_typ == 5)) {
26 printk(BIOS_DEBUG, "Disabling wake on RTC\n");
27 ec_mem_write(EC_EC_PSW, EC_PSW_IKB);
28 }
29}
30
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080031int mainboard_smi_apmc(u8 apmc)
32{
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080033 switch (apmc) {
Kyösti Mälkkid4174b52020-06-27 14:25:20 +030034 case APM_CNT_ACPI_ENABLE:
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080035 /* Clear all pending events and enable SCI */
36 ec_write_cmd(EC_CMD_ENABLE_ACPI_MODE);
37 break;
38
Kyösti Mälkkid4174b52020-06-27 14:25:20 +030039 case APM_CNT_ACPI_DISABLE:
Stefan Reinauerd7bd4eb2013-02-11 11:11:36 -080040 /* Clear all pending events and tell the EC that ACPI is disabled */
41 ec_write_cmd(EC_CMD_DISABLE_ACPI_MODE);
42 break;
43 }
44 return 0;
45}