blob: 970ad21e411a3a6d32e6bbbed8f806b3d0de696a [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>
Dan Handley97043ac2014-04-09 13:14:54 +010036#include <psci.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010037
Achin Gupta4f6ad662013-10-25 09:08:21 +010038/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +010039 * The following two data structures hold the topology tree which in turn tracks
40 * the state of the all the affinity instances supported by the platform.
41 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +010042typedef struct aff_map_node {
Achin Gupta4f6ad662013-10-25 09:08:21 +010043 unsigned long mpidr;
Achin Gupta75f73672013-12-05 16:33:10 +000044 unsigned short ref_count;
Achin Gupta4f6ad662013-10-25 09:08:21 +010045 unsigned char state;
Achin Gupta75f73672013-12-05 16:33:10 +000046 unsigned char level;
Achin Gupta4f6ad662013-10-25 09:08:21 +010047 unsigned int data;
Dan Handleyfb037bf2014-04-10 15:37:22 +010048 bakery_lock_t lock;
49} aff_map_node_t;
Achin Gupta4f6ad662013-10-25 09:08:21 +010050
Dan Handleyfb037bf2014-04-10 15:37:22 +010051typedef struct aff_limits_node {
Achin Gupta4f6ad662013-10-25 09:08:21 +010052 int min;
53 int max;
Dan Handleyfb037bf2014-04-10 15:37:22 +010054} aff_limits_node_t;
Achin Gupta4f6ad662013-10-25 09:08:21 +010055
Achin Guptaa59caa42013-12-05 14:21:04 +000056/*******************************************************************************
57 * This data structure holds secure world context that needs to be preserved
58 * across cpu_suspend calls which enter the power down state.
59 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +010060typedef struct suspend_context {
Vikram Kanigiri759ec932014-04-01 19:26:26 +010061 unsigned int power_state;
Dan Handleyfb037bf2014-04-10 15:37:22 +010062} __aligned(CACHE_WRITEBACK_GRANULE) suspend_context_t;
Achin Guptaa59caa42013-12-05 14:21:04 +000063
Dan Handleyfb037bf2014-04-10 15:37:22 +010064typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]);
65typedef unsigned int (*afflvl_power_on_finisher_t)(unsigned long,
66 aff_map_node_t *);
Achin Gupta4f6ad662013-10-25 09:08:21 +010067
68/*******************************************************************************
69 * Data prototypes
70 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +010071extern suspend_context_t psci_suspend_context[PSCI_NUM_AFFS];
Dan Handley625de1d2014-04-23 13:47:06 +010072extern const plat_pm_ops_t *psci_plat_pm_ops;
Dan Handleyfb037bf2014-04-10 15:37:22 +010073extern aff_map_node_t psci_aff_map[PSCI_NUM_AFFS];
Achin Gupta4f6ad662013-10-25 09:08:21 +010074
75/*******************************************************************************
Jeenu Viswambharan7f366602014-02-20 17:11:00 +000076 * SPD's power management hooks registered with PSCI
Achin Gupta607084e2014-02-09 18:24:19 +000077 ******************************************************************************/
Dan Handleyfb037bf2014-04-10 15:37:22 +010078extern const spd_pm_ops_t *psci_spd_pm;
Achin Gupta607084e2014-02-09 18:24:19 +000079
80/*******************************************************************************
Achin Gupta4f6ad662013-10-25 09:08:21 +010081 * Function prototypes
82 ******************************************************************************/
83/* Private exported functions from psci_common.c */
Dan Handleyc6bc0712014-05-14 12:38:32 +010084int get_max_afflvl(void);
85unsigned short psci_get_state(aff_map_node_t *node);
86unsigned short psci_get_phys_state(aff_map_node_t *node);
87void psci_set_state(aff_map_node_t *node, unsigned short state);
Dan Handleyc6bc0712014-05-14 12:38:32 +010088unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int);
89int psci_validate_mpidr(unsigned long, int);
90int get_power_on_target_afflvl(unsigned long mpidr);
91void psci_afflvl_power_on_finish(unsigned long,
92 int,
93 int,
94 afflvl_power_on_finisher_t *);
Andrew Thoelke167a9352014-06-04 21:10:52 +010095int psci_save_ns_entry(uint64_t mpidr,
96 uint64_t entrypoint, uint64_t context_id,
97 uint32_t caller_scr_el3, uint32_t caller_sctlr_el1);
Dan Handleyc6bc0712014-05-14 12:38:32 +010098int psci_check_afflvl_range(int start_afflvl, int end_afflvl);
99void psci_acquire_afflvl_locks(unsigned long mpidr,
100 int start_afflvl,
101 int end_afflvl,
102 mpidr_aff_map_nodes_t mpidr_nodes);
103void psci_release_afflvl_locks(unsigned long mpidr,
104 int start_afflvl,
105 int end_afflvl,
106 mpidr_aff_map_nodes_t mpidr_nodes);
Achin Gupta0959db52013-12-02 17:33:04 +0000107
Achin Gupta4f6ad662013-10-25 09:08:21 +0100108/* Private exported functions from psci_setup.c */
Dan Handleyc6bc0712014-05-14 12:38:32 +0100109int psci_get_aff_map_nodes(unsigned long mpidr,
110 int start_afflvl,
111 int end_afflvl,
112 mpidr_aff_map_nodes_t mpidr_nodes);
113aff_map_node_t *psci_get_aff_map_node(unsigned long, int);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100114
115/* Private exported functions from psci_affinity_on.c */
Dan Handleyc6bc0712014-05-14 12:38:32 +0100116int psci_afflvl_on(unsigned long,
117 unsigned long,
118 unsigned long,
119 int,
120 int);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100121
122/* Private exported functions from psci_affinity_off.c */
Dan Handleyc6bc0712014-05-14 12:38:32 +0100123int psci_afflvl_off(unsigned long, int, int);
Achin Gupta4f6ad662013-10-25 09:08:21 +0100124
125/* Private exported functions from psci_affinity_suspend.c */
Dan Handleyc6bc0712014-05-14 12:38:32 +0100126void psci_set_suspend_power_state(aff_map_node_t *node,
127 unsigned int power_state);
128int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node);
129int psci_afflvl_suspend(unsigned long,
130 unsigned long,
131 unsigned long,
132 unsigned int,
133 int,
134 int);
135unsigned int psci_afflvl_suspend_finish(unsigned long, int, int);
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000136
Achin Gupta4f6ad662013-10-25 09:08:21 +0100137
138#endif /* __PSCI_PRIVATE_H__ */