blob: 3ba9af6499e9d83ea9c31a24f160f931b455dc87 [file] [log] [blame]
Raul E Rangel0f3bc812021-02-10 16:36:33 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <acpi/acpi.h>
Raul E Rangel58a8ad12021-02-18 16:36:08 -07004#include <acpi/acpigen.h>
Raul E Rangel0f3bc812021-02-10 16:36:33 -07005#include <amdblocks/acpi.h>
Raul E Rangelffab5e62021-02-11 11:07:11 -07006#include <amdblocks/chip.h>
Raul E Rangel58a8ad12021-02-18 16:36:08 -07007#include <assert.h>
Raul E Rangel58a8ad12021-02-18 16:36:08 -07008#include <cpu/amd/mtrr.h>
Raul E Rangel0f3bc812021-02-10 16:36:33 -07009#include <device/device.h>
10#include <types.h>
11
12unsigned 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 Rangel0e560e72021-02-11 10:10:57 -070018
Raul E Rangelffab5e62021-02-11 11:07:11 -070019unsigned 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 Rangel58a8ad12021-02-18 16:36:08 -070039
40/* Used by \_SB.PCI0._CRS */
41void acpi_fill_root_complex_tom(const struct device *device)
42{
Raul E Rangel58a8ad12021-02-18 16:36:08 -070043 const char *scope;
44
45 assert(device);
46
47 scope = acpi_device_scope(device);
48 assert(scope);
49 acpigen_write_scope(scope);
50
Felix Held09906112023-04-20 13:22:34 +020051 acpigen_write_name_dword("TOM1", get_top_of_mem_below_4gb());
52
Raul E Rangel58a8ad12021-02-18 16:36:08 -070053 /*
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 Held27af3e62023-04-22 05:59:52 +020061 acpigen_write_name_dword("TOM2", get_top_of_mem_above_4gb() >> 20);
Raul E Rangel58a8ad12021-02-18 16:36:08 -070062 acpigen_pop_len();
63}