blob: 7545167665a333b8be52752f4e8ff8bb1b3b43f4 [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
34#include <bakery_lock.h>
35
36#ifndef __ASSEMBLY__
37/*******************************************************************************
38 * The following two data structures hold the generic information to bringup
39 * a suspended/hotplugged out cpu
40 ******************************************************************************/
41typedef struct {
42 unsigned long entrypoint;
43 unsigned long spsr;
44} eret_params;
45
46typedef struct {
47 eret_params eret_info;
48 unsigned long context_id;
49 unsigned int scr;
50 unsigned int sctlr;
51} ns_entry_info;
52
53/*******************************************************************************
54 *
55 *
56 ******************************************************************************/
57typedef struct {
58 unsigned long sctlr;
59 unsigned long scr;
60 unsigned long cptr;
61 unsigned long cpacr;
62 unsigned long cntfrq;
63 unsigned long mair;
64 unsigned long tcr;
65 unsigned long ttbr;
66 unsigned long vbar;
Sandrine Bailleux37382742013-11-18 17:26:59 +000067 unsigned long pstate;
Achin Gupta4f6ad662013-10-25 09:08:21 +010068} secure_context;
69
70/*******************************************************************************
71 * The following two data structures hold the topology tree which in turn tracks
72 * the state of the all the affinity instances supported by the platform.
73 ******************************************************************************/
74typedef struct {
75 unsigned long mpidr;
76 unsigned char state;
77 char level;
78 unsigned int data;
79 bakery_lock lock;
80} aff_map_node;
81
82typedef struct {
83 int min;
84 int max;
85} aff_limits_node;
86
Achin Gupta0959db52013-12-02 17:33:04 +000087typedef aff_map_node *mpidr_aff_map_nodes[MPIDR_MAX_AFFLVL];
Achin Gupta4f6ad662013-10-25 09:08:21 +010088typedef unsigned int (*afflvl_power_on_finisher)(unsigned long,
Achin Gupta0959db52013-12-02 17:33:04 +000089 aff_map_node *);
Achin Gupta4f6ad662013-10-25 09:08:21 +010090
91/*******************************************************************************
92 * Data prototypes
93 ******************************************************************************/
94extern secure_context psci_secure_context[PSCI_NUM_AFFS];
95extern ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS];
96extern unsigned int psci_ns_einfo_idx;
97extern aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
98extern plat_pm_ops *psci_plat_pm_ops;
99extern aff_map_node psci_aff_map[PSCI_NUM_AFFS];
100extern afflvl_power_on_finisher psci_afflvl_off_finish_handlers[];
101extern afflvl_power_on_finisher psci_afflvl_sus_finish_handlers[];
102
103/*******************************************************************************
104 * Function prototypes
105 ******************************************************************************/
106/* Private exported functions from psci_common.c */
107extern int get_max_afflvl(void);
108extern unsigned int psci_get_phys_state(unsigned int);
109extern unsigned int psci_get_aff_phys_state(aff_map_node *);
110extern unsigned int psci_calculate_affinity_state(aff_map_node *);
Achin Guptac8afc782013-11-25 18:45:02 +0000111extern void psci_get_ns_entry_info(unsigned int index);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100112extern unsigned long mpidr_set_aff_inst(unsigned long,unsigned char, int);
Achin Gupta0959db52013-12-02 17:33:04 +0000113extern int psci_change_state(mpidr_aff_map_nodes, int, int, unsigned int);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100114extern int psci_validate_mpidr(unsigned long, int);
Achin Gupta0959db52013-12-02 17:33:04 +0000115extern void psci_afflvl_power_on_finish(unsigned long,
Achin Gupta4f6ad662013-10-25 09:08:21 +0100116 int,
117 int,
118 afflvl_power_on_finisher *);
119extern int psci_set_ns_entry_info(unsigned int index,
120 unsigned long entrypoint,
121 unsigned long context_id);
122extern int psci_get_first_present_afflvl(unsigned long,
123 int, int,
124 aff_map_node **);
Achin Gupta0959db52013-12-02 17:33:04 +0000125extern int psci_check_afflvl_range(int start_afflvl, int end_afflvl);
126extern void psci_acquire_afflvl_locks(unsigned long mpidr,
127 int start_afflvl,
128 int end_afflvl,
129 mpidr_aff_map_nodes mpidr_nodes);
130extern void psci_release_afflvl_locks(unsigned long mpidr,
131 int start_afflvl,
132 int end_afflvl,
133 mpidr_aff_map_nodes mpidr_nodes);
134
Achin Gupta4f6ad662013-10-25 09:08:21 +0100135/* Private exported functions from psci_setup.c */
Achin Gupta0959db52013-12-02 17:33:04 +0000136extern int psci_get_aff_map_nodes(unsigned long mpidr,
137 int start_afflvl,
138 int end_afflvl,
139 mpidr_aff_map_nodes mpidr_nodes);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100140extern aff_map_node *psci_get_aff_map_node(unsigned long, int);
141
142/* Private exported functions from psci_affinity_on.c */
143extern int psci_afflvl_on(unsigned long,
144 unsigned long,
145 unsigned long,
146 int,
147 int);
148
149/* Private exported functions from psci_affinity_off.c */
150extern int psci_afflvl_off(unsigned long, int, int);
151
152/* Private exported functions from psci_affinity_suspend.c */
153extern int psci_afflvl_suspend(unsigned long,
154 unsigned long,
155 unsigned long,
156 unsigned int,
157 int,
158 int);
159extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int);
160#endif /*__ASSEMBLY__*/
161
162#endif /* __PSCI_PRIVATE_H__ */