mb/starlabs/{lite_adl,byte_adl}: Don't select MAINBOARD_HAS_TPM2
[coreboot2.git] / src / soc / intel / xeon_sp / memmap.c
blobb70c1cc75ae104436db0b7c408b47268e2d93102
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <arch/romstage.h>
4 #include <cbmem.h>
5 #include <console/console.h>
6 #include <device/pci_ops.h>
7 #include <device/pci_ids.h>
8 #include <cpu/x86/smm.h>
9 #include <soc/soc_util.h>
10 #include <soc/pci_devs.h>
11 #include <soc/util.h>
12 #include <security/intel/txt/txt_platform.h>
14 void smm_region(uintptr_t *start, size_t *size)
16 uintptr_t tseg_base = pci_read_config32(VTD_DEV(0), VTD_TSEG_BASE_CSR);
17 uintptr_t tseg_limit = pci_read_config32(VTD_DEV(0), VTD_TSEG_LIMIT_CSR);
19 tseg_base = ALIGN_DOWN(tseg_base, 1 * MiB);
20 tseg_limit = ALIGN_DOWN(tseg_limit, 1 * MiB);
21 /* Only the upper [31:20] bits of an address are checked against
22 * VTD_TSEG_LIMIT_CSR[31:20] which must be below or equal, so this
23 * effectively means +1MiB for the limit.
25 tseg_limit += 1 * MiB;
27 *start = tseg_base;
28 *size = tseg_limit - tseg_base;
31 void fill_postcar_frame(struct postcar_frame *pcf)
33 const uintptr_t top_of_ram = cbmem_top();
34 uintptr_t cbmem_base;
35 size_t cbmem_size;
37 /* Try account for the CBMEM region currently used and for future use */
38 if (cbmem_get_region((void **)&cbmem_base, &cbmem_size))
39 die("Could not find cbmem region");
40 printk(BIOS_DEBUG, "top_of_ram = 0x%lx\n", top_of_ram);
41 printk(BIOS_DEBUG, "cbmem base_ptr: 0x%lx, size: 0x%zx\n", cbmem_base, cbmem_size);
42 /* Assume 4MiB will be enough for future cbmem objects (FSP-S, ramstage, ...) */
43 cbmem_base -= 4 * MiB;
44 cbmem_base = ALIGN_DOWN(cbmem_base, 4 * MiB);
46 /* Align the top to make sure we don't use too many MTRR's */
47 cbmem_size = ALIGN_UP(top_of_ram - cbmem_base, 4 * MiB);
49 postcar_frame_add_mtrr(pcf, cbmem_base, cbmem_size, MTRR_TYPE_WRBACK);
50 /* Cache the TSEG region */
51 if (CONFIG(TSEG_STAGE_CACHE))
52 postcar_enable_tseg_cache(pcf);
55 #if !defined(__SIMPLE_DEVICE__)
56 union dpr_register txt_get_chipset_dpr(void)
58 union dpr_register dpr;
59 struct device *dev = VTD_DEV(0);
61 dpr.raw = 0;
63 if (!dev) {
64 printk(BIOS_ERR, "BUS 0: Unable to find VTD PCI dev");
65 return dpr;
68 dpr.raw = pci_read_config32(dev, VTD_LTDPR);
70 dev = NULL;
71 /* Look for VTD devices on all sockets */
72 while ((dev = dev_find_device(PCI_VID_INTEL, MMAP_VTD_STACK_CFG_REG_DEVID, dev))) {
73 /* Compare the LTDPR register on all iio stacks */
74 union dpr_register test_dpr = { .raw = pci_read_config32(dev, VTD_LTDPR) };
75 if (dpr.raw != test_dpr.raw) {
76 printk(BIOS_ERR, "LTDPR not the same on all IIO's");
77 dpr.raw = 0;
78 return dpr;
81 return dpr;
83 #endif