mainboard/[g-p]*: Remove copyright notices
[coreboot.git] / src / mainboard / lenovo / t430s / smihandler.c
bloba51eddc0e26b581657e8d4a7db89d9987e8a04d5
1 /*
2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #include <arch/io.h>
17 #include <console/console.h>
18 #include <cpu/x86/smm.h>
19 #include <ec/acpi/ec.h>
20 #include <ec/lenovo/h8/h8.h>
21 #include <southbridge/intel/common/pmutil.h>
22 #include <southbridge/intel/bd82x6x/pch.h>
24 #define GPE_EC_SCI 1
25 #define GPE_EC_WAKE 13
27 static void mainboard_smi_handle_ec_sci(void)
29 u8 status = inb(EC_SC);
30 u8 event;
32 if (!(status & EC_SCI_EVT))
33 return;
35 event = ec_query();
36 printk(BIOS_DEBUG, "EC event %02x\n", event);
39 void mainboard_smi_gpi(u32 gpi_sts)
41 if (gpi_sts & (1 << GPE_EC_SCI))
42 mainboard_smi_handle_ec_sci();
45 int mainboard_smi_apmc(u8 data)
47 switch (data) {
48 case APM_CNT_ACPI_ENABLE:
49 /* use 0x1600/0x1604 to prevent races with userspace */
50 ec_set_ports(0x1604, 0x1600);
51 /* route EC_SCI to SCI */
52 gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SCI);
53 /* discard all events, and enable attention */
54 ec_write(0x80, 0x01);
55 break;
56 case APM_CNT_ACPI_DISABLE:
57 /* we have to use port 0x62/0x66, as 0x1600/0x1604 doesn't
58 provide a EC query function */
59 ec_set_ports(0x66, 0x62);
60 /* route EC_SCI to SMI */
61 gpi_route_interrupt(GPE_EC_SCI, GPI_IS_SMI);
62 /* discard all events, and enable attention */
63 ec_write(0x80, 0x01);
64 break;
65 default:
66 break;
68 return 0;
71 void mainboard_smi_sleep(u8 slp_typ)
73 if (slp_typ == 3) {
74 u8 ec_wake = ec_read(0x32);
75 /* If EC wake events are enabled, enable wake on EC WAKE GPE. */
76 if (ec_wake & 0x14) {
77 /* Redirect EC WAKE GPE to SCI. */
78 gpi_route_interrupt(GPE_EC_WAKE, GPI_IS_SCI);