cpu.c 797 B

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