blob: 72d46122f21f11579c6f21c3daee395812765632 [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
31#ifndef __PSCI_PRIVATE_H__
32#define __PSCI_PRIVATE_H__
33
Achin Guptaa59caa42013-12-05 14:21:04 +000034#include <arch.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010035#include <bakery_lock.h>
36
37#ifndef __ASSEMBLY__
38/*******************************************************************************
39 * The following two data structures hold the generic information to bringup
40 * a suspended/hotplugged out cpu
41 ******************************************************************************/
42typedef struct {
43 unsigned long entrypoint;
44 unsigned long spsr;
45} eret_params;
46
47typedef struct {
48 eret_params eret_info;
49 unsigned long context_id;
50 unsigned int scr;
51 unsigned int sctlr;
52} ns_entry_info;
53
54/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +010055 * The following two data structures hold the topology tree which in turn tracks
56 * the state of the all the affinity instances supported by the platform.
57 ******************************************************************************/
58typedef struct {
59 unsigned long mpidr;
Achin Gupta75f73672013-12-05 16:33:10 +000060 unsigned short ref_count;
Achin Gupta4f6ad662013-10-25 09:08:21 +010061 unsigned char state;
Achin Gupta75f73672013-12-05 16:33:10 +000062 unsigned char level;
Achin Gupta4f6ad662013-10-25 09:08:21 +010063 unsigned int data;
64 bakery_lock lock;
65} aff_map_node;
66
67typedef struct {
68 int min;
69 int max;
70} aff_limits_node;
71
Achin Guptaa59caa42013-12-05 14:21:04 +000072/*******************************************************************************
73 * This data structure holds secure world context that needs to be preserved
74 * across cpu_suspend calls which enter the power down state.
75 ******************************************************************************/
76typedef struct {
Vikram Kanigirif100f412014-04-01 19:26:26 +010077 unsigned int power_state;
78} __aligned(CACHE_WRITEBACK_GRANULE) suspend_context;
Achin Guptaa59caa42013-12-05 14:21:04 +000079
Achin Guptaef7a28c2014-02-01 08:59:56 +000080typedef aff_map_node (*mpidr_aff_map_nodes[MPIDR_MAX_AFFLVL]);
Achin Gupta4f6ad662013-10-25 09:08:21 +010081typedef unsigned int (*afflvl_power_on_finisher)(unsigned long,
Achin Gupta0959db52013-12-02 17:33:04 +000082 aff_map_node *);
Achin Gupta4f6ad662013-10-25 09:08:21 +010083
84/*******************************************************************************
85 * Data prototypes
86 ******************************************************************************/
Achin Guptaa59caa42013-12-05 14:21:04 +000087extern suspend_context psci_suspend_context[PSCI_NUM_AFFS];
Achin Gupta4f6ad662013-10-25 09:08:21 +010088extern ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS];
89extern unsigned int psci_ns_einfo_idx;
90extern aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
91extern plat_pm_ops *psci_plat_pm_ops;
92extern aff_map_node psci_aff_map[PSCI_NUM_AFFS];
93extern afflvl_power_on_finisher psci_afflvl_off_finish_handlers[];
94extern afflvl_power_on_finisher psci_afflvl_sus_finish_handlers[];
95
96/*******************************************************************************
Jeenu Viswambharan7f366602014-02-20 17:11:00 +000097 * SPD's power management hooks registered with PSCI
Achin Gupta607084e2014-02-09 18:24:19 +000098 ******************************************************************************/
Jeenu Viswambharan7f366602014-02-20 17:11:00 +000099extern const spd_pm_ops *psci_spd_pm;
Achin Gupta607084e2014-02-09 18:24:19 +0000100
101/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +0100102 * Function prototypes
103 ******************************************************************************/
104/* Private exported functions from psci_common.c */
105extern int get_max_afflvl(void);
Achin Gupta75f73672013-12-05 16:33:10 +0000106extern unsigned short psci_get_state(aff_map_node *node);
107extern unsigned short psci_get_phys_state(aff_map_node *node);
108extern void psci_set_state(aff_map_node *node, unsigned short state);
Achin Guptac8afc782013-11-25 18:45:02 +0000109extern void psci_get_ns_entry_info(unsigned int index);
Achin Guptaef7a28c2014-02-01 08:59:56 +0000110extern unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100111extern int psci_validate_mpidr(unsigned long, int);
Achin Guptaa45e3972013-12-05 15:10:48 +0000112extern int get_power_on_target_afflvl(unsigned long mpidr);
Achin Gupta0959db52013-12-02 17:33:04 +0000113extern void psci_afflvl_power_on_finish(unsigned long,
Achin Gupta4f6ad662013-10-25 09:08:21 +0100114 int,
115 int,
116 afflvl_power_on_finisher *);
117extern int psci_set_ns_entry_info(unsigned int index,
118 unsigned long entrypoint,
119 unsigned long context_id);
Achin Gupta0959db52013-12-02 17:33:04 +0000120extern int psci_check_afflvl_range(int start_afflvl, int end_afflvl);
121extern void psci_acquire_afflvl_locks(unsigned long mpidr,
122 int start_afflvl,
123 int end_afflvl,
124 mpidr_aff_map_nodes mpidr_nodes);
125extern void psci_release_afflvl_locks(unsigned long mpidr,
126 int start_afflvl,
127 int end_afflvl,
128 mpidr_aff_map_nodes mpidr_nodes);
129
Achin Gupta4f6ad662013-10-25 09:08:21 +0100130/* Private exported functions from psci_setup.c */
Achin Gupta0959db52013-12-02 17:33:04 +0000131extern int psci_get_aff_map_nodes(unsigned long mpidr,
132 int start_afflvl,
133 int end_afflvl,
134 mpidr_aff_map_nodes mpidr_nodes);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100135extern aff_map_node *psci_get_aff_map_node(unsigned long, int);
136
137/* Private exported functions from psci_affinity_on.c */
138extern int psci_afflvl_on(unsigned long,
139 unsigned long,
140 unsigned long,
141 int,
142 int);
143
144/* Private exported functions from psci_affinity_off.c */
145extern int psci_afflvl_off(unsigned long, int, int);
146
147/* Private exported functions from psci_affinity_suspend.c */
Vikram Kanigirif100f412014-04-01 19:26:26 +0100148extern void psci_set_suspend_power_state(aff_map_node *node,
149 unsigned int power_state);
150extern int psci_get_aff_map_node_suspend_afflvl(aff_map_node *node);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100151extern int psci_afflvl_suspend(unsigned long,
152 unsigned long,
153 unsigned long,
154 unsigned int,
155 int,
156 int);
157extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int);
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000158
Achin Gupta4f6ad662013-10-25 09:08:21 +0100159#endif /*__ASSEMBLY__*/
160
161#endif /* __PSCI_PRIVATE_H__ */