1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <southbridge/intel/common/pmutil.h>
7 #include <northbridge/intel/ironlake/ironlake.h>
8 #include <ec/acpi/ec.h>
9 #include <ec/lenovo/h8/h8.h>
14 #define GPE_EC_WAKE 13
16 static void mainboard_smi_handle_ec_sci(void)
18 u8 status
= inb(EC_SC
);
21 if (!(status
& EC_SCI_EVT
))
25 printk(BIOS_DEBUG
, "EC event %#02x\n", event
);
44 /* set dock LED to indicate status */
53 void mainboard_smi_gpi(u32 gpi_sts
)
55 if (gpi_sts
& (1 << GPE_EC_SCI
))
56 mainboard_smi_handle_ec_sci();
59 int mainboard_smi_apmc(u8 data
)
62 case APM_CNT_ACPI_ENABLE
:
63 /* use 0x1600/0x1604 to prevent races with userspace */
64 ec_set_ports(0x1604, 0x1600);
65 /* route H8SCI to SCI */
66 gpi_route_interrupt(GPE_EC_SCI
, GPI_IS_SCI
);
67 /* discard all events, and enable attention */
70 case APM_CNT_ACPI_DISABLE
:
71 /* we have to use port 0x62/0x66, as 0x1600/0x1604 doesn't
72 provide a EC query function */
73 ec_set_ports(0x66, 0x62);
74 /* route H8SCI# to SMI */
75 gpi_route_interrupt(GPE_EC_SCI
, GPI_IS_SMI
);
76 /* discard all events, and enable attention */
85 void mainboard_smi_sleep(u8 slp_typ
)
88 u8 ec_wake
= ec_read(0x32);
89 /* If EC wake events are enabled, enable wake on EC WAKE GPE. */
91 /* Redirect EC WAKE GPE to SCI. */
92 gpi_route_interrupt(GPE_EC_WAKE
, GPI_IS_SCI
);