1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <cpu/x86/smm.h>
6 #include <intelblocks/fast_spi.h>
7 #include <intelblocks/pcr.h>
8 #include <intelblocks/smihandler.h>
10 #include <soc/iomap.h>
12 #include <soc/pcr_ids.h>
17 /* Trap status Register */
18 #define PCR_PSTH_TRPST 0x1E00
20 #define PCR_PSTH_TRPC 0x1E10
21 /* Trapped write data */
22 #define PCR_PSTH_TRPD 0x1E18
25 void smihandler_southbridge_mc(
26 const struct smm_save_state_ops
*save_state_ops
)
28 u32 reg32
= inl(ACPI_BASE_ADDRESS
+ SMI_EN
);
30 /* Are microcontroller SMIs enabled? */
31 if ((reg32
& MCSMI_EN
) == 0)
34 printk(BIOS_DEBUG
, "Microcontroller SMI.\n");
37 void smihandler_southbridge_monitor(
38 const struct smm_save_state_ops
*save_state_ops
)
40 #define IOTRAP(x) (trap_sts & (1 << x))
46 /* TRSR - Trap Status Register */
47 trap_sts
= pcr_read8(PID_PSTH
, PCR_PSTH_TRPST
);
48 /* Clear trap(s) in TRSR */
49 pcr_write8(PID_PSTH
, PCR_PSTH_TRPST
, trap_sts
);
51 /* TRPC - Trapped cycle */
52 trap_cycle
= pcr_read32(PID_PSTH
, PCR_PSTH_TRPC
);
53 for (i
= 16; i
< 20; i
++) {
54 if (trap_cycle
& (1 << i
))
55 mask
|= (0xff << ((i
- 16) << 3));
58 /* IOTRAP(3) SMI function call */
60 if (gnvs
&& gnvs
->smif
)
61 io_trap_handler(gnvs
->smif
);
66 * IOTRAP(2) currently unused
67 * IOTRAP(1) currently unused
72 if (!(trap_cycle
& (1 << 24))) { /* It's a write */
73 printk(BIOS_DEBUG
, "SMI1 command\n");
74 /* Trapped write data */
75 data
= pcr_read32(PID_PSTH
, PCR_PSTH_TRPD
);
77 printk(BIOS_DEBUG
, " iotrap read data = 0x%08x\n", data
);
81 printk(BIOS_DEBUG
, " trapped io address = 0x%x\n",
83 for (i
= 0; i
< 4; i
++)
85 printk(BIOS_DEBUG
, " TRAP = %d\n", i
);
86 printk(BIOS_DEBUG
, " AHBE = %x\n", (trap_cycle
>> 16) & 0xf);
87 printk(BIOS_DEBUG
, " MASK = 0x%08x\n", mask
);
88 printk(BIOS_DEBUG
, " read/write: %s\n",
89 (trap_cycle
& (1 << 24)) ? "read" : "write");
91 if (!(trap_cycle
& (1 << 24))) {
93 data
= pcr_read32(PID_PSTH
, PCR_PSTH_TRPD
);
94 printk(BIOS_DEBUG
, " iotrap written data = 0x%08x\n", data
);