scmi_rstd.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2024, Rockchip, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <drivers/scmi-msg.h>
  7. #include <drivers/scmi.h>
  8. #include "scmi_rstd.h"
  9. #pragma weak rockchip_scmi_rstd_count
  10. #pragma weak rockchip_scmi_get_rstd
  11. size_t rockchip_scmi_rstd_count(unsigned int agent_id __unused)
  12. {
  13. return 0U;
  14. }
  15. rk_scmi_rstd_t *rockchip_scmi_get_rstd(unsigned int agent_id __unused,
  16. unsigned int scmi_id __unused)
  17. {
  18. return NULL;
  19. }
  20. size_t plat_scmi_rstd_count(unsigned int agent_id)
  21. {
  22. return rockchip_scmi_rstd_count(agent_id);
  23. }
  24. const char *plat_scmi_rstd_get_name(unsigned int agent_id,
  25. unsigned int scmi_id)
  26. {
  27. rk_scmi_rstd_t *rstd;
  28. rstd = rockchip_scmi_get_rstd(agent_id, scmi_id);
  29. if (rstd == NULL)
  30. return NULL;
  31. return rstd->name;
  32. }
  33. int32_t plat_scmi_rstd_autonomous(unsigned int agent_id,
  34. unsigned int scmi_id,
  35. unsigned int state)
  36. {
  37. rk_scmi_rstd_t *rstd;
  38. rstd = rockchip_scmi_get_rstd(agent_id, scmi_id);
  39. if (rstd == NULL)
  40. return SCMI_NOT_FOUND;
  41. if ((rstd->rstd_ops && rstd->rstd_ops->reset_auto) != 0)
  42. return rstd->rstd_ops->reset_auto(rstd, state);
  43. else
  44. return SCMI_NOT_SUPPORTED;
  45. }
  46. int32_t plat_scmi_rstd_set_state(unsigned int agent_id,
  47. unsigned int scmi_id,
  48. bool assert_not_deassert)
  49. {
  50. rk_scmi_rstd_t *rstd;
  51. rstd = rockchip_scmi_get_rstd(agent_id, scmi_id);
  52. if (rstd == NULL)
  53. return SCMI_NOT_FOUND;
  54. if ((rstd->rstd_ops && rstd->rstd_ops->reset_explicit) != 0)
  55. return rstd->rstd_ops->reset_explicit(rstd,
  56. assert_not_deassert);
  57. else
  58. return SCMI_NOT_SUPPORTED;
  59. }