1532ed618SSoby Mathew /* 2*621d64f8SAntonio Nino Diaz * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. 3532ed618SSoby Mathew * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 5532ed618SSoby Mathew */ 6532ed618SSoby Mathew 7532ed618SSoby Mathew #include <arch_helpers.h> 8532ed618SSoby Mathew #include <assert.h> 90b32628eSAntonio Nino Diaz #include <console.h> 10532ed618SSoby Mathew #include <debug.h> 11532ed618SSoby Mathew #include <platform.h> 122a4b4b71SIsla Mitchell #include <stddef.h> 13532ed618SSoby Mathew #include "psci_private.h" 14532ed618SSoby Mathew 15aa8d5f88SEtienne Carriere void __dead2 psci_system_off(void) 16532ed618SSoby Mathew { 17532ed618SSoby Mathew psci_print_power_domain_map(); 18532ed618SSoby Mathew 19*621d64f8SAntonio Nino Diaz assert(psci_plat_pm_ops->system_off != NULL); 20532ed618SSoby Mathew 21532ed618SSoby Mathew /* Notify the Secure Payload Dispatcher */ 22*621d64f8SAntonio Nino Diaz if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) { 23532ed618SSoby Mathew psci_spd_pm->svc_system_off(); 24532ed618SSoby Mathew } 25532ed618SSoby Mathew 26*621d64f8SAntonio Nino Diaz (void) console_flush(); 270b32628eSAntonio Nino Diaz 28532ed618SSoby Mathew /* Call the platform specific hook */ 29532ed618SSoby Mathew psci_plat_pm_ops->system_off(); 30532ed618SSoby Mathew 31532ed618SSoby Mathew /* This function does not return. We should never get here */ 32532ed618SSoby Mathew } 33532ed618SSoby Mathew 34aa8d5f88SEtienne Carriere void __dead2 psci_system_reset(void) 35532ed618SSoby Mathew { 36532ed618SSoby Mathew psci_print_power_domain_map(); 37532ed618SSoby Mathew 38*621d64f8SAntonio Nino Diaz assert(psci_plat_pm_ops->system_reset != NULL); 39532ed618SSoby Mathew 40532ed618SSoby Mathew /* Notify the Secure Payload Dispatcher */ 41*621d64f8SAntonio Nino Diaz if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) { 42532ed618SSoby Mathew psci_spd_pm->svc_system_reset(); 43532ed618SSoby Mathew } 44532ed618SSoby Mathew 45*621d64f8SAntonio Nino Diaz (void) console_flush(); 460b32628eSAntonio Nino Diaz 47532ed618SSoby Mathew /* Call the platform specific hook */ 48532ed618SSoby Mathew psci_plat_pm_ops->system_reset(); 49532ed618SSoby Mathew 50532ed618SSoby Mathew /* This function does not return. We should never get here */ 51532ed618SSoby Mathew } 5236a8f8fdSRoberto Vargas 53*621d64f8SAntonio Nino Diaz u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie) 5436a8f8fdSRoberto Vargas { 55*621d64f8SAntonio Nino Diaz unsigned int is_vendor; 5636a8f8fdSRoberto Vargas 5736a8f8fdSRoberto Vargas psci_print_power_domain_map(); 5836a8f8fdSRoberto Vargas 59*621d64f8SAntonio Nino Diaz assert(psci_plat_pm_ops->system_reset2 != NULL); 6036a8f8fdSRoberto Vargas 61*621d64f8SAntonio Nino Diaz is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U; 62*621d64f8SAntonio Nino Diaz if (is_vendor == 0U) { 6336a8f8fdSRoberto Vargas /* 6436a8f8fdSRoberto Vargas * Only WARM_RESET is allowed for architectural type resets. 6536a8f8fdSRoberto Vargas */ 6636a8f8fdSRoberto Vargas if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET) 67*621d64f8SAntonio Nino Diaz return (u_register_t) PSCI_E_INVALID_PARAMS; 68*621d64f8SAntonio Nino Diaz if ((psci_plat_pm_ops->write_mem_protect != NULL) && 69*621d64f8SAntonio Nino Diaz (psci_plat_pm_ops->write_mem_protect(0) < 0)) { 70*621d64f8SAntonio Nino Diaz return (u_register_t) PSCI_E_NOT_SUPPORTED; 7136a8f8fdSRoberto Vargas } 7236a8f8fdSRoberto Vargas } 7336a8f8fdSRoberto Vargas 7436a8f8fdSRoberto Vargas /* Notify the Secure Payload Dispatcher */ 75*621d64f8SAntonio Nino Diaz if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) { 7636a8f8fdSRoberto Vargas psci_spd_pm->svc_system_reset(); 7736a8f8fdSRoberto Vargas } 78*621d64f8SAntonio Nino Diaz (void) console_flush(); 7936a8f8fdSRoberto Vargas 80*621d64f8SAntonio Nino Diaz return (u_register_t) 81*621d64f8SAntonio Nino Diaz psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type, 82*621d64f8SAntonio Nino Diaz cookie); 8336a8f8fdSRoberto Vargas } 84