mt_dp.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2020-2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <inttypes.h>
  7. #include <common/debug.h>
  8. #include <lib/mmio.h>
  9. #include <mt_dp.h>
  10. #include <mtk_sip_svc.h>
  11. #include <platform_def.h>
  12. static uint32_t dp_write_sec_reg(uint32_t is_edp, uint32_t offset,
  13. uint32_t value, uint32_t mask)
  14. {
  15. uint32_t reg = (is_edp != 0U) ? EDP_SEC_BASE : DP_SEC_BASE;
  16. mmio_clrsetbits_32(reg + offset, mask, value);
  17. return mmio_read_32(reg + offset);
  18. }
  19. int32_t dp_secure_handler(uint64_t cmd, uint64_t para, uint32_t *val)
  20. {
  21. int32_t ret = 0L;
  22. uint32_t is_edp = 0UL;
  23. uint32_t regval = 0UL;
  24. uint32_t regmsk = 0UL;
  25. uint32_t fldmask = 0UL;
  26. if ((cmd > DP_ATF_CMD_COUNT) || (val == NULL)) {
  27. INFO("dp_secure_handler error cmd 0x%" PRIx64 "\n", cmd);
  28. return MTK_SIP_E_INVALID_PARAM;
  29. }
  30. switch (cmd) {
  31. case DP_ATF_DP_VIDEO_UNMUTE:
  32. INFO("[%s] DP_ATF_DP_VIDEO_UNMUTE\n", __func__);
  33. is_edp = DP_ATF_TYPE_DP;
  34. ret = MTK_SIP_E_SUCCESS;
  35. break;
  36. case DP_ATF_EDP_VIDEO_UNMUTE:
  37. INFO("[%s] DP_ATF_EDP_VIDEO_UNMUTE\n", __func__);
  38. is_edp = DP_ATF_TYPE_EDP;
  39. ret = MTK_SIP_E_SUCCESS;
  40. break;
  41. default:
  42. ret = MTK_SIP_E_INVALID_PARAM;
  43. break;
  44. }
  45. if (ret == MTK_SIP_E_SUCCESS) {
  46. regmsk = (VIDEO_MUTE_SEL_SECURE_FLDMASK |
  47. VIDEO_MUTE_SW_SECURE_FLDMASK);
  48. if (para > 0U) {
  49. fldmask = VIDEO_MUTE_SW_SECURE_FLDMASK;
  50. } else {
  51. fldmask = 0;
  52. }
  53. regval = (VIDEO_MUTE_SEL_SECURE_FLDMASK | fldmask);
  54. *val = dp_write_sec_reg(is_edp, DP_TX_SECURE_REG11,
  55. regval, regmsk);
  56. }
  57. return ret;
  58. }
  59. u_register_t mtk_dp_sip_handler(u_register_t x1, u_register_t x2,
  60. u_register_t x3, u_register_t x4,
  61. void *handle, struct smccc_res *smccc_ret)
  62. {
  63. uint32_t ret_val;
  64. return dp_secure_handler(x1, x2, &ret_val);
  65. }
  66. DECLARE_SMC_HANDLER(MTK_SIP_DP_CONTROL, mtk_dp_sip_handler);