mtk_apusys.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 <mtk_apusys.h>
  10. #include <plat/common/platform.h>
  11. uint64_t apusys_kernel_ctrl(uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4,
  12. uint32_t *ret1)
  13. {
  14. uint32_t request_ops;
  15. request_ops = (uint32_t)x1;
  16. INFO("[APUSYS] ops=0x%x\n", request_ops);
  17. switch (request_ops) {
  18. case MTK_SIP_APU_START_MCU:
  19. /* setup addr[33:32] in reviser */
  20. mmio_write_32(REVISER_SECUREFW_CTXT, 0U);
  21. mmio_write_32(REVISER_USDRFW_CTXT, 0U);
  22. /* setup secure sideband */
  23. mmio_write_32(AO_SEC_FW,
  24. (SEC_FW_NON_SECURE << SEC_FW_SHIFT_NS) |
  25. (0U << SEC_FW_DOMAIN_SHIFT));
  26. /* setup boot address */
  27. mmio_write_32(AO_MD32_BOOT_CTRL, 0U);
  28. /* setup pre-define region */
  29. mmio_write_32(AO_MD32_PRE_DEFINE,
  30. (PRE_DEFINE_CACHE_TCM << PRE_DEFINE_SHIFT_0G) |
  31. (PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_1G) |
  32. (PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_2G) |
  33. (PRE_DEFINE_CACHE << PRE_DEFINE_SHIFT_3G));
  34. /* release runstall */
  35. mmio_write_32(AO_MD32_SYS_CTRL, SYS_CTRL_RUN);
  36. INFO("[APUSYS] reviser_ctxt=%x,%x\n",
  37. mmio_read_32(REVISER_SECUREFW_CTXT),
  38. mmio_read_32(REVISER_USDRFW_CTXT));
  39. INFO("[APUSYS]fw=0x%08x,boot=0x%08x,def=0x%08x,sys=0x%08x\n",
  40. mmio_read_32(AO_SEC_FW),
  41. mmio_read_32(AO_MD32_BOOT_CTRL),
  42. mmio_read_32(AO_MD32_PRE_DEFINE),
  43. mmio_read_32(AO_MD32_SYS_CTRL));
  44. break;
  45. case MTK_SIP_APU_STOP_MCU:
  46. /* hold runstall */
  47. mmio_write_32(AO_MD32_SYS_CTRL, SYS_CTRL_STALL);
  48. INFO("[APUSYS] md32_boot_ctrl=0x%08x,runstall=0x%08x\n",
  49. mmio_read_32(AO_MD32_BOOT_CTRL),
  50. mmio_read_32(AO_MD32_SYS_CTRL));
  51. break;
  52. default:
  53. ERROR("%s, unknown request_ops = %x\n", __func__, request_ops);
  54. break;
  55. }
  56. return 0UL;
  57. }