xref: /openbmc/u-boot/arch/x86/cpu/qemu/cpu.c (revision 3559028c)
1 /*
2  * Copyright (C) 2015, Miao Yan <yanmiaobest@gmail.com>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <cpu.h>
9 #include <dm.h>
10 #include <errno.h>
11 #include <qfw.h>
12 #include <asm/cpu.h>
13 
14 int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size)
15 {
16 	if (size < CPU_MAX_NAME_LEN)
17 		return -ENOSPC;
18 
19 	cpu_get_name(buf);
20 
21 	return 0;
22 }
23 
24 static int cpu_qemu_get_count(struct udevice *dev)
25 {
26 	return qemu_fwcfg_online_cpus();
27 }
28 
29 static const struct cpu_ops cpu_qemu_ops = {
30 	.get_desc	= cpu_qemu_get_desc,
31 	.get_count	= cpu_qemu_get_count,
32 };
33 
34 static const struct udevice_id cpu_qemu_ids[] = {
35 	{ .compatible = "cpu-qemu" },
36 	{ }
37 };
38 
39 U_BOOT_DRIVER(cpu_qemu_drv) = {
40 	.name		= "cpu_qemu",
41 	.id		= UCLASS_CPU,
42 	.of_match	= cpu_qemu_ids,
43 	.ops		= &cpu_qemu_ops,
44 };
45