blob: adb39f57240bfb5757da7f406e2da6a01f56e5e8 [file] [log] [blame]
Varun Wadekar93bed2a2016-03-18 13:07:33 -07001/*
Varun Wadekarfadd5382019-01-11 14:48:41 -08002 * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
Pritesh Raithatha75c94432018-08-03 15:48:15 +05303 * Copyright (c) 2020, NVIDIA Corporation. All rights reserved.
Varun Wadekar93bed2a2016-03-18 13:07:33 -07004 *
dp-armfa3cf0b2017-05-03 09:38:09 +01005 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekar93bed2a2016-03-18 13:07:33 -07006 */
7
8#include <arch.h>
9#include <asm_macros.S>
Varun Wadekarfadd5382019-01-11 14:48:41 -080010#include <common/bl_common.h>
Varun Wadekar93bed2a2016-03-18 13:07:33 -070011#include <memctrl_v2.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <plat/common/common_def.h>
Varun Wadekar93bed2a2016-03-18 13:07:33 -070013#include <tegra_def.h>
14
Pritesh Raithatha75c94432018-08-03 15:48:15 +053015#define TEGRA186_MC_CTX_SIZE 0x93
Varun Wadekar93bed2a2016-03-18 13:07:33 -070016
Varun Wadekar93bed2a2016-03-18 13:07:33 -070017 .globl tegra186_cpu_reset_handler
18
19/* CPU reset handler routine */
Julius Wernerb4c75e92017-08-01 15:16:36 -070020func tegra186_cpu_reset_handler _align=4
Varun Wadekar2a7d87e2017-11-10 10:26:57 -080021 /* prepare to relocate to TZSRAM */
Varun Wadekar93bed2a2016-03-18 13:07:33 -070022 mov x0, #BL31_BASE
23 adr x1, __tegra186_cpu_reset_handler_end
24 adr x2, __tegra186_cpu_reset_handler_data
25 ldr x2, [x2, #8]
26
27 /* memcpy16 */
28m_loop16:
29 cmp x2, #16
30 b.lt m_loop1
31 ldp x3, x4, [x1], #16
32 stp x3, x4, [x0], #16
33 sub x2, x2, #16
34 b m_loop16
35 /* copy byte per byte */
36m_loop1:
37 cbz x2, boot_cpu
38 ldrb w3, [x1], #1
39 strb w3, [x0], #1
40 subs x2, x2, #1
41 b.ne m_loop1
42
43boot_cpu:
44 adr x0, __tegra186_cpu_reset_handler_data
45 ldr x0, [x0]
46 br x0
47endfunc tegra186_cpu_reset_handler
48
49 /*
50 * Tegra186 reset data (offset 0x0 - 0x430)
51 *
52 * 0x000: secure world's entrypoint
53 * 0x008: BL31 size (RO + RW)
Pritesh Raithatha75c94432018-08-03 15:48:15 +053054 * 0x00C: MC context start
55 * 0x42C: MC context end
Varun Wadekar93bed2a2016-03-18 13:07:33 -070056 */
57
58 .align 4
59 .type __tegra186_cpu_reset_handler_data, %object
60 .globl __tegra186_cpu_reset_handler_data
61__tegra186_cpu_reset_handler_data:
62 .quad tegra_secure_entrypoint
63 .quad __BL31_END__ - BL31_BASE
Varun Wadekarfa887672017-11-08 14:45:08 -080064
Varun Wadekar2a7d87e2017-11-10 10:26:57 -080065 .globl __tegra186_system_suspend_state
66__tegra186_system_suspend_state:
67 .quad 0
68
Varun Wadekarfa887672017-11-08 14:45:08 -080069 .align 4
Pritesh Raithatha75c94432018-08-03 15:48:15 +053070 .globl __tegra186_mc_context
71__tegra186_mc_context:
72 .rept TEGRA186_MC_CTX_SIZE
Varun Wadekar93bed2a2016-03-18 13:07:33 -070073 .quad 0
74 .endr
75 .size __tegra186_cpu_reset_handler_data, \
76 . - __tegra186_cpu_reset_handler_data
77
78 .align 4
79 .globl __tegra186_cpu_reset_handler_end
80__tegra186_cpu_reset_handler_end:
Varun Wadekar8304fc82017-10-25 11:52:07 -070081
82 .globl tegra186_get_cpu_reset_handler_size
83 .globl tegra186_get_cpu_reset_handler_base
Pritesh Raithatha75c94432018-08-03 15:48:15 +053084 .globl tegra186_get_mc_ctx_offset
Varun Wadekar8304fc82017-10-25 11:52:07 -070085
86/* return size of the CPU reset handler */
87func tegra186_get_cpu_reset_handler_size
88 adr x0, __tegra186_cpu_reset_handler_end
89 adr x1, tegra186_cpu_reset_handler
90 sub x0, x0, x1
91 ret
92endfunc tegra186_get_cpu_reset_handler_size
93
94/* return the start address of the CPU reset handler */
95func tegra186_get_cpu_reset_handler_base
96 adr x0, tegra186_cpu_reset_handler
97 ret
98endfunc tegra186_get_cpu_reset_handler_base
Varun Wadekarfa887672017-11-08 14:45:08 -080099
Pritesh Raithatha75c94432018-08-03 15:48:15 +0530100/* return the size of the MC context */
101func tegra186_get_mc_ctx_offset
102 adr x0, __tegra186_mc_context
Varun Wadekarfa887672017-11-08 14:45:08 -0800103 adr x1, tegra186_cpu_reset_handler
104 sub x0, x0, x1
105 ret
Pritesh Raithatha75c94432018-08-03 15:48:15 +0530106endfunc tegra186_get_mc_ctx_offset