1 /* 2 * Copyright (c) 2015, ARM Limited and Contributors. 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 #include <css_pm.h> 31 #include <plat_arm.h> 32 33 /* 34 * Custom `validate_power_state` handler for Juno. According to PSCI 35 * Specification, interrupts targeted to cores in PSCI CPU SUSPEND should 36 * be able to resume it. On Juno, when the system power domain is suspended, 37 * the GIC is also powered down. The SCP resumes the final core to be suspend 38 * when an external wake-up event is received. But the other cores cannot be 39 * woken up by a targeted interrupt, because GIC doesn't forward these 40 * interrupts to the SCP. Due to this hardware limitation, we down-grade PSCI 41 * CPU SUSPEND requests targeted to the system power domain level 42 * to cluster power domain level. 43 * 44 * The system power domain suspend on Juno is only supported only via 45 * PSCI SYSTEM SUSPEND API. 46 */ 47 static int juno_validate_power_state(unsigned int power_state, 48 psci_power_state_t *req_state) 49 { 50 int rc; 51 rc = arm_validate_power_state(power_state, req_state); 52 53 /* 54 * Ensure that the system power domain level is never suspended 55 * via PSCI CPU SUSPEND API. Currently system suspend is only 56 * supported via PSCI SYSTEM SUSPEND API. 57 */ 58 req_state->pwr_domain_state[ARM_PWR_LVL2] = ARM_LOCAL_STATE_RUN; 59 return rc; 60 } 61 62 /******************************************************************************* 63 * Export the platform handlers via plat_arm_psci_pm_ops. The ARM Standard 64 * platform will take care of registering the handlers with PSCI. 65 ******************************************************************************/ 66 const plat_psci_ops_t plat_arm_psci_pm_ops = { 67 .pwr_domain_on = css_pwr_domain_on, 68 .pwr_domain_on_finish = css_pwr_domain_on_finish, 69 .pwr_domain_off = css_pwr_domain_off, 70 .cpu_standby = css_cpu_standby, 71 .pwr_domain_suspend = css_pwr_domain_suspend, 72 .pwr_domain_suspend_finish = css_pwr_domain_suspend_finish, 73 .system_off = css_system_off, 74 .system_reset = css_system_reset, 75 .validate_power_state = juno_validate_power_state, 76 .validate_ns_entrypoint = arm_validate_ns_entrypoint, 77 .get_sys_suspend_power_state = css_get_sys_suspend_power_state 78 }; 79