blob: 0708a380626f296caaf86fe0f6a587c1c0fdaa01 [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
Miao Yan4336af62016-01-07 01:32:01 -08006#include <cpu.h>
7#include <dm.h>
8#include <errno.h>
Miao Yan92106272016-05-22 19:37:17 -07009#include <qfw.h>
Miao Yan4336af62016-01-07 01:32:01 -080010#include <asm/cpu.h>
Miao Yan4336af62016-01-07 01:32:01 -080011
Simon Glass791fa452020-01-26 22:06:27 -070012int cpu_qemu_get_desc(const struct udevice *dev, char *buf, int size)
Miao Yan4336af62016-01-07 01:32:01 -080013{
14 if (size < CPU_MAX_NAME_LEN)
15 return -ENOSPC;
16
17 cpu_get_name(buf);
18
19 return 0;
20}
21
Simon Glass791fa452020-01-26 22:06:27 -070022static int cpu_qemu_get_count(const struct udevice *dev)
Miao Yan4336af62016-01-07 01:32:01 -080023{
Asherah Connor4ffa95d2021-03-19 18:21:40 +110024 int ret;
25 struct udevice *qfw_dev;
26
27 ret = qfw_get_dev(&qfw_dev);
28 if (ret)
29 return ret;
30
31 return qfw_online_cpus(qfw_dev);
Miao Yan4336af62016-01-07 01:32:01 -080032}
33
34static const struct cpu_ops cpu_qemu_ops = {
35 .get_desc = cpu_qemu_get_desc,
36 .get_count = cpu_qemu_get_count,
37};
38
39static const struct udevice_id cpu_qemu_ids[] = {
40 { .compatible = "cpu-qemu" },
41 { }
42};
43
44U_BOOT_DRIVER(cpu_qemu_drv) = {
45 .name = "cpu_qemu",
46 .id = UCLASS_CPU,
47 .of_match = cpu_qemu_ids,
Miao Yan4336af62016-01-07 01:32:01 -080048 .ops = &cpu_qemu_ops,
49};