apusys_power.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. * Copyright (c) 2023, 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. enum APU_CLKSRC_ID {
  10. PLL_CONN = 0, /* MNOC */
  11. PLL_UP,
  12. PLL_VPU,
  13. PLL_DLA,
  14. PLL_NUM,
  15. };
  16. enum APU_ARE_ID {
  17. APU_ARE0 = 0,
  18. APU_ARE1,
  19. APU_ARE2,
  20. APU_ARE_NUM,
  21. };
  22. enum APU_D4_SLV_CTRL {
  23. D4_SLV_OFF = 0,
  24. D4_SLV_ON,
  25. };
  26. enum APU_BACKUP_RESTORE_CTRL {
  27. APU_CTRL_BACKUP = 0,
  28. APU_CTRL_RESTORE = 1,
  29. };
  30. struct apu_restore_data {
  31. uint32_t reg;
  32. uint32_t data;
  33. };
  34. #define APU_POLL_STEP_US (5)
  35. #define OUT_CLK_FREQ_MIN (1500)
  36. #define BASIC_CLK_FREQ (26)
  37. #define DDS_SHIFT (14)
  38. #define APUPLL0_DEFAULT_FREQ (900)
  39. #define APUPLL1_DEFAULT_FREQ (832)
  40. #define APUPLL2_DEFAULT_FREQ (700)
  41. #define APUPLL3_DEFAULT_FREQ (700)
  42. #define APU_TOP_ON_POLLING_TIMEOUT_US (10000)
  43. #define APU_TOP_OFF_POLLING_TIMEOUT_US (5 * APU_TOP_ON_POLLING_TIMEOUT_US)
  44. #define APU_ARE_POLLING_TIMEOUT_US (10000)
  45. /* APU related reg */
  46. #define APU_VCORE_BASE (APU_RCX_VCORE_CONFIG)
  47. #define APU_RCX_BASE (APU_RCX_CONFIG)
  48. #define APU_RPC_BASE (APU_RPCTOP)
  49. #define APU_PCU_BASE (APU_PCUTOP)
  50. #define APU_ARE0_BASE (APU_ARETOP_ARE0)
  51. #define APU_ARE1_BASE (APU_ARETOP_ARE1)
  52. #define APU_ARE2_BASE (APU_ARETOP_ARE2)
  53. #define APU_MBOX0_BASE (APU_MBOX0)
  54. #define APU_AO_CTL_BASE (APU_AO_CTRL)
  55. #define APU_PLL_BASE (APU_PLL)
  56. #define APU_ACC_BASE (APU_ACC)
  57. #define APU_ACX0_RPC_LITE_BASE (APU_ACX0_RPC_LITE)
  58. /* RPC offset define */
  59. #define APU_RPC_TOP_CON (0x0000)
  60. #define APU_RPC_TOP_SEL (0x0004)
  61. #define APU_RPC_STATUS (0x0014)
  62. #define APU_RPC_TOP_SEL_1 (0x0018)
  63. #define APU_RPC_HW_CON (0x001c)
  64. #define APU_RPC_INTF_PWR_RDY (0x0044)
  65. #define APU_RPC_SW_TYPE0 (0x0200)
  66. /* RPC control */
  67. #define SRAM_AOC_ISO_CLR BIT(7)
  68. #define BUCK_ELS_EN_SET BIT(10)
  69. #define BUCK_ELS_EN_CLR BIT(11)
  70. #define BUCK_AO_RST_B_SET BIT(12)
  71. #define BUCK_AO_RST_B_CLR BIT(13)
  72. #define BUCK_PROT_REQ_SET BIT(14)
  73. #define BUCK_PROT_REQ_CLR BIT(15)
  74. #define SW_TYPE BIT(1)
  75. #define RPC_CTRL (0x0000009e)
  76. #define RPC_TOP_CTRL (0x0800501e)
  77. #define RPC_TOP_CTRL1 BIT(20)
  78. #define AFC_ENA BIT(16)
  79. #define REG_WAKEUP_SET BIT(8)
  80. #define REG_WAKEUP_CLR BIT(12)
  81. #define PWR_RDY BIT(0)
  82. #define PWR_OFF (0)
  83. #define RPC_STATUS_RDY BIT(29)
  84. #define RSV10 BIT(10)
  85. #define CLR_IRQ (0x6)
  86. #define SLEEP_REQ BIT(0)
  87. /* PLL offset define */
  88. #define PLL4H_PLL1_CON1 (0x000c)
  89. #define PLL4H_PLL2_CON1 (0x001c)
  90. #define PLL4H_PLL3_CON1 (0x002c)
  91. #define PLL4H_PLL4_CON1 (0x003c)
  92. #define PLL4HPLL_FHCTL_HP_EN (0x0e00)
  93. #define PLL4HPLL_FHCTL_CLK_CON (0x0e08)
  94. #define PLL4HPLL_FHCTL_RST_CON (0x0e0c)
  95. #define PLL4HPLL_FHCTL0_CFG (0x0e3c)
  96. #define PLL4HPLL_FHCTL0_DDS (0x0e44)
  97. #define PLL4HPLL_FHCTL1_CFG (0x0e50)
  98. #define PLL4HPLL_FHCTL1_DDS (0x0e58)
  99. #define PLL4HPLL_FHCTL2_CFG (0x0e64)
  100. #define PLL4HPLL_FHCTL2_DDS (0x0e6c)
  101. #define PLL4HPLL_FHCTL3_CFG (0x0e78)
  102. #define PLL4HPLL_FHCTL3_DDS (0x0e80)
  103. /* PLL control */
  104. #define PLL4H_PLL_HP_EN (0xf)
  105. #define PLL4H_PLL_HP_CLKEN (0xf)
  106. #define PLL4H_PLL_HP_SWRSTB (0xf)
  107. #define FHCTL0_EN BIT(0)
  108. #define SFSTR0_EN BIT(2)
  109. #define RG_PLL_POSDIV_MASK (0x7)
  110. #define RG_PLL_POSDIV_SFT (24)
  111. #define FHCTL_PLL_TGL_ORG BIT(31)
  112. /* ACC offset define */
  113. #define APU_ACC_CONFG_SET0 (0x0000)
  114. #define APU_ACC_CONFG_SET1 (0x0004)
  115. #define APU_ACC_CONFG_SET2 (0x0008)
  116. #define APU_ACC_CONFG_SET3 (0x000c)
  117. #define APU_ACC_CONFG_CLR0 (0x0040)
  118. #define APU_ACC_CONFG_CLR1 (0x0044)
  119. #define APU_ACC_CONFG_CLR2 (0x0048)
  120. #define APU_ACC_CONFG_CLR3 (0x004c)
  121. #define APU_ACC_CLK_INV_EN_SET (0x00e8)
  122. #define APU_ACC_AUTO_CTRL_SET2 (0x0128)
  123. #define APU_ACC_AUTO_CTRL_SET3 (0x012c)
  124. /* ACC control */
  125. #define CGEN_SOC BIT(2)
  126. #define HW_CTRL_EN BIT(15)
  127. #define CLK_REQ_SW_EN BIT(8)
  128. #define CLK_INV_EN (0xaaa8)
  129. /* ARE offset define */
  130. #define APU_ARE_INI_CTRL (0x0000)
  131. #define APU_ARE_GLO_FSM (0x0048)
  132. #define APU_ARE_ENTRY0_SRAM_H (0x0c00)
  133. #define APU_ARE_ENTRY0_SRAM_L (0x0800)
  134. #define APU_ARE_ENTRY1_SRAM_H (0x0c04)
  135. #define APU_ARE_ENTRY1_SRAM_L (0x0804)
  136. #define APU_ARE_ENTRY2_SRAM_H (0x0c08)
  137. #define APU_ARE_ENTRY2_SRAM_L (0x0808)
  138. /* ARE control */
  139. #define ARE_ENTRY_CFG_H (0x00140000)
  140. #define ARE0_ENTRY2_CFG_L (0x004e0804)
  141. #define ARE1_ENTRY2_CFG_L (0x004e0806)
  142. #define ARE2_ENTRY2_CFG_L (0x004e0807)
  143. #define ARE_GLO_FSM_IDLE BIT(0)
  144. #define ARE_ENTRY0_SRAM_H_INIT (0x12345678)
  145. #define ARE_ENTRY0_SRAM_L_INIT (0x89abcdef)
  146. #define ARE_ENTRY1_SRAM_H_INIT (0xfedcba98)
  147. #define ARE_ENTRY1_SRAM_L_INIT (0x76543210)
  148. #define ARE_CONFG_INI BIT(2)
  149. /* VCORE offset define */
  150. #define APUSYS_VCORE_CG_CLR (0x0008)
  151. /* RCX offset define */
  152. #define APU_RCX_CG_CLR (0x0008)
  153. /* SPM offset define */
  154. #define APUSYS_BUCK_ISOLATION (0x03ec)
  155. /* SPM control*/
  156. #define IPU_EXT_BUCK_ISO (0x21)
  157. /* apu_rcx_ao_ctrl */
  158. #define CSR_DUMMY_0_ADDR (0x0024)
  159. /* apu_rcx_ao_ctrl control */
  160. #define VCORE_ARE_REQ BIT(2)
  161. /* xpu2apusys */
  162. #define INFRA_FMEM_BUS_u_SI21_CTRL_0 (0x002c)
  163. #define INFRA_FMEM_BUS_u_SI22_CTRL_0 (0x0044)
  164. #define INFRA_FMEM_BUS_u_SI11_CTRL_0 (0x0048)
  165. #define INFRA_FMEM_M6M7_BUS_u_SI24_CTRL_0 (0x01d0)
  166. /* xpu2apusys */
  167. #define INFRA_FMEM_BUS_u_SI21_CTRL_EN BIT(12)
  168. #define INFRA_FMEM_BUS_u_SI22_CTRL_EN BIT(13)
  169. #define INFRA_FMEM_BUS_u_SI11_CTRL_EN BIT(11)
  170. #define INFRA_FMEM_M6M7_BUS_u_SI24_CTRL_EN BIT(15)
  171. /* PCU offset define */
  172. #define APU_PCU_CTRL_SET (0x0000)
  173. #define APU_PCU_BUCK_STEP_SEL (0x0030)
  174. #define APU_PCU_BUCK_ON_DAT0_L (0x0080)
  175. #define APU_PCU_BUCK_ON_DAT0_H (0x0084)
  176. #define APU_PCU_BUCK_ON_DAT1_L (0x0088)
  177. #define APU_PCU_BUCK_ON_DAT1_H (0x008c)
  178. #define APU_PCU_BUCK_OFF_DAT0_L (0x00a0)
  179. #define APU_PCU_BUCK_OFF_DAT0_H (0x00a4)
  180. #define APU_PCU_BUCK_OFF_DAT1_L (0x00a8)
  181. #define APU_PCU_BUCK_OFF_DAT1_H (0x00ac)
  182. #define APU_PCU_BUCK_ON_SLE0 (0x00c0)
  183. #define APU_PCU_BUCK_ON_SLE1 (0x00c4)
  184. #define APU_PCU_BUCK_ON_SETTLE_TIME (0x012c)
  185. /* PCU initial data */
  186. #define MT6359P_RG_BUCK_VMODEM_EN_ADDR (0x1688)
  187. #define MT6359P_RG_LDO_VSRAM_MD_EN_ADDR (0x1f2e)
  188. #define BUCK_VAPU_PMIC_REG_EN_ADDR MT6359P_RG_BUCK_VMODEM_EN_ADDR
  189. #define BUCK_VAPU_SRAM_PMIC_REG_EN_ADDR MT6359P_RG_LDO_VSRAM_MD_EN_ADDR
  190. /* PCU control */
  191. #define AUTO_BUCK_EN BIT(16)
  192. #define BUCK_ON_OFF_CMD_EN (0x33)
  193. #define BUCK_OFFSET_SFT (16)
  194. #define BUCK_ON_CMD (0x1)
  195. #define BUCK_OFF_CMD (0x0)
  196. #define CMD_OP (0x4)
  197. /* RPC lite offset define */
  198. #define APU_RPC_SW_TYPE2 (0x0208)
  199. #define APU_RPC_SW_TYPE3 (0x020c)
  200. #define APU_RPC_SW_TYPE4 (0x0210)
  201. #define APU_RPC_SW_TYPE5 (0x0214)
  202. #define APU_RPC_SW_TYPE6 (0x0218)
  203. #define APU_RPC_SW_TYPE7 (0x021c)
  204. #define APU_RPC_SW_TYPE8 (0x0220)
  205. #define APU_RPC_SW_TYPE9 (0x0224)
  206. /* power flow sync */
  207. #define PWR_FLOW_SYNC_REG (0x0440)
  208. #define CG_CLR (0xffffffff)
  209. int apusys_power_init(void);
  210. int apusys_kernel_apusys_pwr_top_on(void);
  211. int apusys_kernel_apusys_pwr_top_off(void);
  212. #endif /* APUSYS_POWER_H */