mt_spm_internal.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /*
  2. * Copyright (c) 2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef MT_SPM_INTERNAL
  7. #define MT_SPM_INTERNAL
  8. #include "mt_spm.h"
  9. /* Config and Parameter */
  10. #define POWER_ON_VAL0_DEF (0x0000F100)
  11. #define POWER_ON_VAL1_DEF (0x80015860)
  12. #define PCM_WDT_TIMEOUT (30 * 32768) /* 30s */
  13. #define PCM_TIMER_MAX (0xffffffff - PCM_WDT_TIMEOUT)
  14. /* Define and Declare */
  15. /* PCM_PWR_IO_EN */
  16. #define PCM_PWRIO_EN_R0 BIT(0)
  17. #define PCM_PWRIO_EN_R7 BIT(7)
  18. #define PCM_RF_SYNC_R0 BIT(16)
  19. #define PCM_RF_SYNC_R6 BIT(22)
  20. #define PCM_RF_SYNC_R7 BIT(23)
  21. /* SPM_SWINT */
  22. #define PCM_SW_INT0 BIT(0)
  23. #define PCM_SW_INT1 BIT(1)
  24. #define PCM_SW_INT2 BIT(2)
  25. #define PCM_SW_INT3 BIT(3)
  26. #define PCM_SW_INT4 BIT(4)
  27. #define PCM_SW_INT5 BIT(5)
  28. #define PCM_SW_INT6 BIT(6)
  29. #define PCM_SW_INT7 BIT(7)
  30. #define PCM_SW_INT8 BIT(8)
  31. #define PCM_SW_INT9 BIT(9)
  32. #define PCM_SW_INT_ALL (PCM_SW_INT9 | PCM_SW_INT8 | PCM_SW_INT7 | \
  33. PCM_SW_INT6 | PCM_SW_INT5 | PCM_SW_INT4 | \
  34. PCM_SW_INT3 | PCM_SW_INT2 | PCM_SW_INT1 | \
  35. PCM_SW_INT0)
  36. /* SPM_AP_STANDBY_CON */
  37. #define WFI_OP_AND (1U)
  38. #define WFI_OP_OR (0U)
  39. /* SPM_IRQ_MASK */
  40. #define ISRM_TWAM (1U << 2)
  41. #define ISRM_PCM_RETURN (1U << 3)
  42. #define ISRM_RET_IRQ0 (1U << 8)
  43. #define ISRM_RET_IRQ1 (1U << 9)
  44. #define ISRM_RET_IRQ2 (1U << 10)
  45. #define ISRM_RET_IRQ3 (1U << 11)
  46. #define ISRM_RET_IRQ4 (1U << 12)
  47. #define ISRM_RET_IRQ5 (1U << 13)
  48. #define ISRM_RET_IRQ6 (1U << 14)
  49. #define ISRM_RET_IRQ7 (1U << 15)
  50. #define ISRM_RET_IRQ8 (1U << 16)
  51. #define ISRM_RET_IRQ9 (1U << 17)
  52. #define ISRM_RET_IRQ_AUX ((ISRM_RET_IRQ9) | (ISRM_RET_IRQ8) | \
  53. (ISRM_RET_IRQ7) | (ISRM_RET_IRQ6) | \
  54. (ISRM_RET_IRQ5) | (ISRM_RET_IRQ4) | \
  55. (ISRM_RET_IRQ3) | (ISRM_RET_IRQ2) | \
  56. (ISRM_RET_IRQ1))
  57. #define ISRM_ALL_EXC_TWAM (ISRM_RET_IRQ_AUX)
  58. #define ISRM_ALL (ISRM_ALL_EXC_TWAM | ISRM_TWAM)
  59. /* SPM_IRQ_STA */
  60. #define ISRS_TWAM BIT(2)
  61. #define ISRS_PCM_RETURN BIT(3)
  62. #define ISRC_TWAM ISRS_TWAM
  63. #define ISRC_ALL_EXC_TWAM ISRS_PCM_RETURN
  64. #define ISRC_ALL (ISRC_ALL_EXC_TWAM | ISRC_TWAM)
  65. /* SPM_WAKEUP_MISC */
  66. #define WAKE_MISC_GIC_WAKEUP (0x3FF)
  67. #define WAKE_MISC_DVFSRC_IRQ DVFSRC_IRQ_LSB
  68. #define WAKE_MISC_REG_CPU_WAKEUP SPM_WAKEUP_MISC_REG_CPU_WAKEUP_LSB
  69. #define WAKE_MISC_PCM_TIMER_EVENT PCM_TIMER_EVENT_LSB
  70. #define WAKE_MISC_PMIC_OUT_B ((1U << 19) | (1U << 20))
  71. #define WAKE_MISC_TWAM_IRQ_B TWAM_IRQ_B_LSB
  72. #define WAKE_MISC_SPM_ACK_CHK_WAKEUP_0 SPM_ACK_CHK_WAKEUP_0_LSB
  73. #define WAKE_MISC_SPM_ACK_CHK_WAKEUP_1 SPM_ACK_CHK_WAKEUP_1_LSB
  74. #define WAKE_MISC_SPM_ACK_CHK_WAKEUP_2 SPM_ACK_CHK_WAKEUP_2_LSB
  75. #define WAKE_MISC_SPM_ACK_CHK_WAKEUP_3 SPM_ACK_CHK_WAKEUP_3_LSB
  76. #define WAKE_MISC_SPM_ACK_CHK_WAKEUP_ALL SPM_ACK_CHK_WAKEUP_ALL_LSB
  77. #define WAKE_MISC_PMIC_IRQ_ACK PMIC_IRQ_ACK_LSB
  78. #define WAKE_MISC_PMIC_SCP_IRQ PMIC_SCP_IRQ_LSB
  79. /* ABORT MASK for DEBUG FOORTPRINT */
  80. #define DEBUG_ABORT_MASK \
  81. (SPM_DBG_DEBUG_IDX_DRAM_SREF_ABORT_IN_APSRC | \
  82. SPM_DBG_DEBUG_IDX_DRAM_SREF_ABORT_IN_DDREN)
  83. #define DEBUG_ABORT_MASK_1 \
  84. (SPM_DBG1_DEBUG_IDX_VRCXO_SLEEP_ABORT | \
  85. SPM_DBG1_DEBUG_IDX_PWRAP_SLEEP_ACK_LOW_ABORT | \
  86. SPM_DBG1_DEBUG_IDX_PWRAP_SLEEP_ACK_HIGH_ABORT | \
  87. SPM_DBG1_DEBUG_IDX_EMI_SLP_IDLE_ABORT | \
  88. SPM_DBG1_DEBUG_IDX_SCP_SLP_ACK_LOW_ABORT | \
  89. SPM_DBG1_DEBUG_IDX_SCP_SLP_ACK_HIGH_ABORT | \
  90. SPM_DBG1_DEBUG_IDX_SPM_DVFS_CMD_RDY_ABORT)
  91. #define MCUPM_MBOX_WAKEUP_CPU (0x0C55FD10)
  92. struct pwr_ctrl {
  93. uint32_t pcm_flags;
  94. uint32_t pcm_flags_cust;
  95. uint32_t pcm_flags_cust_set;
  96. uint32_t pcm_flags_cust_clr;
  97. uint32_t pcm_flags1;
  98. uint32_t pcm_flags1_cust;
  99. uint32_t pcm_flags1_cust_set;
  100. uint32_t pcm_flags1_cust_clr;
  101. uint32_t timer_val;
  102. uint32_t timer_val_cust;
  103. uint32_t timer_val_ramp_en;
  104. uint32_t timer_val_ramp_en_sec;
  105. uint32_t wake_src;
  106. uint32_t wake_src_cust;
  107. uint32_t wakelock_timer_val;
  108. uint8_t wdt_disable;
  109. /* Auto-gen Start */
  110. /* SPM_AP_STANDBY_CON */
  111. uint8_t reg_wfi_op;
  112. uint8_t reg_wfi_type;
  113. uint8_t reg_mp0_cputop_idle_mask;
  114. uint8_t reg_mp1_cputop_idle_mask;
  115. uint8_t reg_mcusys_idle_mask;
  116. uint8_t reg_md_apsrc_1_sel;
  117. uint8_t reg_md_apsrc_0_sel;
  118. uint8_t reg_conn_apsrc_sel;
  119. /* SPM_SRC6_MASK */
  120. uint32_t reg_ccif_event_infra_req_mask_b;
  121. uint32_t reg_ccif_event_apsrc_req_mask_b;
  122. /* SPM_SRC_REQ */
  123. uint8_t reg_spm_apsrc_req;
  124. uint8_t reg_spm_f26m_req;
  125. uint8_t reg_spm_infra_req;
  126. uint8_t reg_spm_vrf18_req;
  127. uint8_t reg_spm_ddren_req;
  128. uint8_t reg_spm_dvfs_req;
  129. uint8_t reg_spm_sw_mailbox_req;
  130. uint8_t reg_spm_sspm_mailbox_req;
  131. uint8_t reg_spm_adsp_mailbox_req;
  132. uint8_t reg_spm_scp_mailbox_req;
  133. /* SPM_SRC_MASK */
  134. uint8_t reg_md_0_srcclkena_mask_b;
  135. uint8_t reg_md_0_infra_req_mask_b;
  136. uint8_t reg_md_0_apsrc_req_mask_b;
  137. uint8_t reg_md_0_vrf18_req_mask_b;
  138. uint8_t reg_md_0_ddren_req_mask_b;
  139. uint8_t reg_md_1_srcclkena_mask_b;
  140. uint8_t reg_md_1_infra_req_mask_b;
  141. uint8_t reg_md_1_apsrc_req_mask_b;
  142. uint8_t reg_md_1_vrf18_req_mask_b;
  143. uint8_t reg_md_1_ddren_req_mask_b;
  144. uint8_t reg_conn_srcclkena_mask_b;
  145. uint8_t reg_conn_srcclkenb_mask_b;
  146. uint8_t reg_conn_infra_req_mask_b;
  147. uint8_t reg_conn_apsrc_req_mask_b;
  148. uint8_t reg_conn_vrf18_req_mask_b;
  149. uint8_t reg_conn_ddren_req_mask_b;
  150. uint8_t reg_conn_vfe28_mask_b;
  151. uint8_t reg_srcclkeni_srcclkena_mask_b;
  152. uint8_t reg_srcclkeni_infra_req_mask_b;
  153. uint8_t reg_infrasys_apsrc_req_mask_b;
  154. uint8_t reg_infrasys_ddren_req_mask_b;
  155. uint8_t reg_sspm_srcclkena_mask_b;
  156. uint8_t reg_sspm_infra_req_mask_b;
  157. uint8_t reg_sspm_apsrc_req_mask_b;
  158. uint8_t reg_sspm_vrf18_req_mask_b;
  159. uint8_t reg_sspm_ddren_req_mask_b;
  160. /* SPM_SRC2_MASK */
  161. uint8_t reg_scp_srcclkena_mask_b;
  162. uint8_t reg_scp_infra_req_mask_b;
  163. uint8_t reg_scp_apsrc_req_mask_b;
  164. uint8_t reg_scp_vrf18_req_mask_b;
  165. uint8_t reg_scp_ddren_req_mask_b;
  166. uint8_t reg_audio_dsp_srcclkena_mask_b;
  167. uint8_t reg_audio_dsp_infra_req_mask_b;
  168. uint8_t reg_audio_dsp_apsrc_req_mask_b;
  169. uint8_t reg_audio_dsp_vrf18_req_mask_b;
  170. uint8_t reg_audio_dsp_ddren_req_mask_b;
  171. uint8_t reg_ufs_srcclkena_mask_b;
  172. uint8_t reg_ufs_infra_req_mask_b;
  173. uint8_t reg_ufs_apsrc_req_mask_b;
  174. uint8_t reg_ufs_vrf18_req_mask_b;
  175. uint8_t reg_ufs_ddren_req_mask_b;
  176. uint8_t reg_disp0_apsrc_req_mask_b;
  177. uint8_t reg_disp0_ddren_req_mask_b;
  178. uint8_t reg_disp1_apsrc_req_mask_b;
  179. uint8_t reg_disp1_ddren_req_mask_b;
  180. uint8_t reg_gce_infra_req_mask_b;
  181. uint8_t reg_gce_apsrc_req_mask_b;
  182. uint8_t reg_gce_vrf18_req_mask_b;
  183. uint8_t reg_gce_ddren_req_mask_b;
  184. uint8_t reg_apu_srcclkena_mask_b;
  185. uint8_t reg_apu_infra_req_mask_b;
  186. uint8_t reg_apu_apsrc_req_mask_b;
  187. uint8_t reg_apu_vrf18_req_mask_b;
  188. uint8_t reg_apu_ddren_req_mask_b;
  189. uint8_t reg_cg_check_srcclkena_mask_b;
  190. uint8_t reg_cg_check_apsrc_req_mask_b;
  191. uint8_t reg_cg_check_vrf18_req_mask_b;
  192. uint8_t reg_cg_check_ddren_req_mask_b;
  193. /* SPM_SRC3_MASK */
  194. uint8_t reg_dvfsrc_event_trigger_mask_b;
  195. uint8_t reg_sw2spm_wakeup_mask_b;
  196. uint8_t reg_adsp2spm_wakeup_mask_b;
  197. uint8_t reg_sspm2spm_wakeup_mask_b;
  198. uint8_t reg_scp2spm_wakeup_mask_b;
  199. uint8_t reg_csyspwrup_ack_mask;
  200. uint8_t reg_spm_reserved_srcclkena_mask_b;
  201. uint8_t reg_spm_reserved_infra_req_mask_b;
  202. uint8_t reg_spm_reserved_apsrc_req_mask_b;
  203. uint8_t reg_spm_reserved_vrf18_req_mask_b;
  204. uint8_t reg_spm_reserved_ddren_req_mask_b;
  205. uint8_t reg_mcupm_srcclkena_mask_b;
  206. uint8_t reg_mcupm_infra_req_mask_b;
  207. uint8_t reg_mcupm_apsrc_req_mask_b;
  208. uint8_t reg_mcupm_vrf18_req_mask_b;
  209. uint8_t reg_mcupm_ddren_req_mask_b;
  210. uint8_t reg_msdc0_srcclkena_mask_b;
  211. uint8_t reg_msdc0_infra_req_mask_b;
  212. uint8_t reg_msdc0_apsrc_req_mask_b;
  213. uint8_t reg_msdc0_vrf18_req_mask_b;
  214. uint8_t reg_msdc0_ddren_req_mask_b;
  215. uint8_t reg_msdc1_srcclkena_mask_b;
  216. uint8_t reg_msdc1_infra_req_mask_b;
  217. uint8_t reg_msdc1_apsrc_req_mask_b;
  218. uint8_t reg_msdc1_vrf18_req_mask_b;
  219. uint8_t reg_msdc1_ddren_req_mask_b;
  220. /* SPM_SRC4_MASK */
  221. uint32_t reg_ccif_event_srcclkena_mask_b;
  222. uint8_t reg_bak_psri_srcclkena_mask_b;
  223. uint8_t reg_bak_psri_infra_req_mask_b;
  224. uint8_t reg_bak_psri_apsrc_req_mask_b;
  225. uint8_t reg_bak_psri_vrf18_req_mask_b;
  226. uint8_t reg_bak_psri_ddren_req_mask_b;
  227. uint8_t reg_dramc_md32_infra_req_mask_b;
  228. uint8_t reg_dramc_md32_vrf18_req_mask_b;
  229. uint8_t reg_conn_srcclkenb2pwrap_mask_b;
  230. uint8_t reg_dramc_md32_apsrc_req_mask_b;
  231. /* SPM_SRC5_MASK */
  232. uint32_t reg_mcusys_merge_apsrc_req_mask_b;
  233. uint32_t reg_mcusys_merge_ddren_req_mask_b;
  234. uint8_t reg_afe_srcclkena_mask_b;
  235. uint8_t reg_afe_infra_req_mask_b;
  236. uint8_t reg_afe_apsrc_req_mask_b;
  237. uint8_t reg_afe_vrf18_req_mask_b;
  238. uint8_t reg_afe_ddren_req_mask_b;
  239. uint8_t reg_msdc2_srcclkena_mask_b;
  240. uint8_t reg_msdc2_infra_req_mask_b;
  241. uint8_t reg_msdc2_apsrc_req_mask_b;
  242. uint8_t reg_msdc2_vrf18_req_mask_b;
  243. uint8_t reg_msdc2_ddren_req_mask_b;
  244. /* SPM_WAKEUP_EVENT_MASK */
  245. uint32_t reg_wakeup_event_mask;
  246. /* SPM_WAKEUP_EVENT_EXT_MASK */
  247. uint32_t reg_ext_wakeup_event_mask;
  248. /* SPM_SRC7_MASK */
  249. uint8_t reg_pcie_srcclkena_mask_b;
  250. uint8_t reg_pcie_infra_req_mask_b;
  251. uint8_t reg_pcie_apsrc_req_mask_b;
  252. uint8_t reg_pcie_vrf18_req_mask_b;
  253. uint8_t reg_pcie_ddren_req_mask_b;
  254. uint8_t reg_dpmaif_srcclkena_mask_b;
  255. uint8_t reg_dpmaif_infra_req_mask_b;
  256. uint8_t reg_dpmaif_apsrc_req_mask_b;
  257. uint8_t reg_dpmaif_vrf18_req_mask_b;
  258. uint8_t reg_dpmaif_ddren_req_mask_b;
  259. /* Auto-gen End */
  260. };
  261. /* code gen by spm_pwr_ctrl_atf.pl, need struct pwr_ctrl */
  262. enum pwr_ctrl_enum {
  263. PW_PCM_FLAGS,
  264. PW_PCM_FLAGS_CUST,
  265. PW_PCM_FLAGS_CUST_SET,
  266. PW_PCM_FLAGS_CUST_CLR,
  267. PW_PCM_FLAGS1,
  268. PW_PCM_FLAGS1_CUST,
  269. PW_PCM_FLAGS1_CUST_SET,
  270. PW_PCM_FLAGS1_CUST_CLR,
  271. PW_TIMER_VAL,
  272. PW_TIMER_VAL_CUST,
  273. PW_TIMER_VAL_RAMP_EN,
  274. PW_TIMER_VAL_RAMP_EN_SEC,
  275. PW_WAKE_SRC,
  276. PW_WAKE_SRC_CUST,
  277. PW_WAKELOCK_TIMER_VAL,
  278. PW_WDT_DISABLE,
  279. /* SPM_AP_STANDBY_CON */
  280. PW_REG_WFI_OP,
  281. PW_REG_WFI_TYPE,
  282. PW_REG_MP0_CPUTOP_IDLE_MASK,
  283. PW_REG_MP1_CPUTOP_IDLE_MASK,
  284. PW_REG_MCUSYS_IDLE_MASK,
  285. PW_REG_MD_APSRC_1_SEL,
  286. PW_REG_MD_APSRC_0_SEL,
  287. PW_REG_CONN_APSRC_SEL,
  288. /* SPM_SRC6_MASK */
  289. PW_REG_CCIF_EVENT_INFRA_REQ_MASK_B,
  290. PW_REG_CCIF_EVENT_APSRC_REQ_MASK_B,
  291. /* SPM_WAKEUP_EVENT_SENS */
  292. PW_REG_WAKEUP_EVENT_SENS,
  293. /* SPM_SRC_REQ */
  294. PW_REG_SPM_APSRC_REQ,
  295. PW_REG_SPM_F26M_REQ,
  296. PW_REG_SPM_INFRA_REQ,
  297. PW_REG_SPM_VRF18_REQ,
  298. PW_REG_SPM_DDREN_REQ,
  299. PW_REG_SPM_DVFS_REQ,
  300. PW_REG_SPM_SW_MAILBOX_REQ,
  301. PW_REG_SPM_SSPM_MAILBOX_REQ,
  302. PW_REG_SPM_ADSP_MAILBOX_REQ,
  303. PW_REG_SPM_SCP_MAILBOX_REQ,
  304. /* SPM_SRC_MASK */
  305. PW_REG_MD_0_SRCCLKENA_MASK_B,
  306. PW_REG_MD_0_INFRA_REQ_MASK_B,
  307. PW_REG_MD_0_APSRC_REQ_MASK_B,
  308. PW_REG_MD_0_VRF18_REQ_MASK_B,
  309. PW_REG_MD_0_DDREN_REQ_MASK_B,
  310. PW_REG_MD_1_SRCCLKENA_MASK_B,
  311. PW_REG_MD_1_INFRA_REQ_MASK_B,
  312. PW_REG_MD_1_APSRC_REQ_MASK_B,
  313. PW_REG_MD_1_VRF18_REQ_MASK_B,
  314. PW_REG_MD_1_DDREN_REQ_MASK_B,
  315. PW_REG_CONN_SRCCLKENA_MASK_B,
  316. PW_REG_CONN_SRCCLKENB_MASK_B,
  317. PW_REG_CONN_INFRA_REQ_MASK_B,
  318. PW_REG_CONN_APSRC_REQ_MASK_B,
  319. PW_REG_CONN_VRF18_REQ_MASK_B,
  320. PW_REG_CONN_DDREN_REQ_MASK_B,
  321. PW_REG_CONN_VFE28_MASK_B,
  322. PW_REG_SRCCLKENI_SRCCLKENA_MASK_B,
  323. PW_REG_SRCCLKENI_INFRA_REQ_MASK_B,
  324. PW_REG_INFRASYS_APSRC_REQ_MASK_B,
  325. PW_REG_INFRASYS_DDREN_REQ_MASK_B,
  326. PW_REG_SSPM_SRCCLKENA_MASK_B,
  327. PW_REG_SSPM_INFRA_REQ_MASK_B,
  328. PW_REG_SSPM_APSRC_REQ_MASK_B,
  329. PW_REG_SSPM_VRF18_REQ_MASK_B,
  330. PW_REG_SSPM_DDREN_REQ_MASK_B,
  331. /* SPM_SRC2_MASK */
  332. PW_REG_SCP_SRCCLKENA_MASK_B,
  333. PW_REG_SCP_INFRA_REQ_MASK_B,
  334. PW_REG_SCP_APSRC_REQ_MASK_B,
  335. PW_REG_SCP_VRF18_REQ_MASK_B,
  336. PW_REG_SCP_DDREN_REQ_MASK_B,
  337. PW_REG_AUDIO_DSP_SRCCLKENA_MASK_B,
  338. PW_REG_AUDIO_DSP_INFRA_REQ_MASK_B,
  339. PW_REG_AUDIO_DSP_APSRC_REQ_MASK_B,
  340. PW_REG_AUDIO_DSP_VRF18_REQ_MASK_B,
  341. PW_REG_AUDIO_DSP_DDREN_REQ_MASK_B,
  342. PW_REG_UFS_SRCCLKENA_MASK_B,
  343. PW_REG_UFS_INFRA_REQ_MASK_B,
  344. PW_REG_UFS_APSRC_REQ_MASK_B,
  345. PW_REG_UFS_VRF18_REQ_MASK_B,
  346. PW_REG_UFS_DDREN_REQ_MASK_B,
  347. PW_REG_DISP0_APSRC_REQ_MASK_B,
  348. PW_REG_DISP0_DDREN_REQ_MASK_B,
  349. PW_REG_DISP1_APSRC_REQ_MASK_B,
  350. PW_REG_DISP1_DDREN_REQ_MASK_B,
  351. PW_REG_GCE_INFRA_REQ_MASK_B,
  352. PW_REG_GCE_APSRC_REQ_MASK_B,
  353. PW_REG_GCE_VRF18_REQ_MASK_B,
  354. PW_REG_GCE_DDREN_REQ_MASK_B,
  355. PW_REG_APU_SRCCLKENA_MASK_B,
  356. PW_REG_APU_INFRA_REQ_MASK_B,
  357. PW_REG_APU_APSRC_REQ_MASK_B,
  358. PW_REG_APU_VRF18_REQ_MASK_B,
  359. PW_REG_APU_DDREN_REQ_MASK_B,
  360. PW_REG_CG_CHECK_SRCCLKENA_MASK_B,
  361. PW_REG_CG_CHECK_APSRC_REQ_MASK_B,
  362. PW_REG_CG_CHECK_VRF18_REQ_MASK_B,
  363. PW_REG_CG_CHECK_DDREN_REQ_MASK_B,
  364. /* SPM_SRC3_MASK */
  365. PW_REG_DVFSRC_EVENT_TRIGGER_MASK_B,
  366. PW_REG_SW2SPM_WAKEUP_MASK_B,
  367. PW_REG_ADSP2SPM_WAKEUP_MASK_B,
  368. PW_REG_SSPM2SPM_WAKEUP_MASK_B,
  369. PW_REG_SCP2SPM_WAKEUP_MASK_B,
  370. PW_REG_CSYSPWRUP_ACK_MASK,
  371. PW_REG_SPM_RESERVED_SRCCLKENA_MASK_B,
  372. PW_REG_SPM_RESERVED_INFRA_REQ_MASK_B,
  373. PW_REG_SPM_RESERVED_APSRC_REQ_MASK_B,
  374. PW_REG_SPM_RESERVED_VRF18_REQ_MASK_B,
  375. PW_REG_SPM_RESERVED_DDREN_REQ_MASK_B,
  376. PW_REG_MCUPM_SRCCLKENA_MASK_B,
  377. PW_REG_MCUPM_INFRA_REQ_MASK_B,
  378. PW_REG_MCUPM_APSRC_REQ_MASK_B,
  379. PW_REG_MCUPM_VRF18_REQ_MASK_B,
  380. PW_REG_MCUPM_DDREN_REQ_MASK_B,
  381. PW_REG_MSDC0_SRCCLKENA_MASK_B,
  382. PW_REG_MSDC0_INFRA_REQ_MASK_B,
  383. PW_REG_MSDC0_APSRC_REQ_MASK_B,
  384. PW_REG_MSDC0_VRF18_REQ_MASK_B,
  385. PW_REG_MSDC0_DDREN_REQ_MASK_B,
  386. PW_REG_MSDC1_SRCCLKENA_MASK_B,
  387. PW_REG_MSDC1_INFRA_REQ_MASK_B,
  388. PW_REG_MSDC1_APSRC_REQ_MASK_B,
  389. PW_REG_MSDC1_VRF18_REQ_MASK_B,
  390. PW_REG_MSDC1_DDREN_REQ_MASK_B,
  391. /* SPM_SRC4_MASK */
  392. PW_REG_CCIF_EVENT_SRCCLKENA_MASK_B,
  393. PW_REG_BAK_PSRI_SRCCLKENA_MASK_B,
  394. PW_REG_BAK_PSRI_INFRA_REQ_MASK_B,
  395. PW_REG_BAK_PSRI_APSRC_REQ_MASK_B,
  396. PW_REG_BAK_PSRI_VRF18_REQ_MASK_B,
  397. PW_REG_BAK_PSRI_DDREN_REQ_MASK_B,
  398. PW_REG_DRAMC_MD32_INFRA_REQ_MASK_B,
  399. PW_REG_DRAMC_MD32_VRF18_REQ_MASK_B,
  400. PW_REG_CONN_SRCCLKENB2PWRAP_MASK_B,
  401. PW_REG_DRAMC_MD32_APSRC_REQ_MASK_B,
  402. /* SPM_SRC5_MASK */
  403. PW_REG_MCUSYS_MERGE_APSRC_REQ_MASK_B,
  404. PW_REG_MCUSYS_MERGE_DDREN_REQ_MASK_B,
  405. PW_REG_AFE_SRCCLKENA_MASK_B,
  406. PW_REG_AFE_INFRA_REQ_MASK_B,
  407. PW_REG_AFE_APSRC_REQ_MASK_B,
  408. PW_REG_AFE_VRF18_REQ_MASK_B,
  409. PW_REG_AFE_DDREN_REQ_MASK_B,
  410. PW_REG_MSDC2_SRCCLKENA_MASK_B,
  411. PW_REG_MSDC2_INFRA_REQ_MASK_B,
  412. PW_REG_MSDC2_APSRC_REQ_MASK_B,
  413. PW_REG_MSDC2_VRF18_REQ_MASK_B,
  414. PW_REG_MSDC2_DDREN_REQ_MASK_B,
  415. /* SPM_WAKEUP_EVENT_MASK */
  416. PW_REG_WAKEUP_EVENT_MASK,
  417. /* SPM_WAKEUP_EVENT_EXT_MASK */
  418. PW_REG_EXT_WAKEUP_EVENT_MASK,
  419. /* SPM_SRC7_MASK */
  420. PW_REG_PCIE_SRCCLKENA_MASK_B,
  421. PW_REG_PCIE_INFRA_REQ_MASK_B,
  422. PW_REG_PCIE_APSRC_REQ_MASK_B,
  423. PW_REG_PCIE_VRF18_REQ_MASK_B,
  424. PW_REG_PCIE_DDREN_REQ_MASK_B,
  425. PW_REG_DPMAIF_SRCCLKENA_MASK_B,
  426. PW_REG_DPMAIF_INFRA_REQ_MASK_B,
  427. PW_REG_DPMAIF_APSRC_REQ_MASK_B,
  428. PW_REG_DPMAIF_VRF18_REQ_MASK_B,
  429. PW_REG_DPMAIF_DDREN_REQ_MASK_B,
  430. PW_MAX_COUNT,
  431. };
  432. /*
  433. * ACK HW MODE SETTING
  434. * 0: trigger(1)
  435. * 1: trigger(0)
  436. * 2: trigger(1) and target(0)
  437. * 3: trigger(0) and target(1)
  438. * 4: trigger(1) and target(1)
  439. * 5: trigger(0) and target(0)
  440. */
  441. #define TRIG_H_TAR_L (2U)
  442. #define TRIG_L_TAR_H (3U)
  443. #define TRIG_H_TAR_H (4U)
  444. #define TRIG_L_TAR_L (5U)
  445. #define SPM_INTERNAL_STATUS_HW_S1 (1U << 0)
  446. #define SPM_ACK_CHK_3_SEL_HW_S1 (0x00350098)
  447. #define SPM_ACK_CHK_3_HW_S1_CNT (1U)
  448. #define SPM_ACK_CHK_3_CON_HW_MODE_TRIG (TRIG_L_TAR_H << 9u)
  449. #define SPM_ACK_CHK_3_CON_EN (0x110)
  450. #define SPM_ACK_CHK_3_CON_CLR_ALL (0x2)
  451. #define SPM_ACK_CHK_3_CON_RESULT (0x8000)
  452. struct wake_status_trace_comm {
  453. uint32_t debug_flag; /* PCM_WDT_LATCH_SPARE_0 */
  454. uint32_t debug_flag1; /* PCM_WDT_LATCH_SPARE_1 */
  455. uint32_t timer_out; /* SPM_SW_RSV_6*/
  456. uint32_t b_sw_flag0; /* SPM_SW_RSV_7 */
  457. uint32_t b_sw_flag1; /* SPM_SW_RSV_7 */
  458. uint32_t r12; /* SPM_SW_RSV_0 */
  459. uint32_t r13; /* PCM_REG13_DATA */
  460. uint32_t req_sta0; /* SRC_REQ_STA_0 */
  461. uint32_t req_sta1; /* SRC_REQ_STA_1 */
  462. uint32_t req_sta2; /* SRC_REQ_STA_2 */
  463. uint32_t req_sta3; /* SRC_REQ_STA_3 */
  464. uint32_t req_sta4; /* SRC_REQ_STA_4 */
  465. uint32_t raw_sta; /* SPM_WAKEUP_STA */
  466. uint32_t times_h; /* timestamp high bits */
  467. uint32_t times_l; /* timestamp low bits */
  468. uint32_t resumetime; /* timestamp low bits */
  469. };
  470. struct wake_status_trace {
  471. struct wake_status_trace_comm comm;
  472. };
  473. struct wake_status {
  474. struct wake_status_trace tr;
  475. uint32_t r12; /* SPM_BK_WAKE_EVENT */
  476. uint32_t r12_ext; /* SPM_WAKEUP_EXT_STA */
  477. uint32_t raw_sta; /* SPM_WAKEUP_STA */
  478. uint32_t raw_ext_sta; /* SPM_WAKEUP_EXT_STA */
  479. uint32_t md32pcm_wakeup_sta; /* MD32CPM_WAKEUP_STA */
  480. uint32_t md32pcm_event_sta; /* MD32PCM_EVENT_STA */
  481. uint32_t wake_misc; /* SPM_BK_WAKE_MISC */
  482. uint32_t timer_out; /* SPM_BK_PCM_TIMER */
  483. uint32_t r13; /* PCM_REG13_DATA */
  484. uint32_t idle_sta; /* SUBSYS_IDLE_STA */
  485. uint32_t req_sta0; /* SRC_REQ_STA_0 */
  486. uint32_t req_sta1; /* SRC_REQ_STA_1 */
  487. uint32_t req_sta2; /* SRC_REQ_STA_2 */
  488. uint32_t req_sta3; /* SRC_REQ_STA_3 */
  489. uint32_t req_sta4; /* SRC_REQ_STA_4 */
  490. uint32_t cg_check_sta; /* SPM_CG_CHECK_STA */
  491. uint32_t debug_flag; /* PCM_WDT_LATCH_SPARE_0 */
  492. uint32_t debug_flag1; /* PCM_WDT_LATCH_SPARE_1 */
  493. uint32_t b_sw_flag0; /* SPM_SW_RSV_7 */
  494. uint32_t b_sw_flag1; /* SPM_SW_RSV_8 */
  495. uint32_t isr; /* SPM_IRQ_STA */
  496. uint32_t sw_flag0; /* SPM_SW_FLAG_0 */
  497. uint32_t sw_flag1; /* SPM_SW_FLAG_1 */
  498. uint32_t clk_settle; /* SPM_CLK_SETTLE */
  499. uint32_t src_req; /* SPM_SRC_REQ */
  500. uint32_t log_index;
  501. uint32_t abort;
  502. uint32_t rt_req_sta0; /* SPM_SW_RSV_2 */
  503. uint32_t rt_req_sta1; /* SPM_SW_RSV_3 */
  504. uint32_t rt_req_sta2; /* SPM_SW_RSV_4 */
  505. uint32_t rt_req_sta3; /* SPM_SW_RSV_5 */
  506. uint32_t rt_req_sta4; /* SPM_SW_RSV_6 */
  507. uint32_t mcupm_req_sta;
  508. };
  509. struct spm_lp_scen {
  510. struct pcm_desc *pcmdesc;
  511. struct pwr_ctrl *pwrctrl;
  512. };
  513. extern struct spm_lp_scen __spm_vcorefs;
  514. extern void __spm_set_cpu_status(unsigned int cpu);
  515. extern void __spm_reset_and_init_pcm(const struct pcm_desc *pcmdesc);
  516. extern void __spm_kick_im_to_fetch(const struct pcm_desc *pcmdesc);
  517. extern void __spm_init_pcm_register(void);
  518. extern void __spm_src_req_update(const struct pwr_ctrl *pwrctrl,
  519. unsigned int resource_usage);
  520. extern void __spm_set_power_control(const struct pwr_ctrl *pwrctrl);
  521. extern void __spm_disable_pcm_timer(void);
  522. extern void __spm_set_wakeup_event(const struct pwr_ctrl *pwrctrl);
  523. extern void __spm_kick_pcm_to_run(struct pwr_ctrl *pwrctrl);
  524. extern void __spm_set_pcm_flags(struct pwr_ctrl *pwrctrl);
  525. extern void __spm_send_cpu_wakeup_event(void);
  526. extern void __spm_get_wakeup_status(struct wake_status *wakesta,
  527. unsigned int ext_status);
  528. extern void __spm_clean_after_wakeup(void);
  529. extern wake_reason_t __spm_output_wake_reason(int state_id,
  530. const struct wake_status *wakesta);
  531. extern void __spm_sync_vcore_dvfs_power_control(struct pwr_ctrl *dest_pwr_ctrl,
  532. const struct pwr_ctrl *src_pwr_ctrl);
  533. extern void __spm_set_pcm_wdt(int en);
  534. extern uint32_t _spm_get_wake_period(int pwake_time, wake_reason_t last_wr);
  535. extern void __spm_set_fw_resume_option(struct pwr_ctrl *pwrctrl);
  536. extern void __spm_ext_int_wakeup_req_clr(void);
  537. extern void __spm_xo_soc_bblpm(int en);
  538. static inline void set_pwrctrl_pcm_flags(struct pwr_ctrl *pwrctrl,
  539. uint32_t flags)
  540. {
  541. if (pwrctrl->pcm_flags_cust == 0U) {
  542. pwrctrl->pcm_flags = flags;
  543. } else {
  544. pwrctrl->pcm_flags = pwrctrl->pcm_flags_cust;
  545. }
  546. }
  547. static inline void set_pwrctrl_pcm_flags1(struct pwr_ctrl *pwrctrl,
  548. uint32_t flags)
  549. {
  550. if (pwrctrl->pcm_flags1_cust == 0U) {
  551. pwrctrl->pcm_flags1 = flags;
  552. } else {
  553. pwrctrl->pcm_flags1 = pwrctrl->pcm_flags1_cust;
  554. }
  555. }
  556. extern void __spm_hw_s1_state_monitor(int en, unsigned int *status);
  557. static inline void spm_hw_s1_state_monitor_resume(void)
  558. {
  559. __spm_hw_s1_state_monitor(1, NULL);
  560. }
  561. static inline void spm_hw_s1_state_monitor_pause(unsigned int *status)
  562. {
  563. __spm_hw_s1_state_monitor(0, status);
  564. }
  565. #endif /* MT_SPM_INTERNAL_H */