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