Debian Codegraph @

src/soc/mediatek/mt8189/spm.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2
3 #include <assert.h>
4 #include <delay.h>
5 #include <soc/mcu_common.h>
6 #include <soc/pll.h>
7 #include <soc/spm.h>
8 #include <soc/spm_mtcmos.h>
9
10 static const struct pwr_ctrl spm_init_ctrl = {
11 /* For SPM, this flag is not auto-gen. */
12 .pcm_flags = SPM_FLAG_DISABLE_VCORE_DVS
13 | SPM_FLAG_DISABLE_DDR_DFS
14 | SPM_FLAG_DISABLE_EMI_DFS
15 | SPM_FLAG_DISABLE_BUS_DFS
16 | SPM_FLAG_RUN_COMMON_SCENARIO,
17
18 /* SPM_SRC_REQ */
19 .reg_spm_adsp_mailbox_req = 0,
20 .reg_spm_apsrc_req = 0,
21 .reg_spm_ddren_req = 0,
22 .reg_spm_dvfs_req = 0,
23 .reg_spm_emi_req = 0,
24 .reg_spm_f26m_req = 0,
25 .reg_spm_infra_req = 0,
26 .reg_spm_pmic_req = 0,
27 .reg_spm_scp_mailbox_req = 0,
28 .reg_spm_sspm_mailbox_req = 0,
29 .reg_spm_sw_mailbox_req = 0,
30 .reg_spm_vcore_req = 1,
31 .reg_spm_vrf18_req = 0,
32 .adsp_mailbox_state = 0,
33 .apsrc_state = 0,
34 .ddren_state = 0,
35 .dvfs_state = 0,
36 .emi_state = 0,
37 .f26m_state = 0,
38 .infra_state = 0,
39 .pmic_state = 0,
40 .scp_mailbox_state = 0,
41 .sspm_mailbox_state = 0,
42 .sw_mailbox_state = 0,
43 .vcore_state = 0,
44 .vrf18_state = 0,
45
46 /* SPM_SRC_MASK_0 */
47 .reg_apu_apsrc_req_mask_b = 0x1,
48 .reg_apu_ddren_req_mask_b = 0x1,
49 .reg_apu_emi_req_mask_b = 0x1,
50 .reg_apu_infra_req_mask_b = 0x1,
51 .reg_apu_pmic_req_mask_b = 0x1,
52 .reg_apu_srcclkena_mask_b = 0x1,
53 .reg_apu_vrf18_req_mask_b = 0x1,
54 .reg_audio_dsp_apsrc_req_mask_b = 0x0,
55 .reg_audio_dsp_ddren_req_mask_b = 0x0,
56 .reg_audio_dsp_emi_req_mask_b = 0x0,
57 .reg_audio_dsp_infra_req_mask_b = 0x0,
58 .reg_audio_dsp_pmic_req_mask_b = 0x0,
59 .reg_audio_dsp_srcclkena_mask_b = 0x0,
60 .reg_audio_dsp_vcore_req_mask_b = 0x0,
61 .reg_audio_dsp_vrf18_req_mask_b = 0x0,
62 .reg_cam_apsrc_req_mask_b = 0x1,
63 .reg_cam_ddren_req_mask_b = 0x1,
64 .reg_cam_emi_req_mask_b = 0x1,
65 .reg_cam_infra_req_mask_b = 0x0,
66 .reg_cam_pmic_req_mask_b = 0x0,
67 .reg_cam_srcclkena_mask_b = 0x0,
68 .reg_cam_vrf18_req_mask_b = 0x0,
69 .reg_mdp_emi_req_mask_b = 0x1,
70
71 /* SPM_SRC_MASK_1 */
72 .reg_ccif_apsrc_req_mask_b = 0x0,
73 .reg_ccif_emi_req_mask_b = 0xfff,
74
75 /* SPM_SRC_MASK_2 */
76 .reg_ccif_infra_req_mask_b = 0x0,
77 .reg_ccif_pmic_req_mask_b = 0xfff,
78
79 /* SPM_SRC_MASK_3 */
80 .reg_ccif_srcclkena_mask_b = 0x0,
81 .reg_ccif_vrf18_req_mask_b = 0xfff,
82 .reg_ccu_apsrc_req_mask_b = 0x0,
83 .reg_ccu_ddren_req_mask_b = 0x0,
84 .reg_ccu_emi_req_mask_b = 0x0,
85 .reg_ccu_infra_req_mask_b = 0x0,
86 .reg_ccu_pmic_req_mask_b = 0x0,
87 .reg_ccu_srcclkena_mask_b = 0x0,
88 .reg_ccu_vrf18_req_mask_b = 0x0,
89 .reg_cg_check_apsrc_req_mask_b = 0x1,
90
91 /* SPM_SRC_MASK_4 */
92 .reg_cg_check_ddren_req_mask_b = 0x1,
93 .reg_cg_check_emi_req_mask_b = 0x1,
94 .reg_cg_check_infra_req_mask_b = 0x1,
95 .reg_cg_check_pmic_req_mask_b = 0x1,
96 .reg_cg_check_srcclkena_mask_b = 0x1,
97 .reg_cg_check_vcore_req_mask_b = 0x1,
98 .reg_cg_check_vrf18_req_mask_b = 0x1,
99 .reg_conn_apsrc_req_mask_b = 0x1,
100 .reg_conn_ddren_req_mask_b = 0x1,
101 .reg_conn_emi_req_mask_b = 0x1,
102 .reg_conn_infra_req_mask_b = 0x1,
103 .reg_conn_pmic_req_mask_b = 0x1,
104 .reg_conn_srcclkena_mask_b = 0x1,
105 .reg_conn_srcclkenb_mask_b = 0x1,
106 .reg_conn_vcore_req_mask_b = 0x1,
107 .reg_conn_vrf18_req_mask_b = 0x1,
108 .reg_cpueb_apsrc_req_mask_b = 0x1,
109 .reg_cpueb_ddren_req_mask_b = 0x1,
110 .reg_cpueb_emi_req_mask_b = 0x1,
111 .reg_cpueb_infra_req_mask_b = 0x1,
112 .reg_cpueb_pmic_req_mask_b = 0x1,
113 .reg_cpueb_srcclkena_mask_b = 0x1,
114 .reg_cpueb_vrf18_req_mask_b = 0x1,
115 .reg_disp0_apsrc_req_mask_b = 0x1,
116 .reg_disp0_ddren_req_mask_b = 0x1,
117 .reg_disp0_emi_req_mask_b = 0x1,
118 .reg_disp0_infra_req_mask_b = 0x1,
119 .reg_disp0_pmic_req_mask_b = 0x0,
120 .reg_disp0_srcclkena_mask_b = 0x0,
121 .reg_disp0_vrf18_req_mask_b = 0x1,
122 .reg_disp1_apsrc_req_mask_b = 0x0,
123 .reg_disp1_ddren_req_mask_b = 0x0,
124
125 /* SPM_SRC_MASK_5 */
126 .reg_disp1_emi_req_mask_b = 0x0,
127 .reg_disp1_infra_req_mask_b = 0x0,
128 .reg_disp1_pmic_req_mask_b = 0x0,
129 .reg_disp1_srcclkena_mask_b = 0x0,
130 .reg_disp1_vrf18_req_mask_b = 0x0,
131 .reg_dpm_apsrc_req_mask_b = 0xf,
132 .reg_dpm_ddren_req_mask_b = 0xf,
133 .reg_dpm_emi_req_mask_b = 0xf,
134 .reg_dpm_infra_req_mask_b = 0xf,
135 .reg_dpm_pmic_req_mask_b = 0xf,
136 .reg_dpm_srcclkena_mask_b = 0xf,
137
138 /* SPM_SRC_MASK_6 */
139 .reg_dpm_vcore_req_mask_b = 0xf,
140 .reg_dpm_vrf18_req_mask_b = 0xf,
141 .reg_dpmaif_apsrc_req_mask_b = 0x1,
142 .reg_dpmaif_ddren_req_mask_b = 0x1,
143 .reg_dpmaif_emi_req_mask_b = 0x1,
144 .reg_dpmaif_infra_req_mask_b = 0x1,
145 .reg_dpmaif_pmic_req_mask_b = 0x1,
146 .reg_dpmaif_srcclkena_mask_b = 0x1,
147 .reg_dpmaif_vrf18_req_mask_b = 0x1,
148 .reg_dvfsrc_level_req_mask_b = 0x1,
149 .reg_emisys_apsrc_req_mask_b = 0x0,
150 .reg_emisys_ddren_req_mask_b = 0x1,
151 .reg_emisys_emi_req_mask_b = 0x0,
152 .reg_gce_d_apsrc_req_mask_b = 0x1,
153 .reg_gce_d_ddren_req_mask_b = 0x1,
154 .reg_gce_d_emi_req_mask_b = 0x1,
155 .reg_gce_d_infra_req_mask_b = 0x0,
156 .reg_gce_d_pmic_req_mask_b = 0x0,
157 .reg_gce_d_srcclkena_mask_b = 0x0,
158 .reg_gce_d_vrf18_req_mask_b = 0x0,
159 .reg_gce_m_apsrc_req_mask_b = 0x1,
160 .reg_gce_m_ddren_req_mask_b = 0x1,
161 .reg_gce_m_emi_req_mask_b = 0x1,
162 .reg_gce_m_infra_req_mask_b = 0x0,
163 .reg_gce_m_pmic_req_mask_b = 0x0,
164 .reg_gce_m_srcclkena_mask_b = 0x0,
165
166 /* SPM_SRC_MASK_7 */
167 .reg_gce_m_vrf18_req_mask_b = 0x0,
168 .reg_gpueb_apsrc_req_mask_b = 0x0,
169 .reg_gpueb_ddren_req_mask_b = 0x0,
170 .reg_gpueb_emi_req_mask_b = 0x0,
171 .reg_gpueb_infra_req_mask_b = 0x0,
172 .reg_gpueb_pmic_req_mask_b = 0x0,
173 .reg_gpueb_srcclkena_mask_b = 0x0,
174 .reg_gpueb_vrf18_req_mask_b = 0x0,
175 .reg_hwccf_apsrc_req_mask_b = 0x1,
176 .reg_hwccf_ddren_req_mask_b = 0x1,
177 .reg_hwccf_emi_req_mask_b = 0x1,
178 .reg_hwccf_infra_req_mask_b = 0x1,
179 .reg_hwccf_pmic_req_mask_b = 0x1,
180 .reg_hwccf_srcclkena_mask_b = 0x1,
181 .reg_hwccf_vcore_req_mask_b = 0x1,
182 .reg_hwccf_vrf18_req_mask_b = 0x1,
183 .reg_img_apsrc_req_mask_b = 0x1,
184 .reg_img_ddren_req_mask_b = 0x1,
185 .reg_img_emi_req_mask_b = 0x1,
186 .reg_img_infra_req_mask_b = 0x0,
187 .reg_img_pmic_req_mask_b = 0x0,
188 .reg_img_srcclkena_mask_b = 0x0,
189 .reg_img_vrf18_req_mask_b = 0x0,
190 .reg_infrasys_apsrc_req_mask_b = 0x1,
191 .reg_infrasys_ddren_req_mask_b = 0x1,
192 .reg_infrasys_emi_req_mask_b = 0x1,
193 .reg_ipic_infra_req_mask_b = 0x1,
194 .reg_ipic_vrf18_req_mask_b = 0x1,
195 .reg_mcu_apsrc_req_mask_b = 0x0,
196 .reg_mcu_ddren_req_mask_b = 0x0,
197 .reg_mcu_emi_req_mask_b = 0x0,
198
199 /* SPM_SRC_MASK_8 */
200 .reg_mcusys_apsrc_req_mask_b = 0x7,
201 .reg_mcusys_ddren_req_mask_b = 0x7,
202 .reg_mcusys_emi_req_mask_b = 0x7,
203 .reg_mcusys_infra_req_mask_b = 0x0,
204
205 /* SPM_SRC_MASK_9 */
206 .reg_mcusys_pmic_req_mask_b = 0x0,
207 .reg_mcusys_srcclkena_mask_b = 0x0,
208 .reg_mcusys_vrf18_req_mask_b = 0x0,
209 .reg_md_apsrc_req_mask_b = 0x0,
210 .reg_md_ddren_req_mask_b = 0x0,
211 .reg_md_emi_req_mask_b = 0x0,
212 .reg_md_infra_req_mask_b = 0x0,
213 .reg_md_pmic_req_mask_b = 0x0,
214 .reg_md_srcclkena_mask_b = 0x0,
215 .reg_md_srcclkena1_mask_b = 0x0,
216 .reg_md_vcore_req_mask_b = 0x0,
217
218 /* SPM_SRC_MASK_10 */
219 .reg_md_vrf18_req_mask_b = 0x0,
220 .reg_mdp_apsrc_req_mask_b = 0x0,
221 .reg_mdp_ddren_req_mask_b = 0x0,
222 .reg_mm_proc_apsrc_req_mask_b = 0x0,
223 .reg_mm_proc_ddren_req_mask_b = 0x0,
224 .reg_mm_proc_emi_req_mask_b = 0x0,
225 .reg_mm_proc_infra_req_mask_b = 0x0,
226 .reg_mm_proc_pmic_req_mask_b = 0x0,
227 .reg_mm_proc_srcclkena_mask_b = 0x0,
228 .reg_mm_proc_vrf18_req_mask_b = 0x0,
229 .reg_mmsys_apsrc_req_mask_b = 0x0,
230 .reg_mmsys_ddren_req_mask_b = 0x0,
231 .reg_mmsys_vrf18_req_mask_b = 0x0,
232 .reg_pcie0_apsrc_req_mask_b = 0x0,
233 .reg_pcie0_ddren_req_mask_b = 0x0,
234 .reg_pcie0_infra_req_mask_b = 0x0,
235 .reg_pcie0_srcclkena_mask_b = 0x0,
236 .reg_pcie0_vrf18_req_mask_b = 0x0,
237 .reg_pcie1_apsrc_req_mask_b = 0x0,
238 .reg_pcie1_ddren_req_mask_b = 0x0,
239 .reg_pcie1_infra_req_mask_b = 0x0,
240 .reg_pcie1_srcclkena_mask_b = 0x0,
241 .reg_pcie1_vrf18_req_mask_b = 0x0,
242 .reg_perisys_apsrc_req_mask_b = 0x1,
243 .reg_perisys_ddren_req_mask_b = 0x1,
244 .reg_perisys_emi_req_mask_b = 0x1,
245 .reg_perisys_infra_req_mask_b = 0x1,
246 .reg_perisys_pmic_req_mask_b = 0x1,
247 .reg_perisys_srcclkena_mask_b = 0x1,
248 .reg_perisys_vcore_req_mask_b = 0x1,
249 .reg_perisys_vrf18_req_mask_b = 0x1,
250 .reg_scp_apsrc_req_mask_b = 0x1,
251
252 /* SPM_SRC_MASK_11 */
253 .reg_scp_ddren_req_mask_b = 0x1,
254 .reg_scp_emi_req_mask_b = 0x1,
255 .reg_scp_infra_req_mask_b = 0x1,
256 .reg_scp_pmic_req_mask_b = 0x1,
257 .reg_scp_srcclkena_mask_b = 0x1,
258 .reg_scp_vcore_req_mask_b = 0x1,
259 .reg_scp_vrf18_req_mask_b = 0x1,
260 .reg_srcclkeni_infra_req_mask_b = 0x1,
261 .reg_srcclkeni_pmic_req_mask_b = 0x1,
262 .reg_srcclkeni_srcclkena_mask_b = 0x1,
263 .reg_sspm_apsrc_req_mask_b = 0x1,
264 .reg_sspm_ddren_req_mask_b = 0x1,
265 .reg_sspm_emi_req_mask_b = 0x1,
266 .reg_sspm_infra_req_mask_b = 0x1,
267 .reg_sspm_pmic_req_mask_b = 0x1,
268 .reg_sspm_srcclkena_mask_b = 0x1,
269 .reg_sspm_vrf18_req_mask_b = 0x1,
270 .reg_ssr_apsrc_req_mask_b = 0x0,
271 .reg_ssr_ddren_req_mask_b = 0x0,
272 .reg_ssr_emi_req_mask_b = 0x0,
273 .reg_ssr_infra_req_mask_b = 0x0,
274 .reg_ssr_pmic_req_mask_b = 0x0,
275 .reg_ssr_srcclkena_mask_b = 0x0,
276 .reg_ssr_vrf18_req_mask_b = 0x0,
277 .reg_ufs_apsrc_req_mask_b = 0x1,
278 .reg_ufs_ddren_req_mask_b = 0x1,
279 .reg_ufs_emi_req_mask_b = 0x1,
280 .reg_ufs_infra_req_mask_b = 0x1,
281 .reg_ufs_pmic_req_mask_b = 0x1,
282
283 /* SPM_SRC_MASK_12 */
284 .reg_ufs_srcclkena_mask_b = 0x1,
285 .reg_ufs_vrf18_req_mask_b = 0x1,
286 .reg_vdec_apsrc_req_mask_b = 0x1,
287 .reg_vdec_ddren_req_mask_b = 0x1,
288 .reg_vdec_emi_req_mask_b = 0x1,
289 .reg_vdec_infra_req_mask_b = 0x0,
290 .reg_vdec_pmic_req_mask_b = 0x0,
291 .reg_vdec_srcclkena_mask_b = 0x0,
292 .reg_vdec_vrf18_req_mask_b = 0x0,
293 .reg_venc_apsrc_req_mask_b = 0x1,
294 .reg_venc_ddren_req_mask_b = 0x1,
295 .reg_venc_emi_req_mask_b = 0x1,
296 .reg_venc_infra_req_mask_b = 0x0,
297 .reg_venc_pmic_req_mask_b = 0x0,
298 .reg_venc_srcclkena_mask_b = 0x0,
299 .reg_venc_vrf18_req_mask_b = 0x0,
300 .reg_ipe_apsrc_req_mask_b = 0x1,
301 .reg_ipe_ddren_req_mask_b = 0x1,
302 .reg_ipe_emi_req_mask_b = 0x1,
303 .reg_ipe_infra_req_mask_b = 0x1,
304 .reg_ipe_pmic_req_mask_b = 0x1,
305 .reg_ipe_srcclkena_mask_b = 0x1,
306 .reg_ipe_vrf18_req_mask_b = 0x1,
307 .reg_ufs_vcore_req_mask_b = 0x1,
308
309 /* SPM_EVENT_CON_MISC */
310 .reg_srcclken_fast_resp = 0,
311 .reg_csyspwrup_ack_mask = 0,
312
313 /* Auto-gen End */
314
315 /* SPM_WAKEUP_EVENT_MASK */
316 .reg_wakeup_event_mask = 0xEFFFFFFF,
317
318 /* SPM_WAKEUP_EVENT_EXT_MASK */
319 .reg_ext_wakeup_event_mask = 0xFFFFFFFF,
320 };
321
322 static void spm_hw_s1_state_monitor_pause(void)
323 {
324 SET32_BITFIELDS(&mtk_spm->spm_ack_chk_con_3,
325 SPM_ACK_CHK_3_CON_HW_MODE_TRIG, 1,
326 SPM_ACK_CHK_3_CON_CLR_ALL, 1,
327 SPM_ACK_CHK_3_CON_EN_0, 0,
328 SPM_ACK_CHK_3_CON_EN_1, 0);
329 }
330
331 void spm_set_power_control(const struct pwr_ctrl *pwrctrl)
332 {
333 /* SPM_SRC_REQ */
334 write32(&mtk_spm->spm_src_req,
335 ((pwrctrl->reg_spm_adsp_mailbox_req & 0x1) << 0) |
336 (((pwrctrl->reg_spm_apsrc_req) & 0x1) << 1) |
337 (((pwrctrl->reg_spm_ddren_req) & 0x1) << 2) |
338 ((pwrctrl->reg_spm_dvfs_req & 0x1) << 3) |
339 (((pwrctrl->reg_spm_emi_req) & 0x1) << 4) |
340 (((pwrctrl->reg_spm_f26m_req) & 0x1) << 5) |
341 (((pwrctrl->reg_spm_infra_req) & 0x1) << 6) |
342 (((pwrctrl->reg_spm_pmic_req) & 0x1) << 7) |
343 ((pwrctrl->reg_spm_scp_mailbox_req & 0x1) << 8) |
344 ((pwrctrl->reg_spm_sspm_mailbox_req & 0x1) << 9) |
345 ((pwrctrl->reg_spm_sw_mailbox_req & 0x1) << 10) |
346 (((pwrctrl->reg_spm_vcore_req) & 0x1) << 11) |
347 (((pwrctrl->reg_spm_vrf18_req) & 0x1) << 12) |
348 ((pwrctrl->adsp_mailbox_state & 0x1) << 16) |
349 ((pwrctrl->apsrc_state & 0x1) << 17) |
350 ((pwrctrl->ddren_state & 0x1) << 18) |
351 ((pwrctrl->dvfs_state & 0x1) << 19) |
352 ((pwrctrl->emi_state & 0x1) << 20) |
353 ((pwrctrl->f26m_state & 0x1) << 21) |
354 ((pwrctrl->infra_state & 0x1) << 22) |
355 ((pwrctrl->pmic_state & 0x1) << 23) |
356 ((pwrctrl->scp_mailbox_state & 0x1) << 24) |
357 ((pwrctrl->sspm_mailbox_state & 0x1) << 25) |
358 ((pwrctrl->sw_mailbox_state & 0x1) << 26) |
359 ((pwrctrl->vcore_state & 0x1) << 27) |
360 ((pwrctrl->vrf18_state & 0x1) << 28));
361
362 /* SPM_SRC_MASK_0 */
363 write32(&mtk_spm->spm_src_mask_0,
364 ((pwrctrl->reg_apu_apsrc_req_mask_b & 0x1) << 0) |
365 ((pwrctrl->reg_apu_ddren_req_mask_b & 0x1) << 1) |
366 ((pwrctrl->reg_apu_emi_req_mask_b & 0x1) << 2) |
367 ((pwrctrl->reg_apu_infra_req_mask_b & 0x1) << 3) |
368 ((pwrctrl->reg_apu_pmic_req_mask_b & 0x1) << 4) |
369 ((pwrctrl->reg_apu_srcclkena_mask_b & 0x1) << 5) |
370 ((pwrctrl->reg_apu_vrf18_req_mask_b & 0x1) << 6) |
371 ((pwrctrl->reg_audio_dsp_apsrc_req_mask_b & 0x1) << 7) |
372 ((pwrctrl->reg_audio_dsp_ddren_req_mask_b & 0x1) << 8) |
373 ((pwrctrl->reg_audio_dsp_emi_req_mask_b & 0x1) << 9) |
374 ((pwrctrl->reg_audio_dsp_infra_req_mask_b & 0x1) << 10) |
375 ((pwrctrl->reg_audio_dsp_pmic_req_mask_b & 0x1) << 11) |
376 ((pwrctrl->reg_audio_dsp_srcclkena_mask_b & 0x1) << 12) |
377 ((pwrctrl->reg_audio_dsp_vcore_req_mask_b & 0x1) << 13) |
378 ((pwrctrl->reg_audio_dsp_vrf18_req_mask_b & 0x1) << 14) |
379 ((pwrctrl->reg_cam_apsrc_req_mask_b & 0x1) << 15) |
380 ((pwrctrl->reg_cam_ddren_req_mask_b & 0x1) << 16) |
381 ((pwrctrl->reg_cam_emi_req_mask_b & 0x1) << 17) |
382 ((pwrctrl->reg_cam_infra_req_mask_b & 0x1) << 18) |
383 ((pwrctrl->reg_cam_pmic_req_mask_b & 0x1) << 19) |
384 ((pwrctrl->reg_cam_srcclkena_mask_b & 0x1) << 20) |
385 ((pwrctrl->reg_cam_vrf18_req_mask_b & 0x1) << 21) |
386 ((pwrctrl->reg_mdp_emi_req_mask_b & 0x1) << 22));
387
388 /* SPM_SRC_MASK_1 */
389 write32(&mtk_spm->spm_src_mask_1,
390 ((pwrctrl->reg_ccif_apsrc_req_mask_b & 0xfff) << 0) |
391 ((pwrctrl->reg_ccif_emi_req_mask_b & 0xfff) << 12));
392
393 /* SPM_SRC_MASK_2 */
394 write32(&mtk_spm->spm_src_mask_2,
395 ((pwrctrl->reg_ccif_infra_req_mask_b & 0xfff) << 0) |
396 ((pwrctrl->reg_ccif_pmic_req_mask_b & 0xfff) << 12));
397
398 /* SPM_SRC_MASK_3 */
399 write32(&mtk_spm->spm_src_mask_3,
400 ((pwrctrl->reg_ccif_srcclkena_mask_b & 0xfff) << 0) |
401 ((pwrctrl->reg_ccif_vrf18_req_mask_b & 0xfff) << 12) |
402 ((pwrctrl->reg_ccu_apsrc_req_mask_b & 0x1) << 24) |
403 ((pwrctrl->reg_ccu_ddren_req_mask_b & 0x1) << 25) |
404 ((pwrctrl->reg_ccu_emi_req_mask_b & 0x1) << 26) |
405 ((pwrctrl->reg_ccu_infra_req_mask_b & 0x1) << 27) |
406 ((pwrctrl->reg_ccu_pmic_req_mask_b & 0x1) << 28) |
407 ((pwrctrl->reg_ccu_srcclkena_mask_b & 0x1) << 29) |
408 ((pwrctrl->reg_ccu_vrf18_req_mask_b & 0x1) << 30) |
409 ((pwrctrl->reg_cg_check_apsrc_req_mask_b & 0x1) << 31));
410
411 /* SPM_SRC_MASK_4 */
412 write32(&mtk_spm->spm_src_mask_4,
413 ((pwrctrl->reg_cg_check_ddren_req_mask_b & 0x1) << 0) |
414 ((pwrctrl->reg_cg_check_emi_req_mask_b & 0x1) << 1) |
415 ((pwrctrl->reg_cg_check_infra_req_mask_b & 0x1) << 2) |
416 ((pwrctrl->reg_cg_check_pmic_req_mask_b & 0x1) << 3) |
417 ((pwrctrl->reg_cg_check_srcclkena_mask_b & 0x1) << 4) |
418 ((pwrctrl->reg_cg_check_vcore_req_mask_b & 0x1) << 5) |
419 ((pwrctrl->reg_cg_check_vrf18_req_mask_b & 0x1) << 6) |
420 ((pwrctrl->reg_conn_apsrc_req_mask_b & 0x1) << 7) |
421 ((pwrctrl->reg_conn_ddren_req_mask_b & 0x1) << 8) |
422 ((pwrctrl->reg_conn_emi_req_mask_b & 0x1) << 9) |
423 ((pwrctrl->reg_conn_infra_req_mask_b & 0x1) << 10) |
424 ((pwrctrl->reg_conn_pmic_req_mask_b & 0x1) << 11) |
425 ((pwrctrl->reg_conn_srcclkena_mask_b & 0x1) << 12) |
426 ((pwrctrl->reg_conn_srcclkenb_mask_b & 0x1) << 13) |
427 ((pwrctrl->reg_conn_vcore_req_mask_b & 0x1) << 14) |
428 ((pwrctrl->reg_conn_vrf18_req_mask_b & 0x1) << 15) |
429 ((pwrctrl->reg_cpueb_apsrc_req_mask_b & 0x1) << 16) |
430 ((pwrctrl->reg_cpueb_ddren_req_mask_b & 0x1) << 17) |
431 ((pwrctrl->reg_cpueb_emi_req_mask_b & 0x1) << 18) |
432 ((pwrctrl->reg_cpueb_infra_req_mask_b & 0x1) << 19) |
433 ((pwrctrl->reg_cpueb_pmic_req_mask_b & 0x1) << 20) |
434 ((pwrctrl->reg_cpueb_srcclkena_mask_b & 0x1) << 21) |
435 ((pwrctrl->reg_cpueb_vrf18_req_mask_b & 0x1) << 22) |
436 ((pwrctrl->reg_disp0_apsrc_req_mask_b & 0x1) << 23) |
437 ((pwrctrl->reg_disp0_ddren_req_mask_b & 0x1) << 24) |
438 ((pwrctrl->reg_disp0_emi_req_mask_b & 0x1) << 25) |
439 ((pwrctrl->reg_disp0_infra_req_mask_b & 0x1) << 26) |
440 ((pwrctrl->reg_disp0_pmic_req_mask_b & 0x1) << 27) |
441 ((pwrctrl->reg_disp0_srcclkena_mask_b & 0x1) << 28) |
442 ((pwrctrl->reg_disp0_vrf18_req_mask_b & 0x1) << 29) |
443 ((pwrctrl->reg_disp1_apsrc_req_mask_b & 0x1) << 30) |
444 ((pwrctrl->reg_disp1_ddren_req_mask_b & 0x1) << 31));
445
446 /* SPM_SRC_MASK_5 */
447 write32(&mtk_spm->spm_src_mask_5,
448 ((pwrctrl->reg_disp1_emi_req_mask_b & 0x1) << 0) |
449 ((pwrctrl->reg_disp1_infra_req_mask_b & 0x1) << 1) |
450 ((pwrctrl->reg_disp1_pmic_req_mask_b & 0x1) << 2) |
451 ((pwrctrl->reg_disp1_srcclkena_mask_b & 0x1) << 3) |
452 ((pwrctrl->reg_disp1_vrf18_req_mask_b & 0x1) << 4) |
453 ((pwrctrl->reg_dpm_apsrc_req_mask_b & 0xf) << 5) |
454 ((pwrctrl->reg_dpm_ddren_req_mask_b & 0xf) << 9) |
455 ((pwrctrl->reg_dpm_emi_req_mask_b & 0xf) << 13) |
456 ((pwrctrl->reg_dpm_infra_req_mask_b & 0xf) << 17) |
457 ((pwrctrl->reg_dpm_pmic_req_mask_b & 0xf) << 21) |
458 ((pwrctrl->reg_dpm_srcclkena_mask_b & 0xf) << 25));
459
460 /* SPM_SRC_MASK_6 */
461 write32(&mtk_spm->spm_src_mask_6,
462 ((pwrctrl->reg_dpm_vcore_req_mask_b & 0xf) << 0) |
463 ((pwrctrl->reg_dpm_vrf18_req_mask_b & 0xf) << 4) |
464 ((pwrctrl->reg_dpmaif_apsrc_req_mask_b & 0x1) << 8) |
465 ((pwrctrl->reg_dpmaif_ddren_req_mask_b & 0x1) << 9) |
466 ((pwrctrl->reg_dpmaif_emi_req_mask_b & 0x1) << 10) |
467 ((pwrctrl->reg_dpmaif_infra_req_mask_b & 0x1) << 11) |
468 ((pwrctrl->reg_dpmaif_pmic_req_mask_b & 0x1) << 12) |
469 ((pwrctrl->reg_dpmaif_srcclkena_mask_b & 0x1) << 13) |
470 ((pwrctrl->reg_dpmaif_vrf18_req_mask_b & 0x1) << 14) |
471 ((pwrctrl->reg_dvfsrc_level_req_mask_b & 0x1) << 15) |
472 ((pwrctrl->reg_emisys_apsrc_req_mask_b & 0x1) << 16) |
473 ((pwrctrl->reg_emisys_ddren_req_mask_b & 0x1) << 17) |
474 ((pwrctrl->reg_emisys_emi_req_mask_b & 0x1) << 18) |
475 ((pwrctrl->reg_gce_d_apsrc_req_mask_b & 0x1) << 19) |
476 ((pwrctrl->reg_gce_d_ddren_req_mask_b & 0x1) << 20) |
477 ((pwrctrl->reg_gce_d_emi_req_mask_b & 0x1) << 21) |
478 ((pwrctrl->reg_gce_d_infra_req_mask_b & 0x1) << 22) |
479 ((pwrctrl->reg_gce_d_pmic_req_mask_b & 0x1) << 23) |
480 ((pwrctrl->reg_gce_d_srcclkena_mask_b & 0x1) << 24) |
481 ((pwrctrl->reg_gce_d_vrf18_req_mask_b & 0x1) << 25) |
482 ((pwrctrl->reg_gce_m_apsrc_req_mask_b & 0x1) << 26) |
483 ((pwrctrl->reg_gce_m_ddren_req_mask_b & 0x1) << 27) |
484 ((pwrctrl->reg_gce_m_emi_req_mask_b & 0x1) << 28) |
485 ((pwrctrl->reg_gce_m_infra_req_mask_b & 0x1) << 29) |
486 ((pwrctrl->reg_gce_m_pmic_req_mask_b & 0x1) << 30) |
487 ((pwrctrl->reg_gce_m_srcclkena_mask_b & 0x1) << 31));
488
489 /* SPM_SRC_MASK_7 */
490 write32(&mtk_spm->spm_src_mask_7,
491 ((pwrctrl->reg_gce_m_vrf18_req_mask_b & 0x1) << 0) |
492 ((pwrctrl->reg_gpueb_apsrc_req_mask_b & 0x1) << 1) |
493 ((pwrctrl->reg_gpueb_ddren_req_mask_b & 0x1) << 2) |
494 ((pwrctrl->reg_gpueb_emi_req_mask_b & 0x1) << 3) |
495 ((pwrctrl->reg_gpueb_infra_req_mask_b & 0x1) << 4) |
496 ((pwrctrl->reg_gpueb_pmic_req_mask_b & 0x1) << 5) |
497 ((pwrctrl->reg_gpueb_srcclkena_mask_b & 0x1) << 6) |
498 ((pwrctrl->reg_gpueb_vrf18_req_mask_b & 0x1) << 7) |
499 ((pwrctrl->reg_hwccf_apsrc_req_mask_b & 0x1) << 8) |
500 ((pwrctrl->reg_hwccf_ddren_req_mask_b & 0x1) << 9) |
501 ((pwrctrl->reg_hwccf_emi_req_mask_b & 0x1) << 10) |
502 ((pwrctrl->reg_hwccf_infra_req_mask_b & 0x1) << 11) |
503 ((pwrctrl->reg_hwccf_pmic_req_mask_b & 0x1) << 12) |
504 ((pwrctrl->reg_hwccf_srcclkena_mask_b & 0x1) << 13) |
505 ((pwrctrl->reg_hwccf_vcore_req_mask_b & 0x1) << 14) |
506 ((pwrctrl->reg_hwccf_vrf18_req_mask_b & 0x1) << 15) |
507 ((pwrctrl->reg_img_apsrc_req_mask_b & 0x1) << 16) |
508 ((pwrctrl->reg_img_ddren_req_mask_b & 0x1) << 17) |
509 ((pwrctrl->reg_img_emi_req_mask_b & 0x1) << 18) |
510 ((pwrctrl->reg_img_infra_req_mask_b & 0x1) << 19) |
511 ((pwrctrl->reg_img_pmic_req_mask_b & 0x1) << 20) |
512 ((pwrctrl->reg_img_srcclkena_mask_b & 0x1) << 21) |
513 ((pwrctrl->reg_img_vrf18_req_mask_b & 0x1) << 22) |
514 ((pwrctrl->reg_infrasys_apsrc_req_mask_b & 0x1) << 23) |
515 ((pwrctrl->reg_infrasys_ddren_req_mask_b & 0x1) << 24) |
516 ((pwrctrl->reg_infrasys_emi_req_mask_b & 0x1) << 25) |
517 ((pwrctrl->reg_ipic_infra_req_mask_b & 0x1) << 26) |
518 ((pwrctrl->reg_ipic_vrf18_req_mask_b & 0x1) << 27) |
519 ((pwrctrl->reg_mcu_apsrc_req_mask_b & 0x1) << 28) |
520 ((pwrctrl->reg_mcu_ddren_req_mask_b & 0x1) << 29) |
521 ((pwrctrl->reg_mcu_emi_req_mask_b & 0x1) << 30));
522
523 /* SPM_SRC_MASK_8 */
524 write32(&mtk_spm->spm_src_mask_8,
525 ((pwrctrl->reg_mcusys_apsrc_req_mask_b & 0xff) << 0) |
526 ((pwrctrl->reg_mcusys_ddren_req_mask_b & 0xff) << 8) |
527 ((pwrctrl->reg_mcusys_emi_req_mask_b & 0xff) << 16) |
528 ((pwrctrl->reg_mcusys_infra_req_mask_b & 0xff) << 24));
529
530 /* SPM_SRC_MASK_9 */
531 write32(&mtk_spm->spm_src_mask_9,
532 ((pwrctrl->reg_mcusys_pmic_req_mask_b & 0xff) << 0) |
533 ((pwrctrl->reg_mcusys_srcclkena_mask_b & 0xff) << 8) |
534 ((pwrctrl->reg_mcusys_vrf18_req_mask_b & 0xff) << 16) |
535 ((pwrctrl->reg_md_apsrc_req_mask_b & 0x1) << 24) |
536 ((pwrctrl->reg_md_ddren_req_mask_b & 0x1) << 25) |
537 ((pwrctrl->reg_md_emi_req_mask_b & 0x1) << 26) |
538 ((pwrctrl->reg_md_infra_req_mask_b & 0x1) << 27) |
539 ((pwrctrl->reg_md_pmic_req_mask_b & 0x1) << 28) |
540 ((pwrctrl->reg_md_srcclkena_mask_b & 0x1) << 29) |
541 ((pwrctrl->reg_md_srcclkena1_mask_b & 0x1) << 30) |
542 ((pwrctrl->reg_md_vcore_req_mask_b & 0x1) << 31));
543
544 /* SPM_SRC_MASK_10 */
545 write32(&mtk_spm->spm_src_mask_10,
546 ((pwrctrl->reg_md_vrf18_req_mask_b & 0x1) << 0) |
547 ((pwrctrl->reg_mdp_apsrc_req_mask_b & 0x1) << 1) |
548 ((pwrctrl->reg_mdp_ddren_req_mask_b & 0x1) << 2) |
549 ((pwrctrl->reg_mm_proc_apsrc_req_mask_b & 0x1) << 3) |
550 ((pwrctrl->reg_mm_proc_ddren_req_mask_b & 0x1) << 4) |
551 ((pwrctrl->reg_mm_proc_emi_req_mask_b & 0x1) << 5) |
552 ((pwrctrl->reg_mm_proc_infra_req_mask_b & 0x1) << 6) |
553 ((pwrctrl->reg_mm_proc_pmic_req_mask_b & 0x1) << 7) |
554 ((pwrctrl->reg_mm_proc_srcclkena_mask_b & 0x1) << 8) |
555 ((pwrctrl->reg_mm_proc_vrf18_req_mask_b & 0x1) << 9) |
556 ((pwrctrl->reg_mmsys_apsrc_req_mask_b & 0x1) << 10) |
557 ((pwrctrl->reg_mmsys_ddren_req_mask_b & 0x1) << 11) |
558 ((pwrctrl->reg_mmsys_vrf18_req_mask_b & 0x1) << 12) |
559 ((pwrctrl->reg_pcie0_apsrc_req_mask_b & 0x1) << 13) |
560 ((pwrctrl->reg_pcie0_ddren_req_mask_b & 0x1) << 14) |
561 ((pwrctrl->reg_pcie0_infra_req_mask_b & 0x1) << 15) |
562 ((pwrctrl->reg_pcie0_srcclkena_mask_b & 0x1) << 16) |
563 ((pwrctrl->reg_pcie0_vrf18_req_mask_b & 0x1) << 17) |
564 ((pwrctrl->reg_pcie1_apsrc_req_mask_b & 0x1) << 18) |
565 ((pwrctrl->reg_pcie1_ddren_req_mask_b & 0x1) << 19) |
566 ((pwrctrl->reg_pcie1_infra_req_mask_b & 0x1) << 20) |
567 ((pwrctrl->reg_pcie1_srcclkena_mask_b & 0x1) << 21) |
568 ((pwrctrl->reg_pcie1_vrf18_req_mask_b & 0x1) << 22) |
569 ((pwrctrl->reg_perisys_apsrc_req_mask_b & 0x1) << 23) |
570 ((pwrctrl->reg_perisys_ddren_req_mask_b & 0x1) << 24) |
571 ((pwrctrl->reg_perisys_emi_req_mask_b & 0x1) << 25) |
572 ((pwrctrl->reg_perisys_infra_req_mask_b & 0x1) << 26) |
573 ((pwrctrl->reg_perisys_pmic_req_mask_b & 0x1) << 27) |
574 ((pwrctrl->reg_perisys_srcclkena_mask_b & 0x1) << 28) |
575 ((pwrctrl->reg_perisys_vcore_req_mask_b & 0x1) << 29) |
576 ((pwrctrl->reg_perisys_vrf18_req_mask_b & 0x1) << 30) |
577 ((pwrctrl->reg_scp_apsrc_req_mask_b & 0x1) << 31));
578
579 /* SPM_SRC_MASK_11 */
580 write32(&mtk_spm->spm_src_mask_11,
581 ((pwrctrl->reg_scp_ddren_req_mask_b & 0x1) << 0) |
582 ((pwrctrl->reg_scp_emi_req_mask_b & 0x1) << 1) |
583 ((pwrctrl->reg_scp_infra_req_mask_b & 0x1) << 2) |
584 ((pwrctrl->reg_scp_pmic_req_mask_b & 0x1) << 3) |
585 ((pwrctrl->reg_scp_srcclkena_mask_b & 0x1) << 4) |
586 ((pwrctrl->reg_scp_vcore_req_mask_b & 0x1) << 5) |
587 ((pwrctrl->reg_scp_vrf18_req_mask_b & 0x1) << 6) |
588 ((pwrctrl->reg_srcclkeni_infra_req_mask_b & 0x3) << 7) |
589 ((pwrctrl->reg_srcclkeni_pmic_req_mask_b & 0x3) << 9) |
590 ((pwrctrl->reg_srcclkeni_srcclkena_mask_b & 0x3) << 11) |
591 ((pwrctrl->reg_sspm_apsrc_req_mask_b & 0x1) << 13) |
592 ((pwrctrl->reg_sspm_ddren_req_mask_b & 0x1) << 14) |
593 ((pwrctrl->reg_sspm_emi_req_mask_b & 0x1) << 15) |
594 ((pwrctrl->reg_sspm_infra_req_mask_b & 0x1) << 16) |
595 ((pwrctrl->reg_sspm_pmic_req_mask_b & 0x1) << 17) |
596 ((pwrctrl->reg_sspm_srcclkena_mask_b & 0x1) << 18) |
597 ((pwrctrl->reg_sspm_vrf18_req_mask_b & 0x1) << 19) |
598 ((pwrctrl->reg_ssr_apsrc_req_mask_b & 0x1) << 20) |
599 ((pwrctrl->reg_ssr_ddren_req_mask_b & 0x1) << 21) |
600 ((pwrctrl->reg_ssr_emi_req_mask_b & 0x1) << 22) |
601 ((pwrctrl->reg_ssr_infra_req_mask_b & 0x1) << 23) |
602 ((pwrctrl->reg_ssr_pmic_req_mask_b & 0x1) << 24) |
603 ((pwrctrl->reg_ssr_srcclkena_mask_b & 0x1) << 25) |
604 ((pwrctrl->reg_ssr_vrf18_req_mask_b & 0x1) << 26) |
605 ((pwrctrl->reg_ufs_apsrc_req_mask_b & 0x1) << 27) |
606 ((pwrctrl->reg_ufs_ddren_req_mask_b & 0x1) << 28) |
607 ((pwrctrl->reg_ufs_emi_req_mask_b & 0x1) << 29) |
608 ((pwrctrl->reg_ufs_infra_req_mask_b & 0x1) << 30) |
609 ((pwrctrl->reg_ufs_pmic_req_mask_b & 0x1) << 31));
610
611 /* SPM_SRC_MASK_12 */
612 write32(&mtk_spm->spm_src_mask_12,
613 ((pwrctrl->reg_ufs_srcclkena_mask_b & 0x1) << 0) |
614 ((pwrctrl->reg_ufs_vrf18_req_mask_b & 0x1) << 1) |
615 ((pwrctrl->reg_vdec_apsrc_req_mask_b & 0x1) << 2) |
616 ((pwrctrl->reg_vdec_ddren_req_mask_b & 0x1) << 3) |
617 ((pwrctrl->reg_vdec_emi_req_mask_b & 0x1) << 4) |
618 ((pwrctrl->reg_vdec_infra_req_mask_b & 0x1) << 5) |
619 ((pwrctrl->reg_vdec_pmic_req_mask_b & 0x1) << 6) |
620 ((pwrctrl->reg_vdec_srcclkena_mask_b & 0x1) << 7) |
621 ((pwrctrl->reg_vdec_vrf18_req_mask_b & 0x1) << 8) |
622 ((pwrctrl->reg_venc_apsrc_req_mask_b & 0x1) << 9) |
623 ((pwrctrl->reg_venc_ddren_req_mask_b & 0x1) << 10) |
624 ((pwrctrl->reg_venc_emi_req_mask_b & 0x1) << 11) |
625 ((pwrctrl->reg_venc_infra_req_mask_b & 0x1) << 12) |
626 ((pwrctrl->reg_venc_pmic_req_mask_b & 0x1) << 13) |
627 ((pwrctrl->reg_venc_srcclkena_mask_b & 0x1) << 14) |
628 ((pwrctrl->reg_venc_vrf18_req_mask_b & 0x1) << 15) |
629 ((pwrctrl->reg_ipe_apsrc_req_mask_b & 0x1) << 16) |
630 ((pwrctrl->reg_ipe_ddren_req_mask_b & 0x1) << 17) |
631 ((pwrctrl->reg_ipe_emi_req_mask_b & 0x1) << 18) |
632 ((pwrctrl->reg_ipe_infra_req_mask_b & 0x1) << 19) |
633 ((pwrctrl->reg_ipe_pmic_req_mask_b & 0x1) << 20) |
634 ((pwrctrl->reg_ipe_srcclkena_mask_b & 0x1) << 21) |
635 ((pwrctrl->reg_ipe_vrf18_req_mask_b & 0x1) << 22) |
636 ((pwrctrl->reg_ufs_vcore_req_mask_b & 0x1) << 23));
637
638 /* SPM_EVENT_CON_MISC */
639 write32(&mtk_spm->spm_event_con_misc,
640 ((pwrctrl->reg_srcclken_fast_resp & 0x1) << 0) |
641 ((pwrctrl->reg_csyspwrup_ack_mask & 0x1) << 1));
642
643 /* SPM_WAKEUP_EVENT_MASK */
644 write32(&mtk_spm->spm_wakeup_event_mask,
645 ((pwrctrl->reg_wakeup_event_mask & 0xffffffff) << 0));
646
647 /* SPM_WAKEUP_EVENT_EXT_MASK */
648 write32(&mtk_spm->spm_wakeup_event_ext_mask,
649 ((pwrctrl->reg_ext_wakeup_event_mask & 0xffffffff) << 0));
650 }
651
652 void spm_register_init(void)
653 {
654 /* SPM related clk setting */
655 setbits32(&mtk_infracfg_ao->infra_bus_dcm_ctrl,
656 RG_AXI_DCM_DIS_EN | RG_PLLCK_SEL_NO_SPM);
657
658 /* Enable scpsys(SPM) clock off control, 0: Topck AO */
659 setbits32(&mtk_topckgen->clk_scp_cfg_0, GENMASK(9, 0));
660 clrsetbits32(&mtk_topckgen->clk_scp_cfg_1, BIT(12) | GENMASK(3, 2), GENMASK(1, 0));
661
662 /* enable register control */
663 write32(&mtk_spm->poweron_config_set, SPM_REGWR_CFG_KEY | BCLK_CG_EN_LSB);
664
665 /* Power on spm sram */
666 clrbits32(&mtk_spm->spm_sram_con, GENMASK(19, 16));
667
668 /* SRAM Workaround for Sleep FSM */
669 setbits32(&mtk_spm->spm_sram_sleep_ctrl, BIT(9));
670
671 /* init power control register */
672 /* dram will set this register */
673 /* write32(SPM_POWER_ON_VAL0, POWER_ON_VAL0_DEF); */
674 write32(&mtk_spm->spm_power_on_val[1], POWER_ON_VAL1_DEF);
675
676 /* reset PCM */
677 write32(&mtk_spm->pcm_con0, SPM_REGWR_CFG_KEY | PCM_CK_EN_LSB | PCM_SW_RESET_LSB);
678 write32(&mtk_spm->pcm_con0, SPM_REGWR_CFG_KEY | PCM_CK_EN_LSB);
679 write32(&mtk_spm->pcm_con1, SPM_REGWR_CFG_KEY |
680 REG_SPM_APB_INTERNAL_EN_LSB | REG_SSPM_APB_P2P_EN_LSB);
681 /* initial SPM CLK control register */
682 clrsetbits32(&mtk_spm->spm_clk_con, GENMASK(23, 16), BIT(28) | GENMASK(6, 4));
683 setbits32(&mtk_spm->spm_clk_con1, BIT(0));
684
685 /* clean wakeup event raw status */
686 write32(&mtk_spm->spm_wakeup_event_mask, SPM_WAKEUP_EVENT_MASK_DEF);
687
688 /* clean ISR status */
689 write32(&mtk_spm->spm_irq_mask, ISRM_ALL);
690 write32(&mtk_spm->spm_irq_sta, ISRC_ALL);
691 write32(&mtk_spm->spm_swint_clr, PCM_SW_INT_ALL);
692
693 /* set SPM_AP_STANDBY_CON[5] csyspower_req_mask = 1 */
694 setbits32(&mtk_spm->spm_ap_standby_con, BIT(5));
695
696 /* disable r0 and r7 to control power */
697 write32(&mtk_spm->pcm_pwr_io_en, 0);
698
699 /* DDR EN de-bounce length to 5us */
700 write32(&mtk_spm->ddren_dbc_con, 0x154 | REG_DDREN_DBC_EN_LSB);
701
702 /* Init for SPM Resource ACK */
703 write32(&mtk_spm->spm_resource_ack_con0, 0xCC4E4ECC);
704 write32(&mtk_spm->spm_resource_ack_con1, 0x00CCCCCC);
705 write32(&mtk_spm->spm_resource_ack_mask0, 0x00000000);
706 write32(&mtk_spm->spm_resource_ack_mask1, 0x00000000);
707 write32(&mtk_spm->spm_resource_ack_mask2, 0x00000000);
708 write32(&mtk_spm->spm_resource_ack_mask3, 0x00000000);
709 write32(&mtk_spm->spm_resource_ack_mask4, 0x00000000);
710 write32(&mtk_spm->spm_resource_ack_mask5, 0x00000000);
711 write32(&mtk_spm->spm_resource_ack_mask6, 0x00000000);
712
713 /* Init VCORE DVFS Status */
714 clrsetbits32(&mtk_spm->spm_dvfs_con, SPM_DVFS_FORCE_ENABLE_LSB, SPM_DVFSRC_ENABLE_LSB);
715 write32(&mtk_spm->spm_dvfs_level, 0x00000001);
716 write32(&mtk_spm->spm_dvs_dfs_level, 0x00010001);
717
718 write32(&mtk_spm->spm_ack_chk_sel_3, SPM_ACK_CHK_3_SEL_HW_S1);
719 write32(&mtk_spm->spm_ack_chk_timer_3, SPM_ACK_CHK_3_HW_S1_CNT);
720
721 spm_hw_s1_state_monitor_pause();
722 }
723
724 const struct pwr_ctrl *get_pwr_ctrl(void)
725 {
726 return &spm_init_ctrl;
727 }