apusys.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2023, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /* TF-A system header */
  7. #include <common/debug.h>
  8. /* Vendor header */
  9. #include "apusys.h"
  10. #include "apusys_devapc.h"
  11. #include "apusys_power.h"
  12. #include "apusys_rv.h"
  13. #include "apusys_security_ctrl_plat.h"
  14. #include <lib/mtk_init/mtk_init.h>
  15. #include <mtk_sip_svc.h>
  16. static u_register_t apusys_kernel_handler(u_register_t x1,
  17. u_register_t x2,
  18. u_register_t x3,
  19. u_register_t x4,
  20. void *handle,
  21. struct smccc_res *smccc_ret)
  22. {
  23. uint32_t request_ops;
  24. int32_t ret = -1;
  25. request_ops = (uint32_t)x1;
  26. switch (request_ops) {
  27. case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_ON:
  28. ret = apusys_kernel_apusys_pwr_top_on();
  29. break;
  30. case MTK_APUSYS_KERNEL_OP_APUSYS_PWR_TOP_OFF:
  31. ret = apusys_kernel_apusys_pwr_top_off();
  32. break;
  33. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_SETUP_REVISER:
  34. ret = apusys_kernel_apusys_rv_setup_reviser();
  35. break;
  36. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_RESET_MP:
  37. ret = apusys_kernel_apusys_rv_reset_mp();
  38. break;
  39. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_SETUP_BOOT:
  40. ret = apusys_kernel_apusys_rv_setup_boot();
  41. break;
  42. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_START_MP:
  43. ret = apusys_kernel_apusys_rv_start_mp();
  44. break;
  45. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_STOP_MP:
  46. ret = apusys_kernel_apusys_rv_stop_mp();
  47. break;
  48. case MTK_APUSYS_KERNEL_OP_DEVAPC_INIT_RCX:
  49. ret = apusys_devapc_rcx_init();
  50. break;
  51. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_SETUP_SEC_MEM:
  52. ret = apusys_kernel_apusys_rv_setup_sec_mem();
  53. break;
  54. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_DISABLE_WDT_ISR:
  55. ret = apusys_kernel_apusys_rv_disable_wdt_isr();
  56. break;
  57. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_CLEAR_WDT_ISR:
  58. ret = apusys_kernel_apusys_rv_clear_wdt_isr();
  59. break;
  60. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_CG_GATING:
  61. ret = apusys_kernel_apusys_rv_cg_gating();
  62. break;
  63. case MTK_APUSYS_KERNEL_OP_APUSYS_RV_CG_UNGATING:
  64. ret = apusys_kernel_apusys_rv_cg_ungating();
  65. break;
  66. default:
  67. ERROR(MODULE_TAG "%s unknown request_ops = %x\n", MODULE_TAG, request_ops);
  68. break;
  69. }
  70. return ret;
  71. }
  72. DECLARE_SMC_HANDLER(MTK_SIP_APUSYS_CONTROL, apusys_kernel_handler);
  73. int apusys_init(void)
  74. {
  75. if (apusys_power_init() != 0) {
  76. return -1;
  77. }
  78. if (apusys_devapc_ao_init() != 0) {
  79. return -1;
  80. }
  81. apusys_security_ctrl_init();
  82. apusys_rv_mbox_mpu_init();
  83. return 0;
  84. }
  85. MTK_PLAT_SETUP_1_INIT(apusys_init);