Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Dan Handley | e83b0ca | 2014-01-14 18:17:09 +0000 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 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 | |
Achin Gupta | a59caa4 | 2013-12-05 14:21:04 +0000 | [diff] [blame] | 34 | #include <arch.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 35 | #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 | ******************************************************************************/ |
| 42 | typedef struct { |
| 43 | unsigned long entrypoint; |
| 44 | unsigned long spsr; |
| 45 | } eret_params; |
| 46 | |
| 47 | typedef 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 Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 55 | * 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 | ******************************************************************************/ |
| 58 | typedef struct { |
| 59 | unsigned long mpidr; |
Achin Gupta | 75f7367 | 2013-12-05 16:33:10 +0000 | [diff] [blame] | 60 | unsigned short ref_count; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 61 | unsigned char state; |
Achin Gupta | 75f7367 | 2013-12-05 16:33:10 +0000 | [diff] [blame] | 62 | unsigned char level; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 63 | unsigned int data; |
| 64 | bakery_lock lock; |
| 65 | } aff_map_node; |
| 66 | |
| 67 | typedef struct { |
| 68 | int min; |
| 69 | int max; |
| 70 | } aff_limits_node; |
| 71 | |
Achin Gupta | a59caa4 | 2013-12-05 14:21:04 +0000 | [diff] [blame] | 72 | /******************************************************************************* |
| 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 | ******************************************************************************/ |
| 76 | typedef struct { |
| 77 | /* Align the suspend level to allow per-cpu lockless access */ |
| 78 | int suspend_level |
| 79 | __attribute__((__aligned__(CACHE_WRITEBACK_GRANULE))); |
Achin Gupta | a59caa4 | 2013-12-05 14:21:04 +0000 | [diff] [blame] | 80 | } suspend_context; |
| 81 | |
Achin Gupta | ef7a28c | 2014-02-01 08:59:56 +0000 | [diff] [blame] | 82 | typedef aff_map_node (*mpidr_aff_map_nodes[MPIDR_MAX_AFFLVL]); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 83 | typedef unsigned int (*afflvl_power_on_finisher)(unsigned long, |
Achin Gupta | 0959db5 | 2013-12-02 17:33:04 +0000 | [diff] [blame] | 84 | aff_map_node *); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 85 | |
| 86 | /******************************************************************************* |
| 87 | * Data prototypes |
| 88 | ******************************************************************************/ |
Achin Gupta | a59caa4 | 2013-12-05 14:21:04 +0000 | [diff] [blame] | 89 | extern suspend_context psci_suspend_context[PSCI_NUM_AFFS]; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 90 | extern ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS]; |
| 91 | extern unsigned int psci_ns_einfo_idx; |
| 92 | extern aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1]; |
| 93 | extern plat_pm_ops *psci_plat_pm_ops; |
| 94 | extern aff_map_node psci_aff_map[PSCI_NUM_AFFS]; |
| 95 | extern afflvl_power_on_finisher psci_afflvl_off_finish_handlers[]; |
| 96 | extern afflvl_power_on_finisher psci_afflvl_sus_finish_handlers[]; |
| 97 | |
| 98 | /******************************************************************************* |
| 99 | * Function prototypes |
| 100 | ******************************************************************************/ |
| 101 | /* Private exported functions from psci_common.c */ |
| 102 | extern int get_max_afflvl(void); |
Achin Gupta | 75f7367 | 2013-12-05 16:33:10 +0000 | [diff] [blame] | 103 | extern unsigned short psci_get_state(aff_map_node *node); |
| 104 | extern unsigned short psci_get_phys_state(aff_map_node *node); |
| 105 | extern void psci_set_state(aff_map_node *node, unsigned short state); |
Achin Gupta | c8afc78 | 2013-11-25 18:45:02 +0000 | [diff] [blame] | 106 | extern void psci_get_ns_entry_info(unsigned int index); |
Achin Gupta | ef7a28c | 2014-02-01 08:59:56 +0000 | [diff] [blame] | 107 | extern unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 108 | extern int psci_validate_mpidr(unsigned long, int); |
Achin Gupta | a45e397 | 2013-12-05 15:10:48 +0000 | [diff] [blame] | 109 | extern int get_power_on_target_afflvl(unsigned long mpidr); |
Achin Gupta | 0959db5 | 2013-12-02 17:33:04 +0000 | [diff] [blame] | 110 | extern void psci_afflvl_power_on_finish(unsigned long, |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 111 | int, |
| 112 | int, |
| 113 | afflvl_power_on_finisher *); |
| 114 | extern int psci_set_ns_entry_info(unsigned int index, |
| 115 | unsigned long entrypoint, |
| 116 | unsigned long context_id); |
Achin Gupta | 0959db5 | 2013-12-02 17:33:04 +0000 | [diff] [blame] | 117 | extern int psci_check_afflvl_range(int start_afflvl, int end_afflvl); |
| 118 | extern void psci_acquire_afflvl_locks(unsigned long mpidr, |
| 119 | int start_afflvl, |
| 120 | int end_afflvl, |
| 121 | mpidr_aff_map_nodes mpidr_nodes); |
| 122 | extern void psci_release_afflvl_locks(unsigned long mpidr, |
| 123 | int start_afflvl, |
| 124 | int end_afflvl, |
| 125 | mpidr_aff_map_nodes mpidr_nodes); |
| 126 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 127 | /* Private exported functions from psci_setup.c */ |
Achin Gupta | 0959db5 | 2013-12-02 17:33:04 +0000 | [diff] [blame] | 128 | extern int psci_get_aff_map_nodes(unsigned long mpidr, |
| 129 | int start_afflvl, |
| 130 | int end_afflvl, |
| 131 | mpidr_aff_map_nodes mpidr_nodes); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 132 | extern aff_map_node *psci_get_aff_map_node(unsigned long, int); |
| 133 | |
| 134 | /* Private exported functions from psci_affinity_on.c */ |
| 135 | extern int psci_afflvl_on(unsigned long, |
| 136 | unsigned long, |
| 137 | unsigned long, |
| 138 | int, |
| 139 | int); |
| 140 | |
| 141 | /* Private exported functions from psci_affinity_off.c */ |
| 142 | extern int psci_afflvl_off(unsigned long, int, int); |
| 143 | |
| 144 | /* Private exported functions from psci_affinity_suspend.c */ |
Achin Gupta | a45e397 | 2013-12-05 15:10:48 +0000 | [diff] [blame] | 145 | extern void psci_set_suspend_afflvl(aff_map_node *node, int afflvl); |
| 146 | extern int psci_get_suspend_afflvl(aff_map_node *node); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 147 | extern int psci_afflvl_suspend(unsigned long, |
| 148 | unsigned long, |
| 149 | unsigned long, |
| 150 | unsigned int, |
| 151 | int, |
| 152 | int); |
| 153 | extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int); |
Jeenu Viswambharan | caa8493 | 2014-02-06 10:36:15 +0000 | [diff] [blame] | 154 | |
| 155 | /* Private exported functions from psci_main.c */ |
| 156 | extern uint64_t psci_smc_handler(uint32_t smc_fid, |
| 157 | uint64_t x1, |
| 158 | uint64_t x2, |
| 159 | uint64_t x3, |
| 160 | uint64_t x4, |
| 161 | void *cookie, |
| 162 | void *handle, |
| 163 | uint64_t flags); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 164 | #endif /*__ASSEMBLY__*/ |
| 165 | |
| 166 | #endif /* __PSCI_PRIVATE_H__ */ |