Xeon-SP boards: Factor out OCP VPD `get_cxl_mode()` impl
[coreboot2.git] / src / device / cpu_device.c
blobbe28ff64dce14f4decabc55931aefc8c1b3bc029
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/device.h>
4 #include <console/console.h>
5 #include <stddef.h>
7 struct device *add_cpu_device(struct bus *cpu_bus, unsigned int apic_id,
8 int enabled)
10 struct device_path cpu_path = {};
11 struct device *cpu;
13 /* Build the CPU device path */
14 cpu_path.type = DEVICE_PATH_APIC;
15 cpu_path.apic.apic_id = apic_id;
16 cpu_path.apic.initial_lapicid = apic_id;
18 /* Update CPU in devicetree. */
19 if (enabled)
20 cpu = alloc_find_dev(cpu_bus, &cpu_path);
21 else
22 cpu = find_dev_path(cpu_bus, &cpu_path);
23 if (!cpu)
24 return NULL;
26 cpu->enabled = enabled;
27 printk(BIOS_DEBUG, "CPU: %s %s\n",
28 dev_path(cpu), cpu->enabled?"enabled":"disabled");
30 return cpu;