Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 5 | */ |
| 6 | |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -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> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 10 | #include <device/pci_ops.h> |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 11 | #include <arch/ioapic.h> |
Felix Held | 69a957f | 2021-06-17 15:48:25 +0200 | [diff] [blame] | 12 | #include <arch/smp/mpspec.h> |
Marshall Dawson | e9b862e | 2017-09-22 15:14:46 -0600 | [diff] [blame] | 13 | #include <cpu/x86/smm.h> |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 14 | #include <device/device.h> |
Marc Jones | 6bfcf66 | 2017-08-06 17:42:35 -0600 | [diff] [blame] | 15 | #include <device/pci.h> |
Elyes Haouas | 5e2602a | 2023-01-14 05:46:25 +0100 | [diff] [blame] | 16 | #include <gpio.h> |
Marshall Dawson | 69486ca | 2019-05-02 12:03:45 -0600 | [diff] [blame] | 17 | #include <amdblocks/acpimmio.h> |
Marshall Dawson | 4ee83b2 | 2019-05-03 11:44:22 -0600 | [diff] [blame] | 18 | #include <amdblocks/acpi.h> |
Felix Held | 15024e0 | 2023-02-16 20:34:46 +0100 | [diff] [blame] | 19 | #include <amdblocks/cpu.h> |
Felix Held | 604ffa6 | 2021-02-12 00:43:20 +0100 | [diff] [blame] | 20 | #include <amdblocks/ioapic.h> |
Marc Jones | 257db58 | 2017-06-18 17:33:30 -0600 | [diff] [blame] | 21 | #include <soc/acpi.h> |
Chris Ching | 6a35fab | 2017-10-19 11:45:30 -0600 | [diff] [blame] | 22 | #include <soc/pci_devs.h> |
Marc Jones | dfeb1c4 | 2017-08-07 19:08:24 -0600 | [diff] [blame] | 23 | #include <soc/southbridge.h> |
Patrick Georgi | 4fbefc5 | 2018-10-23 14:35:37 +0200 | [diff] [blame] | 24 | #include <soc/northbridge.h> |
Elyes HAOUAS | 26071aa | 2019-02-15 08:21:33 +0100 | [diff] [blame] | 25 | #include <version.h> |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 26 | |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 27 | unsigned long acpi_fill_madt(unsigned long current) |
| 28 | { |
| 29 | /* create all subtables for processors */ |
Kyösti Mälkki | 66b5e1b | 2022-11-12 21:13:45 +0200 | [diff] [blame] | 30 | current = acpi_create_madt_lapics_with_nmis(current); |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 31 | |
| 32 | /* Write Kern IOAPIC, only one */ |
Kyösti Mälkki | 2e65e9c | 2021-06-16 11:00:40 +0300 | [diff] [blame] | 33 | current += acpi_create_madt_ioapic_from_hw((acpi_madt_ioapic_t *)current, IO_APIC_ADDR); |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 34 | |
Kyösti Mälkki | 2e65e9c | 2021-06-16 11:00:40 +0300 | [diff] [blame] | 35 | current += acpi_create_madt_ioapic_from_hw((acpi_madt_ioapic_t *)current, IO_APIC2_ADDR); |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 36 | |
Felix Held | 69a957f | 2021-06-17 15:48:25 +0200 | [diff] [blame] | 37 | /* PIT is connected to legacy IRQ 0, but IOAPIC GSI 2 */ |
| 38 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, |
| 39 | MP_BUS_ISA, 0, 2, |
| 40 | MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT); |
| 41 | /* SCI IRQ type override */ |
| 42 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, |
Felix Held | 1a14875 | 2023-02-27 21:07:26 +0100 | [diff] [blame] | 43 | MP_BUS_ISA, ACPI_SCI_IRQ, ACPI_SCI_IRQ, |
Felix Held | 69a957f | 2021-06-17 15:48:25 +0200 | [diff] [blame] | 44 | MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW); |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 45 | |
Marc Jones | 5ebc865 | 2017-06-19 23:34:04 -0600 | [diff] [blame] | 46 | return current; |
| 47 | } |
| 48 | |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 49 | /* |
| 50 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 51 | * in the ACPI 3.0b specification. |
| 52 | */ |
Kyösti Mälkki | 61ef71b | 2020-05-30 18:54:39 +0300 | [diff] [blame] | 53 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 54 | { |
Felix Held | 2f8228d | 2021-02-05 01:03:45 +0100 | [diff] [blame] | 55 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 56 | |
Felix Held | 1a14875 | 2023-02-27 21:07:26 +0100 | [diff] [blame] | 57 | fadt->sci_int = ACPI_SCI_IRQ; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 58 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 59 | if (permanent_smi_handler()) { |
Marshall Dawson | e9b862e | 2017-09-22 15:14:46 -0600 | [diff] [blame] | 60 | fadt->smi_cmd = APM_CNT; |
| 61 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 62 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 66 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 67 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 68 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 69 | |
| 70 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 71 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 72 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 73 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 74 | |
Felix Held | 164c5ed | 2022-10-18 00:11:48 +0200 | [diff] [blame] | 75 | fill_fadt_extended_pm_regs(fadt); |
| 76 | |
Felix Held | 54c80e1 | 2023-02-21 17:59:42 +0100 | [diff] [blame^] | 77 | /* p_lvl2_lat and p_lvl3_lat match what the AGESA code does, but those values are |
| 78 | overridden by the _CST packages in the PSTATE SSDT. */ |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 79 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 80 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 81 | fadt->duty_offset = 1; /* CLK_VAL bits 3:1 */ |
| 82 | fadt->duty_width = 3; /* CLK_VAL bits 3:1 */ |
Felix Held | 72b92c9 | 2021-11-18 20:41:40 +0100 | [diff] [blame] | 83 | fadt->day_alrm = RTC_DATE_ALARM; |
Anand K Mistry | dd8e819 | 2021-05-27 14:32:29 +1000 | [diff] [blame] | 84 | fadt->mon_alrm = 0; /* Not supported */ |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 85 | fadt->iapc_boot_arch = FADT_BOOT_ARCH; /* See table 5-10 */ |
Angel Pons | a208c6c | 2020-07-13 00:02:34 +0200 | [diff] [blame] | 86 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-10 ACPI 3.0a spec */ |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 87 | ACPI_FADT_C1_SUPPORTED | |
| 88 | ACPI_FADT_SLEEP_BUTTON | |
| 89 | ACPI_FADT_S4_RTC_WAKE | |
| 90 | ACPI_FADT_32BIT_TIMER | |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 91 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 92 | ACPI_FADT_PLATFORM_CLOCK | |
| 93 | ACPI_FADT_S4_RTC_VALID | |
| 94 | ACPI_FADT_REMOTE_POWER_ON; |
Marc Jones | 2448484 | 2017-05-04 21:17:45 -0600 | [diff] [blame] | 95 | } |
Marc Jones | 257db58 | 2017-06-18 17:33:30 -0600 | [diff] [blame] | 96 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 97 | void generate_cpu_entries(const struct device *device) |
Marc Jones | 6bfcf66 | 2017-08-06 17:42:35 -0600 | [diff] [blame] | 98 | { |
Felix Held | 15024e0 | 2023-02-16 20:34:46 +0100 | [diff] [blame] | 99 | int cpu; |
| 100 | const int cores = get_cpu_count(); |
Marc Jones | 6bfcf66 | 2017-08-06 17:42:35 -0600 | [diff] [blame] | 101 | |
Michał Żygowski | 9550e97 | 2020-03-20 13:56:46 +0100 | [diff] [blame] | 102 | printk(BIOS_DEBUG, "ACPI \\_SB report %d core(s)\n", cores); |
Marc Jones | 6bfcf66 | 2017-08-06 17:42:35 -0600 | [diff] [blame] | 103 | |
Felix Held | 12ec790 | 2023-01-28 04:23:21 +0100 | [diff] [blame] | 104 | /* Generate \_SB.Pxxx */ |
| 105 | for (cpu = 0; cpu < cores; cpu++) { |
| 106 | acpigen_write_processor_device(cpu); |
| 107 | acpigen_write_processor_device_end(); |
Marc Jones | 6bfcf66 | 2017-08-06 17:42:35 -0600 | [diff] [blame] | 108 | } |
Kyösti Mälkki | da321d8 | 2021-01-27 20:22:33 +0200 | [diff] [blame] | 109 | |
Felix Held | 91d006c | 2022-03-02 15:16:17 +0100 | [diff] [blame] | 110 | acpigen_write_processor_package("PPKG", 0, cores); |
Marc Jones | 6bfcf66 | 2017-08-06 17:42:35 -0600 | [diff] [blame] | 111 | } |