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