1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
3 #include <soc/mcu_common.h>
6 static const struct pwr_ctrl spm_init_ctrl
= {
7 .pcm_flags
= SPM_FLAG_DISABLE_VCORE_DVS
| SPM_FLAG_DISABLE_VCORE_DFS
|
8 SPM_FLAG_RUN_COMMON_SCENARIO
,
10 /* SPM_AP_STANDBY_CON */
16 .reg_mp0_cputop_idle_mask
= 0,
18 .reg_mp1_cputop_idle_mask
= 0,
20 .reg_mcusys_idle_mask
= 0,
22 .reg_md_apsrc_1_sel
= 0,
24 .reg_md_apsrc_0_sel
= 0,
26 .reg_conn_apsrc_sel
= 0,
30 .reg_spm_apsrc_req
= 0,
32 .reg_spm_f26m_req
= 0,
34 .reg_spm_infra_req
= 0,
36 .reg_spm_vrf18_req
= 0,
37 /* [7] FIXME: default disable HW Auto S1*/
38 .reg_spm_ddr_en_req
= 1,
40 .reg_spm_dvfs_req
= 0,
42 .reg_spm_sw_mailbox_req
= 0,
44 .reg_spm_sspm_mailbox_req
= 0,
46 .reg_spm_adsp_mailbox_req
= 0,
48 .reg_spm_scp_mailbox_req
= 0,
52 .reg_sspm_srcclkena_0_mask_b
= 1,
54 .reg_sspm_infra_req_0_mask_b
= 1,
56 .reg_sspm_apsrc_req_0_mask_b
= 1,
58 .reg_sspm_vrf18_req_0_mask_b
= 1,
60 .reg_sspm_ddr_en_0_mask_b
= 1,
62 .reg_scp_srcclkena_mask_b
= 1,
64 .reg_scp_infra_req_mask_b
= 1,
66 .reg_scp_apsrc_req_mask_b
= 1,
68 .reg_scp_vrf18_req_mask_b
= 1,
70 .reg_scp_ddr_en_mask_b
= 1,
72 .reg_audio_dsp_srcclkena_mask_b
= 1,
74 .reg_audio_dsp_infra_req_mask_b
= 1,
76 .reg_audio_dsp_apsrc_req_mask_b
= 1,
78 .reg_audio_dsp_vrf18_req_mask_b
= 1,
80 .reg_audio_dsp_ddr_en_mask_b
= 1,
82 .reg_apu_srcclkena_mask_b
= 1,
84 .reg_apu_infra_req_mask_b
= 1,
86 .reg_apu_apsrc_req_mask_b
= 1,
88 .reg_apu_vrf18_req_mask_b
= 1,
90 .reg_apu_ddr_en_mask_b
= 1,
92 .reg_cpueb_srcclkena_mask_b
= 1,
94 .reg_cpueb_infra_req_mask_b
= 1,
96 .reg_cpueb_apsrc_req_mask_b
= 1,
98 .reg_cpueb_vrf18_req_mask_b
= 1,
100 .reg_cpueb_ddr_en_mask_b
= 1,
102 .reg_bak_psri_srcclkena_mask_b
= 0,
104 .reg_bak_psri_infra_req_mask_b
= 0,
106 .reg_bak_psri_apsrc_req_mask_b
= 0,
108 .reg_bak_psri_vrf18_req_mask_b
= 0,
110 .reg_bak_psri_ddr_en_mask_b
= 0,
114 .reg_msdc0_srcclkena_mask_b
= 1,
116 .reg_msdc0_infra_req_mask_b
= 1,
118 .reg_msdc0_apsrc_req_mask_b
= 1,
120 .reg_msdc0_vrf18_req_mask_b
= 1,
122 .reg_msdc0_ddr_en_mask_b
= 1,
124 .reg_msdc1_srcclkena_mask_b
= 1,
126 .reg_msdc1_infra_req_mask_b
= 1,
128 .reg_msdc1_apsrc_req_mask_b
= 1,
130 .reg_msdc1_vrf18_req_mask_b
= 1,
132 .reg_msdc1_ddr_en_mask_b
= 1,
134 .reg_msdc2_srcclkena_mask_b
= 1,
136 .reg_msdc2_infra_req_mask_b
= 1,
138 .reg_msdc2_apsrc_req_mask_b
= 1,
140 .reg_msdc2_vrf18_req_mask_b
= 1,
142 .reg_msdc2_ddr_en_mask_b
= 1,
144 .reg_ufs_srcclkena_mask_b
= 1,
146 .reg_ufs_infra_req_mask_b
= 1,
148 .reg_ufs_apsrc_req_mask_b
= 1,
150 .reg_ufs_vrf18_req_mask_b
= 1,
152 .reg_ufs_ddr_en_mask_b
= 1,
154 .reg_usb_srcclkena_mask_b
= 1,
156 .reg_usb_infra_req_mask_b
= 1,
158 .reg_usb_apsrc_req_mask_b
= 1,
160 .reg_usb_vrf18_req_mask_b
= 1,
162 .reg_usb_ddr_en_mask_b
= 1,
164 .reg_pextp_p0_srcclkena_mask_b
= 1,
166 .reg_pextp_p0_infra_req_mask_b
= 1,
168 .reg_pextp_p0_apsrc_req_mask_b
= 1,
170 .reg_pextp_p0_vrf18_req_mask_b
= 1,
172 .reg_pextp_p0_ddr_en_mask_b
= 1,
176 .reg_pextp_p1_srcclkena_mask_b
= 1,
178 .reg_pextp_p1_infra_req_mask_b
= 1,
180 .reg_pextp_p1_apsrc_req_mask_b
= 1,
182 .reg_pextp_p1_vrf18_req_mask_b
= 1,
184 .reg_pextp_p1_ddr_en_mask_b
= 1,
186 .reg_gce0_infra_req_mask_b
= 1,
188 .reg_gce0_apsrc_req_mask_b
= 1,
190 .reg_gce0_vrf18_req_mask_b
= 1,
192 .reg_gce0_ddr_en_mask_b
= 1,
194 .reg_gce1_infra_req_mask_b
= 1,
196 .reg_gce1_apsrc_req_mask_b
= 1,
198 .reg_gce1_vrf18_req_mask_b
= 1,
200 .reg_gce1_ddr_en_mask_b
= 1,
202 .reg_spm_srcclkena_reserved_mask_b
= 1,
204 .reg_spm_infra_req_reserved_mask_b
= 1,
206 .reg_spm_apsrc_req_reserved_mask_b
= 1,
208 .reg_spm_vrf18_req_reserved_mask_b
= 1,
210 .reg_spm_ddr_en_reserved_mask_b
= 1,
212 .reg_disp0_apsrc_req_mask_b
= 1,
214 .reg_disp0_ddr_en_mask_b
= 1,
216 .reg_disp1_apsrc_req_mask_b
= 1,
218 .reg_disp1_ddr_en_mask_b
= 1,
220 .reg_disp2_apsrc_req_mask_b
= 1,
222 .reg_disp2_ddr_en_mask_b
= 1,
224 .reg_disp3_apsrc_req_mask_b
= 1,
226 .reg_disp3_ddr_en_mask_b
= 1,
228 .reg_infrasys_apsrc_req_mask_b
= 0,
230 .reg_infrasys_ddr_en_mask_b
= 1,
233 .reg_cg_check_srcclkena_mask_b
= 1,
235 .reg_cg_check_apsrc_req_mask_b
= 1,
237 .reg_cg_check_vrf18_req_mask_b
= 1,
239 .reg_cg_check_ddr_en_mask_b
= 1,
243 .reg_mcusys_merge_apsrc_req_mask_b
= 0x17,
245 .reg_mcusys_merge_ddr_en_mask_b
= 0x17,
247 .reg_dramc_md32_infra_req_mask_b
= 0,
249 .reg_dramc_md32_vrf18_req_mask_b
= 0,
251 .reg_dramc_md32_ddr_en_mask_b
= 0,
253 .reg_dvfsrc_event_trigger_mask_b
= 1,
255 /* SPM_WAKEUP_EVENT_MASK2 */
257 .reg_sc_sw2spm_wakeup_mask_b
= 0,
259 .reg_sc_adsp2spm_wakeup_mask_b
= 0,
261 .reg_sc_sspm2spm_wakeup_mask_b
= 0,
263 .reg_sc_scp2spm_wakeup_mask_b
= 0,
265 .reg_csyspwrup_ack_mask
= 0,
267 .reg_csyspwrup_req_mask
= 1,
269 /* SPM_WAKEUP_EVENT_MASK */
271 .reg_wakeup_event_mask
= 0xC1382213,
273 /* SPM_WAKEUP_EVENT_EXT_MASK */
275 .reg_ext_wakeup_event_mask
= 0xFFFFFFFF,
278 void spm_set_power_control(const struct pwr_ctrl
*pwrctrl
)
282 /* SPM_AP_STANDBY_CON */
283 write32(&mtk_spm
->spm_ap_standby_con
,
284 ((pwrctrl
->reg_wfi_op
& 0x1) << 0) |
285 ((pwrctrl
->reg_wfi_type
& 0x1) << 1) |
286 ((pwrctrl
->reg_mp0_cputop_idle_mask
& 0x1) << 2) |
287 ((pwrctrl
->reg_mp1_cputop_idle_mask
& 0x1) << 3) |
288 ((pwrctrl
->reg_mcusys_idle_mask
& 0x1) << 4) |
289 ((pwrctrl
->reg_md_apsrc_1_sel
& 0x1) << 25) |
290 ((pwrctrl
->reg_md_apsrc_0_sel
& 0x1) << 26) |
291 ((pwrctrl
->reg_conn_apsrc_sel
& 0x1) << 29));
294 write32(&mtk_spm
->spm_src_req
,
295 ((pwrctrl
->reg_spm_apsrc_req
& 0x1) << 0) |
296 ((pwrctrl
->reg_spm_f26m_req
& 0x1) << 1) |
297 ((pwrctrl
->reg_spm_infra_req
& 0x1) << 3) |
298 ((pwrctrl
->reg_spm_vrf18_req
& 0x1) << 4) |
299 ((pwrctrl
->reg_spm_ddr_en_req
& 0x1) << 7) |
300 ((pwrctrl
->reg_spm_dvfs_req
& 0x1) << 8) |
301 ((pwrctrl
->reg_spm_sw_mailbox_req
& 0x1) << 9) |
302 ((pwrctrl
->reg_spm_sspm_mailbox_req
& 0x1) << 10) |
303 ((pwrctrl
->reg_spm_adsp_mailbox_req
& 0x1) << 11) |
304 ((pwrctrl
->reg_spm_scp_mailbox_req
& 0x1) << 12));
307 write32(&mtk_spm
->spm_src_mask
,
308 ((pwrctrl
->reg_sspm_srcclkena_0_mask_b
& 0x1) << 0) |
309 ((pwrctrl
->reg_sspm_infra_req_0_mask_b
& 0x1) << 1) |
310 ((pwrctrl
->reg_sspm_apsrc_req_0_mask_b
& 0x1) << 2) |
311 ((pwrctrl
->reg_sspm_vrf18_req_0_mask_b
& 0x1) << 3) |
312 ((pwrctrl
->reg_sspm_ddr_en_0_mask_b
& 0x1) << 4) |
313 ((pwrctrl
->reg_scp_srcclkena_mask_b
& 0x1) << 5) |
314 ((pwrctrl
->reg_scp_infra_req_mask_b
& 0x1) << 6) |
315 ((pwrctrl
->reg_scp_apsrc_req_mask_b
& 0x1) << 7) |
316 ((pwrctrl
->reg_scp_vrf18_req_mask_b
& 0x1) << 8) |
317 ((pwrctrl
->reg_scp_ddr_en_mask_b
& 0x1) << 9) |
318 ((pwrctrl
->reg_audio_dsp_srcclkena_mask_b
& 0x1) << 10) |
319 ((pwrctrl
->reg_audio_dsp_infra_req_mask_b
& 0x1) << 11) |
320 ((pwrctrl
->reg_audio_dsp_apsrc_req_mask_b
& 0x1) << 12) |
321 ((pwrctrl
->reg_audio_dsp_vrf18_req_mask_b
& 0x1) << 13) |
322 ((pwrctrl
->reg_audio_dsp_ddr_en_mask_b
& 0x1) << 14) |
323 ((pwrctrl
->reg_apu_srcclkena_mask_b
& 0x1) << 15) |
324 ((pwrctrl
->reg_apu_infra_req_mask_b
& 0x1) << 16) |
325 ((pwrctrl
->reg_apu_apsrc_req_mask_b
& 0x1) << 17) |
326 ((pwrctrl
->reg_apu_vrf18_req_mask_b
& 0x1) << 18) |
327 ((pwrctrl
->reg_apu_ddr_en_mask_b
& 0x1) << 19) |
328 ((pwrctrl
->reg_cpueb_srcclkena_mask_b
& 0x1) << 20) |
329 ((pwrctrl
->reg_cpueb_infra_req_mask_b
& 0x1) << 21) |
330 ((pwrctrl
->reg_cpueb_apsrc_req_mask_b
& 0x1) << 22) |
331 ((pwrctrl
->reg_cpueb_vrf18_req_mask_b
& 0x1) << 23) |
332 ((pwrctrl
->reg_cpueb_ddr_en_mask_b
& 0x1) << 24) |
333 ((pwrctrl
->reg_bak_psri_srcclkena_mask_b
& 0x1) << 25) |
334 ((pwrctrl
->reg_bak_psri_infra_req_mask_b
& 0x1) << 26) |
335 ((pwrctrl
->reg_bak_psri_apsrc_req_mask_b
& 0x1) << 27) |
336 ((pwrctrl
->reg_bak_psri_vrf18_req_mask_b
& 0x1) << 28) |
337 ((pwrctrl
->reg_bak_psri_ddr_en_mask_b
& 0x1) << 29));
340 write32(&mtk_spm
->spm_src2_mask
,
341 ((pwrctrl
->reg_msdc0_srcclkena_mask_b
& 0x1) << 0) |
342 ((pwrctrl
->reg_msdc0_infra_req_mask_b
& 0x1) << 1) |
343 ((pwrctrl
->reg_msdc0_apsrc_req_mask_b
& 0x1) << 2) |
344 ((pwrctrl
->reg_msdc0_vrf18_req_mask_b
& 0x1) << 3) |
345 ((pwrctrl
->reg_msdc0_ddr_en_mask_b
& 0x1) << 4) |
346 ((pwrctrl
->reg_msdc1_srcclkena_mask_b
& 0x1) << 5) |
347 ((pwrctrl
->reg_msdc1_infra_req_mask_b
& 0x1) << 6) |
348 ((pwrctrl
->reg_msdc1_apsrc_req_mask_b
& 0x1) << 7) |
349 ((pwrctrl
->reg_msdc1_vrf18_req_mask_b
& 0x1) << 8) |
350 ((pwrctrl
->reg_msdc1_ddr_en_mask_b
& 0x1) << 9) |
351 ((pwrctrl
->reg_msdc2_srcclkena_mask_b
& 0x1) << 10) |
352 ((pwrctrl
->reg_msdc2_infra_req_mask_b
& 0x1) << 11) |
353 ((pwrctrl
->reg_msdc2_apsrc_req_mask_b
& 0x1) << 12) |
354 ((pwrctrl
->reg_msdc2_vrf18_req_mask_b
& 0x1) << 13) |
355 ((pwrctrl
->reg_msdc2_ddr_en_mask_b
& 0x1) << 14) |
356 ((pwrctrl
->reg_ufs_srcclkena_mask_b
& 0x1) << 15) |
357 ((pwrctrl
->reg_ufs_infra_req_mask_b
& 0x1) << 16) |
358 ((pwrctrl
->reg_ufs_apsrc_req_mask_b
& 0x1) << 17) |
359 ((pwrctrl
->reg_ufs_vrf18_req_mask_b
& 0x1) << 18) |
360 ((pwrctrl
->reg_ufs_ddr_en_mask_b
& 0x1) << 19) |
361 ((pwrctrl
->reg_usb_srcclkena_mask_b
& 0x1) << 20) |
362 ((pwrctrl
->reg_usb_infra_req_mask_b
& 0x1) << 21) |
363 ((pwrctrl
->reg_usb_apsrc_req_mask_b
& 0x1) << 22) |
364 ((pwrctrl
->reg_usb_vrf18_req_mask_b
& 0x1) << 23) |
365 ((pwrctrl
->reg_usb_ddr_en_mask_b
& 0x1) << 24) |
366 ((pwrctrl
->reg_pextp_p0_srcclkena_mask_b
& 0x1) << 25) |
367 ((pwrctrl
->reg_pextp_p0_infra_req_mask_b
& 0x1) << 26) |
368 ((pwrctrl
->reg_pextp_p0_apsrc_req_mask_b
& 0x1) << 27) |
369 ((pwrctrl
->reg_pextp_p0_vrf18_req_mask_b
& 0x1) << 28) |
370 ((pwrctrl
->reg_pextp_p0_ddr_en_mask_b
& 0x1) << 29));
373 write32(&mtk_spm
->spm_src3_mask
,
374 ((pwrctrl
->reg_pextp_p1_srcclkena_mask_b
& 0x1) << 0) |
375 ((pwrctrl
->reg_pextp_p1_infra_req_mask_b
& 0x1) << 1) |
376 ((pwrctrl
->reg_pextp_p1_apsrc_req_mask_b
& 0x1) << 2) |
377 ((pwrctrl
->reg_pextp_p1_vrf18_req_mask_b
& 0x1) << 3) |
378 ((pwrctrl
->reg_pextp_p1_ddr_en_mask_b
& 0x1) << 4) |
379 ((pwrctrl
->reg_gce0_infra_req_mask_b
& 0x1) << 5) |
380 ((pwrctrl
->reg_gce0_apsrc_req_mask_b
& 0x1) << 6) |
381 ((pwrctrl
->reg_gce0_vrf18_req_mask_b
& 0x1) << 7) |
382 ((pwrctrl
->reg_gce0_ddr_en_mask_b
& 0x1) << 8) |
383 ((pwrctrl
->reg_gce1_infra_req_mask_b
& 0x1) << 9) |
384 ((pwrctrl
->reg_gce1_apsrc_req_mask_b
& 0x1) << 10) |
385 ((pwrctrl
->reg_gce1_vrf18_req_mask_b
& 0x1) << 11) |
386 ((pwrctrl
->reg_gce1_ddr_en_mask_b
& 0x1) << 12) |
387 ((pwrctrl
->reg_spm_srcclkena_reserved_mask_b
& 0x1) << 13) |
388 ((pwrctrl
->reg_spm_infra_req_reserved_mask_b
& 0x1) << 14) |
389 ((pwrctrl
->reg_spm_apsrc_req_reserved_mask_b
& 0x1) << 15) |
390 ((pwrctrl
->reg_spm_vrf18_req_reserved_mask_b
& 0x1) << 16) |
391 ((pwrctrl
->reg_spm_ddr_en_reserved_mask_b
& 0x1) << 17) |
392 ((pwrctrl
->reg_disp0_ddr_en_mask_b
& 0x1) << 18) |
393 ((pwrctrl
->reg_disp0_ddr_en_mask_b
& 0x1) << 19) |
394 ((pwrctrl
->reg_disp1_apsrc_req_mask_b
& 0x1) << 20) |
395 ((pwrctrl
->reg_disp1_ddr_en_mask_b
& 0x1) << 21) |
396 ((pwrctrl
->reg_disp2_apsrc_req_mask_b
& 0x1) << 22) |
397 ((pwrctrl
->reg_disp2_ddr_en_mask_b
& 0x1) << 23) |
398 ((pwrctrl
->reg_disp3_apsrc_req_mask_b
& 0x1) << 24) |
399 ((pwrctrl
->reg_disp3_ddr_en_mask_b
& 0x1) << 25) |
400 ((pwrctrl
->reg_infrasys_apsrc_req_mask_b
& 0x1) << 26) |
401 ((pwrctrl
->reg_infrasys_ddr_en_mask_b
& 0x1) << 27));
404 write32(&mtk_spm
->spm_src4_mask
, 0x1fc0000);
406 /* SPM_WAKEUP_EVENT_MASK */
407 write32(&mtk_spm
->spm_wakeup_event_mask
,
408 ((pwrctrl
->reg_wakeup_event_mask
& 0xffffffff) << 0));
410 /* SPM_WAKEUP_EVENT_EXT_MASK */
411 write32(&mtk_spm
->spm_wakeup_event_ext_mask
,
412 ((pwrctrl
->reg_ext_wakeup_event_mask
& 0xffffffff) << 0));
417 void spm_register_init(void)
419 /* Enable register control */
420 write32(&mtk_spm
->poweron_config_set
,
421 SPM_REGWR_CFG_KEY
| BCLK_CG_EN_LSB
);
423 /* Init power control register */
424 write32(&mtk_spm
->spm_power_on_val1
, POWER_ON_VAL1_DEF
);
425 write32(&mtk_spm
->pcm_pwr_io_en
, 0);
428 write32(&mtk_spm
->pcm_con0
,
429 SPM_REGWR_CFG_KEY
| PCM_CK_EN_LSB
| PCM_SW_RESET_LSB
);
430 write32(&mtk_spm
->pcm_con0
, SPM_REGWR_CFG_KEY
| PCM_CK_EN_LSB
);
431 write32(&mtk_spm
->pcm_con1
,
432 SPM_REGWR_CFG_KEY
| REG_EVENT_LOCK_EN_LSB
|
433 REG_SPM_SRAM_ISOINT_B_LSB
| RG_AHBMIF_APBEN_LSB
|
434 REG_MD32_APB_INTERNAL_EN_LSB
);
436 /* Initial SPM CLK control register */
437 SET32_BITFIELDS(&mtk_spm
->spm_clk_con
,
438 REG_SYSCLK1_SRC_MD2_SRCCLKENA
, 1);
440 /* Clean wakeup event raw status */
441 write32(&mtk_spm
->spm_wakeup_event_mask
, SPM_WAKEUP_EVENT_MASK_DEF
);
443 /* Clean ISR status */
444 write32(&mtk_spm
->spm_irq_mask
, ISRM_ALL
);
445 write32(&mtk_spm
->spm_irq_sta
, ISRC_ALL
);
446 write32(&mtk_spm
->spm_swint_clr
, PCM_SW_INT_ALL
);
448 /* Init r7 with POWER_ON_VAL1 */
449 write32(&mtk_spm
->pcm_reg_data_ini
,
450 read32(&mtk_spm
->spm_power_on_val1
));
451 write32(&mtk_spm
->pcm_pwr_io_en
, PCM_RF_SYNC_R7
);
452 write32(&mtk_spm
->pcm_pwr_io_en
, 0);
454 /* Configure ARMPLL Control Mode for MCDI */
455 write32(&mtk_spm
->armpll_clk_sel
, ARMPLL_CLK_SEL_DEF
);
457 /* Init for SPM Resource ACK */
458 write32(&mtk_spm
->spm_resource_ack_con0
, SPM_RESOURCE_ACK_CON0_DEF
);
459 write32(&mtk_spm
->spm_resource_ack_con1
, SPM_RESOURCE_ACK_CON1_DEF
);
460 write32(&mtk_spm
->spm_resource_ack_con2
, SPM_RESOURCE_ACK_CON2_DEF
);
461 write32(&mtk_spm
->spm_resource_ack_con3
, SPM_RESOURCE_ACK_CON3_DEF
);
463 /* Init VCORE DVFS Status */
464 SET32_BITFIELDS(&mtk_spm
->spm_dvfs_misc
,
465 SPM_DVFS_FORCE_ENABLE_LSB
, 0,
466 SPM_DVFSRC_ENABLE_LSB
, 1);
467 write32(&mtk_spm
->spm_dvfs_level
, SPM_DVFS_LEVEL_DEF
);
468 write32(&mtk_spm
->spm_dvs_dfs_level
, SPM_DVS_DFS_LEVEL_DEF
);
471 void spm_reset_and_init_pcm(void)
473 bool first_load_fw
= true;
475 /* Check the SPM FW is run or not */
476 if (read32(&mtk_spm
->md32pcm_cfgreg_sw_rstn
) &
477 MD32PCM_CFGREG_SW_RSTN_RUN
)
478 first_load_fw
= false;
480 if (!first_load_fw
) {
482 /* Backup PCM r0 -> SPM_POWER_ON_VAL0 before reset PCM */
483 write32(&mtk_spm
->spm_power_on_val0
,
484 read32(&mtk_spm
->pcm_reg0_data
));
487 /* Disable r0 and r7 to control power */
488 write32(&mtk_spm
->pcm_pwr_io_en
, 0);
490 /* Disable pcm timer after leaving FW */
491 clrsetbits32(&mtk_spm
->pcm_con1
,
492 RG_PCM_TIMER_EN_LSB
, SPM_REGWR_CFG_KEY
);
495 write32(&mtk_spm
->pcm_con0
,
496 SPM_REGWR_CFG_KEY
| PCM_CK_EN_LSB
| PCM_SW_RESET_LSB
);
497 write32(&mtk_spm
->pcm_con0
, SPM_REGWR_CFG_KEY
| PCM_CK_EN_LSB
);
499 /* Init PCM_CON1 (disable PCM timer but keep PCM WDT setting) */
500 clrsetbits32(&mtk_spm
->pcm_con1
, ~RG_PCM_WDT_WAKE_LSB
,
501 SPM_REGWR_CFG_KEY
| REG_EVENT_LOCK_EN_LSB
|
502 REG_SPM_SRAM_ISOINT_B_LSB
| RG_AHBMIF_APBEN_LSB
|
503 REG_MD32_APB_INTERNAL_EN_LSB
);
506 void spm_set_wakeup_event(const struct pwr_ctrl
*pwrctrl
)
510 /* Toggle event counter clear */
511 setbits32(&mtk_spm
->pcm_con1
,
512 SPM_REGWR_CFG_KEY
| SPM_EVENT_COUNTER_CLR_LSB
);
514 /* Toggle for reset SYS TIMER start point */
515 SET32_BITFIELDS(&mtk_spm
->sys_timer_con
,
516 SYS_TIMER_START_EN_LSB
, 1);
518 if (pwrctrl
->timer_val_cust
== 0)
519 val
= pwrctrl
->timer_val
? pwrctrl
->timer_val
: PCM_TIMER_MAX
;
521 val
= pwrctrl
->timer_val_cust
;
523 write32(&mtk_spm
->pcm_timer_val
, val
);
525 /* Disable pcm timer */
526 clrsetbits32(&mtk_spm
->pcm_con1
,
527 RG_PCM_TIMER_EN_LSB
, SPM_REGWR_CFG_KEY
);
529 /* Unmask AP wakeup source */
530 if (pwrctrl
->wake_src_cust
== 0)
531 mask
= pwrctrl
->wake_src
;
533 mask
= pwrctrl
->wake_src_cust
;
535 write32(&mtk_spm
->spm_wakeup_event_mask
, ~mask
);
538 SET32_BITFIELDS(&mtk_spm
->spm_irq_mask
,
540 ISRM_RET_IRQ_AUX_BF
, 0x3ff);
542 /* Toggle event counter clear */
543 clrsetbits32(&mtk_spm
->pcm_con1
,
544 SPM_EVENT_COUNTER_CLR_LSB
, SPM_REGWR_CFG_KEY
);
546 /* Toggle for reset SYS TIMER start point */
547 SET32_BITFIELDS(&mtk_spm
->sys_timer_con
,
548 SYS_TIMER_START_EN_LSB
, 0);
551 const struct pwr_ctrl
*get_pwr_ctrl(void)
553 return &spm_init_ctrl
;