coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smihandler.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/io.h>
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <ec/acpi/ec.h>
7 #include <ec/lenovo/h8/h8.h>
10 
11 #define GPE_EC_SCI 6
12 /* FIXME: check this */
13 #define GPE_EC_WAKE 13
14 
15 static void mainboard_smi_handle_ec_sci(void)
16 {
17  u8 status = inb(EC_SC);
18  u8 event;
19 
20  if (!(status & EC_SCI_EVT))
21  return;
22 
23  event = ec_query();
24  printk(BIOS_DEBUG, "EC event %#02x\n", event);
25 }
26 
27 void mainboard_smi_gpi(u32 gpi_sts)
28 {
29  if (gpi_sts & (1 << GPE_EC_SCI))
31 }
32 
34 {
35  switch (data) {
37  /* use 0x1600/0x1604 to prevent races with userspace */
38  ec_set_ports(0x1604, 0x1600);
39  /* route EC_SCI to SCI */
41  /* discard all events, and enable attention */
42  ec_write(0x80, 0x01);
43  break;
45  /* we have to use port 0x62/0x66, as 0x1600/0x1604 doesn't
46  provide a EC query function */
47  ec_set_ports(0x66, 0x62);
48  /* route EC_SCI to SMI */
50  /* discard all events, and enable attention */
51  ec_write(0x80, 0x01);
52  break;
53  default:
54  break;
55  }
56  return 0;
57 }
58 
59 void mainboard_smi_sleep(u8 slp_typ)
60 {
61  if (slp_typ == 3) {
62  u8 ec_wake = ec_read(0x32);
63  /* If EC wake events are enabled, enable wake on EC WAKE GPE. */
64  if (ec_wake & 0x14) {
65  /* Redirect EC WAKE GPE to SCI. */
67  }
68  }
69 }
#define printk(level,...)
Definition: stdlib.h:16
void __weak mainboard_smi_sleep(u8 slp_typ)
Definition: smihandler.c:210
int __weak mainboard_smi_apmc(u8 data)
Definition: smihandler.c:209
void __weak mainboard_smi_gpi(u32 gpi_sts)
Definition: smihandler.c:208
u8 inb(u16 port)
u8 ec_read(u8 addr)
Definition: ec.c:107
u8 ec_query(void)
Definition: ec.c:127
void ec_set_ports(u16 cmd_reg, u16 data_reg)
Definition: ec.c:143
int ec_write(u8 addr, u8 data)
Definition: ec.c:115
#define EC_SC
Definition: ec.h:9
#define EC_SCI_EVT
Definition: ec.h:13
#define APM_CNT_ACPI_DISABLE
Definition: smm.h:21
#define APM_CNT_ACPI_ENABLE
Definition: smm.h:22
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
static void mainboard_smi_handle_ec_sci(void)
Definition: smihandler.c:15
#define GPE_EC_WAKE
Definition: smihandler.c:13
#define GPE_EC_SCI
Definition: smihandler.c:11
#define GPI_IS_SMI
Definition: smihandler.c:34
#define GPI_IS_SCI
Definition: smihandler.c:35
void gpi_route_interrupt(u8 gpi, u8 mode)
Definition: smihandler.c:25
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45