blob: 9ce86b379c4dd72a58c610f911806ac3f1190672 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Miao Yan4336af62016-01-07 01:32:01 -08002/*
3 * Copyright (C) 2015, Miao Yan <yanmiaobest@gmail.com>
Miao Yan4336af62016-01-07 01:32:01 -08004 */
5
6#include <common.h>
7#include <cpu.h>
8#include <dm.h>
9#include <errno.h>
Miao Yan92106272016-05-22 19:37:17 -070010#include <qfw.h>
Miao Yan4336af62016-01-07 01:32:01 -080011#include <asm/cpu.h>
Miao Yan4336af62016-01-07 01:32:01 -080012
Simon Glass791fa452020-01-26 22:06:27 -070013int cpu_qemu_get_desc(const struct udevice *dev, char *buf, int size)
Miao Yan4336af62016-01-07 01:32:01 -080014{
15 if (size < CPU_MAX_NAME_LEN)
16 return -ENOSPC;
17
18 cpu_get_name(buf);
19
20 return 0;
21}
22
Simon Glass791fa452020-01-26 22:06:27 -070023static int cpu_qemu_get_count(const struct udevice *dev)
Miao Yan4336af62016-01-07 01:32:01 -080024{
25 return qemu_fwcfg_online_cpus();
26}
27
28static const struct cpu_ops cpu_qemu_ops = {
29 .get_desc = cpu_qemu_get_desc,
30 .get_count = cpu_qemu_get_count,
31};
32
33static const struct udevice_id cpu_qemu_ids[] = {
34 { .compatible = "cpu-qemu" },
35 { }
36};
37
38U_BOOT_DRIVER(cpu_qemu_drv) = {
39 .name = "cpu_qemu",
40 .id = UCLASS_CPU,
41 .of_match = cpu_qemu_ids,
Miao Yan4336af62016-01-07 01:32:01 -080042 .ops = &cpu_qemu_ops,
43};