soc/intel/pantherlake: Add core scaling factors read support
[coreboot2.git] / src / soc / amd / genoa_poc / smihandler.c
blob1eb051317b4754a7031e25dc8ef22a8302596ec8
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <acpi/acpi.h>
4 #include <amdblocks/acpi.h>
5 #include <amdblocks/acpimmio.h>
6 #include <amdblocks/psp.h>
7 #include <amdblocks/smi.h>
8 #include <amdblocks/smm.h>
9 #include <arch/hlt.h>
10 #include <arch/io.h>
11 #include <console/console.h>
12 #include <cpu/x86/cache.h>
13 #include <cpu/x86/smm.h>
14 #include <soc/smi.h>
15 #include <soc/smu.h>
16 #include <soc/southbridge.h>
17 #include <types.h>
20 * Both the psp_notify_sx_info and the smu_sx_entry call will clobber the SMN index register
21 * during the SMN accesses. Since the SMI handler is the last thing that gets called before
22 * entering S3, this won't interfere with any indirect SMN accesses via the same register pair.
24 static void fch_slp_typ_handler(void)
26 uint32_t pci_ctrl;
27 uint16_t pm1cnt;
28 uint8_t slp_typ, rst_ctrl;
30 /* Figure out SLP_TYP */
31 pm1cnt = acpi_read16(MMIO_ACPI_PM1_CNT_BLK);
32 printk(BIOS_SPEW, "SMI#: SLP = 0x%04x\n", pm1cnt);
33 slp_typ = acpi_sleep_from_pm1(pm1cnt);
35 /* Do any mainboard sleep handling */
36 mainboard_smi_sleep(slp_typ);
38 switch (slp_typ) {
39 case ACPI_S0:
40 printk(BIOS_DEBUG, "SMI#: Entering S0 (On)\n");
41 break;
42 case ACPI_S3:
43 printk(BIOS_DEBUG, "SMI#: Entering S3 (Suspend-To-RAM)\n");
44 break;
45 case ACPI_S4:
46 printk(BIOS_DEBUG, "SMI#: Entering S4 (Suspend-To-Disk)\n");
47 break;
48 case ACPI_S5:
49 printk(BIOS_DEBUG, "SMI#: Entering S5 (Soft Power off)\n");
50 break;
51 default:
52 printk(BIOS_DEBUG, "SMI#: ERROR: SLP_TYP reserved\n");
53 break;
56 if (slp_typ >= ACPI_S3) {
57 wbinvd();
59 clear_all_smi_status();
61 /* Do not send SMI before AcpiPm1CntBlkx00[SlpTyp] */
62 pci_ctrl = pm_read32(PM_PCI_CTRL);
63 pci_ctrl &= ~FORCE_SLPSTATE_RETRY;
64 pm_write32(PM_PCI_CTRL, pci_ctrl);
66 /* Enable SlpTyp */
67 rst_ctrl = pm_read8(PM_RST_CTRL1);
68 rst_ctrl |= SLPTYPE_CONTROL_EN;
69 pm_write8(PM_RST_CTRL1, rst_ctrl);
71 smu_sx_entry(); /* Leave SlpTypeEn clear, SMU will set */
72 printk(BIOS_ERR, "System did not go to sleep\n");
73 hlt();
78 * Table of functions supported in the SMI handler. Note that SMI source setup
79 * in fch.c is unrelated to this list.
81 static const struct smi_sources_t smi_sources[] = {
82 { .type = SMITYPE_SMI_CMD_PORT, .handler = fch_apmc_smi_handler },
83 { .type = SMITYPE_SLP_TYP, .handler = fch_slp_typ_handler},
84 { .type = SMITYPE_PSP, .handler = psp_smi_handler },
87 void *get_smi_source_handler(int source)
89 size_t i;
91 for (i = 0 ; i < ARRAY_SIZE(smi_sources) ; i++)
92 if (smi_sources[i].type == source)
93 return smi_sources[i].handler;
95 return NULL;