Angel Pons | d32b6de | 2020-04-03 01:23:13 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 2 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 3 | #include <console/console.h> |
| 4 | #include <cpu/x86/smm.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 5 | #include <southbridge/intel/bd82x6x/pch.h> |
| 6 | #include <southbridge/intel/bd82x6x/me.h> |
Patrick Rudolph | a28eb8b | 2018-06-28 14:10:49 +0200 | [diff] [blame] | 7 | #include <southbridge/intel/common/pmbase.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 8 | #include <northbridge/intel/sandybridge/sandybridge.h> |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 9 | #include <ec/smsc/mec1308/ec.h> |
| 10 | #include "ec.h" |
| 11 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 12 | static u8 mainboard_smi_ec(void) |
| 13 | { |
| 14 | u8 cmd; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 15 | |
| 16 | cmd = read_ec_command_byte(EC_GET_SMI_CAUSE); |
| 17 | |
| 18 | switch (cmd) { |
| 19 | case EC_LID_CLOSE: |
| 20 | printk(BIOS_DEBUG, "LID CLOSED, SHUTDOWN\n"); |
| 21 | |
| 22 | /* Go to S5 */ |
Patrick Rudolph | a28eb8b | 2018-06-28 14:10:49 +0200 | [diff] [blame] | 23 | write_pmbase32(PM1_CNT, read_pmbase32(PM1_CNT) | (0xf << 10)); |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 24 | break; |
| 25 | } |
| 26 | |
| 27 | return cmd; |
| 28 | } |
| 29 | |
Duncan Laurie | 0edc224 | 2013-04-29 15:04:30 -0700 | [diff] [blame] | 30 | void mainboard_smi_gpi(u32 gpi_sts) |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 31 | { |
| 32 | if (gpi_sts & (1 << EC_SMI_GPI)) { |
| 33 | /* Process all pending EC requests */ |
| 34 | ec_set_ports(EC_MAILBOX_PORT, EC_MAILBOX_PORT+1); |
| 35 | while (mainboard_smi_ec() != 0xff); |
| 36 | |
| 37 | /* The EC may keep asserting SMI# for some |
| 38 | * period unless we kick it here. |
| 39 | */ |
| 40 | send_ec_command(EC_SMI_DISABLE); |
| 41 | send_ec_command(EC_SMI_ENABLE); |
| 42 | } |
| 43 | } |
| 44 | |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 45 | int mainboard_smi_apmc(u8 apmc) |
| 46 | { |
| 47 | ec_set_ports(EC_MAILBOX_PORT, EC_MAILBOX_PORT+1); |
| 48 | |
| 49 | switch (apmc) { |
| 50 | case 0xe1: /* ACPI ENABLE */ |
| 51 | send_ec_command(EC_SMI_DISABLE); |
| 52 | send_ec_command(EC_ACPI_ENABLE); |
| 53 | break; |
| 54 | |
| 55 | case 0x1e: /* ACPI DISABLE */ |
| 56 | send_ec_command(EC_SMI_ENABLE); |
| 57 | send_ec_command(EC_ACPI_DISABLE); |
| 58 | break; |
Stefan Reinauer | 155e9b5 | 2012-04-27 23:19:58 +0200 | [diff] [blame] | 59 | } |
| 60 | return 0; |
| 61 | } |