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> |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 36 | #include <psci.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 37 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 38 | /******************************************************************************* |
| 39 | * The following two data structures hold the generic information to bringup |
| 40 | * a suspended/hotplugged out cpu |
| 41 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 42 | typedef struct eret_params { |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 43 | unsigned long entrypoint; |
| 44 | unsigned long spsr; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 45 | } eret_params_t; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 46 | |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 47 | typedef struct ns_entry_info { |
| 48 | eret_params_t eret_info; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 49 | unsigned long context_id; |
| 50 | unsigned int scr; |
| 51 | unsigned int sctlr; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 52 | } ns_entry_info_t; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 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 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 58 | typedef struct aff_map_node { |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 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; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 64 | bakery_lock_t lock; |
| 65 | } aff_map_node_t; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 66 | |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 67 | typedef struct aff_limits_node { |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 68 | int min; |
| 69 | int max; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 70 | } aff_limits_node_t; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 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 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 76 | typedef struct suspend_context { |
Vikram Kanigiri | f100f41 | 2014-04-01 19:26:26 +0100 | [diff] [blame] | 77 | unsigned int power_state; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 78 | } __aligned(CACHE_WRITEBACK_GRANULE) suspend_context_t; |
Achin Gupta | a59caa4 | 2013-12-05 14:21:04 +0000 | [diff] [blame] | 79 | |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 80 | typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]); |
| 81 | typedef unsigned int (*afflvl_power_on_finisher_t)(unsigned long, |
| 82 | aff_map_node_t *); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 83 | |
| 84 | /******************************************************************************* |
| 85 | * Data prototypes |
| 86 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 87 | extern suspend_context_t psci_suspend_context[PSCI_NUM_AFFS]; |
| 88 | extern ns_entry_info_t psci_ns_entry_info[PSCI_NUM_AFFS]; |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 89 | extern const plat_pm_ops_t *psci_plat_pm_ops; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 90 | extern aff_map_node_t psci_aff_map[PSCI_NUM_AFFS]; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 91 | |
| 92 | /******************************************************************************* |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 93 | * SPD's power management hooks registered with PSCI |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 94 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 95 | extern const spd_pm_ops_t *psci_spd_pm; |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 96 | |
| 97 | /******************************************************************************* |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 98 | * Function prototypes |
| 99 | ******************************************************************************/ |
| 100 | /* Private exported functions from psci_common.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 101 | int get_max_afflvl(void); |
| 102 | unsigned short psci_get_state(aff_map_node_t *node); |
| 103 | unsigned short psci_get_phys_state(aff_map_node_t *node); |
| 104 | void psci_set_state(aff_map_node_t *node, unsigned short state); |
| 105 | void psci_get_ns_entry_info(unsigned int index); |
| 106 | unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int); |
| 107 | int psci_validate_mpidr(unsigned long, int); |
| 108 | int get_power_on_target_afflvl(unsigned long mpidr); |
| 109 | void psci_afflvl_power_on_finish(unsigned long, |
| 110 | int, |
| 111 | int, |
| 112 | afflvl_power_on_finisher_t *); |
| 113 | int psci_set_ns_entry_info(unsigned int index, |
| 114 | unsigned long entrypoint, |
| 115 | unsigned long context_id); |
| 116 | int psci_check_afflvl_range(int start_afflvl, int end_afflvl); |
| 117 | void psci_acquire_afflvl_locks(unsigned long mpidr, |
| 118 | int start_afflvl, |
| 119 | int end_afflvl, |
| 120 | mpidr_aff_map_nodes_t mpidr_nodes); |
| 121 | void psci_release_afflvl_locks(unsigned long mpidr, |
| 122 | int start_afflvl, |
| 123 | int end_afflvl, |
| 124 | mpidr_aff_map_nodes_t mpidr_nodes); |
Achin Gupta | 0959db5 | 2013-12-02 17:33:04 +0000 | [diff] [blame] | 125 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 126 | /* Private exported functions from psci_setup.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 127 | int psci_get_aff_map_nodes(unsigned long mpidr, |
| 128 | int start_afflvl, |
| 129 | int end_afflvl, |
| 130 | mpidr_aff_map_nodes_t mpidr_nodes); |
| 131 | aff_map_node_t *psci_get_aff_map_node(unsigned long, int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 132 | |
| 133 | /* Private exported functions from psci_affinity_on.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 134 | int psci_afflvl_on(unsigned long, |
| 135 | unsigned long, |
| 136 | unsigned long, |
| 137 | int, |
| 138 | int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 139 | |
| 140 | /* Private exported functions from psci_affinity_off.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 141 | int psci_afflvl_off(unsigned long, int, int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 142 | |
| 143 | /* Private exported functions from psci_affinity_suspend.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 144 | void psci_set_suspend_power_state(aff_map_node_t *node, |
| 145 | unsigned int power_state); |
| 146 | int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node); |
| 147 | int psci_afflvl_suspend(unsigned long, |
| 148 | unsigned long, |
| 149 | unsigned long, |
| 150 | unsigned int, |
| 151 | int, |
| 152 | int); |
| 153 | unsigned int psci_afflvl_suspend_finish(unsigned long, int, int); |
Jeenu Viswambharan | caa8493 | 2014-02-06 10:36:15 +0000 | [diff] [blame] | 154 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 155 | |
| 156 | #endif /* __PSCI_PRIVATE_H__ */ |