cpu_sandbox.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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(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(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(struct udevice *dev)
  22. {
  23. return 42;
  24. }
  25. int cpu_sandbox_get_vendor(struct udevice *dev, char *buf, int size)
  26. {
  27. snprintf(buf, size, "Languid Example Garbage Inc.");
  28. return 0;
  29. }
  30. static const struct cpu_ops cpu_sandbox_ops = {
  31. .get_desc = cpu_sandbox_get_desc,
  32. .get_info = cpu_sandbox_get_info,
  33. .get_count = cpu_sandbox_get_count,
  34. .get_vendor = cpu_sandbox_get_vendor,
  35. };
  36. int cpu_sandbox_probe(struct udevice *dev)
  37. {
  38. return 0;
  39. }
  40. static const struct udevice_id cpu_sandbox_ids[] = {
  41. { .compatible = "sandbox,cpu_sandbox" },
  42. { }
  43. };
  44. U_BOOT_DRIVER(cpu_sandbox) = {
  45. .name = "cpu_sandbox",
  46. .id = UCLASS_CPU,
  47. .ops = &cpu_sandbox_ops,
  48. .of_match = cpu_sandbox_ids,
  49. .probe = cpu_sandbox_probe,
  50. };