blob: 4b05221ae0181b4f8b8d8aeff3c29673b5949aa3 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00002
Stefan Reinauer573f7d42009-07-21 21:50:34 +00003#include <types.h>
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00004#include <console/console.h>
Stefan Reinauerdebb11f2008-10-29 04:46:52 +00005#include <cpu/x86/smm.h>
Stefan Reinauer7a3d0952010-01-17 13:49:07 +00006#include <device/pci_def.h>
Kyösti Mälkki661ad462020-12-29 06:26:21 +02007#include <soc/nvs.h>
Arthur Heymans31312b22018-04-10 12:56:19 +02008#include <southbridge/intel/common/pmutil.h>
Stefan Reinauer573f7d42009-07-21 21:50:34 +00009#include "i82801gx.h"
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000010
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000011/* I945 */
12#define SMRAM 0x9d
13#define D_OPEN (1 << 6)
14#define D_CLS (1 << 5)
15#define D_LCK (1 << 4)
16#define G_SMRANE (1 << 3)
17#define C_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0))
18
Elyes HAOUAS92646ea2020-04-04 13:43:03 +020019/* While we read PMBASE dynamically in case it changed, let's initialize it with a sane value */
Stefan Reinauer573f7d42009-07-21 21:50:34 +000020u16 pmbase = DEFAULT_PMBASE;
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000021
Arthur Heymans31312b22018-04-10 12:56:19 +020022void southbridge_smi_monitor(void)
Stefan Reinauer573f7d42009-07-21 21:50:34 +000023{
24#define IOTRAP(x) (trap_sts & (1 << x))
25 u32 trap_sts, trap_cycle;
26 u32 data, mask = 0;
27 int i;
28
29 trap_sts = RCBA32(0x1e00); // TRSR - Trap Status Register
30 RCBA32(0x1e00) = trap_sts; // Clear trap(s) in TRSR
31
32 trap_cycle = RCBA32(0x1e10);
Arthur Heymans3f111b02017-03-09 12:02:52 +010033 for (i = 16; i < 20; i++) {
Stefan Reinauer573f7d42009-07-21 21:50:34 +000034 if (trap_cycle & (1 << i))
Kyösti Mälkkia0720432022-12-03 19:35:53 +020035 mask |= (0xff << ((i - 16) << 3));
Stefan Reinauer573f7d42009-07-21 21:50:34 +000036 }
37
Stefan Reinauer573f7d42009-07-21 21:50:34 +000038 /* IOTRAP(3) SMI function call */
39 if (IOTRAP(3)) {
40 if (gnvs && gnvs->smif)
41 io_trap_handler(gnvs->smif); // call function smif
42 return;
43 }
44
45 /* IOTRAP(2) currently unused
46 * IOTRAP(1) currently unused */
47
Vladimir Serbinenkoa4857052014-08-31 01:09:12 +020048 /* IOTRAP(0) SMIC: currently unused */
Stefan Reinauer573f7d42009-07-21 21:50:34 +000049
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000050 printk(BIOS_DEBUG, " trapped io address = 0x%x\n", trap_cycle & 0xfffc);
Arthur Heymans3f111b02017-03-09 12:02:52 +010051 for (i = 0; i < 4; i++)
52 if (IOTRAP(i))
53 printk(BIOS_DEBUG, " TRAP = %d\n", i);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000054 printk(BIOS_DEBUG, " AHBE = %x\n", (trap_cycle >> 16) & 0xf);
55 printk(BIOS_DEBUG, " MASK = 0x%08x\n", mask);
56 printk(BIOS_DEBUG, " read/write: %s\n", (trap_cycle & (1 << 24)) ? "read" : "write");
Stefan Reinauer573f7d42009-07-21 21:50:34 +000057
58 if (!(trap_cycle & (1 << 24))) {
59 /* Write Cycle */
60 data = RCBA32(0x1e18);
Stefan Reinauerc02b4fc2010-03-22 11:42:32 +000061 printk(BIOS_DEBUG, " iotrap written data = 0x%08x\n", data);
Stefan Reinauer573f7d42009-07-21 21:50:34 +000062 }
63#undef IOTRAP
64}
65
Arthur Heymans31312b22018-04-10 12:56:19 +020066void southbridge_finalize_all(void)
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000067{
Stefan Reinauerdebb11f2008-10-29 04:46:52 +000068}