soc/intel/xeon_sp: Add device to proximity domain map utils

In NUMA architecture, all devices (cpu, memory and PCI device)
belong to specific proximity domain. Add utils to map device
instance to their proximity domain.

Proximity domain ID is the index assigned at the creation of
proximity domains. There is no hard relationship between proximity
domain ID and the device identities (e.g. socket ID). Hence we
need the map utils to explicitly link them.

For now the Sub-NUMA config isn't taken into account.

TEST=Build and boot on intel/archercity CRB

Change-Id: Icd14a98823491ccfc38473e44a26dddfbbcaa7c0
Signed-off-by: Shuo Liu <shuo.liu@intel.com>
Co-authored-by: Ziang Wang <ziang.wang@intel.com>
Co-authored-by: Gang Chen <gang.c.chen@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81440
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/soc/intel/xeon_sp/uncore_acpi.c b/src/soc/intel/xeon_sp/uncore_acpi.c
index bcfb4da..c9e8ccb 100644
--- a/src/soc/intel/xeon_sp/uncore_acpi.c
+++ b/src/soc/intel/xeon_sp/uncore_acpi.c
@@ -60,16 +60,16 @@
 
 		if (is_x2apic_mode()) {
 			printk(BIOS_DEBUG, "SRAT: x2apic cpu_index=%04x, node_id=%02x, apic_id=%08x\n",
-			       i, cpu->path.apic.node_id, cpu->path.apic.apic_id);
+			       i, device_to_pd(cpu), cpu->path.apic.apic_id);
 
 			current += acpi_create_srat_x2apic((acpi_srat_x2apic_t *)current,
-				cpu->path.apic.node_id, cpu->path.apic.apic_id);
+				device_to_pd(cpu), cpu->path.apic.apic_id);
 		} else {
 			printk(BIOS_DEBUG, "SRAT: lapic cpu_index=%02x, node_id=%02x, apic_id=%02x\n",
-			       i, cpu->path.apic.node_id, cpu->path.apic.apic_id);
+			       i, device_to_pd(cpu), cpu->path.apic.apic_id);
 
 			current += acpi_create_srat_lapic((acpi_srat_lapic_t *)current,
-				cpu->path.apic.node_id, cpu->path.apic.apic_id);
+				device_to_pd(cpu), cpu->path.apic.apic_id);
 		}
 	}
 	return current;
@@ -129,7 +129,7 @@
 		srat_mem[mmap_index].base_address_high = (uint32_t)(addr >> 32);
 		srat_mem[mmap_index].length_low = (uint32_t)(size & 0xffffffff);
 		srat_mem[mmap_index].length_high = (uint32_t)(size >> 32);
-		srat_mem[mmap_index].proximity_domain = mem_element->SocketId;
+		srat_mem[mmap_index].proximity_domain = memory_to_pd(mem_element);
 		srat_mem[mmap_index].flags = ACPI_SRAT_MEMORY_ENABLED;
 		if (is_memtype_non_volatile(mem_element->Type))
 			srat_mem[mmap_index].flags |= ACPI_SRAT_MEMORY_NONVOLATILE;
@@ -445,7 +445,6 @@
 {
 	struct device *dev = NULL;
 	struct resource *resource;
-	int socket;
 
 	while ((dev = dev_find_device(PCI_VID_INTEL, MMAP_VTD_CFG_REG_DEVID, dev))) {
 		/* See if there is a resource with the appropriate index. */
@@ -453,11 +452,9 @@
 		if (!resource)
 			continue;
 
-		socket = iio_pci_domain_socket_from_dev(dev);
-
 		printk(BIOS_DEBUG, "[Remapping Hardware Static Affinity] Base Address: %p, "
-			"Proximity Domain: 0x%x\n", res2mmio(resource, 0, 0), socket);
-		current += acpi_create_dmar_rhsa(current, (uintptr_t)res2mmio(resource, 0, 0), socket);
+			"Proximity Domain: 0x%x\n", res2mmio(resource, 0, 0), device_to_pd(dev));
+		current += acpi_create_dmar_rhsa(current, (uintptr_t)res2mmio(resource, 0, 0), device_to_pd(dev));
 	}
 
 	return current;