psci_system_off.c 2.02 KB
Newer Older
1
/*
2
 * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
#include <assert.h>
Isla Mitchell's avatar
Isla Mitchell committed
8
#include <stddef.h>
9
10
11
12
13
14

#include <arch_helpers.h>
#include <common/debug.h>
#include <drivers/console.h>
#include <plat/common/platform.h>

15
16
#include "psci_private.h"

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
26
27
		psci_spd_pm->svc_system_off();
	}

28
	console_flush();
29

30
31
32
33
34
35
	/* Call the platform specific hook */
	psci_plat_pm_ops->system_off();

	/* This function does not return. We should never get here */
}

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
45
46
		psci_spd_pm->svc_system_reset();
	}

47
	console_flush();
48

49
50
51
52
53
	/* Call the platform specific hook */
	psci_plat_pm_ops->system_reset();

	/* This function does not return. We should never get here */
}
54

55
u_register_t psci_system_reset2(uint32_t reset_type, u_register_t cookie)
56
{
57
	unsigned int is_vendor;
58
59
60

	psci_print_power_domain_map();

61
	assert(psci_plat_pm_ops->system_reset2 != NULL);
62

63
64
	is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1U;
	if (is_vendor == 0U) {
65
66
67
68
		/*
		 * Only WARM_RESET is allowed for architectural type resets.
		 */
		if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET)
69
70
71
72
			return (u_register_t) PSCI_E_INVALID_PARAMS;
		if ((psci_plat_pm_ops->write_mem_protect != NULL) &&
		    (psci_plat_pm_ops->write_mem_protect(0) < 0)) {
			return (u_register_t) PSCI_E_NOT_SUPPORTED;
73
74
75
76
		}
	}

	/* Notify the Secure Payload Dispatcher */
77
	if ((psci_spd_pm != NULL) && (psci_spd_pm->svc_system_reset != NULL)) {
78
79
		psci_spd_pm->svc_system_reset();
	}
80
	console_flush();
81

82
83
84
	return (u_register_t)
		psci_plat_pm_ops->system_reset2((int) is_vendor, reset_type,
						cookie);
85
}