Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* ACPI - create the Fixed ACPI Description Tables (FADT) */ |
| 4 | |
| 5 | #include <acpi/acpi.h> |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 6 | #include <amdblocks/acpi.h> |
| 7 | #include <amdblocks/acpimmio.h> |
Raul E Rangel | 65819cd | 2021-02-16 10:37:46 -0700 | [diff] [blame] | 8 | #include <amdblocks/ioapic.h> |
| 9 | #include <arch/ioapic.h> |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 10 | #include <arch/smp/mpspec.h> |
| 11 | #include <console/console.h> |
| 12 | #include <cpu/x86/smm.h> |
| 13 | #include <soc/acpi.h> |
| 14 | #include <soc/iomap.h> |
| 15 | #include <types.h> |
| 16 | #include "chip.h" |
Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [diff] [blame] | 17 | |
| 18 | unsigned long acpi_fill_madt(unsigned long current) |
| 19 | { |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 20 | /* create all subtables for processors */ |
| 21 | current = acpi_create_madt_lapics(current); |
| 22 | |
Raul E Rangel | 65819cd | 2021-02-16 10:37:46 -0700 | [diff] [blame] | 23 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, |
| 24 | FCH_IOAPIC_ID, IO_APIC_ADDR, 0); |
| 25 | |
| 26 | /* TODO: Add GNB-IOAPIC */ |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 27 | |
| 28 | current += acpi_create_madt_irqoverride( |
| 29 | (acpi_madt_irqoverride_t *)current, |
| 30 | MP_BUS_ISA, 0, 2, |
| 31 | MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT); |
| 32 | current += acpi_create_madt_irqoverride( |
| 33 | (acpi_madt_irqoverride_t *)current, |
| 34 | MP_BUS_ISA, ACPI_SCI_IRQ, ACPI_SCI_IRQ, |
| 35 | MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW); |
Raul E Rangel | 9bce1fe | 2021-02-11 11:28:52 -0700 | [diff] [blame^] | 36 | current = acpi_fill_madt_irqoverride(current); |
| 37 | |
| 38 | /* create all subtables for processors */ |
| 39 | current += acpi_create_madt_lapic_nmi( |
| 40 | (acpi_madt_lapic_nmi_t *)current, |
| 41 | ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS, |
| 42 | MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, |
| 43 | 1 /* 1: LINT1 connect to NMI */); |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 44 | |
Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [diff] [blame] | 45 | return current; |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 50 | * in the ACPI 3.0b specification. |
| 51 | */ |
| 52 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 53 | { |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 54 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
| 55 | |
| 56 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
| 57 | |
| 58 | fadt->sci_int = ACPI_SCI_IRQ; |
| 59 | |
| 60 | if (permanent_smi_handler()) { |
| 61 | fadt->smi_cmd = APM_CNT; |
| 62 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 63 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
| 64 | } |
| 65 | |
| 66 | fadt->pstate_cnt = 0; |
| 67 | |
| 68 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
| 69 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
| 70 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 71 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
| 72 | |
| 73 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 74 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
| 75 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 76 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
| 77 | |
| 78 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 79 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
| 80 | fadt->duty_offset = 0; /* Not supported */ |
| 81 | fadt->duty_width = 0; /* Not supported */ |
| 82 | fadt->day_alrm = RTC_DATE_ALARM; |
| 83 | fadt->mon_alrm = 0; |
| 84 | fadt->century = RTC_ALT_CENTURY; |
| 85 | fadt->iapc_boot_arch = cfg->fadt_boot_arch; /* legacy free default */ |
| 86 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 87 | ACPI_FADT_C1_SUPPORTED | |
| 88 | ACPI_FADT_S4_RTC_WAKE | |
| 89 | ACPI_FADT_32BIT_TIMER | |
| 90 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 91 | ACPI_FADT_PLATFORM_CLOCK | |
| 92 | ACPI_FADT_S4_RTC_VALID | |
| 93 | ACPI_FADT_REMOTE_POWER_ON; |
| 94 | fadt->flags |= cfg->fadt_flags; /* additional board-specific flags */ |
| 95 | |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 96 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 97 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 98 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 99 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 100 | fadt->x_pm1a_evt_blk.addrl = ACPI_PM_EVT_BLK; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 101 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 102 | |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 103 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 104 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 105 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 106 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 107 | fadt->x_pm1a_cnt_blk.addrl = ACPI_PM1_CNT_BLK; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 108 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 109 | |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 110 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 111 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 112 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 113 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 114 | fadt->x_pm_tmr_blk.addrl = ACPI_PM_TMR_BLK; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 115 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 116 | |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 117 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 118 | fadt->x_gpe0_blk.bit_width = 64; |
| 119 | fadt->x_gpe0_blk.bit_offset = 0; |
Raul E Rangel | 6e3f383 | 2021-02-19 16:01:05 -0700 | [diff] [blame] | 120 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
| 121 | fadt->x_gpe0_blk.addrl = ACPI_GPE0_BLK; |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame] | 122 | fadt->x_gpe0_blk.addrh = 0x0; |
Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [diff] [blame] | 123 | } |