1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <device/device.h>
7 #include <device/pci.h>
8 #include <device/pci_ops.h>
9 #include <intelblocks/systemagent.h>
10 #include <intelblocks/power_limit.h>
11 #include <soc/iomap.h>
12 #include <soc/soc_chip.h>
13 #include <soc/systemagent.h>
19 * Add all known fixed memory ranges for Host Controller/Memory
22 void soc_add_fixed_mmio_resources(struct device
*dev
, int *index
)
24 static const struct sa_mmio_descriptor soc_fixed_resources
[] = {
25 { PCIEXBAR
, CONFIG_ECAM_MMCONF_BASE_ADDRESS
, CONFIG_ECAM_MMCONF_LENGTH
,
27 { MCHBAR
, MCH_BASE_ADDRESS
, MCH_BASE_SIZE
, "MCHBAR" },
28 { DMIBAR
, DMI_BASE_ADDRESS
, DMI_BASE_SIZE
, "DMIBAR" },
29 { EPBAR
, EP_BASE_ADDRESS
, EP_BASE_SIZE
, "EPBAR" },
30 { REGBAR
, REG_BASE_ADDRESS
, REG_BASE_SIZE
, "REGBAR" },
31 { EDRAMBAR
, EDRAM_BASE_ADDRESS
, EDRAM_BASE_SIZE
, "EDRAMBAR" },
34 sa_add_fixed_mmio_resources(dev
, index
, soc_fixed_resources
,
35 ARRAY_SIZE(soc_fixed_resources
));
37 /* Add Vt-d resources if VT-d is enabled */
38 if ((pci_read_config32(dev
, CAPID0_A
) & VTD_DISABLE
))
41 sa_add_fixed_mmio_resources(dev
, index
, soc_vtd_resources
,
42 ARRAY_SIZE(soc_vtd_resources
));
48 * Perform System Agent Initialization during Ramstage phase.
50 void soc_systemagent_init(struct device
*dev
)
52 struct soc_power_limits_config
*soc_config
;
58 /* Enable Power Aware Interrupt Routing */
59 enable_power_aware_intr();
61 /* Enable BIOS Reset CPL */
62 enable_bios_reset_cpl();
65 config
= config_of_soc();
67 /* Get System Agent PCI ID */
68 sa_pci_id
= dev
? pci_read_config16(dev
, PCI_DEVICE_ID
) : 0xFFFF;
70 if (sa_pci_id
!= 0xFFFF) {
73 /* Choose power limits configuration based on the CPU SA PCI ID and
75 for (i
= 0; i
< ARRAY_SIZE(cpuid_to_jsl
); i
++) {
76 if (sa_pci_id
== cpuid_to_jsl
[i
].pci_did
&&
77 tdp
== cpuid_to_jsl
[i
].cpu_tdp
) {
78 soc_config
= &config
->power_limits_config
[cpuid_to_jsl
[i
].limits
];
79 set_power_limits(MOBILE_SKU_PL1_TIME_SEC
, soc_config
);
85 if (i
== ARRAY_SIZE(cpuid_to_jsl
) || sa_pci_id
== 0xFFFF) {
86 printk(BIOS_ERR
, "unknown SA ID: 0x%4x, can't find its TDP."
87 " Skipped power limits configuration.\n",