cpu_sandbox.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2018
  4. * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <cpu.h>
  9. int cpu_sandbox_get_desc(const struct udevice *dev, char *buf, int size)
  10. {
  11. snprintf(buf, size, "LEG Inc. SuperMegaUltraTurbo CPU No. 1");
  12. return 0;
  13. }
  14. int cpu_sandbox_get_info(const struct udevice *dev, struct cpu_info *info)
  15. {
  16. info->cpu_freq = 42 * 42 * 42 * 42 * 42;
  17. info->features = 0x42424242;
  18. info->address_width = IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32;
  19. return 0;
  20. }
  21. int cpu_sandbox_get_count(const struct udevice *dev)
  22. {
  23. return 42;
  24. }
  25. int cpu_sandbox_get_vendor(const struct udevice *dev, char *buf, int size)
  26. {
  27. snprintf(buf, size, "Languid Example Garbage Inc.");
  28. return 0;
  29. }
  30. int cpu_sandbox_is_current(struct udevice *dev)
  31. {
  32. if (!strcmp(dev->name, "cpu-test1"))
  33. return 1;
  34. return 0;
  35. }
  36. static const struct cpu_ops cpu_sandbox_ops = {
  37. .get_desc = cpu_sandbox_get_desc,
  38. .get_info = cpu_sandbox_get_info,
  39. .get_count = cpu_sandbox_get_count,
  40. .get_vendor = cpu_sandbox_get_vendor,
  41. .is_current = cpu_sandbox_is_current,
  42. };
  43. int cpu_sandbox_probe(struct udevice *dev)
  44. {
  45. return 0;
  46. }
  47. static const struct udevice_id cpu_sandbox_ids[] = {
  48. { .compatible = "sandbox,cpu_sandbox" },
  49. { }
  50. };
  51. U_BOOT_DRIVER(cpu_sandbox) = {
  52. .name = "cpu_sandbox",
  53. .id = UCLASS_CPU,
  54. .ops = &cpu_sandbox_ops,
  55. .of_match = cpu_sandbox_ids,
  56. .probe = cpu_sandbox_probe,
  57. };