xref: /arm-trusted-firmware/plat/arm/css/common/css_pm.c (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier: BSD-3-Clause
5*91f16700Schasinglulu  */
6*91f16700Schasinglulu 
7*91f16700Schasinglulu #include <assert.h>
8*91f16700Schasinglulu 
9*91f16700Schasinglulu #include <platform_def.h>
10*91f16700Schasinglulu 
11*91f16700Schasinglulu #include <arch_helpers.h>
12*91f16700Schasinglulu #include <bl31/interrupt_mgmt.h>
13*91f16700Schasinglulu #include <common/debug.h>
14*91f16700Schasinglulu #include <drivers/arm/css/css_scp.h>
15*91f16700Schasinglulu #include <lib/cassert.h>
16*91f16700Schasinglulu #include <plat/arm/common/plat_arm.h>
17*91f16700Schasinglulu 
18*91f16700Schasinglulu #include <plat/common/platform.h>
19*91f16700Schasinglulu 
20*91f16700Schasinglulu #include <plat/arm/css/common/css_pm.h>
21*91f16700Schasinglulu 
22*91f16700Schasinglulu /* Allow CSS platforms to override `plat_arm_psci_pm_ops` */
23*91f16700Schasinglulu #pragma weak plat_arm_psci_pm_ops
24*91f16700Schasinglulu 
25*91f16700Schasinglulu #if ARM_RECOM_STATE_ID_ENC
26*91f16700Schasinglulu /*
27*91f16700Schasinglulu  *  The table storing the valid idle power states. Ensure that the
28*91f16700Schasinglulu  *  array entries are populated in ascending order of state-id to
29*91f16700Schasinglulu  *  enable us to use binary search during power state validation.
30*91f16700Schasinglulu  *  The table must be terminated by a NULL entry.
31*91f16700Schasinglulu  */
32*91f16700Schasinglulu const unsigned int arm_pm_idle_states[] = {
33*91f16700Schasinglulu 	/* State-id - 0x001 */
34*91f16700Schasinglulu 	arm_make_pwrstate_lvl2(ARM_LOCAL_STATE_RUN, ARM_LOCAL_STATE_RUN,
35*91f16700Schasinglulu 		ARM_LOCAL_STATE_RET, ARM_PWR_LVL0, PSTATE_TYPE_STANDBY),
36*91f16700Schasinglulu 	/* State-id - 0x002 */
37*91f16700Schasinglulu 	arm_make_pwrstate_lvl2(ARM_LOCAL_STATE_RUN, ARM_LOCAL_STATE_RUN,
38*91f16700Schasinglulu 		ARM_LOCAL_STATE_OFF, ARM_PWR_LVL0, PSTATE_TYPE_POWERDOWN),
39*91f16700Schasinglulu 	/* State-id - 0x022 */
40*91f16700Schasinglulu 	arm_make_pwrstate_lvl2(ARM_LOCAL_STATE_RUN, ARM_LOCAL_STATE_OFF,
41*91f16700Schasinglulu 		ARM_LOCAL_STATE_OFF, ARM_PWR_LVL1, PSTATE_TYPE_POWERDOWN),
42*91f16700Schasinglulu #if PLAT_MAX_PWR_LVL > ARM_PWR_LVL1
43*91f16700Schasinglulu 	/* State-id - 0x222 */
44*91f16700Schasinglulu 	arm_make_pwrstate_lvl2(ARM_LOCAL_STATE_OFF, ARM_LOCAL_STATE_OFF,
45*91f16700Schasinglulu 		ARM_LOCAL_STATE_OFF, ARM_PWR_LVL2, PSTATE_TYPE_POWERDOWN),
46*91f16700Schasinglulu #endif
47*91f16700Schasinglulu 	0,
48*91f16700Schasinglulu };
49*91f16700Schasinglulu #endif /* __ARM_RECOM_STATE_ID_ENC__ */
50*91f16700Schasinglulu 
51*91f16700Schasinglulu /*
52*91f16700Schasinglulu  * All the power management helpers in this file assume at least cluster power
53*91f16700Schasinglulu  * level is supported.
54*91f16700Schasinglulu  */
55*91f16700Schasinglulu CASSERT(PLAT_MAX_PWR_LVL >= ARM_PWR_LVL1,
56*91f16700Schasinglulu 		assert_max_pwr_lvl_supported_mismatch);
57*91f16700Schasinglulu 
58*91f16700Schasinglulu /*
59*91f16700Schasinglulu  * Ensure that the PLAT_MAX_PWR_LVL is not greater than CSS_SYSTEM_PWR_DMN_LVL
60*91f16700Schasinglulu  * assumed by the CSS layer.
61*91f16700Schasinglulu  */
62*91f16700Schasinglulu CASSERT(PLAT_MAX_PWR_LVL <= CSS_SYSTEM_PWR_DMN_LVL,
63*91f16700Schasinglulu 		assert_max_pwr_lvl_higher_than_css_sys_lvl);
64*91f16700Schasinglulu 
65*91f16700Schasinglulu /*******************************************************************************
66*91f16700Schasinglulu  * Handler called when a power domain is about to be turned on. The
67*91f16700Schasinglulu  * level and mpidr determine the affinity instance.
68*91f16700Schasinglulu  ******************************************************************************/
69*91f16700Schasinglulu int css_pwr_domain_on(u_register_t mpidr)
70*91f16700Schasinglulu {
71*91f16700Schasinglulu 	css_scp_on(mpidr);
72*91f16700Schasinglulu 
73*91f16700Schasinglulu 	return PSCI_E_SUCCESS;
74*91f16700Schasinglulu }
75*91f16700Schasinglulu 
76*91f16700Schasinglulu static void css_pwr_domain_on_finisher_common(
77*91f16700Schasinglulu 		const psci_power_state_t *target_state)
78*91f16700Schasinglulu {
79*91f16700Schasinglulu 	assert(CSS_CORE_PWR_STATE(target_state) == ARM_LOCAL_STATE_OFF);
80*91f16700Schasinglulu 
81*91f16700Schasinglulu 	/*
82*91f16700Schasinglulu 	 * Perform the common cluster specific operations i.e enable coherency
83*91f16700Schasinglulu 	 * if this cluster was off.
84*91f16700Schasinglulu 	 */
85*91f16700Schasinglulu 	if (CSS_CLUSTER_PWR_STATE(target_state) == ARM_LOCAL_STATE_OFF)
86*91f16700Schasinglulu 		plat_arm_interconnect_enter_coherency();
87*91f16700Schasinglulu }
88*91f16700Schasinglulu 
89*91f16700Schasinglulu /*******************************************************************************
90*91f16700Schasinglulu  * Handler called when a power level has just been powered on after
91*91f16700Schasinglulu  * being turned off earlier. The target_state encodes the low power state that
92*91f16700Schasinglulu  * each level has woken up from. This handler would never be invoked with
93*91f16700Schasinglulu  * the system power domain uninitialized as either the primary would have taken
94*91f16700Schasinglulu  * care of it as part of cold boot or the first core awakened from system
95*91f16700Schasinglulu  * suspend would have already initialized it.
96*91f16700Schasinglulu  ******************************************************************************/
97*91f16700Schasinglulu void css_pwr_domain_on_finish(const psci_power_state_t *target_state)
98*91f16700Schasinglulu {
99*91f16700Schasinglulu 	/* Assert that the system power domain need not be initialized */
100*91f16700Schasinglulu 	assert(css_system_pwr_state(target_state) == ARM_LOCAL_STATE_RUN);
101*91f16700Schasinglulu 
102*91f16700Schasinglulu 	css_pwr_domain_on_finisher_common(target_state);
103*91f16700Schasinglulu }
104*91f16700Schasinglulu 
105*91f16700Schasinglulu /*******************************************************************************
106*91f16700Schasinglulu  * Handler called when a power domain has just been powered on and the cpu
107*91f16700Schasinglulu  * and its cluster are fully participating in coherent transaction on the
108*91f16700Schasinglulu  * interconnect. Data cache must be enabled for CPU at this point.
109*91f16700Schasinglulu  ******************************************************************************/
110*91f16700Schasinglulu void css_pwr_domain_on_finish_late(const psci_power_state_t *target_state)
111*91f16700Schasinglulu {
112*91f16700Schasinglulu 	/* Program the gic per-cpu distributor or re-distributor interface */
113*91f16700Schasinglulu 	plat_arm_gic_pcpu_init();
114*91f16700Schasinglulu 
115*91f16700Schasinglulu 	/* Enable the gic cpu interface */
116*91f16700Schasinglulu 	plat_arm_gic_cpuif_enable();
117*91f16700Schasinglulu 
118*91f16700Schasinglulu 	/* Setup the CPU power down request interrupt for secondary core(s) */
119*91f16700Schasinglulu 	css_setup_cpu_pwr_down_intr();
120*91f16700Schasinglulu }
121*91f16700Schasinglulu 
122*91f16700Schasinglulu /*******************************************************************************
123*91f16700Schasinglulu  * Common function called while turning a cpu off or suspending it. It is called
124*91f16700Schasinglulu  * from css_off() or css_suspend() when these functions in turn are called for
125*91f16700Schasinglulu  * power domain at the highest power level which will be powered down. It
126*91f16700Schasinglulu  * performs the actions common to the OFF and SUSPEND calls.
127*91f16700Schasinglulu  ******************************************************************************/
128*91f16700Schasinglulu static void css_power_down_common(const psci_power_state_t *target_state)
129*91f16700Schasinglulu {
130*91f16700Schasinglulu 	/* Prevent interrupts from spuriously waking up this cpu */
131*91f16700Schasinglulu 	plat_arm_gic_cpuif_disable();
132*91f16700Schasinglulu 
133*91f16700Schasinglulu 	/* Cluster is to be turned off, so disable coherency */
134*91f16700Schasinglulu 	if (CSS_CLUSTER_PWR_STATE(target_state) == ARM_LOCAL_STATE_OFF)
135*91f16700Schasinglulu 		plat_arm_interconnect_exit_coherency();
136*91f16700Schasinglulu }
137*91f16700Schasinglulu 
138*91f16700Schasinglulu /*******************************************************************************
139*91f16700Schasinglulu  * Handler called when a power domain is about to be turned off. The
140*91f16700Schasinglulu  * target_state encodes the power state that each level should transition to.
141*91f16700Schasinglulu  ******************************************************************************/
142*91f16700Schasinglulu void css_pwr_domain_off(const psci_power_state_t *target_state)
143*91f16700Schasinglulu {
144*91f16700Schasinglulu 	assert(CSS_CORE_PWR_STATE(target_state) == ARM_LOCAL_STATE_OFF);
145*91f16700Schasinglulu 	css_power_down_common(target_state);
146*91f16700Schasinglulu 	css_scp_off(target_state);
147*91f16700Schasinglulu }
148*91f16700Schasinglulu 
149*91f16700Schasinglulu /*******************************************************************************
150*91f16700Schasinglulu  * Handler called when a power domain is about to be suspended. The
151*91f16700Schasinglulu  * target_state encodes the power state that each level should transition to.
152*91f16700Schasinglulu  ******************************************************************************/
153*91f16700Schasinglulu void css_pwr_domain_suspend(const psci_power_state_t *target_state)
154*91f16700Schasinglulu {
155*91f16700Schasinglulu 	/*
156*91f16700Schasinglulu 	 * CSS currently supports retention only at cpu level. Just return
157*91f16700Schasinglulu 	 * as nothing is to be done for retention.
158*91f16700Schasinglulu 	 */
159*91f16700Schasinglulu 	if (CSS_CORE_PWR_STATE(target_state) == ARM_LOCAL_STATE_RET)
160*91f16700Schasinglulu 		return;
161*91f16700Schasinglulu 
162*91f16700Schasinglulu 
163*91f16700Schasinglulu 	assert(CSS_CORE_PWR_STATE(target_state) == ARM_LOCAL_STATE_OFF);
164*91f16700Schasinglulu 	css_power_down_common(target_state);
165*91f16700Schasinglulu 
166*91f16700Schasinglulu 	/* Perform system domain state saving if issuing system suspend */
167*91f16700Schasinglulu 	if (css_system_pwr_state(target_state) == ARM_LOCAL_STATE_OFF) {
168*91f16700Schasinglulu 		arm_system_pwr_domain_save();
169*91f16700Schasinglulu 
170*91f16700Schasinglulu 		/* Power off the Redistributor after having saved its context */
171*91f16700Schasinglulu 		plat_arm_gic_redistif_off();
172*91f16700Schasinglulu 	}
173*91f16700Schasinglulu 
174*91f16700Schasinglulu 	css_scp_suspend(target_state);
175*91f16700Schasinglulu }
176*91f16700Schasinglulu 
177*91f16700Schasinglulu /*******************************************************************************
178*91f16700Schasinglulu  * Handler called when a power domain has just been powered on after
179*91f16700Schasinglulu  * having been suspended earlier. The target_state encodes the low power state
180*91f16700Schasinglulu  * that each level has woken up from.
181*91f16700Schasinglulu  * TODO: At the moment we reuse the on finisher and reinitialize the secure
182*91f16700Schasinglulu  * context. Need to implement a separate suspend finisher.
183*91f16700Schasinglulu  ******************************************************************************/
184*91f16700Schasinglulu void css_pwr_domain_suspend_finish(
185*91f16700Schasinglulu 				const psci_power_state_t *target_state)
186*91f16700Schasinglulu {
187*91f16700Schasinglulu 	/* Return as nothing is to be done on waking up from retention. */
188*91f16700Schasinglulu 	if (CSS_CORE_PWR_STATE(target_state) == ARM_LOCAL_STATE_RET)
189*91f16700Schasinglulu 		return;
190*91f16700Schasinglulu 
191*91f16700Schasinglulu 	/* Perform system domain restore if woken up from system suspend */
192*91f16700Schasinglulu 	if (css_system_pwr_state(target_state) == ARM_LOCAL_STATE_OFF)
193*91f16700Schasinglulu 		/*
194*91f16700Schasinglulu 		 * At this point, the Distributor must be powered on to be ready
195*91f16700Schasinglulu 		 * to have its state restored. The Redistributor will be powered
196*91f16700Schasinglulu 		 * on as part of gicv3_rdistif_init_restore.
197*91f16700Schasinglulu 		 */
198*91f16700Schasinglulu 		arm_system_pwr_domain_resume();
199*91f16700Schasinglulu 
200*91f16700Schasinglulu 	css_pwr_domain_on_finisher_common(target_state);
201*91f16700Schasinglulu 
202*91f16700Schasinglulu 	/* Enable the gic cpu interface */
203*91f16700Schasinglulu 	plat_arm_gic_cpuif_enable();
204*91f16700Schasinglulu }
205*91f16700Schasinglulu 
206*91f16700Schasinglulu /*******************************************************************************
207*91f16700Schasinglulu  * Handlers to shutdown/reboot the system
208*91f16700Schasinglulu  ******************************************************************************/
209*91f16700Schasinglulu void __dead2 css_system_off(void)
210*91f16700Schasinglulu {
211*91f16700Schasinglulu 	css_scp_sys_shutdown();
212*91f16700Schasinglulu }
213*91f16700Schasinglulu 
214*91f16700Schasinglulu void __dead2 css_system_reset(void)
215*91f16700Schasinglulu {
216*91f16700Schasinglulu 	css_scp_sys_reboot();
217*91f16700Schasinglulu }
218*91f16700Schasinglulu 
219*91f16700Schasinglulu /*******************************************************************************
220*91f16700Schasinglulu  * Handler called when the CPU power domain is about to enter standby.
221*91f16700Schasinglulu  ******************************************************************************/
222*91f16700Schasinglulu void css_cpu_standby(plat_local_state_t cpu_state)
223*91f16700Schasinglulu {
224*91f16700Schasinglulu 	unsigned int scr;
225*91f16700Schasinglulu 
226*91f16700Schasinglulu 	assert(cpu_state == ARM_LOCAL_STATE_RET);
227*91f16700Schasinglulu 
228*91f16700Schasinglulu 	scr = read_scr_el3();
229*91f16700Schasinglulu 	/*
230*91f16700Schasinglulu 	 * Enable the Non secure interrupt to wake the CPU.
231*91f16700Schasinglulu 	 * In GICv3 affinity routing mode, the non secure group1 interrupts use
232*91f16700Schasinglulu 	 * the PhysicalFIQ at EL3 whereas in GICv2, it uses the PhysicalIRQ.
233*91f16700Schasinglulu 	 * Enabling both the bits works for both GICv2 mode and GICv3 affinity
234*91f16700Schasinglulu 	 * routing mode.
235*91f16700Schasinglulu 	 */
236*91f16700Schasinglulu 	write_scr_el3(scr | SCR_IRQ_BIT | SCR_FIQ_BIT);
237*91f16700Schasinglulu 	isb();
238*91f16700Schasinglulu 	dsb();
239*91f16700Schasinglulu 	wfi();
240*91f16700Schasinglulu 
241*91f16700Schasinglulu 	/*
242*91f16700Schasinglulu 	 * Restore SCR to the original value, synchronisation of scr_el3 is
243*91f16700Schasinglulu 	 * done by eret while el3_exit to save some execution cycles.
244*91f16700Schasinglulu 	 */
245*91f16700Schasinglulu 	write_scr_el3(scr);
246*91f16700Schasinglulu }
247*91f16700Schasinglulu 
248*91f16700Schasinglulu /*******************************************************************************
249*91f16700Schasinglulu  * Handler called to return the 'req_state' for system suspend.
250*91f16700Schasinglulu  ******************************************************************************/
251*91f16700Schasinglulu void css_get_sys_suspend_power_state(psci_power_state_t *req_state)
252*91f16700Schasinglulu {
253*91f16700Schasinglulu 	unsigned int i;
254*91f16700Schasinglulu 
255*91f16700Schasinglulu 	/*
256*91f16700Schasinglulu 	 * System Suspend is supported only if the system power domain node
257*91f16700Schasinglulu 	 * is implemented.
258*91f16700Schasinglulu 	 */
259*91f16700Schasinglulu 	assert(PLAT_MAX_PWR_LVL == CSS_SYSTEM_PWR_DMN_LVL);
260*91f16700Schasinglulu 
261*91f16700Schasinglulu 	for (i = ARM_PWR_LVL0; i <= PLAT_MAX_PWR_LVL; i++)
262*91f16700Schasinglulu 		req_state->pwr_domain_state[i] = ARM_LOCAL_STATE_OFF;
263*91f16700Schasinglulu }
264*91f16700Schasinglulu 
265*91f16700Schasinglulu /*******************************************************************************
266*91f16700Schasinglulu  * Handler to query CPU/cluster power states from SCP
267*91f16700Schasinglulu  ******************************************************************************/
268*91f16700Schasinglulu int css_node_hw_state(u_register_t mpidr, unsigned int power_level)
269*91f16700Schasinglulu {
270*91f16700Schasinglulu 	return css_scp_get_power_state(mpidr, power_level);
271*91f16700Schasinglulu }
272*91f16700Schasinglulu 
273*91f16700Schasinglulu /*
274*91f16700Schasinglulu  * The system power domain suspend is only supported only via
275*91f16700Schasinglulu  * PSCI SYSTEM_SUSPEND API. PSCI CPU_SUSPEND request to system power domain
276*91f16700Schasinglulu  * will be downgraded to the lower level.
277*91f16700Schasinglulu  */
278*91f16700Schasinglulu static int css_validate_power_state(unsigned int power_state,
279*91f16700Schasinglulu 			    psci_power_state_t *req_state)
280*91f16700Schasinglulu {
281*91f16700Schasinglulu 	int rc;
282*91f16700Schasinglulu 	rc = arm_validate_power_state(power_state, req_state);
283*91f16700Schasinglulu 
284*91f16700Schasinglulu 	/*
285*91f16700Schasinglulu 	 * Ensure that we don't overrun the pwr_domain_state array in the case
286*91f16700Schasinglulu 	 * where the platform supported max power level is less than the system
287*91f16700Schasinglulu 	 * power level
288*91f16700Schasinglulu 	 */
289*91f16700Schasinglulu 
290*91f16700Schasinglulu #if (PLAT_MAX_PWR_LVL == CSS_SYSTEM_PWR_DMN_LVL)
291*91f16700Schasinglulu 
292*91f16700Schasinglulu 	/*
293*91f16700Schasinglulu 	 * Ensure that the system power domain level is never suspended
294*91f16700Schasinglulu 	 * via PSCI CPU SUSPEND API. Currently system suspend is only
295*91f16700Schasinglulu 	 * supported via PSCI SYSTEM SUSPEND API.
296*91f16700Schasinglulu 	 */
297*91f16700Schasinglulu 
298*91f16700Schasinglulu 	req_state->pwr_domain_state[CSS_SYSTEM_PWR_DMN_LVL] =
299*91f16700Schasinglulu 							ARM_LOCAL_STATE_RUN;
300*91f16700Schasinglulu #endif
301*91f16700Schasinglulu 
302*91f16700Schasinglulu 	return rc;
303*91f16700Schasinglulu }
304*91f16700Schasinglulu 
305*91f16700Schasinglulu /*
306*91f16700Schasinglulu  * Custom `translate_power_state_by_mpidr` handler for CSS. Unlike in the
307*91f16700Schasinglulu  * `css_validate_power_state`, we do not downgrade the system power
308*91f16700Schasinglulu  * domain level request in `power_state` as it will be used to query the
309*91f16700Schasinglulu  * PSCI_STAT_COUNT/RESIDENCY at the system power domain level.
310*91f16700Schasinglulu  */
311*91f16700Schasinglulu static int css_translate_power_state_by_mpidr(u_register_t mpidr,
312*91f16700Schasinglulu 		unsigned int power_state,
313*91f16700Schasinglulu 		psci_power_state_t *output_state)
314*91f16700Schasinglulu {
315*91f16700Schasinglulu 	return arm_validate_power_state(power_state, output_state);
316*91f16700Schasinglulu }
317*91f16700Schasinglulu 
318*91f16700Schasinglulu /*
319*91f16700Schasinglulu  * Setup the SGI interrupt that will be used trigger the execution of power
320*91f16700Schasinglulu  * down sequence for all the secondary cores. This interrupt is setup to be
321*91f16700Schasinglulu  * handled in EL3 context at a priority defined by the platform.
322*91f16700Schasinglulu  */
323*91f16700Schasinglulu void css_setup_cpu_pwr_down_intr(void)
324*91f16700Schasinglulu {
325*91f16700Schasinglulu #if CSS_SYSTEM_GRACEFUL_RESET
326*91f16700Schasinglulu 	plat_ic_set_interrupt_type(CSS_CPU_PWR_DOWN_REQ_INTR, INTR_TYPE_EL3);
327*91f16700Schasinglulu 	plat_ic_set_interrupt_priority(CSS_CPU_PWR_DOWN_REQ_INTR,
328*91f16700Schasinglulu 			PLAT_REBOOT_PRI);
329*91f16700Schasinglulu 	plat_ic_enable_interrupt(CSS_CPU_PWR_DOWN_REQ_INTR);
330*91f16700Schasinglulu #endif
331*91f16700Schasinglulu }
332*91f16700Schasinglulu 
333*91f16700Schasinglulu /*
334*91f16700Schasinglulu  * For a graceful shutdown/reboot, each CPU in the system should do their power
335*91f16700Schasinglulu  * down sequence. On a PSCI shutdown/reboot request, only one CPU gets an
336*91f16700Schasinglulu  * opportunity to do the powerdown sequence. To achieve graceful reset, of all
337*91f16700Schasinglulu  * cores in the system, the CPU gets the opportunity raise warm reboot SGI to
338*91f16700Schasinglulu  * rest of the CPUs which are online. Add handler for the reboot SGI where the
339*91f16700Schasinglulu  * rest of the CPU execute the powerdown sequence.
340*91f16700Schasinglulu  */
341*91f16700Schasinglulu int css_reboot_interrupt_handler(uint32_t intr_raw, uint32_t flags,
342*91f16700Schasinglulu 		void *handle, void *cookie)
343*91f16700Schasinglulu {
344*91f16700Schasinglulu 	assert(intr_raw == CSS_CPU_PWR_DOWN_REQ_INTR);
345*91f16700Schasinglulu 
346*91f16700Schasinglulu 	/* Deactivate warm reboot SGI */
347*91f16700Schasinglulu 	plat_ic_end_of_interrupt(CSS_CPU_PWR_DOWN_REQ_INTR);
348*91f16700Schasinglulu 
349*91f16700Schasinglulu 	/*
350*91f16700Schasinglulu 	 * Disable GIC CPU interface to prevent pending interrupt from waking
351*91f16700Schasinglulu 	 * up the AP from WFI.
352*91f16700Schasinglulu 	 */
353*91f16700Schasinglulu 	plat_arm_gic_cpuif_disable();
354*91f16700Schasinglulu 	plat_arm_gic_redistif_off();
355*91f16700Schasinglulu 
356*91f16700Schasinglulu 	psci_pwrdown_cpu(PLAT_MAX_PWR_LVL);
357*91f16700Schasinglulu 
358*91f16700Schasinglulu 	dmbsy();
359*91f16700Schasinglulu 
360*91f16700Schasinglulu 	wfi();
361*91f16700Schasinglulu 	return 0;
362*91f16700Schasinglulu }
363*91f16700Schasinglulu 
364*91f16700Schasinglulu /*******************************************************************************
365*91f16700Schasinglulu  * Export the platform handlers via plat_arm_psci_pm_ops. The ARM Standard
366*91f16700Schasinglulu  * platform will take care of registering the handlers with PSCI.
367*91f16700Schasinglulu  ******************************************************************************/
368*91f16700Schasinglulu plat_psci_ops_t plat_arm_psci_pm_ops = {
369*91f16700Schasinglulu 	.pwr_domain_on		= css_pwr_domain_on,
370*91f16700Schasinglulu 	.pwr_domain_on_finish	= css_pwr_domain_on_finish,
371*91f16700Schasinglulu 	.pwr_domain_on_finish_late = css_pwr_domain_on_finish_late,
372*91f16700Schasinglulu 	.pwr_domain_off		= css_pwr_domain_off,
373*91f16700Schasinglulu 	.cpu_standby		= css_cpu_standby,
374*91f16700Schasinglulu 	.pwr_domain_suspend	= css_pwr_domain_suspend,
375*91f16700Schasinglulu 	.pwr_domain_suspend_finish	= css_pwr_domain_suspend_finish,
376*91f16700Schasinglulu 	.system_off		= css_system_off,
377*91f16700Schasinglulu 	.system_reset		= css_system_reset,
378*91f16700Schasinglulu 	.validate_power_state	= css_validate_power_state,
379*91f16700Schasinglulu 	.validate_ns_entrypoint = arm_validate_psci_entrypoint,
380*91f16700Schasinglulu 	.translate_power_state_by_mpidr = css_translate_power_state_by_mpidr,
381*91f16700Schasinglulu 	.get_node_hw_state	= css_node_hw_state,
382*91f16700Schasinglulu 	.get_sys_suspend_power_state = css_get_sys_suspend_power_state,
383*91f16700Schasinglulu 
384*91f16700Schasinglulu #if defined(PLAT_ARM_MEM_PROT_ADDR)
385*91f16700Schasinglulu 	.mem_protect_chk	= arm_psci_mem_protect_chk,
386*91f16700Schasinglulu 	.read_mem_protect	= arm_psci_read_mem_protect,
387*91f16700Schasinglulu 	.write_mem_protect	= arm_nor_psci_write_mem_protect,
388*91f16700Schasinglulu #endif
389*91f16700Schasinglulu #if CSS_USE_SCMI_SDS_DRIVER
390*91f16700Schasinglulu 	.system_reset2		= css_system_reset2,
391*91f16700Schasinglulu #endif
392*91f16700Schasinglulu };
393