plat_secondary.c 1.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
/*
 * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <arch_helpers.h>
#include <common/debug.h>
#include <lib/mmio.h>
#include <mce.h>
#include <string.h>
12
#include <tegra194_private.h>
13
14
15
#include <tegra_def.h>
#include <tegra_private.h>

16
17
#define MISCREG_AA64_RST_LOW		0x2004U
#define MISCREG_AA64_RST_HIGH		0x2008U
18

19
#define CPU_RESET_MODE_AA64		1U
20
21
22
23
24
25
26
27

/*******************************************************************************
 * Setup secondary CPU vectors
 ******************************************************************************/
void plat_secondary_setup(void)
{
	uint32_t addr_low, addr_high;
	plat_params_from_bl2_t *params_from_bl2 = bl31_get_plat_params();
28
	uint64_t cpu_reset_handler_base, cpu_reset_handler_size;
29
30
31

	INFO("Setting up secondary CPU boot\n");

32
33
34
35
36
37
38
39
40
41
42
43
44
45
	/*
	 * The BL31 code resides in the TZSRAM which loses state
	 * when we enter System Suspend. Copy the wakeup trampoline
	 * code to TZDRAM to help us exit from System Suspend.
	 */
	cpu_reset_handler_base = tegra194_get_cpu_reset_handler_base();
	cpu_reset_handler_size = tegra194_get_cpu_reset_handler_size();
	memcpy((void *)((uintptr_t)params_from_bl2->tzdram_base),
		(void *)((uintptr_t)cpu_reset_handler_base),
		cpu_reset_handler_size);

	/* TZDRAM base will be used as the "resume" address */
	addr_low = (uint32_t)params_from_bl2->tzdram_base | CPU_RESET_MODE_AA64;
	addr_high = (uint32_t)((params_from_bl2->tzdram_base >> 32U) & 0x7ffU);
46
47
48
49
50
51

	/* write lower 32 bits first, then the upper 11 bits */
	mmio_write_32(TEGRA_MISC_BASE + MISCREG_AA64_RST_LOW, addr_low);
	mmio_write_32(TEGRA_MISC_BASE + MISCREG_AA64_RST_HIGH, addr_high);

	/* save reset vector to be used during SYSTEM_SUSPEND exit */
52
	mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_RESET_VECTOR_LO,
53
			addr_low);
54
	mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_RESET_VECTOR_HI,
55
56
			addr_high);
}