Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 5 | */ |
| 6 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 7 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 8 | #include <acpi/acpi.h> |
| 9 | #include <acpi/acpigen.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 10 | #include <device/pci_ops.h> |
| 11 | #include <arch/ioapic.h> |
Raul E Rangel | 93b62e6 | 2020-01-31 12:53:45 -0700 | [diff] [blame] | 12 | #include <arch/smp/mpspec.h> |
Jason Glenesk | 498015d | 2020-12-10 03:28:38 -0800 | [diff] [blame] | 13 | #include <cpu/amd/cpuid.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 14 | #include <device/device.h> |
| 15 | #include <device/pci.h> |
Elyes Haouas | 5e2602a | 2023-01-14 05:46:25 +0100 | [diff] [blame] | 16 | #include <gpio.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 17 | #include <amdblocks/acpimmio.h> |
| 18 | #include <amdblocks/acpi.h> |
Raul E Rangel | 1c88b10 | 2021-02-11 10:35:32 -0700 | [diff] [blame] | 19 | #include <amdblocks/chip.h> |
Felix Held | dd2f3fa | 2021-02-08 22:23:54 +0100 | [diff] [blame] | 20 | #include <amdblocks/cpu.h> |
Felix Held | 604ffa6 | 2021-02-12 00:43:20 +0100 | [diff] [blame] | 21 | #include <amdblocks/ioapic.h> |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 22 | #include <device/device.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 23 | #include <soc/pci_devs.h> |
| 24 | #include <soc/southbridge.h> |
Raul E Rangel | 93b62e6 | 2020-01-31 12:53:45 -0700 | [diff] [blame] | 25 | #include "chip.h" |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 26 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 27 | /* |
| 28 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 29 | * in the ACPI 3.0b specification. |
| 30 | */ |
Kyösti Mälkki | 61ef71b | 2020-05-30 18:54:39 +0300 | [diff] [blame] | 31 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 32 | { |
Raul E Rangel | 1c88b10 | 2021-02-11 10:35:32 -0700 | [diff] [blame] | 33 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 34 | |
Felix Held | 757d645 | 2021-02-04 21:31:49 +0100 | [diff] [blame] | 35 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 36 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 37 | |
| 38 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 39 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 40 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 41 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 42 | |
| 43 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 44 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 45 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 46 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 47 | |
Felix Held | b154949 | 2023-12-13 11:59:39 +0100 | [diff] [blame] | 48 | fill_fadt_extended_pm_io(fadt); |
Felix Held | 164c5ed | 2022-10-18 00:11:48 +0200 | [diff] [blame] | 49 | |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 50 | fadt->iapc_boot_arch = cfg->fadt_boot_arch; /* legacy free default */ |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 51 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 52 | ACPI_FADT_C1_SUPPORTED | |
| 53 | ACPI_FADT_S4_RTC_WAKE | |
| 54 | ACPI_FADT_32BIT_TIMER | |
| 55 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 56 | ACPI_FADT_PLATFORM_CLOCK | |
| 57 | ACPI_FADT_S4_RTC_VALID | |
| 58 | ACPI_FADT_REMOTE_POWER_ON; |
| 59 | fadt->flags |= cfg->fadt_flags; /* additional board-specific flags */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 60 | } |
| 61 | |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 62 | unsigned long soc_acpi_write_tables(const struct device *device, unsigned long current, |
| 63 | acpi_rsdp_t *rsdp) |
| 64 | { |
| 65 | /* CRAT */ |
| 66 | current = acpi_add_crat_table(current, rsdp); |
| 67 | |
| 68 | /* IVRS */ |
| 69 | current = acpi_add_ivrs_table(current, rsdp); |
| 70 | |
| 71 | /* Add SRAT, MSCT, SLIT if needed in the future */ |
| 72 | |
Felix Held | 112c227 | 2024-01-26 15:33:59 +0100 | [diff] [blame^] | 73 | if (CONFIG(PLATFORM_USES_FSP2_0)) |
| 74 | current = acpi_add_fsp_tables(current, rsdp); |
Felix Held | 26577d2 | 2024-01-26 15:05:40 +0100 | [diff] [blame] | 75 | |
| 76 | return current; |
| 77 | } |
| 78 | |
Felix Held | 9bb6646 | 2023-03-04 02:33:28 +0100 | [diff] [blame] | 79 | const acpi_cstate_t cstate_cfg_table[] = { |
| 80 | [0] = { |
| 81 | .ctype = 1, |
| 82 | .latency = 1, |
| 83 | .power = 0, |
| 84 | }, |
| 85 | [1] = { |
| 86 | .ctype = 2, |
| 87 | .latency = 400, |
| 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 | } |