1 // © 2021 Qualcomm Innovation Center, Inc. All rights reserved. 2 // 3 // SPDX-License-Identifier: BSD-3-Clause 4 // Checks that the suspend state is valid 5 // 6 // This function checks that the pcpu supports the cpu and cluster level 7 // state specified. If the specified state is not valid, then it returns 8 // PSCI_RET_INVALID_PARAMETERS. 9 psci_ret_t 10 platform_psci_suspend_state_validation(psci_suspend_powerstate_t suspend_state, 11 cpu_index_t cpu, psci_mode_t psci_mode); 12 13 // Gets the cpu state from the suspend power state 14 psci_cpu_state_t 15 platform_psci_get_cpu_state(psci_suspend_powerstate_t suspend_state); 16 17 // Sets cpu state to the stateid of the suspend power state 18 void 19 platform_psci_set_cpu_state(psci_suspend_powerstate_t *suspend_state, 20 psci_cpu_state_t cpu_state); 21 22 // Returns that shallowest state between two cpu states 23 psci_cpu_state_t 24 platform_psci_shallowest_cpu_state(psci_cpu_state_t state1, 25 psci_cpu_state_t state2); 26 27 // Returns the deepest cpu state supported by a cpu 28 psci_cpu_state_t 29 platform_psci_deepest_cpu_state(cpu_index_t cpu); 30 31 // Returns the deepest cpu-level suspend state id supported by a cpu 32 psci_suspend_powerstate_stateid_t 33 platform_psci_deepest_cpu_level_stateid(cpu_index_t cpu); 34 35 // Returns true if cpu state is in active state 36 bool 37 platform_psci_is_cpu_active(psci_cpu_state_t cpu_state); 38 39 // Returns true if cpus is in power collapse state 40 bool 41 platform_psci_is_cpu_poweroff(psci_cpu_state_t cpu_state); 42 43 // Returns true if cluster state is in active state 44 bool 45 platform_psci_is_cluster_active(psci_cluster_state_L3_t cluster_state); 46 47 // Returns the cluster indices 48 uint32_t 49 platform_psci_get_cluster_index(cpu_index_t cpu); 50 51 // Returns the start index of children in hierarchy/counts based on level and 52 // cpu 53 error_t 54 platform_psci_get_index_by_level(cpu_index_t cpu, uint32_t *start_idx, 55 uint32_t *children_counts, uint32_t level); 56 57 #if !defined(PSCI_AFFINITY_LEVELS_NOT_SUPPORTED) || \ 58 !PSCI_AFFINITY_LEVELS_NOT_SUPPORTED 59 // Checks if cluster state corresponds to a power off state 60 bool 61 platform_psci_is_cluster_state_poweroff(psci_suspend_powerstate_t suspend_state); 62 63 // Returns true if cluster state is in active state 64 bool 65 platform_psci_is_cluster_active(psci_cluster_state_L3_t cluster_state); 66 67 // Checks if cluster state corresponds to a retention state 68 bool 69 platform_psci_is_cluster_state_retention( 70 psci_suspend_powerstate_t suspend_state); 71 72 // Gets the cluster state from the suspend power state 73 psci_cluster_state_t 74 platform_psci_get_cluster_state(psci_suspend_powerstate_t suspend_state); 75 76 // Sets cluster state to the stateid of the suspend power state 77 void 78 platform_psci_set_cluster_state(psci_suspend_powerstate_t *suspend_state, 79 psci_cluster_state_t cluster_state); 80 81 #if (PLATFORM_MAX_HIERARCHY == 2) 82 // Gets the system state from the suspend power state 83 psci_system_state_t 84 platform_psci_get_system_state(psci_suspend_powerstate_t suspend_state); 85 86 // Sets system state to the stateid of the suspend power state 87 void 88 platform_psci_set_system_state(psci_suspend_powerstate_t *suspend_state, 89 psci_system_state_t system_state); 90 #endif 91 92 // Returns the suspend level of the last cpu 93 index_t 94 platform_psci_get_last_cpu_level(psci_suspend_powerstate_t suspend_state); 95 96 // Sets the suspend level of the last cpu 97 void 98 platform_psci_set_last_cpu_level(psci_suspend_powerstate_t *suspend_state, 99 index_t last_cpu); 100 101 // Returns that shallowest state between two cluster states 102 psci_cluster_state_t 103 platform_psci_shallowest_cluster_state(psci_cluster_state_t state1, 104 uint16_t state2); 105 106 // Returns the deepest cluster-level suspend state supported by the system 107 psci_cluster_state_t 108 platform_psci_deepest_cluster_state(void); 109 110 // Returns the deepest cluster-level suspend state id supported by a cpu 111 psci_suspend_powerstate_stateid_t 112 platform_psci_deepest_cluster_level_stateid(cpu_index_t cpu); 113 114 #endif 115