thermal_sandbox.c 756 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (c) 2022 Sartura Ltd.
  4. * Written by Robert Marko <robert.marko@sartura.hr>
  5. *
  6. * Sandbox driver for the thermal uclass.
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <thermal.h>
  11. int sandbox_thermal_get_temp(struct udevice *dev, int *temp)
  12. {
  13. /* Simply return 100°C */
  14. *temp = 100;
  15. return 0;
  16. }
  17. static const struct dm_thermal_ops sandbox_thermal_ops = {
  18. .get_temp = sandbox_thermal_get_temp,
  19. };
  20. static const struct udevice_id sandbox_thermal_ids[] = {
  21. { .compatible = "sandbox,thermal" },
  22. { }
  23. };
  24. U_BOOT_DRIVER(thermal_sandbox) = {
  25. .name = "thermal-sandbox",
  26. .id = UCLASS_THERMAL,
  27. .of_match = sandbox_thermal_ids,
  28. .ops = &sandbox_thermal_ops,
  29. .flags = DM_FLAG_PRE_RELOC,
  30. };