Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 2 | * Copyright (c) 2014-2017, 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 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 7 | #include <arch_helpers.h> |
Soby Mathew | 61e615b | 2015-01-15 11:49:49 +0000 | [diff] [blame] | 8 | #include <assert.h> |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 9 | #include <console.h> |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 10 | #include <debug.h> |
| 11 | #include <platform.h> |
Isla Mitchell | 9930501 | 2017-07-11 14:54:08 +0100 | [diff] [blame] | 12 | #include <stddef.h> |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 13 | #include "psci_private.h" |
| 14 | |
Etienne Carriere | 3fdf5f3 | 2017-06-07 16:42:42 +0200 | [diff] [blame] | 15 | void __dead2 psci_system_off(void) |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 16 | { |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 17 | psci_print_power_domain_map(); |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 18 | |
Soby Mathew | 61e615b | 2015-01-15 11:49:49 +0000 | [diff] [blame] | 19 | assert(psci_plat_pm_ops->system_off); |
| 20 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 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 | |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 26 | console_flush(); |
| 27 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 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 | |
Etienne Carriere | 3fdf5f3 | 2017-06-07 16:42:42 +0200 | [diff] [blame] | 34 | void __dead2 psci_system_reset(void) |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 35 | { |
Soby Mathew | 981487a | 2015-07-13 14:10:57 +0100 | [diff] [blame] | 36 | psci_print_power_domain_map(); |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 37 | |
Soby Mathew | 61e615b | 2015-01-15 11:49:49 +0000 | [diff] [blame] | 38 | assert(psci_plat_pm_ops->system_reset); |
| 39 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 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 | |
Antonio Nino Diaz | e3962d0 | 2017-02-16 16:17:19 +0000 | [diff] [blame] | 45 | console_flush(); |
| 46 | |
Juan Castillo | 4dc4a47 | 2014-08-12 11:17:06 +0100 | [diff] [blame] | 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 | } |
Roberto Vargas | b820ad0 | 2017-07-26 09:23:09 +0100 | [diff] [blame] | 52 | |
| 53 | int 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 | } |