blob: 6505adf36cc9186f5129440b695482b5df01abba [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
2 * Copyright (c) 2013, ARM Limited. All rights reserved.
3 *
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
87typedef unsigned int (*afflvl_power_on_finisher)(unsigned long,
88 aff_map_node *,
89 unsigned int);
90
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 *);
111extern unsigned int psci_get_ns_entry_info(unsigned int index);
112extern unsigned long mpidr_set_aff_inst(unsigned long,unsigned char, int);
113extern int psci_change_state(unsigned long, int, int, unsigned int);
114extern int psci_validate_mpidr(unsigned long, int);
115extern unsigned int psci_afflvl_power_on_finish(unsigned long,
116 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 **);
125/* Private exported functions from psci_setup.c */
126extern aff_map_node *psci_get_aff_map_node(unsigned long, int);
127
128/* Private exported functions from psci_affinity_on.c */
129extern int psci_afflvl_on(unsigned long,
130 unsigned long,
131 unsigned long,
132 int,
133 int);
134
135/* Private exported functions from psci_affinity_off.c */
136extern int psci_afflvl_off(unsigned long, int, int);
137
138/* Private exported functions from psci_affinity_suspend.c */
139extern int psci_afflvl_suspend(unsigned long,
140 unsigned long,
141 unsigned long,
142 unsigned int,
143 int,
144 int);
145extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int);
146#endif /*__ASSEMBLY__*/
147
148#endif /* __PSCI_PRIVATE_H__ */