blob: 7cac4e9376db4868f5a854d11e570ab0cdcfda67 [file] [log] [blame]
Juan Castillo4dc4a472014-08-12 11:17:06 +01001/*
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +01002 * Copyright (c) 2014-2018, 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
Juan Castillo4dc4a472014-08-12 11:17:06 +01007#include <arch_helpers.h>
Soby Mathew61e615b2015-01-15 11:49:49 +00008#include <assert.h>
Antonio Nino Diaze3962d02017-02-16 16:17:19 +00009#include <console.h>
Juan Castillo4dc4a472014-08-12 11:17:06 +010010#include <debug.h>
11#include <platform.h>
Isla Mitchell99305012017-07-11 14:54:08 +010012#include <stddef.h>
Juan Castillo4dc4a472014-08-12 11:17:06 +010013#include "psci_private.h"
14
Etienne Carriere3fdf5f32017-06-07 16:42:42 +020015void __dead2 psci_system_off(void)
Juan Castillo4dc4a472014-08-12 11:17:06 +010016{
Soby Mathew981487a2015-07-13 14:10:57 +010017 psci_print_power_domain_map();
Juan Castillo4dc4a472014-08-12 11:17:06 +010018
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010019 assert(psci_plat_pm_ops->system_off != NULL);
Soby Mathew61e615b2015-01-15 11:49:49 +000020
Juan Castillo4dc4a472014-08-12 11:17:06 +010021 /* Notify the Secure Payload Dispatcher */
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010022 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) {
Juan Castillo4dc4a472014-08-12 11:17:06 +010023 psci_spd_pm->svc_system_off();
24 }
25
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010026 (void) console_flush();
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000027
Juan Castillo4dc4a472014-08-12 11:17:06 +010028 /* 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
Etienne Carriere3fdf5f32017-06-07 16:42:42 +020034void __dead2 psci_system_reset(void)
Juan Castillo4dc4a472014-08-12 11:17:06 +010035{
Soby Mathew981487a2015-07-13 14:10:57 +010036 psci_print_power_domain_map();
Juan Castillo4dc4a472014-08-12 11:17:06 +010037
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010038 assert(psci_plat_pm_ops->system_reset != NULL);
Soby Mathew61e615b2015-01-15 11:49:49 +000039
Juan Castillo4dc4a472014-08-12 11:17:06 +010040 /* Notify the Secure Payload Dispatcher */
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010041 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
Juan Castillo4dc4a472014-08-12 11:17:06 +010042 psci_spd_pm->svc_system_reset();
43 }
44
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010045 (void) console_flush();
Antonio Nino Diaze3962d02017-02-16 16:17:19 +000046
Juan Castillo4dc4a472014-08-12 11:17:06 +010047 /* 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}
Roberto Vargasb820ad02017-07-26 09:23:09 +010052
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010053u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie)
Roberto Vargasb820ad02017-07-26 09:23:09 +010054{
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010055 unsigned int is_vendor;
Roberto Vargasb820ad02017-07-26 09:23:09 +010056
57 psci_print_power_domain_map();
58
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010059 assert(psci_plat_pm_ops->system_reset2 != NULL);
Roberto Vargasb820ad02017-07-26 09:23:09 +010060
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010061 is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U;
62 if (is_vendor == 0U) {
Roberto Vargasb820ad02017-07-26 09:23:09 +010063 /*
64 * Only WARM_RESET is allowed for architectural type resets.
65 */
66 if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET)
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010067 return (u_register_t) PSCI_E_INVALID_PARAMS;
68 if ((psci_plat_pm_ops->write_mem_protect != NULL) &&
69 (psci_plat_pm_ops->write_mem_protect(0) < 0)) {
70 return (u_register_t) PSCI_E_NOT_SUPPORTED;
Roberto Vargasb820ad02017-07-26 09:23:09 +010071 }
72 }
73
74 /* Notify the Secure Payload Dispatcher */
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010075 if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
Roberto Vargasb820ad02017-07-26 09:23:09 +010076 psci_spd_pm->svc_system_reset();
77 }
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010078 (void) console_flush();
Roberto Vargasb820ad02017-07-26 09:23:09 +010079
Antonio Nino Diaz56a0e8e2018-07-16 23:19:25 +010080 return (u_register_t)
81 psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type,
82 cookie);
Roberto Vargasb820ad02017-07-26 09:23:09 +010083}