1*54fd6939SJiyong Park /* 2*54fd6939SJiyong Park * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. 3*54fd6939SJiyong Park * 4*54fd6939SJiyong Park * SPDX-License-Identifier: BSD-3-Clause 5*54fd6939SJiyong Park */ 6*54fd6939SJiyong Park 7*54fd6939SJiyong Park #include <assert.h> 8*54fd6939SJiyong Park #include <stddef.h> 9*54fd6939SJiyong Park 10*54fd6939SJiyong Park #include <arch_helpers.h> 11*54fd6939SJiyong Park #include <common/debug.h> 12*54fd6939SJiyong Park #include <drivers/console.h> 13*54fd6939SJiyong Park #include <plat/common/platform.h> 14*54fd6939SJiyong Park 15*54fd6939SJiyong Park #include "psci_private.h" 16*54fd6939SJiyong Park psci_system_off(void)17*54fd6939SJiyong Parkvoid __dead2 psci_system_off(void) 18*54fd6939SJiyong Park { 19*54fd6939SJiyong Park psci_print_power_domain_map(); 20*54fd6939SJiyong Park 21*54fd6939SJiyong Park assert(psci_plat_pm_ops->system_off != NULL); 22*54fd6939SJiyong Park 23*54fd6939SJiyong Park /* Notify the Secure Payload Dispatcher */ 24*54fd6939SJiyong Park if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) { 25*54fd6939SJiyong Park psci_spd_pm->svc_system_off(); 26*54fd6939SJiyong Park } 27*54fd6939SJiyong Park 28*54fd6939SJiyong Park console_flush(); 29*54fd6939SJiyong Park 30*54fd6939SJiyong Park /* Call the platform specific hook */ 31*54fd6939SJiyong Park psci_plat_pm_ops->system_off(); 32*54fd6939SJiyong Park 33*54fd6939SJiyong Park /* This function does not return. We should never get here */ 34*54fd6939SJiyong Park } 35*54fd6939SJiyong Park psci_system_reset(void)36*54fd6939SJiyong Parkvoid __dead2 psci_system_reset(void) 37*54fd6939SJiyong Park { 38*54fd6939SJiyong Park psci_print_power_domain_map(); 39*54fd6939SJiyong Park 40*54fd6939SJiyong Park assert(psci_plat_pm_ops->system_reset != NULL); 41*54fd6939SJiyong Park 42*54fd6939SJiyong Park /* Notify the Secure Payload Dispatcher */ 43*54fd6939SJiyong Park if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) { 44*54fd6939SJiyong Park psci_spd_pm->svc_system_reset(); 45*54fd6939SJiyong Park } 46*54fd6939SJiyong Park 47*54fd6939SJiyong Park console_flush(); 48*54fd6939SJiyong Park 49*54fd6939SJiyong Park /* Call the platform specific hook */ 50*54fd6939SJiyong Park psci_plat_pm_ops->system_reset(); 51*54fd6939SJiyong Park 52*54fd6939SJiyong Park /* This function does not return. We should never get here */ 53*54fd6939SJiyong Park } 54*54fd6939SJiyong Park psci_system_reset2(uint32_t reset_type,u_register_t cookie)55*54fd6939SJiyong Parku_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie) 56*54fd6939SJiyong Park { 57*54fd6939SJiyong Park unsigned int is_vendor; 58*54fd6939SJiyong Park 59*54fd6939SJiyong Park psci_print_power_domain_map(); 60*54fd6939SJiyong Park 61*54fd6939SJiyong Park assert(psci_plat_pm_ops->system_reset2 != NULL); 62*54fd6939SJiyong Park 63*54fd6939SJiyong Park is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U; 64*54fd6939SJiyong Park if (is_vendor == 0U) { 65*54fd6939SJiyong Park /* 66*54fd6939SJiyong Park * Only WARM_RESET is allowed for architectural type resets. 67*54fd6939SJiyong Park */ 68*54fd6939SJiyong Park if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET) 69*54fd6939SJiyong Park return (u_register_t) PSCI_E_INVALID_PARAMS; 70*54fd6939SJiyong Park if ((psci_plat_pm_ops->write_mem_protect != NULL) && 71*54fd6939SJiyong Park (psci_plat_pm_ops->write_mem_protect(0) < 0)) { 72*54fd6939SJiyong Park return (u_register_t) PSCI_E_NOT_SUPPORTED; 73*54fd6939SJiyong Park } 74*54fd6939SJiyong Park } 75*54fd6939SJiyong Park 76*54fd6939SJiyong Park /* Notify the Secure Payload Dispatcher */ 77*54fd6939SJiyong Park if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) { 78*54fd6939SJiyong Park psci_spd_pm->svc_system_reset(); 79*54fd6939SJiyong Park } 80*54fd6939SJiyong Park console_flush(); 81*54fd6939SJiyong Park 82*54fd6939SJiyong Park return (u_register_t) 83*54fd6939SJiyong Park psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type, 84*54fd6939SJiyong Park cookie); 85*54fd6939SJiyong Park } 86