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