mtspmc_private.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Copyright (c) 2019, 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. /*
  9. * per_cpu/cluster helper
  10. */
  11. struct per_cpu_reg {
  12. int cluster_addr;
  13. int cpu_stride;
  14. };
  15. #define per_cpu(cluster, cpu, reg) (reg[cluster].cluster_addr + \
  16. (cpu << reg[cluster].cpu_stride))
  17. #define per_cluster(cluster, reg) (reg[cluster].cluster_addr)
  18. /* SPMC related registers */
  19. #define SPM_POWERON_CONFIG_EN (SPM_BASE + 0x000)
  20. /* bit-fields of SPM_POWERON_CONFIG_EN */
  21. #define BCLK_CG_EN (1 << 0)
  22. #define MD_BCLK_CG_EN (1 << 1)
  23. #define PROJECT_CODE (0xb16 << 16)
  24. #define SPM_PWR_STATUS (SPM_BASE + 0x180)
  25. #define SPM_PWR_STATUS_2ND (SPM_BASE + 0x184)
  26. #define SPM_BYPASS_SPMC (SPM_BASE + 0x2b4)
  27. #define SPM_SPMC_DORMANT_ENABLE (SPM_BASE + 0x2b8)
  28. #define SPM_MP0_CPUTOP_PWR_CON (SPM_BASE + 0x204)
  29. #define SPM_MP0_CPU0_PWR_CON (SPM_BASE + 0x208)
  30. #define SPM_MP0_CPU1_PWR_CON (SPM_BASE + 0x20C)
  31. #define SPM_MP0_CPU2_PWR_CON (SPM_BASE + 0x210)
  32. #define SPM_MP0_CPU3_PWR_CON (SPM_BASE + 0x214)
  33. #define SPM_MP1_CPUTOP_PWR_CON (SPM_BASE + 0x218)
  34. #define SPM_MP1_CPU0_PWR_CON (SPM_BASE + 0x21C)
  35. #define SPM_MP1_CPU1_PWR_CON (SPM_BASE + 0x220)
  36. #define SPM_MP1_CPU2_PWR_CON (SPM_BASE + 0x224)
  37. #define SPM_MP1_CPU3_PWR_CON (SPM_BASE + 0x228)
  38. #define SPM_MP0_CPUTOP_L2_PDN (SPM_BASE + 0x240)
  39. #define SPM_MP0_CPUTOP_L2_SLEEP_B (SPM_BASE + 0x244)
  40. #define SPM_MP0_CPU0_L1_PDN (SPM_BASE + 0x248)
  41. #define SPM_MP0_CPU1_L1_PDN (SPM_BASE + 0x24C)
  42. #define SPM_MP0_CPU2_L1_PDN (SPM_BASE + 0x250)
  43. #define SPM_MP0_CPU3_L1_PDN (SPM_BASE + 0x254)
  44. #define SPM_MP1_CPUTOP_L2_PDN (SPM_BASE + 0x258)
  45. #define SPM_MP1_CPUTOP_L2_SLEEP_B (SPM_BASE + 0x25C)
  46. #define SPM_MP1_CPU0_L1_PDN (SPM_BASE + 0x260)
  47. #define SPM_MP1_CPU1_L1_PDN (SPM_BASE + 0x264)
  48. #define SPM_MP1_CPU2_L1_PDN (SPM_BASE + 0x268)
  49. #define SPM_MP1_CPU3_L1_PDN (SPM_BASE + 0x26C)
  50. #define SPM_CPU_EXT_BUCK_ISO (SPM_BASE + 0x290)
  51. /* bit-fields of SPM_CPU_EXT_BUCK_ISO */
  52. #define MP0_EXT_BUCK_ISO (1 << 0)
  53. #define MP1_EXT_BUCK_ISO (1 << 1)
  54. #define MP_EXT_BUCK_ISO (1 << 2)
  55. /* bit-fields of SPM_PWR_STATUS */
  56. #define PWR_STATUS_MD (1 << 0)
  57. #define PWR_STATUS_CONN (1 << 1)
  58. #define PWR_STATUS_DDRPHY (1 << 2)
  59. #define PWR_STATUS_DISP (1 << 3)
  60. #define PWR_STATUS_MFG (1 << 4)
  61. #define PWR_STATUS_ISP (1 << 5)
  62. #define PWR_STATUS_INFRA (1 << 6)
  63. #define PWR_STATUS_VDEC (1 << 7)
  64. #define PWR_STATUS_MP0_CPUTOP (1 << 8)
  65. #define PWR_STATUS_MP0_CPU0 (1 << 9)
  66. #define PWR_STATUS_MP0_CPU1 (1 << 10)
  67. #define PWR_STATUS_MP0_CPU2 (1 << 11)
  68. #define PWR_STATUS_MP0_CPU3 (1 << 12)
  69. #define PWR_STATUS_MCUSYS (1 << 14)
  70. #define PWR_STATUS_MP1_CPUTOP (1 << 15)
  71. #define PWR_STATUS_MP1_CPU0 (1 << 16)
  72. #define PWR_STATUS_MP1_CPU1 (1 << 17)
  73. #define PWR_STATUS_MP1_CPU2 (1 << 18)
  74. #define PWR_STATUS_MP1_CPU3 (1 << 19)
  75. #define PWR_STATUS_VEN (1 << 21)
  76. #define PWR_STATUS_MFG_ASYNC (1 << 23)
  77. #define PWR_STATUS_AUDIO (1 << 24)
  78. #define PWR_STATUS_C2K (1 << 28)
  79. #define PWR_STATUS_MD_INFRA (1 << 29)
  80. /* bit-fields of SPM_*_PWR_CON */
  81. #define PWRCTRL_PWR_RST_B (1 << 0)
  82. #define PWRCTRL_PWR_ISO (1 << 1)
  83. #define PWRCTRL_PWR_ON (1 << 2)
  84. #define PWRCTRL_PWR_ON_2ND (1 << 3)
  85. #define PWRCTRL_PWR_CLK_DIS (1 << 4)
  86. #define PWRCTRL_PWR_SRAM_CKISO (1 << 5)
  87. #define PWRCTRL_PWR_SRAM_ISOINT_B (1 << 6)
  88. #define PWRCTRL_PWR_SRAM_PD_SLPB_CLAMP (1 << 7)
  89. #define PWRCTRL_PWR_SRAM_PDN (1 << 8)
  90. #define PWRCTRL_PWR_SRAM_SLEEP_B (1 << 12)
  91. #define PWRCTRL_PWR_SRAM_PDN_ACK (1 << 24)
  92. #define PWRCTRL_PWR_SRAM_SLEEP_B_ACK (1 << 28)
  93. /* per_cpu registers for SPM_MP?_CPU?_PWR_CON */
  94. static const struct per_cpu_reg SPM_CPU_PWR[] = {
  95. [0] = { .cluster_addr = SPM_MP0_CPU0_PWR_CON, .cpu_stride = 2 },
  96. [1] = { .cluster_addr = SPM_MP1_CPU0_PWR_CON, .cpu_stride = 2 },
  97. };
  98. /* per_cluster registers for SPM_MP?_CPUTOP_PWR_CON */
  99. static const struct per_cpu_reg SPM_CLUSTER_PWR[] = {
  100. [0] = { .cluster_addr = SPM_MP0_CPUTOP_PWR_CON },
  101. [1] = { .cluster_addr = SPM_MP1_CPUTOP_PWR_CON },
  102. };
  103. /* APB Module infracfg_ao */
  104. #define INFRA_TOPAXI_PROTECTEN_1 (INFRACFG_AO_BASE + 0x250)
  105. #define INFRA_TOPAXI_PROTECTEN_STA1_1 (INFRACFG_AO_BASE + 0x258)
  106. #define INFRA_TOPAXI_PROTECTEN_1_SET (INFRACFG_AO_BASE + 0x2A8)
  107. #define INFRA_TOPAXI_PROTECTEN_1_CLR (INFRACFG_AO_BASE + 0x2AC)
  108. /* bit-fields of INFRA_TOPAXI_PROTECTEN_1_SET */
  109. #define MP0_CPUTOP_PROT_STEP1_0_MASK ((1 << 10)|(1 << 12)| \
  110. (1 << 13)|(1 << 26))
  111. #define MP1_CPUTOP_PROT_STEP1_0_MASK ((1 << 11)|(1 << 14)| \
  112. (1 << 15)|(1 << 27))
  113. /* bit-fields of INFRA_TOPAXI_PROTECTEN_STA1_1 */
  114. #define MP0_CPUTOP_PROT_STEP1_0_ACK_MASK ((1 << 10)|(1 << 12)| \
  115. (1 << 13)|(1 << 26))
  116. #define MP1_CPUTOP_PROT_STEP1_0_ACK_MASK ((1 << 11)|(1 << 14)| \
  117. (1 << 15)|(1 << 27))
  118. /*
  119. * MCU configuration registers
  120. */
  121. /* bit-fields of MCUCFG_MP?_AXI_CONFIG */
  122. #define MCUCFG_AXI_CONFIG_BROADCASTINNER (1 << 0)
  123. #define MCUCFG_AXI_CONFIG_BROADCASTOUTER (1 << 1)
  124. #define MCUCFG_AXI_CONFIG_BROADCASTCACHEMAINT (1 << 2)
  125. #define MCUCFG_AXI_CONFIG_SYSBARDISABLE (1 << 3)
  126. #define MCUCFG_AXI_CONFIG_ACINACTM (1 << 4)
  127. #define MCUCFG_AXI_CONFIG_AINACTS (1 << 5)
  128. #define MCUCFG_MP0_MISC_CONFIG2 ((uintptr_t)&mt8183_mcucfg->mp0_misc_config[2])
  129. #define MCUCFG_MP0_MISC_CONFIG3 ((uintptr_t)&mt8183_mcucfg->mp0_misc_config[3])
  130. #define MCUCFG_MP1_MISC_CONFIG2 ((uintptr_t)&mt8183_mcucfg->mp1_misc_config[2])
  131. #define MCUCFG_MP1_MISC_CONFIG3 ((uintptr_t)&mt8183_mcucfg->mp1_misc_config[3])
  132. #define MCUCFG_CPUSYS0_SPARKVRETCNTRL (MCUCFG_BASE + 0x1c00)
  133. /* bit-fields of MCUCFG_CPUSYS0_SPARKVRETCNTRL */
  134. #define CPU0_SPARK_VRET_CTRL (0x3f << 0)
  135. #define CPU1_SPARK_VRET_CTRL (0x3f << 8)
  136. #define CPU2_SPARK_VRET_CTRL (0x3f << 16)
  137. #define CPU3_SPARK_VRET_CTRL (0x3f << 24)
  138. /* SPARK control in little cores */
  139. #define MCUCFG_CPUSYS0_CPU0_SPMC_CTL (MCUCFG_BASE + 0x1c30)
  140. #define MCUCFG_CPUSYS0_CPU1_SPMC_CTL (MCUCFG_BASE + 0x1c34)
  141. #define MCUCFG_CPUSYS0_CPU2_SPMC_CTL (MCUCFG_BASE + 0x1c38)
  142. #define MCUCFG_CPUSYS0_CPU3_SPMC_CTL (MCUCFG_BASE + 0x1c3c)
  143. /* bit-fields of MCUCFG_CPUSYS0_CPU?_SPMC_CTL */
  144. #define SW_SPARK_EN (1 << 0)
  145. #define SW_NO_WAIT_Q (1 << 1)
  146. /* the MCUCFG which BIG cores used is at (MCUCFG_BASE + 0x2000) */
  147. #define MCUCFG_MP2_BASE (MCUCFG_BASE + 0x2000)
  148. #define MCUCFG_MP2_PWR_RST_CTL (MCUCFG_MP2_BASE + 0x8)
  149. /* bit-fields of MCUCFG_MP2_PWR_RST_CTL */
  150. #define SW_RST_B (1 << 0)
  151. #define TOPAON_APB_MASK (1 << 1)
  152. #define MCUCFG_MP2_CPUCFG (MCUCFG_MP2_BASE + 0x208)
  153. #define MCUCFG_MP2_RVADDR0 (MCUCFG_MP2_BASE + 0x290)
  154. #define MCUCFG_MP2_RVADDR1 (MCUCFG_MP2_BASE + 0x298)
  155. #define MCUCFG_MP2_RVADDR2 (MCUCFG_MP2_BASE + 0x2c0)
  156. #define MCUCFG_MP2_RVADDR3 (MCUCFG_MP2_BASE + 0x2c8)
  157. /* SPMC control */
  158. #define MCUCFG_MP0_SPMC (MCUCFG_BASE + 0x788)
  159. #define MCUCFG_MP2_SPMC (MCUCFG_MP2_BASE + 0x2a0)
  160. #define MCUCFG_MP2_COQ (MCUCFG_MP2_BASE + 0x2bC)
  161. /* per_cpu registers for MCUCFG_MP?_MISC_CONFIG2 */
  162. static const struct per_cpu_reg MCUCFG_BOOTADDR[] = {
  163. [0] = { .cluster_addr = MCUCFG_MP0_MISC_CONFIG2, .cpu_stride = 3 },
  164. };
  165. /* per_cpu registers for MCUCFG_MP?_MISC_CONFIG3 */
  166. static const struct per_cpu_reg MCUCFG_INITARCH[] = {
  167. [0] = { .cluster_addr = MCUCFG_MP0_MISC_CONFIG3 },
  168. [1] = { .cluster_addr = MCUCFG_MP2_CPUCFG },
  169. };
  170. /* SPARK control in BIG cores */
  171. #define MCUCFG_MP2_PTP3_CPU0_SPMC0 (MCUCFG_MP2_BASE + 0x430)
  172. #define MCUCFG_MP2_PTP3_CPU0_SPMC1 (MCUCFG_MP2_BASE + 0x434)
  173. #define MCUCFG_MP2_PTP3_CPU1_SPMC0 (MCUCFG_MP2_BASE + 0x438)
  174. #define MCUCFG_MP2_PTP3_CPU1_SPMC1 (MCUCFG_MP2_BASE + 0x43c)
  175. #define MCUCFG_MP2_PTP3_CPU2_SPMC0 (MCUCFG_MP2_BASE + 0x440)
  176. #define MCUCFG_MP2_PTP3_CPU2_SPMC1 (MCUCFG_MP2_BASE + 0x444)
  177. #define MCUCFG_MP2_PTP3_CPU3_SPMC0 (MCUCFG_MP2_BASE + 0x448)
  178. #define MCUCFG_MP2_PTP3_CPU3_SPMC1 (MCUCFG_MP2_BASE + 0x44c)
  179. /* bit-fields of MCUCFG_MP2_PTP3_CPU?_SPMC? */
  180. #define SW_SPARK_EN (1 << 0)
  181. #define SW_NO_WAIT_Q (1 << 1)
  182. #define MCUCFG_MP2_SPARK2LDO (MCUCFG_MP2_BASE + 0x700)
  183. /* bit-fields of MCUCFG_MP2_SPARK2LDO */
  184. #define SPARK_VRET_CTRL (0x3f << 0)
  185. #define CPU0_SPARK_LDO_AMUXSEL (0xf << 6)
  186. #define CPU1_SPARK_LDO_AMUXSEL (0xf << 10)
  187. #define CPU2_SPARK_LDO_AMUXSEL (0xf << 14)
  188. #define CPU3_SPARK_LDO_AMUXSEL (0xf << 18)
  189. /* per_cpu registers for SPARK */
  190. static const struct per_cpu_reg MCUCFG_SPARK[] = {
  191. [0] = { .cluster_addr = MCUCFG_CPUSYS0_CPU0_SPMC_CTL, .cpu_stride = 2 },
  192. [1] = { .cluster_addr = MCUCFG_MP2_PTP3_CPU0_SPMC0, .cpu_stride = 3 },
  193. };
  194. /* per_cpu registers for SPARK2LDO */
  195. static const struct per_cpu_reg MCUCFG_SPARK2LDO[] = {
  196. [0] = { .cluster_addr = MCUCFG_CPUSYS0_SPARKVRETCNTRL },
  197. [1] = { .cluster_addr = MCUCFG_MP2_SPARK2LDO },
  198. };
  199. #endif /* MTSPMC_PRIVATE_H */