blob: b95db5de94ed2f6b43d956b2b078d9dec7c2134b [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5c354b92019-04-22 14:55:16 -06002
3/*
4 * ACPI - create the Fixed ACPI Description Tables (FADT)
5 */
6
Martin Roth5c354b92019-04-22 14:55:16 -06007#include <console/console.h>
Furquan Shaikh76cedd22020-05-02 10:24:23 -07008#include <acpi/acpi.h>
9#include <acpi/acpigen.h>
Martin Roth5c354b92019-04-22 14:55:16 -060010#include <device/pci_ops.h>
11#include <arch/ioapic.h>
Raul E Rangel93b62e62020-01-31 12:53:45 -070012#include <arch/smp/mpspec.h>
Jason Glenesk498015d2020-12-10 03:28:38 -080013#include <cpu/amd/cpuid.h>
Martin Roth5c354b92019-04-22 14:55:16 -060014#include <device/device.h>
15#include <device/pci.h>
Elyes Haouas5e2602a2023-01-14 05:46:25 +010016#include <gpio.h>
Martin Roth5c354b92019-04-22 14:55:16 -060017#include <amdblocks/acpimmio.h>
18#include <amdblocks/acpi.h>
Raul E Rangel1c88b102021-02-11 10:35:32 -070019#include <amdblocks/chip.h>
Felix Helddd2f3fa2021-02-08 22:23:54 +010020#include <amdblocks/cpu.h>
Felix Held604ffa62021-02-12 00:43:20 +010021#include <amdblocks/ioapic.h>
Felix Held26577d22024-01-26 15:05:40 +010022#include <device/device.h>
Martin Roth5c354b92019-04-22 14:55:16 -060023#include <soc/pci_devs.h>
24#include <soc/southbridge.h>
Raul E Rangel93b62e62020-01-31 12:53:45 -070025#include "chip.h"
Martin Roth5c354b92019-04-22 14:55:16 -060026
Martin Roth5c354b92019-04-22 14:55:16 -060027/*
28 * Reference section 5.2.9 Fixed ACPI Description Table (FADT)
29 * in the ACPI 3.0b specification.
30 */
Kyösti Mälkki61ef71b2020-05-30 18:54:39 +030031void acpi_fill_fadt(acpi_fadt_t *fadt)
Martin Roth5c354b92019-04-22 14:55:16 -060032{
Raul E Rangel1c88b102021-02-11 10:35:32 -070033 const struct soc_amd_common_config *cfg = soc_get_common_config();
Martin Rotheca8faa2019-12-01 16:49:19 -070034
Felix Held757d6452021-02-04 21:31:49 +010035 printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE);
Martin Roth5c354b92019-04-22 14:55:16 -060036
Martin Roth5c354b92019-04-22 14:55:16 -060037
38 fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK;
Martin Roth5c354b92019-04-22 14:55:16 -060039 fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK;
Martin Roth5c354b92019-04-22 14:55:16 -060040 fadt->pm_tmr_blk = ACPI_PM_TMR_BLK;
41 fadt->gpe0_blk = ACPI_GPE0_BLK;
Martin Roth5c354b92019-04-22 14:55:16 -060042
43 fadt->pm1_evt_len = 4; /* 32 bits */
44 fadt->pm1_cnt_len = 2; /* 16 bits */
Martin Roth5c354b92019-04-22 14:55:16 -060045 fadt->pm_tmr_len = 4; /* 32 bits */
46 fadt->gpe0_blk_len = 8; /* 64 bits */
Martin Roth5c354b92019-04-22 14:55:16 -060047
Felix Heldb1549492023-12-13 11:59:39 +010048 fill_fadt_extended_pm_io(fadt);
Felix Held164c5ed2022-10-18 00:11:48 +020049
Martin Rotheca8faa2019-12-01 16:49:19 -070050 fadt->iapc_boot_arch = cfg->fadt_boot_arch; /* legacy free default */
Martin Rotheca8faa2019-12-01 16:49:19 -070051 fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */
52 ACPI_FADT_C1_SUPPORTED |
53 ACPI_FADT_S4_RTC_WAKE |
54 ACPI_FADT_32BIT_TIMER |
55 ACPI_FADT_PCI_EXPRESS_WAKE |
56 ACPI_FADT_PLATFORM_CLOCK |
57 ACPI_FADT_S4_RTC_VALID |
58 ACPI_FADT_REMOTE_POWER_ON;
59 fadt->flags |= cfg->fadt_flags; /* additional board-specific flags */
Martin Roth5c354b92019-04-22 14:55:16 -060060}
61
Felix Held26577d22024-01-26 15:05:40 +010062unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current,
63 acpi_rsdp_t *rsdp)
64{
65 /* CRAT */
66 current = acpi_add_crat_table(current, rsdp);
67
68 /* IVRS */
69 current = acpi_add_ivrs_table(current, rsdp);
70
71 /* Add SRAT, MSCT, SLIT if needed in the future */
72
Felix Held112c2272024-01-26 15:33:59 +010073 if (CONFIG(PLATFORM_USES_FSP2_0))
74 current = acpi_add_fsp_tables(current, rsdp);
Felix Held26577d22024-01-26 15:05:40 +010075
76 return current;
77}
78
Felix Held9bb66462023-03-04 02:33:28 +010079const acpi_cstate_t cstate_cfg_table[] = {
80 [0] = {
81 .ctype = 1,
82 .latency = 1,
83 .power = 0,
84 },
85 [1] = {
86 .ctype = 2,
87 .latency = 400,
88 .power = 0,
89 },
90};
91
92const acpi_cstate_t *get_cstate_config_data(size_t *size)
93{
94 *size = ARRAY_SIZE(cstate_cfg_table);
95 return cstate_cfg_table;
96}