Angel Pons | c74dae9 | 2020-04-02 23:48:16 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 2 | |
| 3 | #include <device/device.h> |
| 4 | #include <console/console.h> |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 5 | |
Elyes HAOUAS | 8cf8a63 | 2019-06-09 10:23:25 +0200 | [diff] [blame] | 6 | struct device *add_cpu_device(struct bus *cpu_bus, unsigned int apic_id, |
Elyes HAOUAS | e348066 | 2018-05-06 20:32:23 +0200 | [diff] [blame] | 7 | int enabled) |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 8 | { |
| 9 | struct device_path cpu_path; |
Elyes HAOUAS | e348066 | 2018-05-06 20:32:23 +0200 | [diff] [blame] | 10 | struct device *cpu; |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 11 | |
Elyes HAOUAS | fa640a2 | 2016-07-28 21:31:40 +0200 | [diff] [blame] | 12 | /* Build the CPU device path */ |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 13 | cpu_path.type = DEVICE_PATH_APIC; |
| 14 | cpu_path.apic.apic_id = apic_id; |
| 15 | |
| 16 | /* Update CPU in devicetree. */ |
| 17 | if (enabled) |
| 18 | cpu = alloc_find_dev(cpu_bus, &cpu_path); |
| 19 | else |
| 20 | cpu = find_dev_path(cpu_bus, &cpu_path); |
| 21 | if (!cpu) |
| 22 | return NULL; |
| 23 | |
| 24 | cpu->enabled = enabled; |
| 25 | printk(BIOS_DEBUG, "CPU: %s %s\n", |
| 26 | dev_path(cpu), cpu->enabled?"enabled":"disabled"); |
| 27 | |
| 28 | return cpu; |
| 29 | } |
| 30 | |
Elyes HAOUAS | 8cf8a63 | 2019-06-09 10:23:25 +0200 | [diff] [blame] | 31 | void set_cpu_topology(struct device *cpu, unsigned int node, |
| 32 | unsigned int package, unsigned int core, |
| 33 | unsigned int thread) |
Kyösti Mälkki | c33f1e9 | 2012-08-07 17:12:11 +0300 | [diff] [blame] | 34 | { |
| 35 | cpu->path.apic.node_id = node; |
| 36 | cpu->path.apic.package_id = package; |
| 37 | cpu->path.apic.core_id = core; |
| 38 | cpu->path.apic.thread_id = thread; |
| 39 | } |