plat_secondary.c 1.65 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * 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>
#include <tegra_def.h>
#include <tegra_private.h>

15
16
17
#define MISCREG_CPU_RESET_VECTOR	0x2000U
#define MISCREG_AA64_RST_LOW		0x2004U
#define MISCREG_AA64_RST_HIGH		0x2008U
18

19
#define CPU_RESET_MODE_AA64		1U
20

21
22
extern void tegra194_cpu_reset_handler(void);
extern uint64_t __tegra194_smmu_ctx_start;
23
24
25
26
27
28
29
30
31
32
33
34
35

/*******************************************************************************
 * 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();
	uint64_t cpu_reset_handler_base = params_from_bl2->tzdram_base;

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

	memcpy((void *)((uintptr_t)cpu_reset_handler_base),
36
37
38
		 (void *)(uintptr_t)tegra194_cpu_reset_handler,
		 (uintptr_t)&__tegra194_smmu_ctx_start -
		 (uintptr_t)&tegra194_cpu_reset_handler);
39
40

	addr_low = (uint32_t)cpu_reset_handler_base | CPU_RESET_MODE_AA64;
41
	addr_high = (uint32_t)((cpu_reset_handler_base >> 32U) & 0x7ffU);
42
43
44
45
46
47

	/* 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 */
48
	mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_RESET_VECTOR_LO,
49
			addr_low);
50
	mmio_write_32(TEGRA_SCRATCH_BASE + SCRATCH_RESET_VECTOR_HI,
51
52
			addr_high);
}