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 <asm/cpu.h> 12 #include <asm/fw_cfg.h> 13 14 DECLARE_GLOBAL_DATA_PTR; 15 16 int cpu_qemu_bind(struct udevice *dev) 17 { 18 struct cpu_platdata *plat = dev_get_parent_platdata(dev); 19 20 plat->cpu_id = fdtdec_get_int(gd->fdt_blob, dev->of_offset, 21 "intel,apic-id", -1); 22 23 return 0; 24 } 25 26 int cpu_qemu_get_desc(struct udevice *dev, char *buf, int size) 27 { 28 if (size < CPU_MAX_NAME_LEN) 29 return -ENOSPC; 30 31 cpu_get_name(buf); 32 33 return 0; 34 } 35 36 static int cpu_qemu_get_count(struct udevice *dev) 37 { 38 return qemu_fwcfg_online_cpus(); 39 } 40 41 static const struct cpu_ops cpu_qemu_ops = { 42 .get_desc = cpu_qemu_get_desc, 43 .get_count = cpu_qemu_get_count, 44 }; 45 46 static const struct udevice_id cpu_qemu_ids[] = { 47 { .compatible = "cpu-qemu" }, 48 { } 49 }; 50 51 U_BOOT_DRIVER(cpu_qemu_drv) = { 52 .name = "cpu_qemu", 53 .id = UCLASS_CPU, 54 .of_match = cpu_qemu_ids, 55 .bind = cpu_qemu_bind, 56 .ops = &cpu_qemu_ops, 57 }; 58