blob: b5676ffb9aa25367f2b8e01a7c1849d2bd088785 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgie72a8a32012-11-06 11:05:09 +01002
3#include <types.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01004#include <console/console.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01005#include <cpu/x86/smm.h>
6#include <device/pci_def.h>
Arthur Heymansaade90e2018-01-25 00:33:45 +01007#include <southbridge/intel/common/pmutil.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01008#include "i82801ix.h"
9
Kyösti Mälkki661ad462020-12-29 06:26:21 +020010#include <soc/nvs.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010011
Arthur Heymansaade90e2018-01-25 00:33:45 +010012void southbridge_smi_monitor(void)
Patrick Georgie72a8a32012-11-06 11:05:09 +010013{
14#define IOTRAP(x) (trap_sts & (1 << x))
15 u32 trap_sts, trap_cycle;
16 u32 data, mask = 0;
17 int i;
18
19 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
20 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
21
22 trap_cycle = RCBA32(0x1e10);
23 for (i=16; i<20; i++) {
24 if (trap_cycle & (1 << i))
25 mask |= (0xff << ((i - 16) << 3));
26 }
27
Patrick Georgie72a8a32012-11-06 11:05:09 +010028 /* IOTRAP(3) SMI function call */
29 if (IOTRAP(3)) {
30 if (gnvs && gnvs->smif)
31 io_trap_handler(gnvs->smif); // call function smif
32 return;
33 }
34
35 /* IOTRAP(2) currently unused
36 * IOTRAP(1) currently unused */
37
38 /* IOTRAP(0) SMIC */
39 if (IOTRAP(0)) {
40 if (!(trap_cycle & (1 << 24))) { // It's a write
41 printk(BIOS_DEBUG, "SMI1 command\n");
42 data = RCBA32(0x1e18);
Patrick Georgie72a8a32012-11-06 11:05:09 +010043 }
44 // Fall through to debug
45 }
46
47 printk(BIOS_DEBUG, " trapped io address = 0x%x\n", trap_cycle & 0xfffc);
Elyes HAOUAS70d79a42016-08-21 18:36:06 +020048 for (i=0; i < 4; i++) if (IOTRAP(i)) printk(BIOS_DEBUG, " TRAP = %d\n", i);
Patrick Georgie72a8a32012-11-06 11:05:09 +010049 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
50 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
51 printk(BIOS_DEBUG, " read/write: %s\n", (trap_cycle & (1 << 24)) ? "read" : "write");
52
53 if (!(trap_cycle & (1 << 24))) {
54 /* Write Cycle */
55 data = RCBA32(0x1e18);
56 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
57 }
58#undef IOTRAP
59}
60
Arthur Heymansaade90e2018-01-25 00:33:45 +010061void southbridge_finalize_all(void)
Patrick Georgie72a8a32012-11-06 11:05:09 +010062{
Patrick Georgie72a8a32012-11-06 11:05:09 +010063}