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