blob: d69c5f5183d15f5539c8610b72709ed1f7dcc2c6 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
Dan Handley97043ac2014-04-09 13:14:54 +010031#include <arch.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010032#include <arch_helpers.h>
Dan Handley97043ac2014-04-09 13:14:54 +010033#include <assert.h>
34#include <bl_common.h>
35#include <context.h>
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000036#include <context_mgmt.h>
Dan Handley35e98e52014-04-09 13:13:04 +010037#include <debug.h>
Dan Handley5f0cdb02014-05-14 17:44:19 +010038#include <platform.h>
Andrew Thoelke167a9352014-06-04 21:10:52 +010039#include <string.h>
Dan Handley35e98e52014-04-09 13:13:04 +010040#include "psci_private.h"
Achin Gupta4f6ad662013-10-25 09:08:21 +010041
Achin Gupta607084e2014-02-09 18:24:19 +000042/*
Jeenu Viswambharan7f366602014-02-20 17:11:00 +000043 * SPD power management operations, expected to be supplied by the registered
44 * SPD on successful SP initialization
Achin Gupta607084e2014-02-09 18:24:19 +000045 */
Dan Handleyfb037bf2014-04-10 15:37:22 +010046const spd_pm_ops_t *psci_spd_pm;
Achin Gupta607084e2014-02-09 18:24:19 +000047
Achin Gupta4f6ad662013-10-25 09:08:21 +010048/*******************************************************************************
49 * Arrays that contains information needs to resume a cpu's execution when woken
Dan Handley7a9a5f22014-05-14 15:13:16 +010050 * out of suspend or off states. Each cpu is allocated a single entry in each
51 * array during startup.
Achin Gupta4f6ad662013-10-25 09:08:21 +010052 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +010053suspend_context_t psci_suspend_context[PSCI_NUM_AFFS];
Achin Gupta4f6ad662013-10-25 09:08:21 +010054
55/*******************************************************************************
56 * Grand array that holds the platform's topology information for state
57 * management of affinity instances. Each node (aff_map_node) in the array
58 * corresponds to an affinity instance e.g. cluster, cpu within an mpidr
59 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +010060aff_map_node_t psci_aff_map[PSCI_NUM_AFFS]
Achin Gupta4f6ad662013-10-25 09:08:21 +010061__attribute__ ((section("tzfw_coherent_mem")));
62
63/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +010064 * Pointer to functions exported by the platform to complete power mgmt. ops
65 ******************************************************************************/
Dan Handley625de1d2014-04-23 13:47:06 +010066const plat_pm_ops_t *psci_plat_pm_ops;
Achin Gupta4f6ad662013-10-25 09:08:21 +010067
68/*******************************************************************************
Achin Guptaa45e3972013-12-05 15:10:48 +000069 * Routine to return the maximum affinity level to traverse to after a cpu has
70 * been physically powered up. It is expected to be called immediately after
71 * reset from assembler code. It has to find its 'aff_map_node' instead of
72 * getting it as an argument.
73 * TODO: Calling psci_get_aff_map_node() with the MMU disabled is slow. Add
74 * support to allow faster access to the target affinity level.
75 ******************************************************************************/
76int get_power_on_target_afflvl(unsigned long mpidr)
77{
Dan Handleyfb037bf2014-04-10 15:37:22 +010078 aff_map_node_t *node;
Achin Guptaa45e3972013-12-05 15:10:48 +000079 unsigned int state;
Vikram Kanigiri759ec932014-04-01 19:26:26 +010080 int afflvl;
Achin Guptaa45e3972013-12-05 15:10:48 +000081
82 /* Retrieve our node from the topology tree */
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000083 node = psci_get_aff_map_node(mpidr & MPIDR_AFFINITY_MASK,
84 MPIDR_AFFLVL0);
Achin Guptaa45e3972013-12-05 15:10:48 +000085 assert(node);
86
87 /*
88 * Return the maximum supported affinity level if this cpu was off.
89 * Call the handler in the suspend code if this cpu had been suspended.
90 * Any other state is invalid.
91 */
Achin Gupta75f73672013-12-05 16:33:10 +000092 state = psci_get_state(node);
Achin Guptaa45e3972013-12-05 15:10:48 +000093 if (state == PSCI_STATE_ON_PENDING)
94 return get_max_afflvl();
95
Vikram Kanigiri759ec932014-04-01 19:26:26 +010096 if (state == PSCI_STATE_SUSPEND) {
97 afflvl = psci_get_aff_map_node_suspend_afflvl(node);
98 assert(afflvl != PSCI_INVALID_DATA);
99 return afflvl;
100 }
Achin Guptaa45e3972013-12-05 15:10:48 +0000101 return PSCI_E_INVALID_PARAMS;
102}
103
104/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +0100105 * Simple routine to retrieve the maximum affinity level supported by the
106 * platform and check that it makes sense.
107 ******************************************************************************/
108int get_max_afflvl()
109{
110 int aff_lvl;
111
112 aff_lvl = plat_get_max_afflvl();
113 assert(aff_lvl <= MPIDR_MAX_AFFLVL && aff_lvl >= MPIDR_AFFLVL0);
114
115 return aff_lvl;
116}
117
118/*******************************************************************************
119 * Simple routine to set the id of an affinity instance at a given level in the
120 * mpidr.
121 ******************************************************************************/
122unsigned long mpidr_set_aff_inst(unsigned long mpidr,
123 unsigned char aff_inst,
124 int aff_lvl)
125{
126 unsigned long aff_shift;
127
128 assert(aff_lvl <= MPIDR_AFFLVL3);
129
130 /*
131 * Decide the number of bits to shift by depending upon
132 * the affinity level
133 */
134 aff_shift = get_afflvl_shift(aff_lvl);
135
136 /* Clear the existing affinity instance & set the new one*/
137 mpidr &= ~(MPIDR_AFFLVL_MASK << aff_shift);
138 mpidr |= aff_inst << aff_shift;
139
140 return mpidr;
141}
142
143/*******************************************************************************
Achin Gupta0959db52013-12-02 17:33:04 +0000144 * This function sanity checks a range of affinity levels.
145 ******************************************************************************/
146int psci_check_afflvl_range(int start_afflvl, int end_afflvl)
147{
148 /* Sanity check the parameters passed */
149 if (end_afflvl > MPIDR_MAX_AFFLVL)
150 return PSCI_E_INVALID_PARAMS;
151
152 if (start_afflvl < MPIDR_AFFLVL0)
153 return PSCI_E_INVALID_PARAMS;
154
155 if (end_afflvl < start_afflvl)
156 return PSCI_E_INVALID_PARAMS;
157
158 return PSCI_E_SUCCESS;
159}
160
161/*******************************************************************************
162 * This function is passed an array of pointers to affinity level nodes in the
163 * topology tree for an mpidr. It picks up locks for each affinity level bottom
164 * up in the range specified.
165 ******************************************************************************/
166void psci_acquire_afflvl_locks(unsigned long mpidr,
167 int start_afflvl,
168 int end_afflvl,
Dan Handleyfb037bf2014-04-10 15:37:22 +0100169 mpidr_aff_map_nodes_t mpidr_nodes)
Achin Gupta0959db52013-12-02 17:33:04 +0000170{
171 int level;
172
173 for (level = start_afflvl; level <= end_afflvl; level++) {
174 if (mpidr_nodes[level] == NULL)
175 continue;
176 bakery_lock_get(mpidr, &mpidr_nodes[level]->lock);
177 }
178}
179
180/*******************************************************************************
181 * This function is passed an array of pointers to affinity level nodes in the
182 * topology tree for an mpidr. It releases the lock for each affinity level top
183 * down in the range specified.
184 ******************************************************************************/
185void psci_release_afflvl_locks(unsigned long mpidr,
186 int start_afflvl,
187 int end_afflvl,
Dan Handleyfb037bf2014-04-10 15:37:22 +0100188 mpidr_aff_map_nodes_t mpidr_nodes)
Achin Gupta0959db52013-12-02 17:33:04 +0000189{
190 int level;
191
192 for (level = end_afflvl; level >= start_afflvl; level--) {
193 if (mpidr_nodes[level] == NULL)
194 continue;
195 bakery_lock_release(mpidr, &mpidr_nodes[level]->lock);
196 }
197}
198
199/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +0100200 * Simple routine to determine whether an affinity instance at a given level
201 * in an mpidr exists or not.
202 ******************************************************************************/
203int psci_validate_mpidr(unsigned long mpidr, int level)
204{
Dan Handleyfb037bf2014-04-10 15:37:22 +0100205 aff_map_node_t *node;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100206
207 node = psci_get_aff_map_node(mpidr, level);
208 if (node && (node->state & PSCI_AFF_PRESENT))
209 return PSCI_E_SUCCESS;
210 else
211 return PSCI_E_INVALID_PARAMS;
212}
213
214/*******************************************************************************
Andrew Thoelke167a9352014-06-04 21:10:52 +0100215 * This function determines the full entrypoint information for the requested
216 * PSCI entrypoint on power on/resume and saves this in the non-secure CPU
217 * cpu_context, ready for when the core boots.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100218 ******************************************************************************/
Andrew Thoelke167a9352014-06-04 21:10:52 +0100219int psci_save_ns_entry(uint64_t mpidr,
220 uint64_t entrypoint, uint64_t context_id,
221 uint32_t ns_scr_el3, uint32_t ns_sctlr_el1)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100222{
Andrew Thoelke167a9352014-06-04 21:10:52 +0100223 uint32_t ep_attr, mode, sctlr, daif, ee;
224 entry_point_info_t ep;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100225
Andrew Thoelke167a9352014-06-04 21:10:52 +0100226 sctlr = ns_scr_el3 & SCR_HCE_BIT ? read_sctlr_el2() : ns_sctlr_el1;
227 ee = 0;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100228
Andrew Thoelke167a9352014-06-04 21:10:52 +0100229 ep_attr = NON_SECURE | EP_ST_DISABLE;
230 if (sctlr & SCTLR_EE_BIT) {
231 ep_attr |= EP_EE_BIG;
232 ee = 1;
233 }
234 SET_PARAM_HEAD(&ep, PARAM_EP, VERSION_1, ep_attr);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100235
Andrew Thoelke167a9352014-06-04 21:10:52 +0100236 ep.pc = entrypoint;
237 memset(&ep.args, 0, sizeof(ep.args));
238 ep.args.arg0 = context_id;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100239
240 /*
241 * Figure out whether the cpu enters the non-secure address space
242 * in aarch32 or aarch64
243 */
Andrew Thoelke167a9352014-06-04 21:10:52 +0100244 if (ns_scr_el3 & SCR_RW_BIT) {
Achin Gupta4f6ad662013-10-25 09:08:21 +0100245
246 /*
247 * Check whether a Thumb entry point has been provided for an
248 * aarch64 EL
249 */
250 if (entrypoint & 0x1)
251 return PSCI_E_INVALID_PARAMS;
252
Andrew Thoelke167a9352014-06-04 21:10:52 +0100253 mode = ns_scr_el3 & SCR_HCE_BIT ? MODE_EL2 : MODE_EL1;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100254
Andrew Thoelke167a9352014-06-04 21:10:52 +0100255 ep.spsr = SPSR_64(mode, MODE_SP_ELX, DISABLE_ALL_EXCEPTIONS);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100256 } else {
257
Andrew Thoelke167a9352014-06-04 21:10:52 +0100258 mode = ns_scr_el3 & SCR_HCE_BIT ? MODE32_hyp : MODE32_svc;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100259
260 /*
261 * TODO: Choose async. exception bits if HYP mode is not
262 * implemented according to the values of SCR.{AW, FW} bits
263 */
Vikram Kanigiri23ff9ba2014-05-13 14:42:08 +0100264 daif = DAIF_ABT_BIT | DAIF_IRQ_BIT | DAIF_FIQ_BIT;
265
Andrew Thoelke167a9352014-06-04 21:10:52 +0100266 ep.spsr = SPSR_MODE32(mode, entrypoint & 0x1, ee, daif);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100267 }
268
Andrew Thoelke167a9352014-06-04 21:10:52 +0100269 /* initialise an entrypoint to set up the CPU context */
270 cm_init_context(mpidr, &ep);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100271
Andrew Thoelke167a9352014-06-04 21:10:52 +0100272 return PSCI_E_SUCCESS;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100273}
274
275/*******************************************************************************
Achin Gupta75f73672013-12-05 16:33:10 +0000276 * This function takes a pointer to an affinity node in the topology tree and
277 * returns its state. State of a non-leaf node needs to be calculated.
278 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +0100279unsigned short psci_get_state(aff_map_node_t *node)
Achin Gupta75f73672013-12-05 16:33:10 +0000280{
281 assert(node->level >= MPIDR_AFFLVL0 && node->level <= MPIDR_MAX_AFFLVL);
282
283 /* A cpu node just contains the state which can be directly returned */
284 if (node->level == MPIDR_AFFLVL0)
285 return (node->state >> PSCI_STATE_SHIFT) & PSCI_STATE_MASK;
286
287 /*
288 * For an affinity level higher than a cpu, the state has to be
289 * calculated. It depends upon the value of the reference count
290 * which is managed by each node at the next lower affinity level
291 * e.g. for a cluster, each cpu increments/decrements the reference
292 * count. If the reference count is 0 then the affinity level is
293 * OFF else ON.
294 */
295 if (node->ref_count)
296 return PSCI_STATE_ON;
297 else
298 return PSCI_STATE_OFF;
299}
300
301/*******************************************************************************
302 * This function takes a pointer to an affinity node in the topology tree and
303 * a target state. State of a non-leaf node needs to be converted to a reference
304 * count. State of a leaf node can be set directly.
305 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +0100306void psci_set_state(aff_map_node_t *node, unsigned short state)
Achin Gupta75f73672013-12-05 16:33:10 +0000307{
308 assert(node->level >= MPIDR_AFFLVL0 && node->level <= MPIDR_MAX_AFFLVL);
309
310 /*
311 * For an affinity level higher than a cpu, the state is used
312 * to decide whether the reference count is incremented or
313 * decremented. Entry into the ON_PENDING state does not have
314 * effect.
315 */
316 if (node->level > MPIDR_AFFLVL0) {
317 switch (state) {
318 case PSCI_STATE_ON:
319 node->ref_count++;
320 break;
321 case PSCI_STATE_OFF:
322 case PSCI_STATE_SUSPEND:
323 node->ref_count--;
324 break;
325 case PSCI_STATE_ON_PENDING:
326 /*
327 * An affinity level higher than a cpu will not undergo
328 * a state change when it is about to be turned on
329 */
330 return;
331 default:
332 assert(0);
333 }
334 } else {
335 node->state &= ~(PSCI_STATE_MASK << PSCI_STATE_SHIFT);
336 node->state |= (state & PSCI_STATE_MASK) << PSCI_STATE_SHIFT;
337 }
338}
339
340/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +0100341 * An affinity level could be on, on_pending, suspended or off. These are the
Achin Gupta3140a9e2013-12-02 16:23:12 +0000342 * logical states it can be in. Physically either it is off or on. When it is in
343 * the state on_pending then it is about to be turned on. It is not possible to
Achin Gupta4f6ad662013-10-25 09:08:21 +0100344 * tell whether that's actually happenned or not. So we err on the side of
345 * caution & treat the affinity level as being turned off.
346 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +0100347unsigned short psci_get_phys_state(aff_map_node_t *node)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100348{
Achin Gupta75f73672013-12-05 16:33:10 +0000349 unsigned int state;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100350
Achin Gupta75f73672013-12-05 16:33:10 +0000351 state = psci_get_state(node);
352 return get_phys_state(state);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100353}
354
355/*******************************************************************************
Achin Gupta0959db52013-12-02 17:33:04 +0000356 * This function takes an array of pointers to affinity instance nodes in the
357 * topology tree and calls the physical power on handler for the corresponding
358 * affinity levels
359 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +0100360static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
Achin Gupta0959db52013-12-02 17:33:04 +0000361 int start_afflvl,
362 int end_afflvl,
Dan Handleyfb037bf2014-04-10 15:37:22 +0100363 afflvl_power_on_finisher_t *pon_handlers,
Achin Gupta0959db52013-12-02 17:33:04 +0000364 unsigned long mpidr)
365{
366 int rc = PSCI_E_INVALID_PARAMS, level;
Dan Handleyfb037bf2014-04-10 15:37:22 +0100367 aff_map_node_t *node;
Achin Gupta0959db52013-12-02 17:33:04 +0000368
369 for (level = end_afflvl; level >= start_afflvl; level--) {
370 node = mpidr_nodes[level];
371 if (node == NULL)
372 continue;
373
374 /*
375 * If we run into any trouble while powering up an
376 * affinity instance, then there is no recovery path
377 * so simply return an error and let the caller take
378 * care of the situation.
379 */
380 rc = pon_handlers[level](mpidr, node);
381 if (rc != PSCI_E_SUCCESS)
382 break;
383 }
384
385 return rc;
386}
387
388/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +0100389 * Generic handler which is called when a cpu is physically powered on. It
Achin Gupta0959db52013-12-02 17:33:04 +0000390 * traverses through all the affinity levels performing generic, architectural,
Achin Gupta4f6ad662013-10-25 09:08:21 +0100391 * platform setup and state management e.g. for a cluster that's been powered
392 * on, it will call the platform specific code which will enable coherency at
393 * the interconnect level. For a cpu it could mean turning on the MMU etc.
394 *
Achin Gupta0959db52013-12-02 17:33:04 +0000395 * The state of all the relevant affinity levels is changed after calling the
396 * affinity level specific handlers as their actions would depend upon the state
397 * the affinity level is exiting from.
398 *
399 * The affinity level specific handlers are called in descending order i.e. from
400 * the highest to the lowest affinity level implemented by the platform because
401 * to turn on affinity level X it is neccesary to turn on affinity level X + 1
402 * first.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100403 *
404 * CAUTION: This function is called with coherent stacks so that coherency and
405 * the mmu can be turned on safely.
406 ******************************************************************************/
Achin Gupta0959db52013-12-02 17:33:04 +0000407void psci_afflvl_power_on_finish(unsigned long mpidr,
408 int start_afflvl,
409 int end_afflvl,
Dan Handleyfb037bf2014-04-10 15:37:22 +0100410 afflvl_power_on_finisher_t *pon_handlers)
Achin Gupta4f6ad662013-10-25 09:08:21 +0100411{
Dan Handleyfb037bf2014-04-10 15:37:22 +0100412 mpidr_aff_map_nodes_t mpidr_nodes;
Achin Gupta0959db52013-12-02 17:33:04 +0000413 int rc;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100414
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000415 mpidr &= MPIDR_AFFINITY_MASK;
Achin Gupta4f6ad662013-10-25 09:08:21 +0100416
417 /*
Achin Gupta0959db52013-12-02 17:33:04 +0000418 * Collect the pointers to the nodes in the topology tree for
419 * each affinity instance in the mpidr. If this function does
420 * not return successfully then either the mpidr or the affinity
421 * levels are incorrect. Either case is an irrecoverable error.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100422 */
Achin Gupta0959db52013-12-02 17:33:04 +0000423 rc = psci_get_aff_map_nodes(mpidr,
424 start_afflvl,
425 end_afflvl,
426 mpidr_nodes);
James Morrissey40a6f642014-02-10 14:24:36 +0000427 if (rc != PSCI_E_SUCCESS)
428 panic();
Achin Gupta4f6ad662013-10-25 09:08:21 +0100429
430 /*
Achin Gupta0959db52013-12-02 17:33:04 +0000431 * This function acquires the lock corresponding to each affinity
432 * level so that by the time all locks are taken, the system topology
433 * is snapshot and state management can be done safely.
Achin Gupta4f6ad662013-10-25 09:08:21 +0100434 */
Achin Gupta0959db52013-12-02 17:33:04 +0000435 psci_acquire_afflvl_locks(mpidr,
436 start_afflvl,
437 end_afflvl,
438 mpidr_nodes);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100439
440 /* Perform generic, architecture and platform specific handling */
Achin Gupta0959db52013-12-02 17:33:04 +0000441 rc = psci_call_power_on_handlers(mpidr_nodes,
442 start_afflvl,
443 end_afflvl,
444 pon_handlers,
445 mpidr);
James Morrissey40a6f642014-02-10 14:24:36 +0000446 if (rc != PSCI_E_SUCCESS)
447 panic();
Achin Gupta4f6ad662013-10-25 09:08:21 +0100448
449 /*
Achin Gupta0959db52013-12-02 17:33:04 +0000450 * This loop releases the lock corresponding to each affinity level
451 * in the reverse order to which they were acquired.
452 */
453 psci_release_afflvl_locks(mpidr,
454 start_afflvl,
455 end_afflvl,
456 mpidr_nodes);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100457}
Jeenu Viswambharan7f366602014-02-20 17:11:00 +0000458
459/*******************************************************************************
460 * This function initializes the set of hooks that PSCI invokes as part of power
461 * management operation. The power management hooks are expected to be provided
462 * by the SPD, after it finishes all its initialization
463 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +0100464void psci_register_spd_pm_hook(const spd_pm_ops_t *pm)
Jeenu Viswambharan7f366602014-02-20 17:11:00 +0000465{
466 psci_spd_pm = pm;
467}