apusys_power.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Copyright (c) 2024, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef APUSYS_POWER_H
  7. #define APUSYS_POWER_H
  8. #include <platform_def.h>
  9. #define CFG_APU_ARDCM_ENABLE (0)
  10. #define CFG_CTL_RPC_BY_CE (1)
  11. #define APUPLL0_DEFAULT_FREQ (800)
  12. #define APUPLL1_DEFAULT_FREQ (960)
  13. #define APUPLL2_DEFAULT_FREQ (1200)
  14. #define APUPLL3_DEFAULT_FREQ (1230)
  15. enum t_acx_id {
  16. D_ACX0 = 0,
  17. ACX0,
  18. ACX1,
  19. ACX2,
  20. CLUSTER_NUM,
  21. RCX,
  22. };
  23. enum rcx_ao_range {
  24. RCX_AO_BEGIN = 0,
  25. PLL_ENTRY_BEGIN = 0,
  26. PLL_ENTRY_END = 27,
  27. ACC_ENTRY_BEGIN = 28,
  28. ACC_ENTRY_END = 37,
  29. RCX_AO_END = 37,
  30. };
  31. #define SYS_VLP (0x000000)
  32. #define SYS_SPM (0x000000)
  33. #define APU_RCX (0x020000)
  34. #define APU_RCX_DLA (0x040000)
  35. #define APU_ARE (0x0a0000)
  36. #define APU_ARE_REG (0x0b0000)
  37. #define APU_VCORE (0x0e0000)
  38. #define APU_MD32_MBOX (0x0e1000)
  39. #define APU_RPC (0x0f0000)
  40. #define APU_PCU (0x0f1000)
  41. #define APU_AO_CTL (0x0f2000)
  42. #define APU_ACC (0x0f3000)
  43. #define APU_PLL (0x0f6000)
  44. #define APU_RPCTOP_MDLA (0x0F7400)
  45. #define APU_ACX0 (0x100000)
  46. #define APU_ACX0_RPC_LITE (0x140000)
  47. #define APU_ACX1 (0x200000)
  48. #define APU_ACX1_RPC_LITE (0x240000)
  49. #define APU_ACX2 (0x300000)
  50. #define APU_ACX2_RPC_LITE (0x340000)
  51. /* APU GRP offset define */
  52. #define APU_GRP_0_BASE (0x0000)
  53. #define APU_GRP_1_BASE (0x0400)
  54. #define APU_GRP_2_BASE (0x0800)
  55. #define APU_GRP_3_BASE (0x0C00)
  56. #define MDLA_PLL_BASE APU_GRP_0_BASE
  57. #define MVPU_PLL_BASE APU_GRP_1_BASE
  58. #define MNOC_PLL_BASE APU_GRP_2_BASE
  59. #define UP_PLL_BASE APU_GRP_3_BASE
  60. #define MDLA_ACC_BASE APU_GRP_0_BASE
  61. #define MVPU_ACC_BASE APU_GRP_1_BASE
  62. #define MNOC_ACC_BASE APU_GRP_2_BASE
  63. #define UP_ACC_BASE APU_GRP_3_BASE
  64. /* RPC / RPC_LITE control */
  65. #define APU_RPC_SW_TYPE0_OFF (0x200)
  66. #define APU_RPC_SW_TYPE1_OFF (0x204)
  67. #define APU_RPC_SW_TYPE2_OFF (0x208)
  68. #define APU_RPC_SW_TYPE3_OFF (0x20C)
  69. #define APU_RPC_SW_TYPE4_OFF (0x210)
  70. #define SW_TYPE_MVPU_MDLA_RV BIT(0)
  71. #define CE_ENABLE BIT(10)
  72. #define BUCK_PROT_SEL BIT(20)
  73. #define RPC_TYPE_INIT_VAL (0x18)
  74. #define TOP_SEL_VAL (0xB2)
  75. #define RPC_TOP_SEL_VAL (0xB800D50F)
  76. #define APUSYS_AO_CTL (APUSYS_BASE + APU_AO_CTL)
  77. #define APUSYS_RPC (APUSYS_BASE + APU_RPC)
  78. #define APUSYS_ACC (APUSYS_BASE + APU_ACC)
  79. #define APUSYS_PLL (APUSYS_BASE + APU_PLL)
  80. #define APUSYS_PCU (APUSYS_BASE + APU_PCU)
  81. /* ARE control */
  82. #define ARE_VCORE_EN BIT(20)
  83. #define ARE_RCX_AO_EN BIT(21)
  84. #define ARE_VCORE_OFF (20)
  85. #define ARE_CONF_START (0x04)
  86. #define ARE_CONF_END (0x6C)
  87. #define ARE_REG_SIZE (4)
  88. /* ACC offset */
  89. #define APU_ACC_CONFG_SET0 (0x000)
  90. #define APU_ACC_CONFG_CLR0 (0x010)
  91. #define APU_ACC_AUTO_CTRL_SET0 (0x084)
  92. #define APU_ARDCM_CTRL0 (0x100)
  93. #define APU_ARDCM_CTRL1 (0x104)
  94. /* ACC control */
  95. #define APU_ARDCM_CTRL0_VAL_0 (0x00000016)
  96. #define APU_ARDCM_CTRL0_VAL_1 (0x00000036)
  97. #define APU_ARDCM_CTRL1_VAL_0 (0x00001006)
  98. #define APU_ARDCM_CTRL1_VAL_1 (0x07F0F006)
  99. #define CGEN_SOC BIT(2)
  100. #define CLK_REQ_SW_EN BIT(8)
  101. #define HW_CTRL_EN BIT(15)
  102. /* APU PLL1C offset */
  103. #define RG_PLLGP_LVR_REFSEL (0x204)
  104. #define PLL1C_PLL1_CON1 (0x20C)
  105. #define PLL1CPLL_FHCTL_HP_EN (0x300)
  106. #define PLL1CPLL_FHCTL_CLK_CON (0x308)
  107. #define PLL1CPLL_FHCTL_RST_CON (0x30C)
  108. #define PLL1CPLL_FHCTL0_CFG (0x314)
  109. #define PLL1CPLL_FHCTL0_DDS (0x31C)
  110. /* PLL control */
  111. #define RG_PLLGP_LVR_REFSEL_VAL (0x3)
  112. #define FHCTL_CTRL (0x1)
  113. #define FHCTL_NO_RESET (0x1)
  114. #define FHCTL_CLKEN (0x1)
  115. #define FHCTL_HOPPING_EN BIT(0)
  116. #define FHCTL_SFSTR0_EN BIT(2)
  117. #define RG_PLL_SDM_PCW_CHG_OFF (31)
  118. #define RG_PLL_POSDIV_OFF (24)
  119. #define FHCTL0_PLL_TGL_ORG (31)
  120. /* RPC offset define */
  121. #define APU_RPC_TOP_SEL (0x0004)
  122. #define APU_RPC_TOP_SEL_1 (0x0018)
  123. #define APU_RPC_HW_CON (0x001C)
  124. #define APU_RPC_STATUS_1 (0x0034)
  125. #define APU_RPC_INTF_PWR_RDY (0x0044)
  126. /* RPC control */
  127. #define SRAM_AOC_LHENB_SET BIT(4)
  128. #define SRAM_AOC_ISO_SET BIT(6)
  129. #define SRAM_AOC_ISO_CLR BIT(7)
  130. #define PLL_AOC_ISO_EN_SET BIT(8)
  131. #define PLL_AOC_ISO_EN_CLR BIT(9)
  132. #define BUCK_ELS_EN_SET BIT(10)
  133. #define BUCK_ELS_EN_CLR BIT(11)
  134. #define BUCK_AO_RST_B_SET BIT(12)
  135. #define BUCK_AO_RST_B_CLR BIT(13)
  136. #define BUCK_PROT_REQ_SET BIT(14)
  137. #define BUCK_PROT_REQ_CLR BIT(15)
  138. /* mt6373_vbuck2 */
  139. #define MT6373_SLAVE_ID (0x5)
  140. #define MT6373_RG_BUCK_VBUCK2_SET (0x241)
  141. #define MT6373_RG_BUCK_VBUCK2_CLR (0x242)
  142. #define MT6373_RG_BUCK_VBUCK2_EN_SHIFT (2)
  143. #define MT6373_RG_BUCK_VBUCK2_VOSEL_ADDR (0x24e)
  144. /* PCU initial data */
  145. #define APU_PCUTOP_CTRL_SET (0x0)
  146. #define APU_PCU_BUCK_STEP_SEL (0x0030)
  147. #define APU_PCU_BUCK_ON_DAT0_L (0x0080)
  148. #define APU_PCU_BUCK_ON_DAT0_H (0x0084)
  149. #define APU_PCU_BUCK_ON_DAT1_L (0x0088)
  150. #define APU_PCU_BUCK_ON_DAT1_H (0x008C)
  151. #define APU_PCU_BUCK_OFF_DAT0_L (0x00A0)
  152. #define APU_PCU_BUCK_OFF_DAT0_H (0x00A4)
  153. #define APU_PCU_BUCK_ON_SLE0 (0x00C0)
  154. #define APU_PCU_BUCK_ON_SLE1 (0x00C4)
  155. #define VAPU_BUCK_ON_SETTLE_TIME (0x00C8)
  156. #define APU_PCU_PMIC_TAR_BUF1 (0x0190)
  157. #define APU_PCU_PMIC_TAR_BUF2 (0x0194)
  158. #define APU_PCU_PMIC_CMD (0x0184)
  159. #define APU_PCU_PMIC_IRQ (0x0180)
  160. /* PCU control */
  161. #define PMIC_CMD_IRQ BIT(0)
  162. #define PMIC_IRQ_EN BIT(2)
  163. #define AUTO_BUCK_EN BIT(3)
  164. #define PMIC_PMIFID_OFF (3)
  165. #define PMIC_SLVID_OFF (4)
  166. #define PCU_CMD_OP_W (0x7)
  167. #define PMIC_OFF_ADDR_OFF (16)
  168. #define PMIC_CMD_EN (0x1)
  169. #define BUCK_STEP_SEL_VAL (0x13)
  170. #define PCU_BUCK_OFF_CMD (0x7)
  171. /* sram_core: mt6363_vbuck4 */
  172. #define MT6363_RG_BUCK_VBUCK4_VOSEL_ADDR (0x250)
  173. /* sub_pmic */
  174. #define BUCK_VAPU_PMIC_ID MT6373_SLAVE_ID
  175. #define BUCK_VAPU_PMIC_REG_VOSEL_ADDR MT6373_RG_BUCK_VBUCK2_VOSEL_ADDR
  176. #define BUCK_VAPU_PMIC_REG_EN_SET_ADDR MT6373_RG_BUCK_VBUCK2_SET
  177. #define BUCK_VAPU_PMIC_REG_EN_CLR_ADDR MT6373_RG_BUCK_VBUCK2_CLR
  178. #define BUCK_VAPU_PMIC_REG_EN_SHIFT MT6373_RG_BUCK_VBUCK2_EN_SHIFT
  179. /* vlp offset define */
  180. #define APUSYS_AO_SRAM_CONFIG (0x70)
  181. #define APUSYS_AO_SRAM_SET (0x74)
  182. #define APUSYS_AO_SRAM_CLR (0x78)
  183. #define APUSYS_AO_SRAM_EN (0x1)
  184. #define ARE_ENTRIES(x, y) ((((y) - (x)) + 1) * 2)
  185. #define ARE_ENTRY(x) (((x) * 2) + 36)
  186. #define ARE_RCX_AO_CONFIG (0x0014)
  187. #define ARE_RCX_AO_CONFIG_HIGH_OFF (16)
  188. #define APU_ACE_HW_FLAG_DIS (APUSYS_CE_BASE + 0x05D4)
  189. #define APU_ACE_DIS_FLAG_VAL (0xffff7ff8)
  190. #define OUT_CLK_FREQ_MIN (1500)
  191. #define DDS_SHIFT (14)
  192. #define BASIC_CLK_FREQ (26)
  193. int apusys_power_init(void);
  194. #endif /* APUSYS_POWER_H */