mtk_apusys.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (c) 2021, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <drivers/console.h>
  8. #include <lib/mmio.h>
  9. #include <apupwr_clkctl.h>
  10. #include <mtk_apusys.h>
  11. #include <plat/common/platform.h>
  12. int32_t apusys_kernel_ctrl(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4,
  13. uint32_t *ret1)
  14. {
  15. int32_t ret = 0L;
  16. uint32_t request_ops;
  17. request_ops = (uint32_t)x1;
  18. switch (request_ops) {
  19. case MTK_SIP_APU_START_MCU:
  20. /* setup addr[33:32] in reviser */
  21. mmio_write_32(REVISER_SECUREFW_CTXT, 0U);
  22. mmio_write_32(REVISER_USDRFW_CTXT, 0U);
  23. /* setup secure sideband */
  24. mmio_write_32(AO_SEC_FW,
  25. (SEC_FW_NON_SECURE << SEC_FW_SHIFT_NS) |
  26. (0U << SEC_FW_DOMAIN_SHIFT));
  27. /* setup boot address */
  28. mmio_write_32(AO_MD32_BOOT_CTRL, 0U);
  29. /* setup pre-define region */
  30. mmio_write_32(AO_MD32_PRE_DEFINE,
  31. (PRE_DEFINE_CACHE_TCM << PRE_DEFINE_SHIFT_0G) |
  32. (PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_1G) |
  33. (PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_2G) |
  34. (PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_3G));
  35. /* release runstall */
  36. mmio_write_32(AO_MD32_SYS_CTRL, SYS_CTRL_RUN);
  37. INFO("[APUSYS] rev(0x%08x,0x%08x)\n",
  38. mmio_read_32(REVISER_SECUREFW_CTXT),
  39. mmio_read_32(REVISER_USDRFW_CTXT));
  40. INFO("[APUSYS] ao(0x%08x,0x%08x,0x%08x,0x%08x,0x%08x)\n",
  41. mmio_read_32(AO_SEC_FW),
  42. mmio_read_32(AO_SEC_USR_FW),
  43. mmio_read_32(AO_MD32_BOOT_CTRL),
  44. mmio_read_32(AO_MD32_PRE_DEFINE),
  45. mmio_read_32(AO_MD32_SYS_CTRL));
  46. break;
  47. case MTK_SIP_APU_STOP_MCU:
  48. /* hold runstall */
  49. mmio_write_32(AO_MD32_SYS_CTRL, SYS_CTRL_STALL);
  50. INFO("[APUSYS] md32_boot_ctrl=0x%08x,runstall=0x%08x\n",
  51. mmio_read_32(AO_MD32_BOOT_CTRL),
  52. mmio_read_32(AO_MD32_SYS_CTRL));
  53. break;
  54. case MTK_SIP_APUPWR_BUS_PROT_CG_ON:
  55. apupwr_smc_bus_prot_cg_on();
  56. break;
  57. case MTK_SIP_APUPWR_BULK_PLL:
  58. ret = apupwr_smc_bulk_pll((bool)x2);
  59. break;
  60. case MTK_SIP_APUPWR_ACC_INIT_ALL:
  61. ret = apupwr_smc_acc_init_all();
  62. break;
  63. case MTK_SIP_APUPWR_ACC_TOP:
  64. apupwr_smc_acc_top((bool)x2);
  65. break;
  66. default:
  67. ERROR("%s, unknown request_ops=0x%x\n", __func__, request_ops);
  68. break;
  69. }
  70. return ret;
  71. }