Debian Codegraph @

src/soc/amd/picasso/root_complex.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <acpi/acpigen.h>
4 #include <amdblocks/alib.h>
5 #include <amdblocks/data_fabric.h>
6 #include <amdblocks/ioapic.h>
7 #include <amdblocks/root_complex.h>
8 #include <arch/ioapic.h>
9 #include <device/device.h>
10 #include <device/pci.h>
11 #include <static.h>
12 #include <stdint.h>
13 #include <soc/iomap.h>
14 #include "chip.h"
15
16 #define DPTC_TOTAL_UPDATE_PARAMS 4
17
18 struct dptc_input {
19 uint16_t size;
20 struct alib_dptc_param params[DPTC_TOTAL_UPDATE_PARAMS];
21 } __packed;
22
23 #define DPTC_INPUTS(_thermctllmit, _sustained, _fast, _slow) \
24 { \
25 .size = sizeof(struct dptc_input), \
26 .params = { \
27 { \
28 .id = ALIB_DPTC_THERMAL_CONTROL_LIMIT_ID, \
29 .value = _thermctllmit, \
30 }, \
31 { \
32 .id = ALIB_DPTC_SUSTAINED_POWER_LIMIT_ID, \
33 .value = _sustained, \
34 }, \
35 { \
36 .id = ALIB_DPTC_FAST_PPT_LIMIT_ID, \
37 .value = _fast, \
38 }, \
39 { \
40 .id = ALIB_DPTC_SLOW_PPT_LIMIT_ID, \
41 .value = _slow, \
42 }, \
43 }, \
44 }
45
46 static void acipgen_dptci(void)
47 {
48 const struct soc_amd_picasso_config *config = config_of_soc();
49
50 /* Normal mode DPTC values. */
51 struct dptc_input default_input = DPTC_INPUTS(config->thermctl_limit_degreeC,
52 config->sustained_power_limit_mW,
53 config->fast_ppt_limit_mW,
54 config->slow_ppt_limit_mW);
55 acpigen_write_alib_dptc_default((uint8_t *)&default_input, sizeof(default_input));
56
57 /* Tablet Mode */
58 struct dptc_input tablet_mode_input = DPTC_INPUTS(
59 config->thermctl_limit_tablet_mode_degreeC,
60 config->sustained_power_limit_tablet_mode_mW,
61 config->fast_ppt_limit_tablet_mode_mW,
62 config->slow_ppt_limit_tablet_mode_mW);
63 acpigen_write_alib_dptc_tablet((uint8_t *)&tablet_mode_input,
64 sizeof(tablet_mode_input));
65 }
66
67 static void root_complex_fill_ssdt(const struct device *device)
68 {
69 if (CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC))
70 acipgen_dptci();
71 }
72
73 static const char *gnb_acpi_name(const struct device *dev)
74 {
75 return "GNB";
76 }
77
78 struct device_operations picasso_root_complex_operations = {
79 /* The root complex has no PCI BARs implemented, so there's no need to call
80 pci_dev_read_resources for it */
81 .read_resources = noop_read_resources,
82 .set_resources = noop_set_resources,
83 .enable_resources = pci_dev_enable_resources,
84 .acpi_name = gnb_acpi_name,
85 .acpi_fill_ssdt = root_complex_fill_ssdt,
86 };
87
88 static const struct domain_iohc_info iohc_info[] = {
89 [0] = {
90 .fabric_id = IOMS0_FABRIC_ID,
91 .misc_smn_base = SMN_IOHC_MISC_BASE_13B1,
92 },
93 };
94
95 const struct domain_iohc_info *get_iohc_info(size_t *count)
96 {
97 *count = ARRAY_SIZE(iohc_info);
98 return iohc_info;
99 }
100
101 static const struct non_pci_mmio_reg non_pci_mmio[] = {
102 { 0x2e0, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO },
103 { 0x2e8, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO },
104 /* The hardware has a 256 byte alignment requirement for the IOAPIC MMIO base, but we
105 tell the FSP to configure a 4k-aligned base address and this is reported as 4 KiB
106 resource. */
107 { 0x2f0, 0xffffffffff00ull, 4 * KiB, IOMMU_IOAPIC_IDX },
108 { 0x2f8, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO },
109 { 0x300, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO },
110 { 0x308, 0xfffffffff000ull, 4 * KiB, NON_PCI_RES_IDX_AUTO },
111 { 0x318, 0xfffffff80000ull, 512 * KiB, NON_PCI_RES_IDX_AUTO },
112 };
113
114 const struct non_pci_mmio_reg *get_iohc_non_pci_mmio_regs(size_t *count)
115 {
116 *count = ARRAY_SIZE(non_pci_mmio);
117 return non_pci_mmio;
118 }