apusys_rv_pwr_ctrl.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2024, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef APUSYS_RV_PWR_CTL_H
  7. #define APUSYS_RV_PWR_CTL_H
  8. #include <platform_def.h>
  9. #include "apusys_rv.h"
  10. #define SUPPORT_APU_CLEAR_MBOX_DUMMY (1)
  11. enum apu_hw_sem_sys_id {
  12. APU_HW_SEM_SYS_APU = 0UL, /* mbox0 */
  13. APU_HW_SEM_SYS_GZ = 1UL, /* mbox1 */
  14. APU_HW_SEM_SYS_SCP = 3UL, /* mbox3 */
  15. APU_HW_SEM_SYS_APMCU = 11UL, /* mbox11 */
  16. };
  17. int apusys_rv_pwr_ctrl(enum APU_PWR_OP op);
  18. int rv_iommu_hw_sem_unlock(void);
  19. int rv_iommu_hw_sem_trylock(void);
  20. int apu_hw_sema_ctl(uint32_t sem_addr, uint8_t usr_bit, uint8_t ctl, uint32_t timeout,
  21. uint8_t bypass);
  22. #define HW_SEM_TIMEOUT (300) /* 300 us */
  23. /* APU MBOX */
  24. #define MBOX_WKUP_CFG (0x80)
  25. #define MBOX_WKUP_MASK (0x84)
  26. #define MBOX_FUNC_CFG (0xb0)
  27. #define MBOX_DOMAIN_CFG (0xe0)
  28. #define MBOX_CTRL_LOCK BIT(0)
  29. #define MBOX_NO_MPU_SHIFT (16)
  30. #define MBOX_RC_SHIFT (24)
  31. #define MBOX_RX_NS_SHIFT (16)
  32. #define MBOX_RX_DOMAIN_SHIFT (17)
  33. #define MBOX_TX_NS_SHIFT (24)
  34. #define MBOX_TX_DOMAIN_SHIFT (25)
  35. #define APU_REG_AO_GLUE_CONFG (APU_AO_CTRL + 0x20)
  36. #define ENABLE_INFRA_WA
  37. enum apu_infra_bit_id {
  38. APU_INFRA_SYS_APMCU = 1UL,
  39. APU_INFRA_SYS_GZ = 2UL,
  40. APU_INFRA_SYS_SCP = 3UL,
  41. };
  42. #define APU_MBOX(i) (APU_MBOX0 + 0x10000 * i)
  43. #define APU_MBOX_FUNC_CFG(i) (APU_MBOX(i) + MBOX_FUNC_CFG)
  44. #define APU_MBOX_DOMAIN_CFG(i) (APU_MBOX(i) + MBOX_DOMAIN_CFG)
  45. #define APU_MBOX_WKUP_CFG(i) (APU_MBOX(i) + MBOX_WKUP_CFG)
  46. enum apu_hw_sem_op {
  47. HW_SEM_PUT = 0,
  48. HW_SEM_GET = 1,
  49. };
  50. #define HW_SEM_PUT_BIT_SHIFT (16)
  51. /* bypass mbox register Dump for secure master */
  52. #define APU_MBOX_DBG_EN (0x190f2380)
  53. /* apu_mbox register definition for mbox addr change*/
  54. #define APU_MBOX_SEMA0_CTRL (0x090)
  55. #define APU_MBOX_SEMA0_RST (0x094)
  56. #define APU_MBOX_SEMA0_STA (0x098)
  57. #define APU_MBOX_SEMA1_CTRL (0x0A0)
  58. #define APU_MBOX_SEMA1_RST (0x0A4)
  59. #define APU_MBOX_SEMA1_STA (0x0A8)
  60. #define APU_MBOX_DUMMY (0x040)
  61. #define APU_MBOX_OFFSET(i) (0x10000 * i)
  62. /* apu infra workaround */
  63. #define APU_INFRA_DISABLE (APU_INFRA_BASE + 0xC18)
  64. #define APU_INFRA_ENABLE (APU_INFRA_BASE + 0xC14)
  65. #define APU_INFRA_STATUS (APU_INFRA_BASE + 0xC10)
  66. #define APU_INFRA_STATUS_MASK (0x1fffe)
  67. #define APU_INFRA_HW_SEM (APUSYS_CE_BASE + 0xE00)
  68. #define APU_RPC_STATUS (0x190f0044)
  69. #define APU_INFRA_BIT_OFF (16)
  70. #define APU_RPC_STATUS_BIT BIT(0)
  71. #endif /* APUSYS_RV_PWR_CTL_H */