mtspmc_private.h 5.7 KB

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