1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <acpi/acpigen.h>
5 #include <device/device.h>
6 #include <device/pci.h>
7 #include <device/pci_ids.h>
11 #include <soc/pci_devs.h>
12 #include <soc/ramstage.h>
17 * +--------------------------+ BMBOUND_HI
19 * +--------------------------+ 4GiB
20 * | PCI Address Space |
21 * +--------------------------+ BMBOUND
23 * +--------------------------+ IMR2
25 * +--------------------------+ IMR1
27 * +--------------------------+
29 * +--------------------------+ SMMRRH, IRM0
31 * +--------------------------+ SMMRRL
33 * +--------------------------+ 0
35 * Note that there are really only a few regions that need to enumerated w.r.t.
36 * coreboot's resource model:
38 * +--------------------------+ BMBOUND_HI
39 * | Cacheable/Usable |
40 * +--------------------------+ 4GiB
42 * +--------------------------+ BMBOUND
43 * | Uncacheable/Reserved |
44 * +--------------------------+ SMMRRH
45 * | Cacheable/Reserved |
46 * +--------------------------+ SMMRRL
47 * | Cacheable/Usable |
48 * +--------------------------+ 0
51 uint32_t nc_read_top_of_low_memory(void)
58 tolm
= iosf_bunit_read(BUNIT_BMBOUND
) & ~((1 << 27) - 1);
63 static void nc_read_resources(struct device
*dev
)
72 /* Read standard PCI resources. */
73 pci_dev_read_resources(dev
);
75 /* PCIe memory-mapped config space access - 256 MiB. */
76 mmconf
= iosf_bunit_read(BUNIT_MMCONF_REG
) & ~((1 << 28) - 1);
77 mmio_range(dev
, BUNIT_MMCONF_REG
, mmconf
, CONFIG_ECAM_MMCONF_BUS_NUMBER
* MiB
);
80 ram_from_to(dev
, index
++, 0, 0xa0000);
82 /* The SMMRR registers are 1MiB granularity with smmrrh being
83 * inclusive of the SMM region. */
84 smmrrl
= (iosf_bunit_read(BUNIT_SMRRL
) & 0xffff) * MiB
;
85 smmrrh
= ((iosf_bunit_read(BUNIT_SMRRH
) & 0xffff) + 1) * MiB
;
87 /* 0xc0000 -> smrrl - cacheable and usable */
88 ram_from_to(dev
, index
++, 0xc0000, smmrrl
);
91 reserved_ram_from_to(dev
, index
++, smmrrl
, smmrrh
);
93 /* All address space between bmbound and smmrrh is unusable. */
94 bmbound
= nc_read_top_of_low_memory();
95 mmio_from_to(dev
, index
++, smmrrh
, bmbound
);
98 * The BMBOUND_HI register matches register bits of 31:24 with address
99 * bits of 35:28. Therefore, shift register to align properly.
101 bmbound_hi
= iosf_bunit_read(BUNIT_BMBOUND_HI
) & ~((1 << 24) - 1);
103 upper_ram_end(dev
, index
++, bmbound_hi
);
106 * Reserve everything between A segment and 1MB:
108 * 0xa0000 - 0xbffff: legacy VGA
109 * 0xc0000 - 0xfffff: RAM
111 mmio_from_to(dev
, index
++, 0xa0000, 0xc0000);
112 reserved_ram_from_to(dev
, index
++, 0xc0000, 1 * MiB
);
115 static void nc_generate_ssdt(const struct device
*dev
)
117 generate_cpu_entries(dev
);
119 acpigen_write_scope("\\");
120 acpigen_write_name_dword("TOLM", nc_read_top_of_low_memory());
124 static struct device_operations nc_ops
= {
125 .read_resources
= nc_read_resources
,
126 .acpi_fill_ssdt
= nc_generate_ssdt
,
127 .ops_pci
= &soc_pci_ops
,
130 static const struct pci_driver nc_driver __pci_driver
= {
132 .vendor
= PCI_VID_INTEL
,