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> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 22 | #include <soc/acpi.h> |
| 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 | |
| 27 | unsigned long acpi_fill_madt(unsigned long current) |
| 28 | { |
Kyösti Mälkki | 2e65e9c | 2021-06-16 11:00:40 +0300 | [diff] [blame] | 29 | current += acpi_create_madt_ioapic_from_hw((acpi_madt_ioapic_t *)current, |
| 30 | GNB_IO_APIC_ADDR); |
Jason Glenesk | f459a40 | 2020-09-02 16:49:10 -0700 | [diff] [blame] | 31 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 32 | return current; |
| 33 | } |
| 34 | |
| 35 | /* |
| 36 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 37 | * in the ACPI 3.0b specification. |
| 38 | */ |
Kyösti Mälkki | 61ef71b | 2020-05-30 18:54:39 +0300 | [diff] [blame] | 39 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 40 | { |
Raul E Rangel | 1c88b10 | 2021-02-11 10:35:32 -0700 | [diff] [blame] | 41 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 42 | |
Felix Held | 757d645 | 2021-02-04 21:31:49 +0100 | [diff] [blame] | 43 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 44 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 45 | |
| 46 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 47 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 48 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 49 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 50 | |
| 51 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 52 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 53 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 54 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 55 | |
Felix Held | b154949 | 2023-12-13 11:59:39 +0100 | [diff] [blame^] | 56 | fill_fadt_extended_pm_io(fadt); |
Felix Held | 164c5ed | 2022-10-18 00:11:48 +0200 | [diff] [blame] | 57 | |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 58 | fadt->iapc_boot_arch = cfg->fadt_boot_arch; /* legacy free default */ |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 59 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 60 | ACPI_FADT_C1_SUPPORTED | |
| 61 | ACPI_FADT_S4_RTC_WAKE | |
| 62 | ACPI_FADT_32BIT_TIMER | |
| 63 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 64 | ACPI_FADT_PLATFORM_CLOCK | |
| 65 | ACPI_FADT_S4_RTC_VALID | |
| 66 | ACPI_FADT_REMOTE_POWER_ON; |
| 67 | fadt->flags |= cfg->fadt_flags; /* additional board-specific flags */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 68 | } |
| 69 | |
Felix Held | 9bb6646 | 2023-03-04 02:33:28 +0100 | [diff] [blame] | 70 | const acpi_cstate_t cstate_cfg_table[] = { |
| 71 | [0] = { |
| 72 | .ctype = 1, |
| 73 | .latency = 1, |
| 74 | .power = 0, |
| 75 | }, |
| 76 | [1] = { |
| 77 | .ctype = 2, |
| 78 | .latency = 400, |
| 79 | .power = 0, |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | const acpi_cstate_t *get_cstate_config_data(size_t *size) |
| 84 | { |
| 85 | *size = ARRAY_SIZE(cstate_cfg_table); |
| 86 | return cstate_cfg_table; |
| 87 | } |