mt_spm_internal.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * Copyright (c) 2023, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef MT_SPM_INTERNAL_H
  7. #define MT_SPM_INTERNAL_H
  8. #include <mt_spm.h>
  9. /* PCM_WDT_VAL */
  10. #define PCM_WDT_TIMEOUT (30 * 32768) /* 30s */
  11. /* PCM_TIMER_VAL */
  12. #define PCM_TIMER_MAX (0xffffffff - PCM_WDT_TIMEOUT)
  13. /* PCM_PWR_IO_EN */
  14. #define PCM_PWRIO_EN_R0 BIT(0)
  15. #define PCM_PWRIO_EN_R7 BIT(7)
  16. #define PCM_RF_SYNC_R0 BIT(16)
  17. #define PCM_RF_SYNC_R6 BIT(22)
  18. #define PCM_RF_SYNC_R7 BIT(23)
  19. /* SPM_SWINT */
  20. #define PCM_SW_INT0 BIT(0)
  21. #define PCM_SW_INT1 BIT(1)
  22. #define PCM_SW_INT2 BIT(2)
  23. #define PCM_SW_INT3 BIT(3)
  24. #define PCM_SW_INT4 BIT(4)
  25. #define PCM_SW_INT5 BIT(5)
  26. #define PCM_SW_INT6 BIT(6)
  27. #define PCM_SW_INT7 BIT(7)
  28. #define PCM_SW_INT8 BIT(8)
  29. #define PCM_SW_INT9 BIT(9)
  30. #define PCM_SW_INT_ALL (PCM_SW_INT9 | PCM_SW_INT8 | PCM_SW_INT7 | \
  31. PCM_SW_INT6 | PCM_SW_INT5 | PCM_SW_INT4 | \
  32. PCM_SW_INT3 | PCM_SW_INT2 | PCM_SW_INT1 | \
  33. PCM_SW_INT0)
  34. /* SPM_AP_STANDBY_CON */
  35. #define WFI_OP_AND (1U)
  36. #define WFI_OP_OR (0U)
  37. /* SPM_IRQ_MASK */
  38. #define ISRM_TWAM BIT(2)
  39. #define ISRM_PCM_RETURN BIT(3)
  40. #define ISRM_RET_IRQ0 BIT(8)
  41. #define ISRM_RET_IRQ1 BIT(9)
  42. #define ISRM_RET_IRQ2 BIT(10)
  43. #define ISRM_RET_IRQ3 BIT(11)
  44. #define ISRM_RET_IRQ4 BIT(12)
  45. #define ISRM_RET_IRQ5 BIT(13)
  46. #define ISRM_RET_IRQ6 BIT(14)
  47. #define ISRM_RET_IRQ7 BIT(15)
  48. #define ISRM_RET_IRQ8 BIT(16)
  49. #define ISRM_RET_IRQ9 BIT(17)
  50. #define ISRM_RET_IRQ_AUX ((ISRM_RET_IRQ9) | (ISRM_RET_IRQ8) | \
  51. (ISRM_RET_IRQ7) | (ISRM_RET_IRQ6) | \
  52. (ISRM_RET_IRQ5) | (ISRM_RET_IRQ4) | \
  53. (ISRM_RET_IRQ3) | (ISRM_RET_IRQ2) | \
  54. (ISRM_RET_IRQ1))
  55. #define ISRM_ALL_EXC_TWAM ISRM_RET_IRQ_AUX
  56. #define ISRM_ALL (ISRM_ALL_EXC_TWAM | ISRM_TWAM)
  57. /* SPM_IRQ_STA */
  58. #define ISRS_TWAM BIT(2)
  59. #define ISRS_PCM_RETURN BIT(3)
  60. #define ISRC_TWAM ISRS_TWAM
  61. #define ISRC_ALL_EXC_TWAM ISRS_PCM_RETURN
  62. #define ISRC_ALL (ISRC_ALL_EXC_TWAM | ISRC_TWAM)
  63. /* SPM_WAKEUP_MISC */
  64. #define WAKE_MISC_GIC_WAKEUP (0x3FF)
  65. #define WAKE_MISC_DVFSRC_IRQ DVFSRC_IRQ_LSB
  66. #define WAKE_MISC_REG_CPU_WAKEUP SPM_WAKEUP_MISC_REG_CPU_WAKEUP_LSB
  67. #define WAKE_MISC_PCM_TIMER_EVENT PCM_TIMER_EVENT_LSB
  68. #define WAKE_MISC_TWAM_IRQ_B TWAM_IRQ_B_LSB
  69. #define WAKE_MISC_PMSR_IRQ_B_SET0 PMSR_IRQ_B_SET0_LSB
  70. #define WAKE_MISC_PMSR_IRQ_B_SET1 PMSR_IRQ_B_SET1_LSB
  71. #define WAKE_MISC_PMSR_IRQ_B_SET2 PMSR_IRQ_B_SET2_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. /* MD32PCM ADDR for SPM code fetch */
  80. #define MD32PCM_BASE (SPM_BASE + 0x0A00)
  81. #define MD32PCM_CFGREG_SW_RSTN (MD32PCM_BASE + 0x0000)
  82. #define MD32PCM_DMA0_SRC (MD32PCM_BASE + 0x0200)
  83. #define MD32PCM_DMA0_DST (MD32PCM_BASE + 0x0204)
  84. #define MD32PCM_DMA0_WPPT (MD32PCM_BASE + 0x0208)
  85. #define MD32PCM_DMA0_WPTO (MD32PCM_BASE + 0x020C)
  86. #define MD32PCM_DMA0_COUNT (MD32PCM_BASE + 0x0210)
  87. #define MD32PCM_DMA0_CON (MD32PCM_BASE + 0x0214)
  88. #define MD32PCM_DMA0_START (MD32PCM_BASE + 0x0218)
  89. #define MD32PCM_DMA0_RLCT (MD32PCM_BASE + 0x0224)
  90. #define MD32PCM_INTC_IRQ_RAW_STA (MD32PCM_BASE + 0x033C)
  91. /* ABORT MASK for DEBUG FOORTPRINT */
  92. #define DEBUG_ABORT_MASK (SPM_DBG_DEBUG_IDX_DRAM_SREF_ABORT_IN_APSRC | \
  93. SPM_DBG_DEBUG_IDX_DRAM_SREF_ABORT_IN_DDREN)
  94. #define DEBUG_ABORT_MASK_1 (SPM_DBG1_DEBUG_IDX_VRCXO_SLEEP_ABORT | \
  95. SPM_DBG1_DEBUG_IDX_PWRAP_SLEEP_ACK_LOW_ABORT | \
  96. SPM_DBG1_DEBUG_IDX_PWRAP_SLEEP_ACK_HIGH_ABORT | \
  97. SPM_DBG1_DEBUG_IDX_EMI_SLP_IDLE_ABORT | \
  98. SPM_DBG1_DEBUG_IDX_SCP_SLP_ACK_LOW_ABORT | \
  99. SPM_DBG1_DEBUG_IDX_SCP_SLP_ACK_HIGH_ABORT | \
  100. SPM_DBG1_DEBUG_IDX_SPM_DVFS_CMD_RDY_ABORT)
  101. #define MCUPM_MBOX_WAKEUP_CPU (0x0C55FD10)
  102. struct pcm_desc {
  103. const char *version; /* PCM code version */
  104. uint32_t *base; /* binary array base */
  105. uintptr_t base_dma; /* dma addr of base */
  106. uint32_t pmem_words;
  107. uint32_t total_words;
  108. uint32_t pmem_start;
  109. uint32_t dmem_start;
  110. };
  111. struct pwr_ctrl {
  112. /* for SPM */
  113. uint32_t pcm_flags;
  114. /* can override pcm_flags */
  115. uint32_t pcm_flags_cust;
  116. /* set bit of pcm_flags, after pcm_flags_cust */
  117. uint32_t pcm_flags_cust_set;
  118. /* clr bit of pcm_flags, after pcm_flags_cust */
  119. uint32_t pcm_flags_cust_clr;
  120. uint32_t pcm_flags1;
  121. /* can override pcm_flags1 */
  122. uint32_t pcm_flags1_cust;
  123. /* set bit of pcm_flags1, after pcm_flags1_cust */
  124. uint32_t pcm_flags1_cust_set;
  125. /* clr bit of pcm_flags1, after pcm_flags1_cust */
  126. uint32_t pcm_flags1_cust_clr;
  127. /* @ 1T 32K */
  128. uint32_t timer_val;
  129. /* @ 1T 32K, can override timer_val */
  130. uint32_t timer_val_cust;
  131. /* stress for dpidle */
  132. uint32_t timer_val_ramp_en;
  133. /* stress for suspend */
  134. uint32_t timer_val_ramp_en_sec;
  135. uint32_t wake_src;
  136. /* can override wake_src */
  137. uint32_t wake_src_cust;
  138. /* disable wdt in suspend */
  139. uint8_t wdt_disable;
  140. /* SPM_AP_STANDBY_CON */
  141. /* [0] */
  142. uint8_t reg_wfi_op;
  143. /* [1] */
  144. uint8_t reg_wfi_type;
  145. /* [2] */
  146. uint8_t reg_mp0_cputop_idle_mask;
  147. /* [3] */
  148. uint8_t reg_mp1_cputop_idle_mask;
  149. /* [4] */
  150. uint8_t reg_mcusys_idle_mask;
  151. /* [25] */
  152. uint8_t reg_md_apsrc_1_sel;
  153. /* [26] */
  154. uint8_t reg_md_apsrc_0_sel;
  155. /* [29] */
  156. uint8_t reg_conn_apsrc_sel;
  157. /* SPM_SRC_REQ */
  158. /* [0] */
  159. uint8_t reg_spm_apsrc_req;
  160. /* [1] */
  161. uint8_t reg_spm_f26m_req;
  162. /* [3] */
  163. uint8_t reg_spm_infra_req;
  164. /* [4] */
  165. uint8_t reg_spm_vrf18_req;
  166. /* [7] */
  167. uint8_t reg_spm_ddr_en_req;
  168. /* [8] */
  169. uint8_t reg_spm_dvfs_req;
  170. /* [9] */
  171. uint8_t reg_spm_sw_mailbox_req;
  172. /* [10] */
  173. uint8_t reg_spm_sspm_mailbox_req;
  174. /* [11] */
  175. uint8_t reg_spm_adsp_mailbox_req;
  176. /* [12] */
  177. uint8_t reg_spm_scp_mailbox_req;
  178. /* SPM_SRC_MASK */
  179. /* [0] */
  180. uint8_t reg_sspm_srcclkena_0_mask_b;
  181. /* [1] */
  182. uint8_t reg_sspm_infra_req_0_mask_b;
  183. /* [2] */
  184. uint8_t reg_sspm_apsrc_req_0_mask_b;
  185. /* [3] */
  186. uint8_t reg_sspm_vrf18_req_0_mask_b;
  187. /* [4] */
  188. uint8_t reg_sspm_ddr_en_0_mask_b;
  189. /* [5] */
  190. uint8_t reg_scp_srcclkena_mask_b;
  191. /* [6] */
  192. uint8_t reg_scp_infra_req_mask_b;
  193. /* [7] */
  194. uint8_t reg_scp_apsrc_req_mask_b;
  195. /* [8] */
  196. uint8_t reg_scp_vrf18_req_mask_b;
  197. /* [9] */
  198. uint8_t reg_scp_ddr_en_mask_b;
  199. /* [10] */
  200. uint8_t reg_audio_dsp_srcclkena_mask_b;
  201. /* [11] */
  202. uint8_t reg_audio_dsp_infra_req_mask_b;
  203. /* [12] */
  204. uint8_t reg_audio_dsp_apsrc_req_mask_b;
  205. /* [13] */
  206. uint8_t reg_audio_dsp_vrf18_req_mask_b;
  207. /* [14] */
  208. uint8_t reg_audio_dsp_ddr_en_mask_b;
  209. /* [15] */
  210. uint8_t reg_apu_srcclkena_mask_b;
  211. /* [16] */
  212. uint8_t reg_apu_infra_req_mask_b;
  213. /* [17] */
  214. uint8_t reg_apu_apsrc_req_mask_b;
  215. /* [18] */
  216. uint8_t reg_apu_vrf18_req_mask_b;
  217. /* [19] */
  218. uint8_t reg_apu_ddr_en_mask_b;
  219. /* [20] */
  220. uint8_t reg_cpueb_srcclkena_mask_b;
  221. /* [21] */
  222. uint8_t reg_cpueb_infra_req_mask_b;
  223. /* [22] */
  224. uint8_t reg_cpueb_apsrc_req_mask_b;
  225. /* [23] */
  226. uint8_t reg_cpueb_vrf18_req_mask_b;
  227. /* [24] */
  228. uint8_t reg_cpueb_ddr_en_mask_b;
  229. /* [25] */
  230. uint8_t reg_bak_psri_srcclkena_mask_b;
  231. /* [26] */
  232. uint8_t reg_bak_psri_infra_req_mask_b;
  233. /* [27] */
  234. uint8_t reg_bak_psri_apsrc_req_mask_b;
  235. /* [28] */
  236. uint8_t reg_bak_psri_vrf18_req_mask_b;
  237. /* [29] */
  238. uint8_t reg_bak_psri_ddr_en_mask_b;
  239. /* [30] */
  240. uint8_t reg_cam_ddren_req_mask_b;
  241. /* [31] */
  242. uint8_t reg_img_ddren_req_mask_b;
  243. /* SPM_SRC2_MASK */
  244. /* [0] */
  245. uint8_t reg_msdc0_srcclkena_mask_b;
  246. /* [1] */
  247. uint8_t reg_msdc0_infra_req_mask_b;
  248. /* [2] */
  249. uint8_t reg_msdc0_apsrc_req_mask_b;
  250. /* [3] */
  251. uint8_t reg_msdc0_vrf18_req_mask_b;
  252. /* [4] */
  253. uint8_t reg_msdc0_ddr_en_mask_b;
  254. /* [5] */
  255. uint8_t reg_msdc1_srcclkena_mask_b;
  256. /* [6] */
  257. uint8_t reg_msdc1_infra_req_mask_b;
  258. /* [7] */
  259. uint8_t reg_msdc1_apsrc_req_mask_b;
  260. /* [8] */
  261. uint8_t reg_msdc1_vrf18_req_mask_b;
  262. /* [9] */
  263. uint8_t reg_msdc1_ddr_en_mask_b;
  264. /* [10] */
  265. uint8_t reg_msdc2_srcclkena_mask_b;
  266. /* [11] */
  267. uint8_t reg_msdc2_infra_req_mask_b;
  268. /* [12] */
  269. uint8_t reg_msdc2_apsrc_req_mask_b;
  270. /* [13] */
  271. uint8_t reg_msdc2_vrf18_req_mask_b;
  272. /* [14] */
  273. uint8_t reg_msdc2_ddr_en_mask_b;
  274. /* [15] */
  275. uint8_t reg_ufs_srcclkena_mask_b;
  276. /* [16] */
  277. uint8_t reg_ufs_infra_req_mask_b;
  278. /* [17] */
  279. uint8_t reg_ufs_apsrc_req_mask_b;
  280. /* [18] */
  281. uint8_t reg_ufs_vrf18_req_mask_b;
  282. /* [19] */
  283. uint8_t reg_ufs_ddr_en_mask_b;
  284. /* [20] */
  285. uint8_t reg_usb_srcclkena_mask_b;
  286. /* [21] */
  287. uint8_t reg_usb_infra_req_mask_b;
  288. /* [22] */
  289. uint8_t reg_usb_apsrc_req_mask_b;
  290. /* [23] */
  291. uint8_t reg_usb_vrf18_req_mask_b;
  292. /* [24] */
  293. uint8_t reg_usb_ddr_en_mask_b;
  294. /* [25] */
  295. uint8_t reg_pextp_p0_srcclkena_mask_b;
  296. /* [26] */
  297. uint8_t reg_pextp_p0_infra_req_mask_b;
  298. /* [27] */
  299. uint8_t reg_pextp_p0_apsrc_req_mask_b;
  300. /* [28] */
  301. uint8_t reg_pextp_p0_vrf18_req_mask_b;
  302. /* [29] */
  303. uint8_t reg_pextp_p0_ddr_en_mask_b;
  304. /* SPM_SRC3_MASK */
  305. /* [0] */
  306. uint8_t reg_pextp_p1_srcclkena_mask_b;
  307. /* [1] */
  308. uint8_t reg_pextp_p1_infra_req_mask_b;
  309. /* [2] */
  310. uint8_t reg_pextp_p1_apsrc_req_mask_b;
  311. /* [3] */
  312. uint8_t reg_pextp_p1_vrf18_req_mask_b;
  313. /* [4] */
  314. uint8_t reg_pextp_p1_ddr_en_mask_b;
  315. /* [5] */
  316. uint8_t reg_gce0_infra_req_mask_b;
  317. /* [6] */
  318. uint8_t reg_gce0_apsrc_req_mask_b;
  319. /* [7] */
  320. uint8_t reg_gce0_vrf18_req_mask_b;
  321. /* [8] */
  322. uint8_t reg_gce0_ddr_en_mask_b;
  323. /* [9] */
  324. uint8_t reg_gce1_infra_req_mask_b;
  325. /* [10] */
  326. uint8_t reg_gce1_apsrc_req_mask_b;
  327. /* [11] */
  328. uint8_t reg_gce1_vrf18_req_mask_b;
  329. /* [12] */
  330. uint8_t reg_gce1_ddr_en_mask_b;
  331. /* [13] */
  332. uint8_t reg_spm_srcclkena_reserved_mask_b;
  333. /* [14] */
  334. uint8_t reg_spm_infra_req_reserved_mask_b;
  335. /* [15] */
  336. uint8_t reg_spm_apsrc_req_reserved_mask_b;
  337. /* [16] */
  338. uint8_t reg_spm_vrf18_req_reserved_mask_b;
  339. /* [17] */
  340. uint8_t reg_spm_ddr_en_reserved_mask_b;
  341. /* [18] */
  342. uint8_t reg_disp0_apsrc_req_mask_b;
  343. /* [19] */
  344. uint8_t reg_disp0_ddr_en_mask_b;
  345. /* [20] */
  346. uint8_t reg_disp1_apsrc_req_mask_b;
  347. /* [21] */
  348. uint8_t reg_disp1_ddr_en_mask_b;
  349. /* [22] */
  350. uint8_t reg_disp2_apsrc_req_mask_b;
  351. /* [23] */
  352. uint8_t reg_disp2_ddr_en_mask_b;
  353. /* [24] */
  354. uint8_t reg_disp3_apsrc_req_mask_b;
  355. /* [25] */
  356. uint8_t reg_disp3_ddr_en_mask_b;
  357. /* [26] */
  358. uint8_t reg_infrasys_apsrc_req_mask_b;
  359. /* [27] */
  360. uint8_t reg_infrasys_ddr_en_mask_b;
  361. /* [28] */
  362. uint8_t reg_cg_check_srcclkena_mask_b;
  363. /* [29] */
  364. uint8_t reg_cg_check_apsrc_req_mask_b;
  365. /* [30] */
  366. uint8_t reg_cg_check_vrf18_req_mask_b;
  367. /* [31] */
  368. uint8_t reg_cg_check_ddr_en_mask_b;
  369. /* SPM_SRC4_MASK */
  370. /* [8:0] */
  371. uint32_t reg_mcusys_merge_apsrc_req_mask_b;
  372. /* [17:9] */
  373. uint32_t reg_mcusys_merge_ddr_en_mask_b;
  374. /* [19:18] */
  375. uint8_t reg_dramc_md32_infra_req_mask_b;
  376. /* [21:20] */
  377. uint8_t reg_dramc_md32_vrf18_req_mask_b;
  378. /* [23:22] */
  379. uint8_t reg_dramc_md32_ddr_en_mask_b;
  380. /* [24] */
  381. uint8_t reg_dvfsrc_event_trigger_mask_b;
  382. /* SPM_WAKEUP_EVENT_MASK2 */
  383. /* [3:0] */
  384. uint8_t reg_sc_sw2spm_wakeup_mask_b;
  385. /* [4] */
  386. uint8_t reg_sc_adsp2spm_wakeup_mask_b;
  387. /* [8:5] */
  388. uint8_t reg_sc_sspm2spm_wakeup_mask_b;
  389. /* [9] */
  390. uint8_t reg_sc_scp2spm_wakeup_mask_b;
  391. /* [10] */
  392. uint8_t reg_csyspwrup_ack_mask;
  393. /* [11] */
  394. uint8_t reg_csyspwrup_req_mask;
  395. /* SPM_WAKEUP_EVENT_MASK */
  396. /* [31:0] */
  397. uint32_t reg_wakeup_event_mask;
  398. /* SPM_WAKEUP_EVENT_EXT_MASK */
  399. /* [31:0] */
  400. uint32_t reg_ext_wakeup_event_mask;
  401. };
  402. /* code gen by spm_pwr_ctrl_atf.pl, need struct pwr_ctrl */
  403. enum pwr_ctrl_enum {
  404. PW_PCM_FLAGS,
  405. PW_PCM_FLAGS_CUST,
  406. PW_PCM_FLAGS_CUST_SET,
  407. PW_PCM_FLAGS_CUST_CLR,
  408. PW_PCM_FLAGS1,
  409. PW_PCM_FLAGS1_CUST,
  410. PW_PCM_FLAGS1_CUST_SET,
  411. PW_PCM_FLAGS1_CUST_CLR,
  412. PW_TIMER_VAL,
  413. PW_TIMER_VAL_CUST,
  414. PW_TIMER_VAL_RAMP_EN,
  415. PW_TIMER_VAL_RAMP_EN_SEC,
  416. PW_WAKE_SRC,
  417. PW_WAKE_SRC_CUST,
  418. PW_WDT_DISABLE,
  419. /* SPM_AP_STANDBY_CON */
  420. PW_REG_WFI_OP,
  421. PW_REG_WFI_TYPE,
  422. PW_REG_MP0_CPUTOP_IDLE_MASK,
  423. PW_REG_MP1_CPUTOP_IDLE_MASK,
  424. PW_REG_MCUSYS_IDLE_MASK,
  425. PW_REG_MD_APSRC_1_SEL,
  426. PW_REG_MD_APSRC_0_SEL,
  427. PW_REG_CONN_APSRC_SEL,
  428. /* SPM_SRC_REQ */
  429. PW_REG_SPM_APSRC_REQ,
  430. PW_REG_SPM_F26M_REQ,
  431. PW_REG_SPM_INFRA_REQ,
  432. PW_REG_SPM_VRF18_REQ,
  433. PW_REG_SPM_DDR_EN_REQ,
  434. PW_REG_SPM_DVFS_REQ,
  435. PW_REG_SPM_SW_MAILBOX_REQ,
  436. PW_REG_SPM_SSPM_MAILBOX_REQ,
  437. PW_REG_SPM_ADSP_MAILBOX_REQ,
  438. PW_REG_SPM_SCP_MAILBOX_REQ,
  439. /* SPM_SRC_MASK */
  440. PW_REG_SSPM_SRCCLKENA_0_MASK_B,
  441. PW_REG_SSPM_INFRA_REQ_0_MASK_B,
  442. PW_REG_SSPM_APSRC_REQ_0_MASK_B,
  443. PW_REG_SSPM_VRF18_REQ_0_MASK_B,
  444. PW_REG_SSPM_DDR_EN_0_MASK_B,
  445. PW_REG_SCP_SRCCLKENA_MASK_B,
  446. PW_REG_SCP_INFRA_REQ_MASK_B,
  447. PW_REG_SCP_APSRC_REQ_MASK_B,
  448. PW_REG_SCP_VRF18_REQ_MASK_B,
  449. PW_REG_SCP_DDR_EN_MASK_B,
  450. PW_REG_AUDIO_DSP_SRCCLKENA_MASK_B,
  451. PW_REG_AUDIO_DSP_INFRA_REQ_MASK_B,
  452. PW_REG_AUDIO_DSP_APSRC_REQ_MASK_B,
  453. PW_REG_AUDIO_DSP_VRF18_REQ_MASK_B,
  454. PW_REG_AUDIO_DSP_DDR_EN_MASK_B,
  455. PW_REG_APU_SRCCLKENA_MASK_B,
  456. PW_REG_APU_INFRA_REQ_MASK_B,
  457. PW_REG_APU_APSRC_REQ_MASK_B,
  458. PW_REG_APU_VRF18_REQ_MASK_B,
  459. PW_REG_APU_DDR_EN_MASK_B,
  460. PW_REG_CPUEB_SRCCLKENA_MASK_B,
  461. PW_REG_CPUEB_INFRA_REQ_MASK_B,
  462. PW_REG_CPUEB_APSRC_REQ_MASK_B,
  463. PW_REG_CPUEB_VRF18_REQ_MASK_B,
  464. PW_REG_CPUEB_DDR_EN_MASK_B,
  465. PW_REG_BAK_PSRI_SRCCLKENA_MASK_B,
  466. PW_REG_BAK_PSRI_INFRA_REQ_MASK_B,
  467. PW_REG_BAK_PSRI_APSRC_REQ_MASK_B,
  468. PW_REG_BAK_PSRI_VRF18_REQ_MASK_B,
  469. PW_REG_BAK_PSRI_DDR_EN_MASK_B,
  470. PW_REG_CAM_DDREN_REQ_MASK_B,
  471. PW_REG_IMG_DDREN_REQ_MASK_B,
  472. /* SPM_SRC2_MASK */
  473. PW_REG_MSDC0_SRCCLKENA_MASK_B,
  474. PW_REG_MSDC0_INFRA_REQ_MASK_B,
  475. PW_REG_MSDC0_APSRC_REQ_MASK_B,
  476. PW_REG_MSDC0_VRF18_REQ_MASK_B,
  477. PW_REG_MSDC0_DDR_EN_MASK_B,
  478. PW_REG_MSDC1_SRCCLKENA_MASK_B,
  479. PW_REG_MSDC1_INFRA_REQ_MASK_B,
  480. PW_REG_MSDC1_APSRC_REQ_MASK_B,
  481. PW_REG_MSDC1_VRF18_REQ_MASK_B,
  482. PW_REG_MSDC1_DDR_EN_MASK_B,
  483. PW_REG_MSDC2_SRCCLKENA_MASK_B,
  484. PW_REG_MSDC2_INFRA_REQ_MASK_B,
  485. PW_REG_MSDC2_APSRC_REQ_MASK_B,
  486. PW_REG_MSDC2_VRF18_REQ_MASK_B,
  487. PW_REG_MSDC2_DDR_EN_MASK_B,
  488. PW_REG_UFS_SRCCLKENA_MASK_B,
  489. PW_REG_UFS_INFRA_REQ_MASK_B,
  490. PW_REG_UFS_APSRC_REQ_MASK_B,
  491. PW_REG_UFS_VRF18_REQ_MASK_B,
  492. PW_REG_UFS_DDR_EN_MASK_B,
  493. PW_REG_USB_SRCCLKENA_MASK_B,
  494. PW_REG_USB_INFRA_REQ_MASK_B,
  495. PW_REG_USB_APSRC_REQ_MASK_B,
  496. PW_REG_USB_VRF18_REQ_MASK_B,
  497. PW_REG_USB_DDR_EN_MASK_B,
  498. PW_REG_PEXTP_P0_SRCCLKENA_MASK_B,
  499. PW_REG_PEXTP_P0_INFRA_REQ_MASK_B,
  500. PW_REG_PEXTP_P0_APSRC_REQ_MASK_B,
  501. PW_REG_PEXTP_P0_VRF18_REQ_MASK_B,
  502. PW_REG_PEXTP_P0_DDR_EN_MASK_B,
  503. /* SPM_SRC3_MASK */
  504. PW_REG_PEXTP_P1_SRCCLKENA_MASK_B,
  505. PW_REG_PEXTP_P1_INFRA_REQ_MASK_B,
  506. PW_REG_PEXTP_P1_APSRC_REQ_MASK_B,
  507. PW_REG_PEXTP_P1_VRF18_REQ_MASK_B,
  508. PW_REG_PEXTP_P1_DDR_EN_MASK_B,
  509. PW_REG_GCE0_INFRA_REQ_MASK_B,
  510. PW_REG_GCE0_APSRC_REQ_MASK_B,
  511. PW_REG_GCE0_VRF18_REQ_MASK_B,
  512. PW_REG_GCE0_DDR_EN_MASK_B,
  513. PW_REG_GCE1_INFRA_REQ_MASK_B,
  514. PW_REG_GCE1_APSRC_REQ_MASK_B,
  515. PW_REG_GCE1_VRF18_REQ_MASK_B,
  516. PW_REG_GCE1_DDR_EN_MASK_B,
  517. PW_REG_SPM_SRCCLKENA_RESERVED_MASK_B,
  518. PW_REG_SPM_INFRA_REQ_RESERVED_MASK_B,
  519. PW_REG_SPM_APSRC_REQ_RESERVED_MASK_B,
  520. PW_REG_SPM_VRF18_REQ_RESERVED_MASK_B,
  521. PW_REG_SPM_DDR_EN_RESERVED_MASK_B,
  522. PW_REG_DISP0_APSRC_REQ_MASK_B,
  523. PW_REG_DISP0_DDR_EN_MASK_B,
  524. PW_REG_DISP1_APSRC_REQ_MASK_B,
  525. PW_REG_DISP1_DDR_EN_MASK_B,
  526. PW_REG_DISP2_APSRC_REQ_MASK_B,
  527. PW_REG_DISP2_DDR_EN_MASK_B,
  528. PW_REG_DISP3_APSRC_REQ_MASK_B,
  529. PW_REG_DISP3_DDR_EN_MASK_B,
  530. PW_REG_INFRASYS_APSRC_REQ_MASK_B,
  531. PW_REG_INFRASYS_DDR_EN_MASK_B,
  532. PW_REG_CG_CHECK_SRCCLKENA_MASK_B,
  533. PW_REG_CG_CHECK_APSRC_REQ_MASK_B,
  534. PW_REG_CG_CHECK_VRF18_REQ_MASK_B,
  535. PW_REG_CG_CHECK_DDR_EN_MASK_B,
  536. /* SPM_SRC4_MASK */
  537. PW_REG_MCUSYS_MERGE_APSRC_REQ_MASK_B,
  538. PW_REG_MCUSYS_MERGE_DDR_EN_MASK_B,
  539. PW_REG_DRAMC_MD32_INFRA_REQ_MASK_B,
  540. PW_REG_DRAMC_MD32_VRF18_REQ_MASK_B,
  541. PW_REG_DRAMC_MD32_DDR_EN_MASK_B,
  542. PW_REG_DVFSRC_EVENT_TRIGGER_MASK_B,
  543. /* SPM_WAKEUP_EVENT_MASK2 */
  544. PW_REG_SC_SW2SPM_WAKEUP_MASK_B,
  545. PW_REG_SC_ADSP2SPM_WAKEUP_MASK_B,
  546. PW_REG_SC_SSPM2SPM_WAKEUP_MASK_B,
  547. PW_REG_SC_SCP2SPM_WAKEUP_MASK_B,
  548. PW_REG_CSYSPWRUP_ACK_MASK,
  549. PW_REG_CSYSPWRUP_REQ_MASK,
  550. /* SPM_WAKEUP_EVENT_MASK */
  551. PW_REG_WAKEUP_EVENT_MASK,
  552. /* SPM_WAKEUP_EVENT_EXT_MASK */
  553. PW_REG_EXT_WAKEUP_EVENT_MASK,
  554. PW_MAX_COUNT,
  555. };
  556. /* spm_internal.c internal status */
  557. #define SPM_INTERNAL_STATUS_HW_S1 BIT(0)
  558. #define SPM_ACK_CHK_3_CON_HW_MODE_TRIG (0x800)
  559. /* BIT[0]: SW_EN, BIT[4]: STA_EN, BIT[8]: HW_EN */
  560. #define SPM_ACK_CHK_3_CON_EN (0x110)
  561. #define SPM_ACK_CHK_3_CON_CLR_ALL (0x2)
  562. /* BIT[15]: RESULT */
  563. #define SPM_ACK_CHK_3_CON_RESULT (0x8000)
  564. struct wake_status_trace_comm {
  565. uint32_t debug_flag; /* PCM_WDT_LATCH_SPARE_0 */
  566. uint32_t debug_flag1; /* PCM_WDT_LATCH_SPARE_1 */
  567. uint32_t timer_out; /* SPM_SW_RSV_6*/
  568. uint32_t b_sw_flag0; /* SPM_SW_RSV_7 */
  569. uint32_t b_sw_flag1; /* SPM_SW_RSV_7 */
  570. uint32_t r12; /* SPM_SW_RSV_0 */
  571. uint32_t r13; /* PCM_REG13_DATA */
  572. uint32_t req_sta0; /* SRC_REQ_STA_0 */
  573. uint32_t req_sta1; /* SRC_REQ_STA_1 */
  574. uint32_t req_sta2; /* SRC_REQ_STA_2 */
  575. uint32_t req_sta3; /* SRC_REQ_STA_3 */
  576. uint32_t req_sta4; /* SRC_REQ_STA_4 */
  577. uint32_t raw_sta; /* SPM_WAKEUP_STA */
  578. uint32_t times_h; /* timestamp high bits */
  579. uint32_t times_l; /* timestamp low bits */
  580. uint32_t resumetime; /* timestamp low bits */
  581. };
  582. struct wake_status_trace {
  583. struct wake_status_trace_comm comm;
  584. };
  585. struct wake_status {
  586. struct wake_status_trace tr;
  587. uint32_t r12_ext; /* SPM_WAKEUP_EXT_STA */
  588. uint32_t raw_ext_sta; /* SPM_WAKEUP_EXT_STA */
  589. uint32_t md32pcm_wakeup_sta; /* MD32PCM_WAKEUP_STA */
  590. uint32_t md32pcm_event_sta; /* MD32PCM_EVENT_STA */
  591. uint32_t wake_misc; /* SPM_SW_RSV_5 */
  592. uint32_t idle_sta; /* SUBSYS_IDLE_STA */
  593. uint32_t cg_check_sta; /* SPM_CG_CHECK_STA */
  594. uint32_t sw_flag0; /* SPM_SW_FLAG_0 */
  595. uint32_t sw_flag1; /* SPM_SW_FLAG_1 */
  596. uint32_t isr; /* SPM_IRQ_STA */
  597. uint32_t clk_settle; /* SPM_CLK_SETTLE */
  598. uint32_t src_req; /* SPM_SRC_REQ */
  599. uint32_t log_index;
  600. uint32_t is_abort;
  601. uint32_t rt_req_sta0; /* SPM_SW_RSV_2 */
  602. uint32_t rt_req_sta1; /* SPM_SW_RSV_3 */
  603. uint32_t rt_req_sta2; /* SPM_SW_RSV_4 */
  604. uint32_t rt_req_sta3; /* SPM_SW_RSV_5 */
  605. uint32_t rt_req_sta4; /* SPM_SW_RSV_6 */
  606. };
  607. struct spm_lp_scen {
  608. struct pcm_desc *pcmdesc;
  609. struct pwr_ctrl *pwrctrl;
  610. };
  611. void __spm_set_cpu_status(unsigned int cpu);
  612. void __spm_src_req_update(const struct pwr_ctrl *pwrctrl, unsigned int resource_usage);
  613. void __spm_set_power_control(const struct pwr_ctrl *pwrctrl);
  614. void __spm_set_wakeup_event(const struct pwr_ctrl *pwrctrl);
  615. void __spm_set_pcm_flags(struct pwr_ctrl *pwrctrl);
  616. void __spm_send_cpu_wakeup_event(void);
  617. void __spm_get_wakeup_status(struct wake_status *wakesta, unsigned int ext_status);
  618. void __spm_clean_after_wakeup(void);
  619. wake_reason_t __spm_output_wake_reason(const struct wake_status *wakesta);
  620. void __spm_set_pcm_wdt(int en);
  621. void __spm_ext_int_wakeup_req_clr(void);
  622. void __spm_hw_s1_state_monitor(int en, unsigned int *status);
  623. static inline void spm_hw_s1_state_monitor_resume(void)
  624. {
  625. __spm_hw_s1_state_monitor(1, NULL);
  626. }
  627. static inline void spm_hw_s1_state_monitor_pause(unsigned int *status)
  628. {
  629. __spm_hw_s1_state_monitor(0, status);
  630. }
  631. void __spm_clean_before_wfi(void);
  632. #endif /* MT_SPM_INTERNAL */