psci_system_off.c 1.82 KB
Newer Older
1
/*
2
 * Copyright (c) 2014-2017, 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 <arch_helpers.h>
8
#include <assert.h>
9
#include <console.h>
10
11
#include <debug.h>
#include <platform.h>
Isla Mitchell's avatar
Isla Mitchell committed
12
#include <stddef.h>
13
14
#include "psci_private.h"

15
void __dead2 psci_system_off(void)
16
{
17
	psci_print_power_domain_map();
18

19
20
	assert(psci_plat_pm_ops->system_off);

21
22
23
24
25
	/* Notify the Secure Payload Dispatcher */
	if (psci_spd_pm && psci_spd_pm->svc_system_off) {
		psci_spd_pm->svc_system_off();
	}

26
27
	console_flush();

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

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

34
void __dead2 psci_system_reset(void)
35
{
36
	psci_print_power_domain_map();
37

38
39
	assert(psci_plat_pm_ops->system_reset);

40
41
42
43
44
	/* Notify the Secure Payload Dispatcher */
	if (psci_spd_pm && psci_spd_pm->svc_system_reset) {
		psci_spd_pm->svc_system_reset();
	}

45
46
	console_flush();

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

	/* This function does not return. We should never get here */
}
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81

int psci_system_reset2(uint32_t reset_type, u_register_t cookie)
{
	int is_vendor;

	psci_print_power_domain_map();

	assert(psci_plat_pm_ops->system_reset2);

	is_vendor = (reset_type >> PSCI_RESET2_TYPE_VENDOR_SHIFT) & 1;
	if (!is_vendor) {
		/*
		 * Only WARM_RESET is allowed for architectural type resets.
		 */
		if (reset_type != PSCI_RESET2_SYSTEM_WARM_RESET)
			return PSCI_E_INVALID_PARAMS;
		if (psci_plat_pm_ops->write_mem_protect &&
		    psci_plat_pm_ops->write_mem_protect(0) < 0) {
			return PSCI_E_NOT_SUPPORTED;
		}
	}

	/* Notify the Secure Payload Dispatcher */
	if (psci_spd_pm && psci_spd_pm->svc_system_reset) {
		psci_spd_pm->svc_system_reset();
	}
	console_flush();

	return psci_plat_pm_ops->system_reset2(is_vendor, reset_type, cookie);
}