1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
11 #include <asm/global_data.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 int cpu_x86_bind(struct udevice *dev)
17 struct cpu_plat *plat = dev_get_parent_plat(dev);
18 struct cpuid_result res;
20 plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
22 plat->family = gd->arch.x86;
24 plat->id[0] = res.eax;
25 plat->id[1] = res.edx;
30 int cpu_x86_get_vendor(const struct udevice *dev, char *buf, int size)
32 const char *vendor = cpu_vendor_name(gd->arch.x86_vendor);
34 if (size < (strlen(vendor) + 1))
42 int cpu_x86_get_desc(const struct udevice *dev, char *buf, int size)
46 if (size < CPU_MAX_NAME_LEN)
49 ptr = cpu_get_name(buf);
56 int cpu_x86_get_count(const struct udevice *dev)
61 node = fdt_path_offset(gd->fdt_blob, "/cpus");
65 for (cpu = fdt_first_subnode(gd->fdt_blob, node);
67 cpu = fdt_next_subnode(gd->fdt_blob, cpu)) {
68 const char *device_type;
70 device_type = fdt_getprop(gd->fdt_blob, cpu,
74 if (strcmp(device_type, "cpu") == 0)
81 static const struct cpu_ops cpu_x86_ops = {
82 .get_desc = cpu_x86_get_desc,
83 .get_count = cpu_x86_get_count,
84 .get_vendor = cpu_x86_get_vendor,
87 static const struct udevice_id cpu_x86_ids[] = {
88 { .compatible = "cpu-x86" },
92 U_BOOT_DRIVER(cpu_x86_drv) = {
95 .of_match = cpu_x86_ids,
98 .flags = DM_FLAG_PRE_RELOC,