blob: 002392cad2a6869b58ee7433282f3d0ec6d8c4b3 [file] [log] [blame]
Juan Castillo4dc4a472014-08-12 11:17:06 +01001/*
Jimmy Brisson39f9eee2020-08-05 13:44:05 -05002 * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
Juan Castillo4dc4a472014-08-12 11:17:06 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillo4dc4a472014-08-12 11:17:06 +01005 */
6
Soby Mathew61e615b2015-01-15 11:49:49 +00007#include <assert.h>
Isla Mitchell99305012017-07-11 14:54:08 +01008#include <stddef.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009
10#include <arch_helpers.h>
11#include <common/debug.h>
12#include <drivers/console.h>
13#include <plat/common/platform.h>
14
Juan Castillo4dc4a472014-08-12 11:17:06 +010015#include "psci_private.h"
16
Etienne Carriere3fdf5f32017-06-07 16:42:42 +020017void __dead2 psci_system_off(void)
Juan Castillo4dc4a472014-08-12 11:17:06 +010018{
Soby Mathew981487a2015-07-13 14:10:57 +010019 psci_print_power_domain_map();
Juan Castillo4dc4a472014-08-12 11:17:06 +010020
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010021 assert(psci_plat_pm_ops->system_off != NULL);
Soby Mathew61e615b2015-01-15 11:49:49 +000022
Juan Castillo4dc4a472014-08-12 11:17:06 +010023 /* Notify the Secure Payload Dispatcher */
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010024 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) {
Juan Castillo4dc4a472014-08-12 11:17:06 +010025 psci_spd_pm->svc_system_off();
26 }
27
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050028 console_flush();
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000029
Juan Castillo4dc4a472014-08-12 11:17:06 +010030 /* Call the platform specific hook */
31 psci_plat_pm_ops->system_off();
32
33 /* This function does not return. We should never get here */
34}
35
Etienne Carriere3fdf5f32017-06-07 16:42:42 +020036void __dead2 psci_system_reset(void)
Juan Castillo4dc4a472014-08-12 11:17:06 +010037{
Soby Mathew981487a2015-07-13 14:10:57 +010038 psci_print_power_domain_map();
Juan Castillo4dc4a472014-08-12 11:17:06 +010039
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010040 assert(psci_plat_pm_ops->system_reset != NULL);
Soby Mathew61e615b2015-01-15 11:49:49 +000041
Juan Castillo4dc4a472014-08-12 11:17:06 +010042 /* Notify the Secure Payload Dispatcher */
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010043 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
Juan Castillo4dc4a472014-08-12 11:17:06 +010044 psci_spd_pm->svc_system_reset();
45 }
46
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050047 console_flush();
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000048
Juan Castillo4dc4a472014-08-12 11:17:06 +010049 /* Call the platform specific hook */
50 psci_plat_pm_ops->system_reset();
51
52 /* This function does not return. We should never get here */
53}
Roberto Vargasb820ad02017-07-26 09:23:09 +010054
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010055u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie)
Roberto Vargasb820ad02017-07-26 09:23:09 +010056{
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010057 unsigned int is_vendor;
Roberto Vargasb820ad02017-07-26 09:23:09 +010058
59 psci_print_power_domain_map();
60
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010061 assert(psci_plat_pm_ops->system_reset2 != NULL);
Roberto Vargasb820ad02017-07-26 09:23:09 +010062
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010063 is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U;
64 if (is_vendor == 0U) {
Roberto Vargasb820ad02017-07-26 09:23:09 +010065 /*
66 * Only WARM_RESET is allowed for architectural type resets.
67 */
68 if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET)
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010069 return (u_register_t) PSCI_E_INVALID_PARAMS;
70 if ((psci_plat_pm_ops->write_mem_protect != NULL) &&
71 (psci_plat_pm_ops->write_mem_protect(0) < 0)) {
72 return (u_register_t) PSCI_E_NOT_SUPPORTED;
Roberto Vargasb820ad02017-07-26 09:23:09 +010073 }
74 }
75
76 /* Notify the Secure Payload Dispatcher */
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010077 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
Roberto Vargasb820ad02017-07-26 09:23:09 +010078 psci_spd_pm->svc_system_reset();
79 }
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050080 console_flush();
Roberto Vargasb820ad02017-07-26 09:23:09 +010081
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010082 return (u_register_t)
83 psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type,
84 cookie);
Roberto Vargasb820ad02017-07-26 09:23:09 +010085}