Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 1 | /* |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 2 | * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Soby Mathew | 61e615b | 2015-01-15 11:49:49 +0000 | [diff] [blame] | 7 | #include <assert.h> |
Isla Mitchell | 9930501 | 2017-07-11 14:54:08 +0100 | [diff] [blame] | 8 | #include <stddef.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | |
| 10 | #include <arch_helpers.h> |
| 11 | #include <common/debug.h> |
| 12 | #include <drivers/console.h> |
| 13 | #include <plat/common/platform.h> |
| 14 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 15 | #include "psci_private.h" |
| 16 | |
Etienne Carriere | 3fdf5f3 | 2017-06-07 16:42:42 +0200 | [diff] [blame] | 17 | void __dead2 psci_system_off(void) |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 18 | { |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 19 | psci_print_power_domain_map(); |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 20 | |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 21 | assert(psci_plat_pm_ops->system_off != NULL); |
Soby Mathew | 61e615b | 2015-01-15 11:49:49 +0000 | [diff] [blame] | 22 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 23 | /* Notify the Secure Payload Dispatcher */ |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 24 | if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_off != NULL)) { |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 25 | psci_spd_pm->svc_system_off(); |
| 26 | } |
| 27 | |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 28 | console_flush(); |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 29 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 30 | /* 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 Carriere | 3fdf5f3 | 2017-06-07 16:42:42 +0200 | [diff] [blame] | 36 | void __dead2 psci_system_reset(void) |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 37 | { |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 38 | psci_print_power_domain_map(); |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 39 | |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 40 | assert(psci_plat_pm_ops->system_reset != NULL); |
Soby Mathew | 61e615b | 2015-01-15 11:49:49 +0000 | [diff] [blame] | 41 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 42 | /* Notify the Secure Payload Dispatcher */ |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 43 | if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) { |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 44 | psci_spd_pm->svc_system_reset(); |
| 45 | } |
| 46 | |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 47 | console_flush(); |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 48 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 49 | /* 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 Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 54 | |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 55 | u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie) |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 56 | { |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 57 | unsigned int is_vendor; |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 58 | |
| 59 | psci_print_power_domain_map(); |
| 60 | |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 61 | assert(psci_plat_pm_ops->system_reset2 != NULL); |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 62 | |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 63 | is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U; |
| 64 | if (is_vendor == 0U) { |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 65 | /* |
| 66 | * Only WARM_RESET is allowed for architectural type resets. |
| 67 | */ |
| 68 | if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET) |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 69 | 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 Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | |
| 76 | /* Notify the Secure Payload Dispatcher */ |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 77 | if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) { |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 78 | psci_spd_pm->svc_system_reset(); |
| 79 | } |
Jimmy Brisson | 39f9eee | 2020-08-05 13:44:05 -0500 | [diff] [blame] | 80 | console_flush(); |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 81 | |
Antonio Nino Diaz | 56a0e8e | 2018-07-16 23:19:25 +0100 | [diff] [blame] | 82 | return (u_register_t) |
| 83 | psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type, |
| 84 | cookie); |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 85 | } |