plat_psci.c 1.65 KB
Newer Older
1
/*
2
 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3
4
5
6
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

7
#include <plat_private.h>
8
#include <pm_common.h>
9
10
11
12
13
#include <common/debug.h>
#include <lib/mmio.h>
#include <lib/psci/psci.h>
#include <plat/common/platform.h>

14
15
16
#include "pm_api_sys.h"
#include "pm_client.h"

17
18
static uintptr_t versal_sec_entry;

19
static int versal_pwr_domain_on(u_register_t mpidr)
20
21
{
	unsigned int cpu_id = plat_core_pos_by_mpidr(mpidr);
22
	const struct pm_proc *proc;
23
24
25
26
27
28

	VERBOSE("%s: mpidr: 0x%lx\n", __func__, mpidr);

	if (cpu_id == -1)
		return PSCI_E_INTERN_FAIL;

29
30
31
32
33
34
35
36
	proc = pm_get_proc(cpu_id);

	/* Send request to PMC to wake up selected ACPU core */
	pm_req_wakeup(proc->node_id, (versal_sec_entry & 0xFFFFFFFF) | 0x1,
		      versal_sec_entry >> 32, 0);

	/* Clear power down request */
	pm_client_wakeup(proc);
37
38
39
40
41
42
43
44
45
46
47
48
49
50

	return PSCI_E_SUCCESS;
}

void versal_pwr_domain_on_finish(const psci_power_state_t *target_state)
{
	/* Enable the gic cpu interface */
	plat_versal_gic_pcpu_init();

	/* Program the gic per-cpu distributor or re-distributor interface */
	plat_versal_gic_cpuif_enable();
}

static const struct plat_psci_ops versal_nopmc_psci_ops = {
51
	.pwr_domain_on			= versal_pwr_domain_on,
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
	.pwr_domain_on_finish		= versal_pwr_domain_on_finish,
};

/*******************************************************************************
 * Export the platform specific power ops.
 ******************************************************************************/
int plat_setup_psci_ops(uintptr_t sec_entrypoint,
			const struct plat_psci_ops **psci_ops)
{
	versal_sec_entry = sec_entrypoint;

	*psci_ops = &versal_nopmc_psci_ops;

	return 0;
}