blob: b1a965e7156d227e79af60eec90312de4780e780 [file] [log] [blame]
Miao Yan4336af62016-01-07 01:32:01 -08001/*
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>
Miao Yan92106272016-05-22 19:37:17 -070011#include <qfw.h>
Miao Yan4336af62016-01-07 01:32:01 -080012#include <asm/cpu.h>
Miao Yan4336af62016-01-07 01:32:01 -080013
14DECLARE_GLOBAL_DATA_PTR;
15
Miao Yan4336af62016-01-07 01:32:01 -080016int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size)
17{
18 if (size < CPU_MAX_NAME_LEN)
19 return -ENOSPC;
20
21 cpu_get_name(buf);
22
23 return 0;
24}
25
26static int cpu_qemu_get_count(struct udevice *dev)
27{
28 return qemu_fwcfg_online_cpus();
29}
30
31static const struct cpu_ops cpu_qemu_ops = {
32 .get_desc = cpu_qemu_get_desc,
33 .get_count = cpu_qemu_get_count,
34};
35
36static const struct udevice_id cpu_qemu_ids[] = {
37 { .compatible = "cpu-qemu" },
38 { }
39};
40
41U_BOOT_DRIVER(cpu_qemu_drv) = {
42 .name = "cpu_qemu",
43 .id = UCLASS_CPU,
44 .of_match = cpu_qemu_ids,
Miao Yan4336af62016-01-07 01:32:01 -080045 .ops = &cpu_qemu_ops,
46};