1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpigen.h>
6 #include <cpu/x86/smm.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <device/pci_ids.h>
10 #include <cpu/x86/lapic_def.h>
12 #include <soc/iomap.h>
14 #include <soc/pci_devs.h>
15 #include <soc/ramstage.h>
21 * +--------------------------+ BMBOUND_HI
23 * +--------------------------+ 4GiB
24 * | PCI Address Space |
25 * +--------------------------+ BMBOUND
27 * +--------------------------+ IMR2
29 * +--------------------------+ IMR1
31 * +--------------------------+
33 * +--------------------------+ SMMRRH, IRM0
35 * +--------------------------+ SMMRRL
37 * +--------------------------+ 0
39 * Note that there are really only a few regions that need to enumerated w.r.t.
40 * coreboot's resource model:
42 * +--------------------------+ BMBOUND_HI
43 * | Cacheable/Usable |
44 * +--------------------------+ 4GiB
46 * +--------------------------+ BMBOUND
47 * | Uncacheable/Reserved |
48 * +--------------------------+ SMMRRH
49 * | Cacheable/Reserved |
50 * +--------------------------+ SMMRRL
51 * | Cacheable/Usable |
52 * +--------------------------+ 0
54 uint32_t nc_read_top_of_low_memory(void)
61 tolm
= iosf_bunit_read(BUNIT_BMBOUND
) & ~((1 << 27) - 1);
66 static void nc_read_resources(struct device
*dev
)
75 uint64_t fsp_res_base
;
76 void *fsp_reserved_memory_area
;
79 /* Read standard PCI resources. */
80 pci_dev_read_resources(dev
);
82 /* Determine TSEG data */
83 smm_region(&smm_base
, &smm_size
);
85 tseg_top
= tseg_base
+ smm_size
;
87 /* Determine the base of the FSP reserved memory */
88 fsp_reserved_memory_area
= cbmem_find(CBMEM_ID_FSP_RESERVED_MEMORY
);
89 if (fsp_reserved_memory_area
) {
90 fsp_res_base
= (uintptr_t)fsp_reserved_memory_area
;
92 /* If no FSP reserved area */
93 fsp_res_base
= tseg_base
;
96 /* PCIe memory-mapped config space access - 256 MiB. */
97 mmconf
= iosf_bunit_read(BUNIT_MMCONF_REG
) & ~((1 << 28) - 1);
98 mmio_range(dev
, BUNIT_MMCONF_REG
, mmconf
, CONFIG_ECAM_MMCONF_BUS_NUMBER
* MiB
);
101 ram_from_to(dev
, index
++, 0, 0xa0000);
103 /* High memory -> fsp_res_base - cacheable and usable */
104 ram_from_to(dev
, index
++, 1 * MiB
, fsp_res_base
);
106 /* fsp_res_base -> tseg_top - Reserved */
107 reserved_ram_from_to(dev
, index
++, fsp_res_base
, tseg_top
);
109 /* TSEG TOP -> bmbound is memory backed mmio. */
110 bmbound
= nc_read_top_of_low_memory();
111 mmio_from_to(dev
, index
++, tseg_top
, bmbound
);
114 * The BMBOUND_HI register matches register bits of 31:24 with address
115 * bits of 35:28. Therefore, shift register to align properly.
117 bmbound_hi
= iosf_bunit_read(BUNIT_BMBOUND_HI
) & ~((1 << 24) - 1);
119 upper_ram_end(dev
, index
++, bmbound_hi
);
122 * Reserve everything between A segment and 1MB:
124 * 0xa0000 - 0xbffff: legacy VGA
125 * 0xc0000 - 0xfffff: RAM
127 mmio_from_to(dev
, index
++, 0xa0000, 0xc0000);
128 reserved_ram_from_to(dev
, index
++, 0xc0000, 1 * MiB
);
133 mmio_range(dev
, index
++, LAPIC_DEFAULT_BASE
, 1 * MiB
);
136 static void nc_generate_ssdt(const struct device
*dev
)
138 generate_cpu_entries(dev
);
140 acpigen_write_scope("\\");
141 acpigen_write_name_dword("TOLM", nc_read_top_of_low_memory());
145 static struct device_operations nc_ops
= {
146 .read_resources
= nc_read_resources
,
147 .acpi_fill_ssdt
= nc_generate_ssdt
,
148 .ops_pci
= &soc_pci_ops
,
151 static const struct pci_driver nc_driver __pci_driver
= {
153 .vendor
= PCI_VID_INTEL
,