Felix Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 1 | /* 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 Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 9 | #include <arch/ioapic.h> |
| 10 | #include <console/console.h> |
Felix Held | b499c1f | 2023-12-12 20:39:38 +0100 | [diff] [blame] | 11 | #include <device/device.h> |
| 12 | #include <soc/acpi.h> |
Felix Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 13 | #include <vendorcode/amd/opensil/genoa_poc/opensil.h> |
| 14 | |
Felix Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 15 | void 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 Held | b154949 | 2023-12-13 11:59:39 +0100 | [diff] [blame] | 25 | fill_fadt_extended_pm_io(fadt); |
Felix Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 26 | |
| 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 Held | b499c1f | 2023-12-12 20:39:38 +0100 | [diff] [blame] | 41 | unsigned 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 Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 55 | /* There are only the following 2 C-states reported by the reference firmware */ |
| 56 | const 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 | |
| 69 | const acpi_cstate_t *get_cstate_config_data(size_t *size) |
| 70 | { |
| 71 | *size = ARRAY_SIZE(cstate_cfg_table); |
| 72 | return cstate_cfg_table; |
| 73 | } |