thermal.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. /* Driver for thermal unit located in Marvell ARMADA 8K and compatible SoCs */
  8. #include <common/debug.h>
  9. #include <drivers/marvell/thermal.h>
  10. int marvell_thermal_init(struct tsen_config *tsen_cfg)
  11. {
  12. if (tsen_cfg->tsen_ready == 1) {
  13. INFO("thermal sensor is already initialized\n");
  14. return 0;
  15. }
  16. if (tsen_cfg->ptr_tsen_probe == NULL) {
  17. ERROR("initial thermal sensor configuration is missing\n");
  18. return -1;
  19. }
  20. if (tsen_cfg->ptr_tsen_probe(tsen_cfg)) {
  21. ERROR("thermal sensor initialization failed\n");
  22. return -1;
  23. }
  24. VERBOSE("thermal sensor was initialized\n");
  25. return 0;
  26. }
  27. int marvell_thermal_read(struct tsen_config *tsen_cfg, int *temp)
  28. {
  29. if (temp == NULL) {
  30. ERROR("NULL pointer for temperature read\n");
  31. return -1;
  32. }
  33. if (tsen_cfg->ptr_tsen_read == NULL ||
  34. tsen_cfg->tsen_ready == 0) {
  35. ERROR("thermal sensor was not initialized\n");
  36. return -1;
  37. }
  38. if (tsen_cfg->ptr_tsen_read(tsen_cfg, temp)) {
  39. ERROR("temperature read failed\n");
  40. return -1;
  41. }
  42. return 0;
  43. }