mtspmc_private.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (c) 2021, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef MTSPMC_PRIVATE_H
  7. #define MTSPMC_PRIVATE_H
  8. #include <lib/utils_def.h>
  9. #include <platform_def.h>
  10. unsigned long read_cpuectlr(void);
  11. void write_cpuectlr(unsigned long cpuectlr);
  12. unsigned long read_cpupwrctlr_el1(void);
  13. void write_cpupwrctlr_el1(unsigned long cpuectlr);
  14. /* per_cpu/cluster helper */
  15. struct per_cpu_reg {
  16. unsigned int cluster_addr;
  17. unsigned int cpu_stride;
  18. };
  19. #define per_cpu(cluster, cpu, reg) \
  20. (reg[cluster].cluster_addr + (cpu << reg[cluster].cpu_stride))
  21. #define per_cluster(cluster, reg) (reg[cluster].cluster_addr)
  22. #define SPM_REG(ofs) (uint32_t)(SPM_BASE + (ofs))
  23. #define MCUCFG_REG(ofs) (uint32_t)(MCUCFG_BASE + (ofs))
  24. #define INFRACFG_AO_REG(ofs) (uint32_t)(INFRACFG_AO_BASE + (ofs))
  25. /* SPMC related registers */
  26. #define SPM_POWERON_CONFIG_EN SPM_REG(0x000)
  27. /* bit-fields of SPM_POWERON_CONFIG_EN */
  28. #define PROJECT_CODE (U(0xb16) << 16)
  29. #define BCLK_CG_EN BIT(0)
  30. #define SPM_PWR_STATUS SPM_REG(0x16c)
  31. #define SPM_PWR_STATUS_2ND SPM_REG(0x170)
  32. #define SPM_CPU_PWR_STATUS SPM_REG(0x174)
  33. /* bit-fields of SPM_PWR_STATUS */
  34. #define MD BIT(0)
  35. #define CONN BIT(1)
  36. #define DDRPHY BIT(2)
  37. #define DISP BIT(3)
  38. #define MFG BIT(4)
  39. #define ISP BIT(5)
  40. #define INFRA BIT(6)
  41. #define VDEC BIT(7)
  42. #define MP0_CPUTOP BIT(8)
  43. #define MP0_CPU0 BIT(9)
  44. #define MP0_CPU1 BIT(10)
  45. #define MP0_CPU2 BIT(11)
  46. #define MP0_CPU3 BIT(12)
  47. #define MCUSYS BIT(14)
  48. #define MP0_CPU4 BIT(15)
  49. #define MP0_CPU5 BIT(16)
  50. #define MP0_CPU6 BIT(17)
  51. #define MP0_CPU7 BIT(18)
  52. #define VEN BIT(21)
  53. /* SPMC related registers */
  54. #define SPM_MCUSYS_PWR_CON SPM_REG(0x200)
  55. #define SPM_MP0_CPUTOP_PWR_CON SPM_REG(0x204)
  56. #define SPM_MP0_CPU0_PWR_CON SPM_REG(0x208)
  57. #define SPM_MP0_CPU1_PWR_CON SPM_REG(0x20c)
  58. #define SPM_MP0_CPU2_PWR_CON SPM_REG(0x210)
  59. #define SPM_MP0_CPU3_PWR_CON SPM_REG(0x214)
  60. #define SPM_MP0_CPU4_PWR_CON SPM_REG(0x218)
  61. #define SPM_MP0_CPU5_PWR_CON SPM_REG(0x21c)
  62. #define SPM_MP0_CPU6_PWR_CON SPM_REG(0x220)
  63. #define SPM_MP0_CPU7_PWR_CON SPM_REG(0x224)
  64. /* bit-fields of SPM_*_PWR_CON */
  65. #define PWR_ON_ACK BIT(31)
  66. #define VPROC_EXT_OFF BIT(7)
  67. #define DORMANT_EN BIT(6)
  68. #define RESETPWRON_CONFIG BIT(5)
  69. #define PWR_CLK_DIS BIT(4)
  70. #define PWR_ON BIT(2)
  71. #define PWR_RST_B BIT(0)
  72. /* per_cpu registers for SPM_MP0_CPU_PWR_CON */
  73. static const struct per_cpu_reg SPM_CPU_PWR[] = {
  74. { .cluster_addr = SPM_MP0_CPU0_PWR_CON, .cpu_stride = 2U }
  75. };
  76. /* per_cluster registers for SPM_MP0_CPUTOP_PWR_CON */
  77. static const struct per_cpu_reg SPM_CLUSTER_PWR[] = {
  78. { .cluster_addr = SPM_MP0_CPUTOP_PWR_CON, .cpu_stride = 0U }
  79. };
  80. /* MCUCFG related registers */
  81. #define MCUCFG_MP0_CLUSTER_CFG5 MCUCFG_REG(0xc8e4)
  82. /* reset vectors */
  83. #define MCUCFG_MP0_CLUSTER_CFG8 MCUCFG_REG(0xc900)
  84. #define MCUCFG_MP0_CLUSTER_CFG10 MCUCFG_REG(0xc908)
  85. #define MCUCFG_MP0_CLUSTER_CFG12 MCUCFG_REG(0xc910)
  86. #define MCUCFG_MP0_CLUSTER_CFG14 MCUCFG_REG(0xc918)
  87. #define MCUCFG_MP0_CLUSTER_CFG16 MCUCFG_REG(0xc920)
  88. #define MCUCFG_MP0_CLUSTER_CFG18 MCUCFG_REG(0xc928)
  89. #define MCUCFG_MP0_CLUSTER_CFG20 MCUCFG_REG(0xc930)
  90. #define MCUCFG_MP0_CLUSTER_CFG22 MCUCFG_REG(0xc938)
  91. /* per_cpu registers for MCUCFG_MP0_CLUSTER_CFG */
  92. static const struct per_cpu_reg MCUCFG_BOOTADDR[] = {
  93. { .cluster_addr = MCUCFG_MP0_CLUSTER_CFG8, .cpu_stride = 3U }
  94. };
  95. /* per_cpu registers for MCUCFG_MP0_CLUSTER_CFG5 */
  96. static const struct per_cpu_reg MCUCFG_INITARCH[] = {
  97. { .cluster_addr = MCUCFG_MP0_CLUSTER_CFG5, .cpu_stride = 0U }
  98. };
  99. #define MCUCFG_INITARCH_CPU_BIT(cpu) BIT(16U + cpu)
  100. /* CPC control */
  101. #define MCUCFG_CPC_FLOW_CTRL_CFG MCUCFG_REG(0xa814)
  102. #define MCUCFG_CPC_SPMC_PWR_STATUS MCUCFG_REG(0xa840)
  103. /* bit-fields of CPC_FLOW_CTRL_CFG */
  104. #define CPC_CTRL_ENABLE BIT(16)
  105. #define SSPM_ALL_PWR_CTRL_EN BIT(13) /* for cpu-hotplug */
  106. #define GIC_WAKEUP_IGNORE(cpu) BIT(21 + cpu)
  107. /* bit-fields of CPC_SPMC_PWR_STATUS */
  108. #define CORE_SPMC_PWR_ON_ACK GENMASK(11, 0)
  109. /* APB module infracfg_ao */
  110. #define INFRA_TOPAXI_PROTECTEN INFRACFG_AO_REG(0x0220)
  111. #define INFRA_TOPAXI_PROTECTEN_STA0 INFRACFG_AO_REG(0x0224)
  112. #define INFRA_TOPAXI_PROTECTEN_STA1 INFRACFG_AO_REG(0x0228)
  113. #define INFRA_TOPAXI_PROTECTEN_SET INFRACFG_AO_REG(0x02a0)
  114. #define INFRA_TOPAXI_PROTECTEN_CLR INFRACFG_AO_REG(0x02a4)
  115. #define INFRA_TOPAXI_PROTECTEN_1 INFRACFG_AO_REG(0x0250)
  116. #define INFRA_TOPAXI_PROTECTEN_STA0_1 INFRACFG_AO_REG(0x0254)
  117. #define INFRA_TOPAXI_PROTECTEN_STA1_1 INFRACFG_AO_REG(0x0258)
  118. #define INFRA_TOPAXI_PROTECTEN_1_SET INFRACFG_AO_REG(0x02a8)
  119. #define INFRA_TOPAXI_PROTECTEN_1_CLR INFRACFG_AO_REG(0x02ac)
  120. /* bit-fields of INFRA_TOPAXI_PROTECTEN */
  121. #define MP0_SPMC_PROT_STEP1_0_MASK BIT(12)
  122. #define MP0_SPMC_PROT_STEP1_1_MASK (BIT(26) | BIT(12))
  123. /* SPARK */
  124. #define VOLTAGE_04 U(0x40)
  125. #define VOLTAGE_05 U(0x60)
  126. #define PTP3_CPU0_SPMC_SW_CFG MCUCFG_REG(0x200)
  127. #define CPU0_ILDO_CONTROL5 MCUCFG_REG(0x334)
  128. #define CPU0_ILDO_CONTROL8 MCUCFG_REG(0x340)
  129. /* bit-fields of CPU0_ILDO_CONTROL5 */
  130. #define ILDO_RET_VOSEL GENMASK(7, 0)
  131. /* bit-fields of PTP3_CPU_SPMC_SW_CFG */
  132. #define SW_SPARK_EN BIT(0)
  133. /* bit-fields of CPU0_ILDO_CONTROL8 */
  134. #define ILDO_BYPASS_B BIT(0)
  135. static const struct per_cpu_reg MCUCFG_SPARK[] = {
  136. { .cluster_addr = PTP3_CPU0_SPMC_SW_CFG, .cpu_stride = 11U }
  137. };
  138. static const struct per_cpu_reg ILDO_CONTROL5[] = {
  139. { .cluster_addr = CPU0_ILDO_CONTROL5, .cpu_stride = 11U }
  140. };
  141. static const struct per_cpu_reg ILDO_CONTROL8[] = {
  142. { .cluster_addr = CPU0_ILDO_CONTROL8, .cpu_stride = 11U }
  143. };
  144. #endif /* MTSPMC_PRIVATE_H */