blob: 7762e9d4c7a403f8e47aaed6bb3357d3b1518842 [file] [log] [blame]
Felix Heldd1065a32023-12-12 19:36:55 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
3/* ACPI - create the Fixed ACPI Description Tables (FADT) */
4
5#include <acpi/acpi.h>
6#include <amdblocks/acpi.h>
7#include <amdblocks/acpimmio.h>
8#include <amdblocks/cpu.h>
Felix Heldd1065a32023-12-12 19:36:55 +01009#include <arch/ioapic.h>
10#include <console/console.h>
Felix Heldb499c1f2023-12-12 20:39:38 +010011#include <device/device.h>
12#include <soc/acpi.h>
Felix Heldd1065a32023-12-12 19:36:55 +010013#include <vendorcode/amd/opensil/genoa_poc/opensil.h>
14
Felix Heldd1065a32023-12-12 19:36:55 +010015void acpi_fill_fadt(acpi_fadt_t *fadt)
16{
17 /* Fill in pm1_evt, pm1_cnt, pm_tmr, gpe0_blk from openSIL input structure */
18 opensil_fill_fadt_io_ports(fadt);
19
20 fadt->pm1_evt_len = 4; /* 32 bits */
21 fadt->pm1_cnt_len = 2; /* 16 bits */
22 fadt->pm_tmr_len = 4; /* 32 bits */
23 fadt->gpe0_blk_len = 8; /* 64 bits */
24
Felix Heldb1549492023-12-13 11:59:39 +010025 fill_fadt_extended_pm_io(fadt);
Felix Heldd1065a32023-12-12 19:36:55 +010026
27 fadt->iapc_boot_arch = ACPI_FADT_LEGACY_FREE; /* legacy free default */
28 fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */
29 ACPI_FADT_C1_SUPPORTED |
30 ACPI_FADT_S4_RTC_WAKE |
31 ACPI_FADT_32BIT_TIMER |
32 ACPI_FADT_PCI_EXPRESS_WAKE |
33 ACPI_FADT_PLATFORM_CLOCK |
34 ACPI_FADT_S4_RTC_VALID |
35 ACPI_FADT_REMOTE_POWER_ON;
36
37 fadt->x_firmware_ctl_l = 0; /* set to 0 if firmware_ctrl is used */
38 fadt->x_firmware_ctl_h = 0;
39}
40
Felix Heldb499c1f2023-12-12 20:39:38 +010041unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current,
42 struct acpi_rsdp *rsdp)
43{
44 /* IVRS */
45 acpi_ivrs_t *ivrs;
46 current = acpi_align_current(current);
47 ivrs = (acpi_ivrs_t *)current;
48 acpi_create_ivrs(ivrs, acpi_fill_ivrs);
49 current += ivrs->header.length;
50 acpi_add_table(rsdp, ivrs);
51
52 return current;
53}
54
Felix Heldd1065a32023-12-12 19:36:55 +010055/* There are only the following 2 C-states reported by the reference firmware */
56const acpi_cstate_t cstate_cfg_table[] = {
57 [0] = {
58 .ctype = 1,
59 .latency = 1,
60 .power = 0,
61 },
62 [1] = {
63 .ctype = 2,
64 .latency = 0x12,
65 .power = 0,
66 },
67};
68
69const acpi_cstate_t *get_cstate_config_data(size_t *size)
70{
71 *size = ARRAY_SIZE(cstate_cfg_table);
72 return cstate_cfg_table;
73}