Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Martin Roth | 20646cd | 2023-01-04 21:27:06 -0700 | [diff] [blame] | 3 | /* TODO: Update for Phoenix */ |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 4 | /* TODO: See what can be made common */ |
| 5 | |
| 6 | /* ACPI - create the Fixed ACPI Description Tables (FADT) */ |
| 7 | |
| 8 | #include <acpi/acpi.h> |
| 9 | #include <acpi/acpigen.h> |
| 10 | #include <amdblocks/acpi.h> |
| 11 | #include <amdblocks/cppc.h> |
| 12 | #include <amdblocks/cpu.h> |
| 13 | #include <amdblocks/acpimmio.h> |
| 14 | #include <amdblocks/ioapic.h> |
| 15 | #include <arch/ioapic.h> |
| 16 | #include <arch/smp/mpspec.h> |
| 17 | #include <console/console.h> |
| 18 | #include <cpu/amd/cpuid.h> |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 19 | #include <device/device.h> |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 20 | #include <soc/iomap.h> |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 21 | #include <types.h> |
| 22 | #include "chip.h" |
| 23 | |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 24 | /* |
| 25 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 26 | * in the ACPI 3.0b specification. |
| 27 | */ |
| 28 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 29 | { |
Martin Roth | 20646cd | 2023-01-04 21:27:06 -0700 | [diff] [blame] | 30 | const struct soc_amd_phoenix_config *cfg = config_of_soc(); |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 31 | |
| 32 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
| 33 | |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 34 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
| 35 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
| 36 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 37 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
| 38 | |
| 39 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 40 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
| 41 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 42 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
| 43 | |
Felix Held | b154949 | 2023-12-13 11:59:39 +0100 | [diff] [blame] | 44 | fill_fadt_extended_pm_io(fadt); |
Felix Held | 164c5ed | 2022-10-18 00:11:48 +0200 | [diff] [blame] | 45 | |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 46 | fadt->iapc_boot_arch = cfg->common_config.fadt_boot_arch; /* legacy free default */ |
| 47 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 48 | ACPI_FADT_C1_SUPPORTED | |
| 49 | ACPI_FADT_S4_RTC_WAKE | |
| 50 | ACPI_FADT_32BIT_TIMER | |
| 51 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 52 | ACPI_FADT_PLATFORM_CLOCK | |
| 53 | ACPI_FADT_S4_RTC_VALID | |
| 54 | ACPI_FADT_REMOTE_POWER_ON; |
| 55 | if (cfg->s0ix_enable) |
| 56 | fadt->flags |= ACPI_FADT_LOW_PWR_IDLE_S0; |
| 57 | |
| 58 | fadt->flags |= cfg->common_config.fadt_flags; /* additional board-specific flags */ |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 59 | } |
| 60 | |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 61 | unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current, |
| 62 | acpi_rsdp_t *rsdp) |
| 63 | { |
| 64 | /* TODO: look into adding CRAT */ |
| 65 | |
| 66 | /* IVRS */ |
| 67 | current = acpi_add_ivrs_table(current, rsdp); |
| 68 | |
Felix Held | 112c227 | 2024-01-26 15:33:59 +0100 | [diff] [blame^] | 69 | if (CONFIG(PLATFORM_USES_FSP2_0)) |
| 70 | current = acpi_add_fsp_tables(current, rsdp); |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 71 | |
| 72 | return current; |
| 73 | } |
| 74 | |
Felix Held | 8ec90ac | 2023-03-07 00:31:41 +0100 | [diff] [blame] | 75 | const acpi_cstate_t cstate_cfg_table[] = { |
| 76 | [0] = { |
| 77 | .ctype = 1, |
| 78 | .latency = 1, |
| 79 | .power = 0, |
| 80 | }, |
| 81 | [1] = { |
| 82 | .ctype = 2, |
| 83 | .latency = 0x12, |
| 84 | .power = 0, |
| 85 | }, |
| 86 | [2] = { |
| 87 | .ctype = 3, |
| 88 | .latency = 350, |
| 89 | .power = 0, |
| 90 | }, |
| 91 | }; |
| 92 | |
| 93 | const acpi_cstate_t *get_cstate_config_data(size_t *size) |
| 94 | { |
| 95 | *size = ARRAY_SIZE(cstate_cfg_table); |
| 96 | return cstate_cfg_table; |
| 97 | } |