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> |
| 9 | #include <amdblocks/data_fabric.h> |
| 10 | #include <arch/ioapic.h> |
| 11 | #include <console/console.h> |
Felix Held | b499c1f | 2023-12-12 20:39:38 +0100 | [diff] [blame] | 12 | #include <device/device.h> |
| 13 | #include <soc/acpi.h> |
Felix Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 14 | #include <vendorcode/amd/opensil/genoa_poc/opensil.h> |
| 15 | |
| 16 | /* TODO: this can go in a common place */ |
| 17 | unsigned long acpi_fill_madt(unsigned long current) |
| 18 | { |
| 19 | struct device *dev = NULL; |
| 20 | while ((dev = dev_find_path(dev, DEVICE_PATH_DOMAIN)) != NULL) { |
| 21 | struct resource *res = probe_resource(dev, IOMMU_IOAPIC_IDX); |
| 22 | if (!res) |
| 23 | continue; |
| 24 | |
| 25 | current += acpi_create_madt_ioapic_from_hw((acpi_madt_ioapic_t *)current, |
| 26 | res->base); |
| 27 | } |
| 28 | |
| 29 | return current; |
| 30 | } |
| 31 | |
| 32 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 33 | { |
| 34 | /* Fill in pm1_evt, pm1_cnt, pm_tmr, gpe0_blk from openSIL input structure */ |
| 35 | opensil_fill_fadt_io_ports(fadt); |
| 36 | |
| 37 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 38 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
| 39 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 40 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
| 41 | |
| 42 | fill_fadt_extended_pm_regs(fadt); |
| 43 | |
| 44 | fadt->iapc_boot_arch = ACPI_FADT_LEGACY_FREE; /* legacy free default */ |
| 45 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 46 | ACPI_FADT_C1_SUPPORTED | |
| 47 | ACPI_FADT_S4_RTC_WAKE | |
| 48 | ACPI_FADT_32BIT_TIMER | |
| 49 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 50 | ACPI_FADT_PLATFORM_CLOCK | |
| 51 | ACPI_FADT_S4_RTC_VALID | |
| 52 | ACPI_FADT_REMOTE_POWER_ON; |
| 53 | |
| 54 | fadt->x_firmware_ctl_l = 0; /* set to 0 if firmware_ctrl is used */ |
| 55 | fadt->x_firmware_ctl_h = 0; |
| 56 | } |
| 57 | |
Felix Held | b499c1f | 2023-12-12 20:39:38 +0100 | [diff] [blame] | 58 | unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current, |
| 59 | struct acpi_rsdp *rsdp) |
| 60 | { |
| 61 | /* IVRS */ |
| 62 | acpi_ivrs_t *ivrs; |
| 63 | current = acpi_align_current(current); |
| 64 | ivrs = (acpi_ivrs_t *)current; |
| 65 | acpi_create_ivrs(ivrs, acpi_fill_ivrs); |
| 66 | current += ivrs->header.length; |
| 67 | acpi_add_table(rsdp, ivrs); |
| 68 | |
| 69 | return current; |
| 70 | } |
| 71 | |
Felix Held | d1065a3 | 2023-12-12 19:36:55 +0100 | [diff] [blame] | 72 | /* There are only the following 2 C-states reported by the reference firmware */ |
| 73 | const acpi_cstate_t cstate_cfg_table[] = { |
| 74 | [0] = { |
| 75 | .ctype = 1, |
| 76 | .latency = 1, |
| 77 | .power = 0, |
| 78 | }, |
| 79 | [1] = { |
| 80 | .ctype = 2, |
| 81 | .latency = 0x12, |
| 82 | .power = 0, |
| 83 | }, |
| 84 | }; |
| 85 | |
| 86 | const acpi_cstate_t *get_cstate_config_data(size_t *size) |
| 87 | { |
| 88 | *size = ARRAY_SIZE(cstate_cfg_table); |
| 89 | return cstate_cfg_table; |
| 90 | } |