dfd.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch_helpers.h>
  7. #include <common/debug.h>
  8. #include <lib/mmio.h>
  9. #include <dfd.h>
  10. #include <mtk_sip_svc.h>
  11. #include <plat_dfd.h>
  12. static u_register_t dfd_smc_dispatcher(u_register_t arg0, u_register_t arg1,
  13. u_register_t arg2, u_register_t arg3,
  14. void *handle, struct smccc_res *smccc_ret)
  15. {
  16. int ret = MTK_SIP_E_SUCCESS;
  17. switch (arg0) {
  18. case PLAT_MTK_DFD_SETUP_MAGIC:
  19. INFO("[%s] DFD setup call from kernel\n", __func__);
  20. dfd_setup(arg1, arg2, arg3);
  21. break;
  22. case PLAT_MTK_DFD_READ_MAGIC:
  23. /* only allow to access DFD register base + 0x200 */
  24. if (arg1 <= 0x200) {
  25. ret = mmio_read_32(MISC1_CFG_BASE + arg1);
  26. }
  27. break;
  28. case PLAT_MTK_DFD_WRITE_MAGIC:
  29. /* only allow to access DFD register base + 0x200 */
  30. if (arg1 <= 0x200) {
  31. sync_writel(MISC1_CFG_BASE + arg1, arg2);
  32. }
  33. break;
  34. default:
  35. ret = MTK_SIP_E_INVALID_PARAM;
  36. break;
  37. }
  38. return ret;
  39. }
  40. DECLARE_SMC_HANDLER(MTK_SIP_KERNEL_DFD, dfd_smc_dispatcher);