a5ds_pm.c 2 KB
Newer Older
1
2
3
4
5
6
7
8
/*
 * Copyright (c) 2019, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <lib/psci/psci.h>
#include <plat/arm/common/plat_arm.h>
Usama Arif's avatar
Usama Arif committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <plat/common/platform.h>
#include <drivers/arm/gicv2.h>

/*******************************************************************************
 * Platform handler called when a power domain is about to be turned on. The
 * mpidr determines the CPU to be turned on.
 ******************************************************************************/
static int a5ds_pwr_domain_on(u_register_t mpidr)
{
	unsigned int pos = plat_core_pos_by_mpidr(mpidr);
	uint64_t *hold_base = (uint64_t *)A5DS_HOLD_BASE;

	hold_base[pos] = A5DS_HOLD_STATE_GO;
	dsbish();
	sev();

	return PSCI_E_SUCCESS;
}

/*******************************************************************************
 * Platform handler called when a power domain has just been powered on after
 * being turned off earlier. The target_state encodes the low power state that
 * each level has woken up from.
 ******************************************************************************/
void a5ds_pwr_domain_on_finish(const psci_power_state_t *target_state)
{
	/* TODO: This setup is needed only after a cold boot*/
	gicv2_pcpu_distif_init();

	/* Enable the gic cpu interface */
	gicv2_cpuif_enable();
}
41
42
43
44
45
46
47
48

/*******************************************************************************
 * Export the platform handlers via a5ds_psci_pm_ops. The ARM Standard
 * platform layer will take care of registering the handlers with PSCI.
 ******************************************************************************/
plat_psci_ops_t a5ds_psci_pm_ops = {
	/* dummy struct */
	.validate_ns_entrypoint = NULL,
Usama Arif's avatar
Usama Arif committed
49
50
	.pwr_domain_on = a5ds_pwr_domain_on,
	.pwr_domain_on_finish = a5ds_pwr_domain_on_finish
51
52
53
54
55
};

int __init plat_setup_psci_ops(uintptr_t sec_entrypoint,
				const plat_psci_ops_t **psci_ops)
{
Usama Arif's avatar
Usama Arif committed
56
57
58
	uintptr_t *mailbox = (void *)A5DS_TRUSTED_MAILBOX_BASE;
	*mailbox = sec_entrypoint;

59
60
61
62
	*psci_ops = &a5ds_psci_pm_ops;

	return 0;
}