cpu-uclass.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2015 Google, Inc
  3. * Written by Simon Glass <sjg@chromium.org>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <cpu.h>
  9. #include <dm.h>
  10. #include <errno.h>
  11. #include <dm/lists.h>
  12. #include <dm/root.h>
  13. int cpu_get_desc(struct udevice *dev, char *buf, int size)
  14. {
  15. struct cpu_ops *ops = cpu_get_ops(dev);
  16. if (!ops->get_desc)
  17. return -ENOSYS;
  18. return ops->get_desc(dev, buf, size);
  19. }
  20. int cpu_get_info(struct udevice *dev, struct cpu_info *info)
  21. {
  22. struct cpu_ops *ops = cpu_get_ops(dev);
  23. if (!ops->get_info)
  24. return -ENOSYS;
  25. return ops->get_info(dev, info);
  26. }
  27. U_BOOT_DRIVER(cpu_bus) = {
  28. .name = "cpu_bus",
  29. .id = UCLASS_SIMPLE_BUS,
  30. .per_child_platdata_auto_alloc_size = sizeof(struct cpu_platdata),
  31. };
  32. static int uclass_cpu_init(struct uclass *uc)
  33. {
  34. struct udevice *dev;
  35. int node;
  36. int ret;
  37. node = fdt_path_offset(gd->fdt_blob, "/cpus");
  38. if (node < 0)
  39. return 0;
  40. ret = device_bind_driver_to_node(dm_root(), "cpu_bus", "cpus", node,
  41. &dev);
  42. return ret;
  43. }
  44. UCLASS_DRIVER(cpu) = {
  45. .id = UCLASS_CPU,
  46. .name = "cpu",
  47. .flags = DM_UC_FLAG_SEQ_ALIAS,
  48. .init = uclass_cpu_init,
  49. };