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> |
Andrew Thoelke | 56f4470 | 2014-06-20 00:36:14 +0100 | [diff] [blame] | 36 | #include <platform_def.h> /* for PLATFORM_NUM_AFFS */ |
Dan Handley | 2bd4ef2 | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 37 | #include <psci.h> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 38 | |
Andrew Thoelke | 56f4470 | 2014-06-20 00:36:14 +0100 | [diff] [blame] | 39 | /* Number of affinity instances whose state this psci imp. can track */ |
| 40 | #ifdef PLATFORM_NUM_AFFS |
| 41 | #define PSCI_NUM_AFFS PLATFORM_NUM_AFFS |
| 42 | #else |
| 43 | #define PSCI_NUM_AFFS (2 * PLATFORM_CORE_COUNT) |
| 44 | #endif |
| 45 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 46 | /******************************************************************************* |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 47 | * The following two data structures hold the topology tree which in turn tracks |
| 48 | * the state of the all the affinity instances supported by the platform. |
| 49 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 50 | typedef struct aff_map_node { |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 51 | unsigned long mpidr; |
Achin Gupta | 75f7367 | 2013-12-05 16:33:10 +0000 | [diff] [blame] | 52 | unsigned short ref_count; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 53 | unsigned char state; |
Achin Gupta | 75f7367 | 2013-12-05 16:33:10 +0000 | [diff] [blame] | 54 | unsigned char level; |
Andrew Thoelke | e9a0d11 | 2014-06-20 00:38:03 +0100 | [diff] [blame] | 55 | unsigned int power_state; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 56 | bakery_lock_t lock; |
| 57 | } aff_map_node_t; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 58 | |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 59 | typedef struct aff_limits_node { |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 60 | int min; |
| 61 | int max; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 62 | } aff_limits_node_t; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 63 | |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 64 | typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]); |
Andrew Thoelke | 2bc0785 | 2014-06-09 12:44:21 +0100 | [diff] [blame] | 65 | typedef unsigned int (*afflvl_power_on_finisher_t)(aff_map_node_t *); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 66 | |
| 67 | /******************************************************************************* |
| 68 | * Data prototypes |
| 69 | ******************************************************************************/ |
Dan Handley | a4cb68e | 2014-04-23 13:47:06 +0100 | [diff] [blame] | 70 | extern const plat_pm_ops_t *psci_plat_pm_ops; |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 71 | extern aff_map_node_t psci_aff_map[PSCI_NUM_AFFS]; |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 72 | |
| 73 | /******************************************************************************* |
Jeenu Viswambharan | 7f36660 | 2014-02-20 17:11:00 +0000 | [diff] [blame] | 74 | * SPD's power management hooks registered with PSCI |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 75 | ******************************************************************************/ |
Dan Handley | e2712bc | 2014-04-10 15:37:22 +0100 | [diff] [blame] | 76 | extern const spd_pm_ops_t *psci_spd_pm; |
Achin Gupta | 607084e | 2014-02-09 18:24:19 +0000 | [diff] [blame] | 77 | |
| 78 | /******************************************************************************* |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 79 | * Function prototypes |
| 80 | ******************************************************************************/ |
| 81 | /* Private exported functions from psci_common.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 82 | int get_max_afflvl(void); |
| 83 | unsigned short psci_get_state(aff_map_node_t *node); |
| 84 | unsigned short psci_get_phys_state(aff_map_node_t *node); |
| 85 | void psci_set_state(aff_map_node_t *node, unsigned short state); |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 86 | unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int); |
| 87 | int psci_validate_mpidr(unsigned long, int); |
| 88 | int get_power_on_target_afflvl(unsigned long mpidr); |
Andrew Thoelke | 2bc0785 | 2014-06-09 12:44:21 +0100 | [diff] [blame] | 89 | void psci_afflvl_power_on_finish(int, |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 90 | int, |
| 91 | afflvl_power_on_finisher_t *); |
Andrew Thoelke | 4e12607 | 2014-06-04 21:10:52 +0100 | [diff] [blame] | 92 | int psci_save_ns_entry(uint64_t mpidr, |
| 93 | uint64_t entrypoint, uint64_t context_id, |
| 94 | uint32_t caller_scr_el3, uint32_t caller_sctlr_el1); |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 95 | int psci_check_afflvl_range(int start_afflvl, int end_afflvl); |
Andrew Thoelke | 2bc0785 | 2014-06-09 12:44:21 +0100 | [diff] [blame] | 96 | void psci_acquire_afflvl_locks(int start_afflvl, |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 97 | int end_afflvl, |
| 98 | mpidr_aff_map_nodes_t mpidr_nodes); |
Andrew Thoelke | 2bc0785 | 2014-06-09 12:44:21 +0100 | [diff] [blame] | 99 | void psci_release_afflvl_locks(int start_afflvl, |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 100 | int end_afflvl, |
| 101 | mpidr_aff_map_nodes_t mpidr_nodes); |
Achin Gupta | 0959db5 | 2013-12-02 17:33:04 +0000 | [diff] [blame] | 102 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 103 | /* Private exported functions from psci_setup.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 104 | int psci_get_aff_map_nodes(unsigned long mpidr, |
| 105 | int start_afflvl, |
| 106 | int end_afflvl, |
| 107 | mpidr_aff_map_nodes_t mpidr_nodes); |
| 108 | aff_map_node_t *psci_get_aff_map_node(unsigned long, int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 109 | |
| 110 | /* Private exported functions from psci_affinity_on.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 111 | int psci_afflvl_on(unsigned long, |
| 112 | unsigned long, |
| 113 | unsigned long, |
| 114 | int, |
| 115 | int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 116 | |
| 117 | /* Private exported functions from psci_affinity_off.c */ |
Andrew Thoelke | 2bc0785 | 2014-06-09 12:44:21 +0100 | [diff] [blame] | 118 | int psci_afflvl_off(int, int); |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 119 | |
| 120 | /* Private exported functions from psci_affinity_suspend.c */ |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 121 | void psci_set_suspend_power_state(aff_map_node_t *node, |
| 122 | unsigned int power_state); |
| 123 | int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node); |
| 124 | int psci_afflvl_suspend(unsigned long, |
| 125 | unsigned long, |
Dan Handley | a17fefa | 2014-05-14 12:38:32 +0100 | [diff] [blame] | 126 | unsigned int, |
| 127 | int, |
| 128 | int); |
Andrew Thoelke | 2bc0785 | 2014-06-09 12:44:21 +0100 | [diff] [blame] | 129 | unsigned int psci_afflvl_suspend_finish(int, int); |
Jeenu Viswambharan | caa8493 | 2014-02-06 10:36:15 +0000 | [diff] [blame] | 130 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 131 | |
| 132 | #endif /* __PSCI_PRIVATE_H__ */ |