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> |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame] | 8 | #include <cpu/amd/mtrr.h> |
Raul E Rangel | 0f3bc81 | 2021-02-10 16:36:33 -0700 | [diff] [blame] | 9 | #include <device/device.h> |
| 10 | #include <types.h> |
| 11 | |
| 12 | unsigned long southbridge_write_acpi_tables(const struct device *device, |
| 13 | unsigned long current, |
| 14 | struct acpi_rsdp *rsdp) |
| 15 | { |
| 16 | return acpi_write_hpet(device, current, rsdp); |
| 17 | } |
Raul E Rangel | 0e560e7 | 2021-02-11 10:10:57 -0700 | [diff] [blame] | 18 | |
Raul E Rangel | ffab5e6 | 2021-02-11 11:07:11 -0700 | [diff] [blame] | 19 | unsigned long acpi_fill_madt_irqoverride(unsigned long current) |
| 20 | { |
| 21 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
| 22 | unsigned int i; |
| 23 | uint8_t irq; |
| 24 | uint8_t flags; |
| 25 | |
| 26 | for (i = 0; i < ARRAY_SIZE(cfg->irq_override); ++i) { |
| 27 | irq = cfg->irq_override[i].irq; |
| 28 | flags = cfg->irq_override[i].flags; |
| 29 | |
| 30 | if (!flags) |
| 31 | continue; |
| 32 | |
| 33 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, 0, |
| 34 | irq, irq, flags); |
| 35 | } |
| 36 | |
| 37 | return current; |
| 38 | } |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame] | 39 | |
| 40 | /* Used by \_SB.PCI0._CRS */ |
| 41 | void acpi_fill_root_complex_tom(const struct device *device) |
| 42 | { |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame] | 43 | const char *scope; |
| 44 | |
| 45 | assert(device); |
| 46 | |
| 47 | scope = acpi_device_scope(device); |
| 48 | assert(scope); |
| 49 | acpigen_write_scope(scope); |
| 50 | |
Felix Held | 0990611 | 2023-04-20 13:22:34 +0200 | [diff] [blame^] | 51 | acpigen_write_name_dword("TOM1", get_top_of_mem_below_4gb()); |
| 52 | |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame] | 53 | /* |
| 54 | * Since XP only implements parts of ACPI 2.0, we can't use a qword |
| 55 | * here. |
| 56 | * See http://www.acpi.info/presentations/S01USMOBS169_OS%2520new.ppt |
| 57 | * slide 22ff. |
| 58 | * Shift value right by 20 bit to make it fit into 32bit, |
| 59 | * giving us 1MB granularity and a limit of almost 4Exabyte of memory. |
| 60 | */ |
Felix Held | 0990611 | 2023-04-20 13:22:34 +0200 | [diff] [blame^] | 61 | acpigen_write_name_dword("TOM2", get_top_of_mem_above_4g() >> 20); |
Raul E Rangel | 58a8ad1 | 2021-02-18 16:36:08 -0700 | [diff] [blame] | 62 | acpigen_pop_len(); |
| 63 | } |