1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <device/pci_ops.h>
6 #include <console/console.h>
7 #include <device/pci_def.h>
8 #include <cpu/intel/em64t101_save_state.h>
9 #include <cpu/intel/model_2065x/model_2065x.h>
10 #include <southbridge/intel/common/finalize.h>
11 #include <southbridge/intel/common/pmbase.h>
12 #include <southbridge/intel/ibexpeak/me.h>
15 /* We are using PCIe accesses for now
16 * 1. the chipset can do it
17 * 2. we don't need to worry about how we leave 0xcf8/0xcfc behind
19 #include <northbridge/intel/ironlake/ironlake.h>
20 #include <southbridge/intel/common/gpio.h>
21 #include <southbridge/intel/common/pmutil.h>
23 static void southbridge_gate_memory_reset_real(int offset
,
24 u16 use
, u16 io
, u16 lvl
)
28 /* Make sure it is set as GPIO */
30 if (!(reg32
& (1 << offset
))) {
31 reg32
|= (1 << offset
);
35 /* Make sure it is set as output */
37 if (reg32
& (1 << offset
)) {
38 reg32
&= ~(1 << offset
);
42 /* Drive the output low */
44 reg32
&= ~(1 << offset
);
49 * Drive GPIO 60 low to gate memory reset in S3.
51 * Intel reference designs all use GPIO 60 but it is
52 * not a requirement and boards could use a different pin.
54 void southbridge_gate_memory_reset(void)
58 gpiobase
= pci_read_config16(PCI_DEV(0, 0x1f, 0), GPIOBASE
) & 0xfffc;
62 if (CONFIG_DRAM_RESET_GATE_GPIO
>= 32)
63 southbridge_gate_memory_reset_real(CONFIG_DRAM_RESET_GATE_GPIO
- 32,
64 gpiobase
+ GPIO_USE_SEL2
,
65 gpiobase
+ GP_IO_SEL2
,
68 southbridge_gate_memory_reset_real(CONFIG_DRAM_RESET_GATE_GPIO
,
69 gpiobase
+ GPIO_USE_SEL
,
74 void southbridge_smi_monitor(void)
76 #define IOTRAP(x) (trap_sts & (1 << x))
77 u32 trap_sts
, trap_cycle
;
81 trap_sts
= RCBA32(0x1e00); // TRSR - Trap Status Register
82 RCBA32(0x1e00) = trap_sts
; // Clear trap(s) in TRSR
84 trap_cycle
= RCBA32(0x1e10);
85 for (i
= 16; i
< 20; i
++) {
86 if (trap_cycle
& (1 << i
))
87 mask
|= (0xff << ((i
- 16) << 3));
90 /* IOTRAP(3) SMI function call */
95 /* IOTRAP(2) currently unused
96 * IOTRAP(1) currently unused */
100 if (!(trap_cycle
& (1 << 24))) { // It's a write
101 printk(BIOS_DEBUG
, "SMI1 command\n");
102 data
= RCBA32(0x1e18);
105 // southbridge_smi_command(data);
108 // Fall through to debug
111 printk(BIOS_DEBUG
, " trapped io address = 0x%x\n", trap_cycle
& 0xfffc);
112 for (i
= 0; i
< 4; i
++) {
114 printk(BIOS_DEBUG
, " TRAP = %d\n", i
);
116 printk(BIOS_DEBUG
, " AHBE = %x\n", (trap_cycle
>> 16) & 0xf);
117 printk(BIOS_DEBUG
, " MASK = 0x%08x\n", mask
);
118 printk(BIOS_DEBUG
, " read/write: %s\n", (trap_cycle
& (1 << 24)) ? "read" : "write");
120 if (!(trap_cycle
& (1 << 24))) {
122 data
= RCBA32(0x1e18);
123 printk(BIOS_DEBUG
, " iotrap written data = 0x%08x\n", data
);
128 void southbridge_finalize_all(void)
130 /* TODO: Finalize ME */
131 intel_pch_finalize_smm();
132 intel_ironlake_finalize_smm();
133 intel_model_2065x_finalize_smm();