xref: /arm-trusted-firmware/plat/imx/imx8qm/imx8qm_psci.c (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  */
6*91f16700Schasinglulu 
7*91f16700Schasinglulu #include <stdbool.h>
8*91f16700Schasinglulu 
9*91f16700Schasinglulu #include <arch.h>
10*91f16700Schasinglulu #include <arch_helpers.h>
11*91f16700Schasinglulu #include <common/debug.h>
12*91f16700Schasinglulu #include <drivers/arm/cci.h>
13*91f16700Schasinglulu #include <drivers/arm/gicv3.h>
14*91f16700Schasinglulu #include <lib/mmio.h>
15*91f16700Schasinglulu #include <lib/psci/psci.h>
16*91f16700Schasinglulu 
17*91f16700Schasinglulu #include <plat_imx8.h>
18*91f16700Schasinglulu #include <sci/sci.h>
19*91f16700Schasinglulu 
20*91f16700Schasinglulu #include "../../common/sci/imx8_mu.h"
21*91f16700Schasinglulu 
22*91f16700Schasinglulu #define CORE_PWR_STATE(state) \
23*91f16700Schasinglulu 	((state)->pwr_domain_state[MPIDR_AFFLVL0])
24*91f16700Schasinglulu #define CLUSTER_PWR_STATE(state) \
25*91f16700Schasinglulu 	((state)->pwr_domain_state[MPIDR_AFFLVL1])
26*91f16700Schasinglulu #define SYSTEM_PWR_STATE(state) \
27*91f16700Schasinglulu 	((state)->pwr_domain_state[PLAT_MAX_PWR_LVL])
28*91f16700Schasinglulu 
29*91f16700Schasinglulu static const int ap_core_index[PLATFORM_CORE_COUNT] = {
30*91f16700Schasinglulu 	SC_R_A53_0, SC_R_A53_1, SC_R_A53_2,
31*91f16700Schasinglulu 	SC_R_A53_3, SC_R_A72_0, SC_R_A72_1,
32*91f16700Schasinglulu };
33*91f16700Schasinglulu 
34*91f16700Schasinglulu /* save gic dist/redist context when GIC is poewr down */
35*91f16700Schasinglulu static struct plat_gic_ctx imx_gicv3_ctx;
36*91f16700Schasinglulu static unsigned int gpt_lpcg, gpt_reg[2];
37*91f16700Schasinglulu 
38*91f16700Schasinglulu static void imx_enable_irqstr_wakeup(void)
39*91f16700Schasinglulu {
40*91f16700Schasinglulu 	uint32_t irq_mask;
41*91f16700Schasinglulu 	gicv3_dist_ctx_t *dist_ctx = &imx_gicv3_ctx.dist_ctx;
42*91f16700Schasinglulu 
43*91f16700Schasinglulu 	/* put IRQSTR into ON mode */
44*91f16700Schasinglulu 	sc_pm_set_resource_power_mode(ipc_handle, SC_R_IRQSTR_SCU2, SC_PM_PW_MODE_ON);
45*91f16700Schasinglulu 
46*91f16700Schasinglulu 	/* enable the irqsteer to handle wakeup irq */
47*91f16700Schasinglulu 	mmio_write_32(IMX_WUP_IRQSTR_BASE, 0x1);
48*91f16700Schasinglulu 	for (int i = 0; i < 15; i++) {
49*91f16700Schasinglulu 		irq_mask = dist_ctx->gicd_isenabler[i];
50*91f16700Schasinglulu 		mmio_write_32(IMX_WUP_IRQSTR_BASE + 0x3c - 0x4 * i, irq_mask);
51*91f16700Schasinglulu 	}
52*91f16700Schasinglulu 
53*91f16700Schasinglulu 	/* set IRQSTR low power mode */
54*91f16700Schasinglulu 	if (imx_is_wakeup_src_irqsteer())
55*91f16700Schasinglulu 		sc_pm_set_resource_power_mode(ipc_handle, SC_R_IRQSTR_SCU2, SC_PM_PW_MODE_STBY);
56*91f16700Schasinglulu 	else
57*91f16700Schasinglulu 		sc_pm_set_resource_power_mode(ipc_handle, SC_R_IRQSTR_SCU2, SC_PM_PW_MODE_OFF);
58*91f16700Schasinglulu }
59*91f16700Schasinglulu 
60*91f16700Schasinglulu static void imx_disable_irqstr_wakeup(void)
61*91f16700Schasinglulu {
62*91f16700Schasinglulu 	/* put IRQSTR into ON from STBY mode */
63*91f16700Schasinglulu 	sc_pm_set_resource_power_mode(ipc_handle, SC_R_IRQSTR_SCU2, SC_PM_PW_MODE_ON);
64*91f16700Schasinglulu 
65*91f16700Schasinglulu 	/* disable the irqsteer */
66*91f16700Schasinglulu 	mmio_write_32(IMX_WUP_IRQSTR_BASE, 0x0);
67*91f16700Schasinglulu 	for (int i = 0; i < 16; i++)
68*91f16700Schasinglulu 		mmio_write_32(IMX_WUP_IRQSTR_BASE + 0x4 + 0x4 * i, 0x0);
69*91f16700Schasinglulu 
70*91f16700Schasinglulu 	/* put IRQSTR into OFF mode */
71*91f16700Schasinglulu 	sc_pm_set_resource_power_mode(ipc_handle, SC_R_IRQSTR_SCU2, SC_PM_PW_MODE_OFF);
72*91f16700Schasinglulu }
73*91f16700Schasinglulu 
74*91f16700Schasinglulu int imx_pwr_domain_on(u_register_t mpidr)
75*91f16700Schasinglulu {
76*91f16700Schasinglulu 	int ret = PSCI_E_SUCCESS;
77*91f16700Schasinglulu 	unsigned int cluster_id = MPIDR_AFFLVL1_VAL(mpidr);
78*91f16700Schasinglulu 	unsigned int cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
79*91f16700Schasinglulu 
80*91f16700Schasinglulu 	sc_pm_set_resource_power_mode(ipc_handle, cluster_id == 0 ?
81*91f16700Schasinglulu 		SC_R_A53 : SC_R_A72, SC_PM_PW_MODE_ON);
82*91f16700Schasinglulu 
83*91f16700Schasinglulu 	if (cluster_id == 1)
84*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_ON);
85*91f16700Schasinglulu 
86*91f16700Schasinglulu 	if (sc_pm_set_resource_power_mode(ipc_handle,
87*91f16700Schasinglulu 		ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
88*91f16700Schasinglulu 		SC_PM_PW_MODE_ON) != SC_ERR_NONE) {
89*91f16700Schasinglulu 		ERROR("core %d power on failed!\n", cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id);
90*91f16700Schasinglulu 		ret = PSCI_E_INTERN_FAIL;
91*91f16700Schasinglulu 	}
92*91f16700Schasinglulu 
93*91f16700Schasinglulu 	if (sc_pm_cpu_start(ipc_handle,
94*91f16700Schasinglulu 		ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
95*91f16700Schasinglulu 		true, BL31_BASE) != SC_ERR_NONE) {
96*91f16700Schasinglulu 		ERROR("boot core %d failed!\n", cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id);
97*91f16700Schasinglulu 		ret = PSCI_E_INTERN_FAIL;
98*91f16700Schasinglulu 	}
99*91f16700Schasinglulu 
100*91f16700Schasinglulu 	return ret;
101*91f16700Schasinglulu }
102*91f16700Schasinglulu 
103*91f16700Schasinglulu void imx_pwr_domain_on_finish(const psci_power_state_t *target_state)
104*91f16700Schasinglulu {
105*91f16700Schasinglulu 	uint64_t mpidr = read_mpidr_el1();
106*91f16700Schasinglulu 
107*91f16700Schasinglulu 	if (CLUSTER_PWR_STATE(target_state) == PLAT_MAX_OFF_STATE)
108*91f16700Schasinglulu 		cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(mpidr));
109*91f16700Schasinglulu 
110*91f16700Schasinglulu 	plat_gic_pcpu_init();
111*91f16700Schasinglulu 	plat_gic_cpuif_enable();
112*91f16700Schasinglulu }
113*91f16700Schasinglulu 
114*91f16700Schasinglulu void imx_pwr_domain_off(const psci_power_state_t *target_state)
115*91f16700Schasinglulu {
116*91f16700Schasinglulu 	u_register_t mpidr = read_mpidr_el1();
117*91f16700Schasinglulu 	unsigned int cluster_id = MPIDR_AFFLVL1_VAL(mpidr);
118*91f16700Schasinglulu 	unsigned int cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
119*91f16700Schasinglulu 
120*91f16700Schasinglulu 	plat_gic_cpuif_disable();
121*91f16700Schasinglulu 	sc_pm_req_cpu_low_power_mode(ipc_handle,
122*91f16700Schasinglulu 		ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
123*91f16700Schasinglulu 		SC_PM_PW_MODE_OFF, SC_PM_WAKE_SRC_NONE);
124*91f16700Schasinglulu 
125*91f16700Schasinglulu 	if (is_local_state_off(CLUSTER_PWR_STATE(target_state))) {
126*91f16700Schasinglulu 		cci_disable_snoop_dvm_reqs(cluster_id);
127*91f16700Schasinglulu 		if (cluster_id == 1)
128*91f16700Schasinglulu 			sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_OFF);
129*91f16700Schasinglulu 	}
130*91f16700Schasinglulu 	printf("turn off cluster:%d core:%d\n", cluster_id, cpu_id);
131*91f16700Schasinglulu }
132*91f16700Schasinglulu 
133*91f16700Schasinglulu void imx_domain_suspend(const psci_power_state_t *target_state)
134*91f16700Schasinglulu {
135*91f16700Schasinglulu 	u_register_t mpidr = read_mpidr_el1();
136*91f16700Schasinglulu 	unsigned int cluster_id = MPIDR_AFFLVL1_VAL(mpidr);
137*91f16700Schasinglulu 	unsigned int cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
138*91f16700Schasinglulu 
139*91f16700Schasinglulu 	if (is_local_state_off(CORE_PWR_STATE(target_state))) {
140*91f16700Schasinglulu 		plat_gic_cpuif_disable();
141*91f16700Schasinglulu 		sc_pm_set_cpu_resume(ipc_handle,
142*91f16700Schasinglulu 			ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
143*91f16700Schasinglulu 			true, BL31_BASE);
144*91f16700Schasinglulu 		sc_pm_req_cpu_low_power_mode(ipc_handle,
145*91f16700Schasinglulu 			ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
146*91f16700Schasinglulu 			SC_PM_PW_MODE_OFF, SC_PM_WAKE_SRC_GIC);
147*91f16700Schasinglulu 	} else {
148*91f16700Schasinglulu 		dsb();
149*91f16700Schasinglulu 		write_scr_el3(read_scr_el3() | SCR_FIQ_BIT);
150*91f16700Schasinglulu 		isb();
151*91f16700Schasinglulu 	}
152*91f16700Schasinglulu 
153*91f16700Schasinglulu 	if (is_local_state_off(CLUSTER_PWR_STATE(target_state))) {
154*91f16700Schasinglulu 		cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(mpidr));
155*91f16700Schasinglulu 		if (cluster_id == 1)
156*91f16700Schasinglulu 			sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_OFF);
157*91f16700Schasinglulu 	}
158*91f16700Schasinglulu 
159*91f16700Schasinglulu 	if (is_local_state_retn(SYSTEM_PWR_STATE(target_state))) {
160*91f16700Schasinglulu 		plat_gic_cpuif_disable();
161*91f16700Schasinglulu 
162*91f16700Schasinglulu 		/* save gic context */
163*91f16700Schasinglulu 		plat_gic_save(cpu_id, &imx_gicv3_ctx);
164*91f16700Schasinglulu 		/* enable the irqsteer for wakeup */
165*91f16700Schasinglulu 		imx_enable_irqstr_wakeup();
166*91f16700Schasinglulu 
167*91f16700Schasinglulu 		cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(mpidr));
168*91f16700Schasinglulu 
169*91f16700Schasinglulu 		/* Put GIC in LP mode. */
170*91f16700Schasinglulu 		sc_pm_set_resource_power_mode(ipc_handle, SC_R_GIC, SC_PM_PW_MODE_OFF);
171*91f16700Schasinglulu 		/* Save GPT clock and registers, then turn off its power */
172*91f16700Schasinglulu 		gpt_lpcg = mmio_read_32(IMX_GPT_LPCG_BASE);
173*91f16700Schasinglulu 		gpt_reg[0] = mmio_read_32(IMX_GPT_BASE);
174*91f16700Schasinglulu 		gpt_reg[1] = mmio_read_32(IMX_GPT_BASE + 0x4);
175*91f16700Schasinglulu 		sc_pm_set_resource_power_mode(ipc_handle, SC_R_GPT_0, SC_PM_PW_MODE_OFF);
176*91f16700Schasinglulu 
177*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_A53, SC_PM_PW_MODE_OFF);
178*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_OFF);
179*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_CCI, SC_PM_PW_MODE_OFF);
180*91f16700Schasinglulu 
181*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_DDR,
182*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_OFF);
183*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_DDR,
184*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_OFF);
185*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_MU,
186*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_OFF);
187*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_MU,
188*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_OFF);
189*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_INTERCONNECT,
190*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_OFF);
191*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_INTERCONNECT,
192*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_OFF);
193*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_CCI, SC_PM_PW_MODE_OFF);
194*91f16700Schasinglulu 
195*91f16700Schasinglulu 		sc_pm_set_cpu_resume(ipc_handle,
196*91f16700Schasinglulu 			ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
197*91f16700Schasinglulu 			true, BL31_BASE);
198*91f16700Schasinglulu 		if (imx_is_wakeup_src_irqsteer())
199*91f16700Schasinglulu 			sc_pm_req_cpu_low_power_mode(ipc_handle,
200*91f16700Schasinglulu 				ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
201*91f16700Schasinglulu 				SC_PM_PW_MODE_OFF, SC_PM_WAKE_SRC_IRQSTEER);
202*91f16700Schasinglulu 		else
203*91f16700Schasinglulu 			sc_pm_req_cpu_low_power_mode(ipc_handle,
204*91f16700Schasinglulu 				ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
205*91f16700Schasinglulu 				SC_PM_PW_MODE_OFF, SC_PM_WAKE_SRC_SCU);
206*91f16700Schasinglulu 	}
207*91f16700Schasinglulu }
208*91f16700Schasinglulu 
209*91f16700Schasinglulu void imx_domain_suspend_finish(const psci_power_state_t *target_state)
210*91f16700Schasinglulu {
211*91f16700Schasinglulu 	u_register_t mpidr = read_mpidr_el1();
212*91f16700Schasinglulu 	unsigned int cluster_id = MPIDR_AFFLVL1_VAL(mpidr);
213*91f16700Schasinglulu 	unsigned int cpu_id = MPIDR_AFFLVL0_VAL(mpidr);
214*91f16700Schasinglulu 
215*91f16700Schasinglulu 	/* check the system level status */
216*91f16700Schasinglulu 	if (is_local_state_retn(SYSTEM_PWR_STATE(target_state))) {
217*91f16700Schasinglulu 		MU_Resume(SC_IPC_BASE);
218*91f16700Schasinglulu 
219*91f16700Schasinglulu 		sc_pm_req_cpu_low_power_mode(ipc_handle,
220*91f16700Schasinglulu 			ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
221*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_WAKE_SRC_GIC);
222*91f16700Schasinglulu 
223*91f16700Schasinglulu 		/* Put GIC/IRQSTR back to high power mode. */
224*91f16700Schasinglulu 		sc_pm_set_resource_power_mode(ipc_handle, SC_R_GIC, SC_PM_PW_MODE_ON);
225*91f16700Schasinglulu 
226*91f16700Schasinglulu 		/* Turn GPT power and restore its clock and registers */
227*91f16700Schasinglulu 		sc_pm_set_resource_power_mode(ipc_handle, SC_R_GPT_0, SC_PM_PW_MODE_ON);
228*91f16700Schasinglulu 		sc_pm_clock_enable(ipc_handle, SC_R_GPT_0, SC_PM_CLK_PER, true, 0);
229*91f16700Schasinglulu 		mmio_write_32(IMX_GPT_BASE, gpt_reg[0]);
230*91f16700Schasinglulu 		mmio_write_32(IMX_GPT_BASE + 0x4, gpt_reg[1]);
231*91f16700Schasinglulu 		mmio_write_32(IMX_GPT_LPCG_BASE, gpt_lpcg);
232*91f16700Schasinglulu 
233*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_A53, SC_PM_PW_MODE_ON);
234*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_ON);
235*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_CCI, SC_PM_PW_MODE_ON);
236*91f16700Schasinglulu 
237*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_DDR,
238*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
239*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_DDR,
240*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
241*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_MU,
242*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
243*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_MU,
244*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
245*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_INTERCONNECT,
246*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
247*91f16700Schasinglulu 		sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_INTERCONNECT,
248*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
249*91f16700Schasinglulu 		sc_pm_req_low_power_mode(ipc_handle, SC_R_CCI, SC_PM_PW_MODE_ON);
250*91f16700Schasinglulu 
251*91f16700Schasinglulu 		cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(mpidr));
252*91f16700Schasinglulu 
253*91f16700Schasinglulu 		/* restore gic context */
254*91f16700Schasinglulu 		plat_gic_restore(cpu_id, &imx_gicv3_ctx);
255*91f16700Schasinglulu 		/* disable the irqsteer wakeup */
256*91f16700Schasinglulu 		imx_disable_irqstr_wakeup();
257*91f16700Schasinglulu 
258*91f16700Schasinglulu 		plat_gic_cpuif_enable();
259*91f16700Schasinglulu 	}
260*91f16700Schasinglulu 
261*91f16700Schasinglulu 	/* check the cluster level power status */
262*91f16700Schasinglulu 	if (is_local_state_off(CLUSTER_PWR_STATE(target_state))) {
263*91f16700Schasinglulu 		cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(mpidr));
264*91f16700Schasinglulu 		if (cluster_id == 1)
265*91f16700Schasinglulu 			sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_ON);
266*91f16700Schasinglulu 	}
267*91f16700Schasinglulu 
268*91f16700Schasinglulu 	/* check the core level power status */
269*91f16700Schasinglulu 	if (is_local_state_off(CORE_PWR_STATE(target_state))) {
270*91f16700Schasinglulu 		sc_pm_set_cpu_resume(ipc_handle,
271*91f16700Schasinglulu 			ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
272*91f16700Schasinglulu 			false, BL31_BASE);
273*91f16700Schasinglulu 		sc_pm_req_cpu_low_power_mode(ipc_handle,
274*91f16700Schasinglulu 			ap_core_index[cpu_id + PLATFORM_CLUSTER0_CORE_COUNT * cluster_id],
275*91f16700Schasinglulu 			SC_PM_PW_MODE_ON, SC_PM_WAKE_SRC_GIC);
276*91f16700Schasinglulu 		plat_gic_cpuif_enable();
277*91f16700Schasinglulu 	} else {
278*91f16700Schasinglulu 		write_scr_el3(read_scr_el3() & (~SCR_FIQ_BIT));
279*91f16700Schasinglulu 		isb();
280*91f16700Schasinglulu 	}
281*91f16700Schasinglulu }
282*91f16700Schasinglulu 
283*91f16700Schasinglulu int imx_validate_ns_entrypoint(uintptr_t ns_entrypoint)
284*91f16700Schasinglulu {
285*91f16700Schasinglulu 	return PSCI_E_SUCCESS;
286*91f16700Schasinglulu }
287*91f16700Schasinglulu 
288*91f16700Schasinglulu static const plat_psci_ops_t imx_plat_psci_ops = {
289*91f16700Schasinglulu 	.pwr_domain_on = imx_pwr_domain_on,
290*91f16700Schasinglulu 	.pwr_domain_on_finish = imx_pwr_domain_on_finish,
291*91f16700Schasinglulu 	.pwr_domain_off = imx_pwr_domain_off,
292*91f16700Schasinglulu 	.pwr_domain_suspend = imx_domain_suspend,
293*91f16700Schasinglulu 	.pwr_domain_suspend_finish = imx_domain_suspend_finish,
294*91f16700Schasinglulu 	.get_sys_suspend_power_state = imx_get_sys_suspend_power_state,
295*91f16700Schasinglulu 	.validate_power_state = imx_validate_power_state,
296*91f16700Schasinglulu 	.validate_ns_entrypoint = imx_validate_ns_entrypoint,
297*91f16700Schasinglulu 	.system_off = imx_system_off,
298*91f16700Schasinglulu 	.system_reset = imx_system_reset,
299*91f16700Schasinglulu };
300*91f16700Schasinglulu 
301*91f16700Schasinglulu int plat_setup_psci_ops(uintptr_t sec_entrypoint,
302*91f16700Schasinglulu 			const plat_psci_ops_t **psci_ops)
303*91f16700Schasinglulu {
304*91f16700Schasinglulu 	imx_mailbox_init(sec_entrypoint);
305*91f16700Schasinglulu 	*psci_ops = &imx_plat_psci_ops;
306*91f16700Schasinglulu 
307*91f16700Schasinglulu 	/* make sure system sources power ON in low power mode by default */
308*91f16700Schasinglulu 	sc_pm_req_low_power_mode(ipc_handle, SC_R_A53, SC_PM_PW_MODE_ON);
309*91f16700Schasinglulu 	sc_pm_req_low_power_mode(ipc_handle, SC_R_A72, SC_PM_PW_MODE_ON);
310*91f16700Schasinglulu 	sc_pm_req_low_power_mode(ipc_handle, SC_R_CCI, SC_PM_PW_MODE_ON);
311*91f16700Schasinglulu 
312*91f16700Schasinglulu 	sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_DDR,
313*91f16700Schasinglulu 		SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
314*91f16700Schasinglulu 	sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_DDR,
315*91f16700Schasinglulu 		SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
316*91f16700Schasinglulu 	sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_MU,
317*91f16700Schasinglulu 		SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
318*91f16700Schasinglulu 	sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_MU,
319*91f16700Schasinglulu 		SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
320*91f16700Schasinglulu 	sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A53, SC_PM_SYS_IF_INTERCONNECT,
321*91f16700Schasinglulu 		SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
322*91f16700Schasinglulu 	sc_pm_req_sys_if_power_mode(ipc_handle, SC_R_A72, SC_PM_SYS_IF_INTERCONNECT,
323*91f16700Schasinglulu 		SC_PM_PW_MODE_ON, SC_PM_PW_MODE_ON);
324*91f16700Schasinglulu 
325*91f16700Schasinglulu 	return 0;
326*91f16700Schasinglulu }
327