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> |
| 8 | #include <arch/smp/mpspec.h> |
| 9 | #include <console/console.h> |
| 10 | #include <cpu/x86/smm.h> |
| 11 | #include <soc/acpi.h> |
| 12 | #include <soc/iomap.h> |
| 13 | #include <types.h> |
| 14 | #include "chip.h" |
Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [diff] [blame] | 15 | |
| 16 | unsigned long acpi_fill_madt(unsigned long current) |
| 17 | { |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame^] | 18 | /* create all subtables for processors */ |
| 19 | current = acpi_create_madt_lapics(current); |
| 20 | |
| 21 | /* TODO: Add IOAPIC and GNB-IOAPIC */ |
| 22 | |
| 23 | current += acpi_create_madt_irqoverride( |
| 24 | (acpi_madt_irqoverride_t *)current, |
| 25 | MP_BUS_ISA, 0, 2, |
| 26 | MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT); |
| 27 | current += acpi_create_madt_irqoverride( |
| 28 | (acpi_madt_irqoverride_t *)current, |
| 29 | MP_BUS_ISA, ACPI_SCI_IRQ, ACPI_SCI_IRQ, |
| 30 | MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW); |
| 31 | |
Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [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 | */ |
| 39 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
| 40 | { |
Raul E Rangel | 12c6a58 | 2021-02-10 16:45:49 -0700 | [diff] [blame^] | 41 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
| 42 | |
| 43 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
| 44 | |
| 45 | fadt->sci_int = ACPI_SCI_IRQ; |
| 46 | |
| 47 | if (permanent_smi_handler()) { |
| 48 | fadt->smi_cmd = APM_CNT; |
| 49 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 50 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
| 51 | } |
| 52 | |
| 53 | fadt->pstate_cnt = 0; |
| 54 | |
| 55 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
| 56 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
| 57 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 58 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
| 59 | |
| 60 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 61 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
| 62 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 63 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
| 64 | |
| 65 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 66 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
| 67 | fadt->duty_offset = 0; /* Not supported */ |
| 68 | fadt->duty_width = 0; /* Not supported */ |
| 69 | fadt->day_alrm = RTC_DATE_ALARM; |
| 70 | fadt->mon_alrm = 0; |
| 71 | fadt->century = RTC_ALT_CENTURY; |
| 72 | fadt->iapc_boot_arch = cfg->fadt_boot_arch; /* legacy free default */ |
| 73 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 74 | ACPI_FADT_C1_SUPPORTED | |
| 75 | ACPI_FADT_S4_RTC_WAKE | |
| 76 | ACPI_FADT_32BIT_TIMER | |
| 77 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 78 | ACPI_FADT_PLATFORM_CLOCK | |
| 79 | ACPI_FADT_S4_RTC_VALID | |
| 80 | ACPI_FADT_REMOTE_POWER_ON; |
| 81 | fadt->flags |= cfg->fadt_flags; /* additional board-specific flags */ |
| 82 | |
| 83 | /* |
| 84 | * The Cezanne PPR defines the ACPI registers starting at PMx00000500. This translates |
| 85 | * to 0x300 + 0x500 = 0x800 which is identical to acpimmio_acpi. |
| 86 | */ |
| 87 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 88 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 89 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 90 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 91 | fadt->x_pm1a_evt_blk.addrl = (u32)acpimmio_acpi + MMIO_ACPI_PM1_EVT_BLK; |
| 92 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 93 | |
| 94 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 95 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 96 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
| 97 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 98 | fadt->x_pm1a_cnt_blk.addrl = (u32)acpimmio_acpi + MMIO_ACPI_PM1_CNT_BLK; |
| 99 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 100 | |
| 101 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 102 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 103 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 104 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 105 | fadt->x_pm_tmr_blk.addrl = (u32)acpimmio_acpi + MMIO_ACPI_PM_TMR_BLK; |
| 106 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 107 | |
| 108 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_MEMORY; |
| 109 | fadt->x_gpe0_blk.bit_width = 64; |
| 110 | fadt->x_gpe0_blk.bit_offset = 0; |
| 111 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 112 | fadt->x_gpe0_blk.addrl = (u32)acpimmio_acpi + MMIO_ACPI_GPE0_BLK; |
| 113 | fadt->x_gpe0_blk.addrh = 0x0; |
Felix Held | 8602495 | 2021-02-03 23:44:28 +0100 | [diff] [blame] | 114 | } |