Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi.h> |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame^] | 4 | #include <acpi/acpigen.h> |
Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 5 | #include <amdblocks/acpi.h> |
Raul E Rangel | ffab5e6 | 2021-02-11 11:07:11 -0700 | [diff] [blame] | 6 | #include <amdblocks/chip.h> |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame^] | 7 | #include <assert.h> |
| 8 | #include <cpu/amd/msr.h> |
| 9 | #include <cpu/amd/mtrr.h> |
Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 10 | #include <device/device.h> |
| 11 | #include <types.h> |
| 12 | |
| 13 | unsigned long southbridge_write_acpi_tables(const struct device *device, |
| 14 | unsigned long current, |
| 15 | struct acpi_rsdp *rsdp) |
| 16 | { |
| 17 | return acpi_write_hpet(device, current, rsdp); |
| 18 | } |
Raul E Rangel | 0e560e7 | 2021-02-11 10:10:57 -0700 | [diff] [blame] | 19 | |
| 20 | unsigned long acpi_fill_mcfg(unsigned long current) |
| 21 | { |
| 22 | |
| 23 | current += acpi_create_mcfg_mmconfig((acpi_mcfg_mmconfig_t *)current, |
| 24 | CONFIG_MMCONF_BASE_ADDRESS, |
| 25 | 0, |
| 26 | 0, |
| 27 | CONFIG_MMCONF_BUS_NUMBER - 1); |
| 28 | |
| 29 | return current; |
| 30 | } |
Raul E Rangel | ffab5e6 | 2021-02-11 11:07:11 -0700 | [diff] [blame] | 31 | |
| 32 | unsigned long acpi_fill_madt_irqoverride(unsigned long current) |
| 33 | { |
| 34 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
| 35 | unsigned int i; |
| 36 | uint8_t irq; |
| 37 | uint8_t flags; |
| 38 | |
| 39 | for (i = 0; i < ARRAY_SIZE(cfg->irq_override); ++i) { |
| 40 | irq = cfg->irq_override[i].irq; |
| 41 | flags = cfg->irq_override[i].flags; |
| 42 | |
| 43 | if (!flags) |
| 44 | continue; |
| 45 | |
| 46 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, 0, |
| 47 | irq, irq, flags); |
| 48 | } |
| 49 | |
| 50 | return current; |
| 51 | } |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame^] | 52 | |
| 53 | /* Used by \_SB.PCI0._CRS */ |
| 54 | void acpi_fill_root_complex_tom(const struct device *device) |
| 55 | { |
| 56 | msr_t msr; |
| 57 | const char *scope; |
| 58 | |
| 59 | assert(device); |
| 60 | |
| 61 | scope = acpi_device_scope(device); |
| 62 | assert(scope); |
| 63 | acpigen_write_scope(scope); |
| 64 | |
| 65 | msr = rdmsr(TOP_MEM); |
| 66 | acpigen_write_name_dword("TOM1", msr.lo); |
| 67 | msr = rdmsr(TOP_MEM2); |
| 68 | /* |
| 69 | * Since XP only implements parts of ACPI 2.0, we can't use a qword |
| 70 | * here. |
| 71 | * See http://www.acpi.info/presentations/S01USMOBS169_OS%2520new.ppt |
| 72 | * slide 22ff. |
| 73 | * Shift value right by 20 bit to make it fit into 32bit, |
| 74 | * giving us 1MB granularity and a limit of almost 4Exabyte of memory. |
| 75 | */ |
| 76 | acpigen_write_name_dword("TOM2", (msr.hi << 12) | msr.lo >> 20); |
| 77 | acpigen_pop_len(); |
| 78 | } |