Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame^] | 1 | /* |
| 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 | ******************************************************************************/ |
| 41 | typedef struct { |
| 42 | unsigned long entrypoint; |
| 43 | unsigned long spsr; |
| 44 | } eret_params; |
| 45 | |
| 46 | typedef 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 | ******************************************************************************/ |
| 57 | typedef 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; |
| 67 | } secure_context; |
| 68 | |
| 69 | /******************************************************************************* |
| 70 | * The following two data structures hold the topology tree which in turn tracks |
| 71 | * the state of the all the affinity instances supported by the platform. |
| 72 | ******************************************************************************/ |
| 73 | typedef struct { |
| 74 | unsigned long mpidr; |
| 75 | unsigned char state; |
| 76 | char level; |
| 77 | unsigned int data; |
| 78 | bakery_lock lock; |
| 79 | } aff_map_node; |
| 80 | |
| 81 | typedef struct { |
| 82 | int min; |
| 83 | int max; |
| 84 | } aff_limits_node; |
| 85 | |
| 86 | typedef unsigned int (*afflvl_power_on_finisher)(unsigned long, |
| 87 | aff_map_node *, |
| 88 | unsigned int); |
| 89 | |
| 90 | /******************************************************************************* |
| 91 | * Data prototypes |
| 92 | ******************************************************************************/ |
| 93 | extern secure_context psci_secure_context[PSCI_NUM_AFFS]; |
| 94 | extern ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS]; |
| 95 | extern unsigned int psci_ns_einfo_idx; |
| 96 | extern aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1]; |
| 97 | extern plat_pm_ops *psci_plat_pm_ops; |
| 98 | extern aff_map_node psci_aff_map[PSCI_NUM_AFFS]; |
| 99 | extern afflvl_power_on_finisher psci_afflvl_off_finish_handlers[]; |
| 100 | extern afflvl_power_on_finisher psci_afflvl_sus_finish_handlers[]; |
| 101 | |
| 102 | /******************************************************************************* |
| 103 | * Function prototypes |
| 104 | ******************************************************************************/ |
| 105 | /* Private exported functions from psci_common.c */ |
| 106 | extern int get_max_afflvl(void); |
| 107 | extern unsigned int psci_get_phys_state(unsigned int); |
| 108 | extern unsigned int psci_get_aff_phys_state(aff_map_node *); |
| 109 | extern unsigned int psci_calculate_affinity_state(aff_map_node *); |
| 110 | extern unsigned int psci_get_ns_entry_info(unsigned int index); |
| 111 | extern unsigned long mpidr_set_aff_inst(unsigned long,unsigned char, int); |
| 112 | extern int psci_change_state(unsigned long, int, int, unsigned int); |
| 113 | extern int psci_validate_mpidr(unsigned long, int); |
| 114 | extern unsigned int psci_afflvl_power_on_finish(unsigned long, |
| 115 | int, |
| 116 | int, |
| 117 | afflvl_power_on_finisher *); |
| 118 | extern int psci_set_ns_entry_info(unsigned int index, |
| 119 | unsigned long entrypoint, |
| 120 | unsigned long context_id); |
| 121 | extern int psci_get_first_present_afflvl(unsigned long, |
| 122 | int, int, |
| 123 | aff_map_node **); |
| 124 | /* Private exported functions from psci_setup.c */ |
| 125 | extern aff_map_node *psci_get_aff_map_node(unsigned long, int); |
| 126 | |
| 127 | /* Private exported functions from psci_affinity_on.c */ |
| 128 | extern int psci_afflvl_on(unsigned long, |
| 129 | unsigned long, |
| 130 | unsigned long, |
| 131 | int, |
| 132 | int); |
| 133 | |
| 134 | /* Private exported functions from psci_affinity_off.c */ |
| 135 | extern int psci_afflvl_off(unsigned long, int, int); |
| 136 | |
| 137 | /* Private exported functions from psci_affinity_suspend.c */ |
| 138 | extern int psci_afflvl_suspend(unsigned long, |
| 139 | unsigned long, |
| 140 | unsigned long, |
| 141 | unsigned int, |
| 142 | int, |
| 143 | int); |
| 144 | extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int); |
| 145 | #endif /*__ASSEMBLY__*/ |
| 146 | |
| 147 | #endif /* __PSCI_PRIVATE_H__ */ |