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
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.
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>
25 #define GPE_EC_WAKE 13
27 static void mainboard_smi_handle_ec_sci(void)
29 u8 status
= inb(EC_SC
);
32 if (!(status
& EC_SCI_EVT
))
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
)
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 */
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 */
71 void mainboard_smi_sleep(u8 slp_typ
)
74 u8 ec_wake
= ec_read(0x32);
75 /* If EC wake events are enabled, enable wake on EC WAKE GPE. */
77 /* Redirect EC WAKE GPE to SCI. */
78 gpi_route_interrupt(GPE_EC_WAKE
, GPI_IS_SCI
);