mb/google/nissa/var/rull: Configure Acoustic noise mitigation
[coreboot2.git] / src / soc / amd / common / block / pci / pcie_gpp.c
blob0f983d04bea8dd698dbd283601732c0c7b268620
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <acpi/acpi_device.h>
4 #include <acpi/acpigen.h>
5 #include <acpi/acpigen_pci.h>
6 #include <amdblocks/amd_pci_util.h>
7 #include <assert.h>
8 #include <device/device.h>
9 #include <device/pci.h>
10 #include <device/pciexp.h>
11 #include <soc/pci_devs.h>
12 #include <stdio.h>
13 #include <stdlib.h>
15 static const char *pcie_gpp_acpi_name(const struct device *dev)
17 char *name;
19 if (dev->path.type != DEVICE_PATH_PCI)
20 return NULL;
22 name = malloc(ACPI_NAME_BUFFER_SIZE);
23 snprintf(name, ACPI_NAME_BUFFER_SIZE, "GP%02X", dev->path.pci.devfn);
24 name[4] = '\0';
26 return name;
29 static void acpi_device_write_gpp_pci_dev(const struct device *dev)
31 const char *scope = acpi_device_scope(dev);
32 const char *name = acpi_device_name(dev);
34 assert(dev->path.type == DEVICE_PATH_PCI);
35 assert(name);
36 assert(scope);
38 acpigen_write_scope(scope);
39 acpigen_write_device(name);
41 acpigen_write_ADR_pci_device(dev);
42 acpigen_write_STA(acpi_device_status(dev));
44 acpigen_write_pci_GNB_PRT(dev);
46 acpigen_pop_len(); /* Device */
47 acpigen_pop_len(); /* Scope */
50 /* Latency tolerance reporting, max snoop/non-snoop latency value 1.049ms */
51 #define PCIE_LTR_MAX_LATENCY_1049US 0x1001
53 static void pcie_get_ltr_max_latencies(u16 *max_snoop, u16 *max_nosnoop)
55 *max_snoop = PCIE_LTR_MAX_LATENCY_1049US;
56 *max_nosnoop = PCIE_LTR_MAX_LATENCY_1049US;
59 static struct pci_operations pcie_ops = {
60 .get_ltr_max_latencies = pcie_get_ltr_max_latencies,
61 .set_subsystem = pci_dev_set_subsystem,
64 struct device_operations amd_internal_pcie_gpp_ops = {
65 .read_resources = pci_bus_read_resources,
66 .set_resources = pci_dev_set_resources,
67 .enable_resources = pci_bus_enable_resources,
68 .scan_bus = pci_scan_bridge,
69 .reset_bus = pci_bus_reset,
70 .acpi_name = pcie_gpp_acpi_name,
71 .acpi_fill_ssdt = acpi_device_write_gpp_pci_dev,
74 struct device_operations amd_external_pcie_gpp_ops = {
75 .read_resources = pci_bus_read_resources,
76 .set_resources = pci_dev_set_resources,
77 .enable_resources = pci_bus_enable_resources,
78 .scan_bus = pciexp_scan_bridge,
79 .reset_bus = pci_bus_reset,
80 .acpi_name = pcie_gpp_acpi_name,
81 .acpi_fill_ssdt = acpi_device_write_gpp_pci_dev,
82 .ops_pci = &pcie_ops,