2 * Copyright (C) 2014, NVIDIA
3 * Copyright (C) 2015, Siemens AG
6 * Thierry Reding <treding@nvidia.com>
7 * Jan Kiszka <jan.kiszka@siemens.com>
9 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/linkage.h>
13 #include <asm/macro.h>
16 .pushsection ._secure.text, "ax"
19 #define TEGRA_SB_CSR_0 0x6000c200
20 #define NS_RST_VEC_WR_DIS (1 << 1)
22 #define TEGRA_RESET_EXCEPTION_VECTOR 0x6000f100
24 #define TEGRA_FLOW_CTRL_BASE 0x60007000
25 #define FLOW_CTRL_CPU_CSR 0x08
26 #define CSR_ENABLE (1 << 0)
27 #define CSR_IMMEDIATE_WAKE (1 << 3)
28 #define CSR_WAIT_WFI_SHIFT 8
29 #define FLOW_CTRL_CPU1_CSR 0x18
31 @ converts CPU ID into FLOW_CTRL_CPUn_CSR offset
32 .macro get_csr_reg cpu, ofs, tmp
34 lsl \tmp, \cpu, #3 @ multiple by 8 (register offset CPU1-3)
35 moveq \ofs, #FLOW_CTRL_CPU_CSR
36 addne \ofs, \tmp, #FLOW_CTRL_CPU1_CSR - 8
42 mrc p15, 0, r5, c1, c1, 0 @ Read SCR
43 bic r5, r5, #1 @ Secure mode
44 mcr p15, 0, r5, c1, c1, 0 @ Write SCR
47 @ lock reset vector for non-secure
48 ldr r4, =TEGRA_SB_CSR_0
50 orr r5, r5, #NS_RST_VEC_WR_DIS
53 bl psci_get_cpu_id @ CPU ID => r0
55 adr r5, _sys_clock_freq
58 mrceq p15, 0, r7, c14, c0, 0 @ read CNTFRQ from CPU0
62 mcrne p15, 0, r7, c14, c0, 0 @ write CNTFRQ to CPU1..3
65 ENDPROC(psci_arch_init)
71 bl psci_cpu_off_common
73 bl psci_get_cpu_id @ CPU ID => r0
75 get_csr_reg r0, r2, r3
77 ldr r6, =TEGRA_FLOW_CTRL_BASE
79 mov r4, #(1 << CSR_WAIT_WFI_SHIFT)
93 bl psci_save_target_pc @ store target PC
96 ldr r6, =TEGRA_RESET_EXCEPTION_VECTOR
97 ldr r5, =psci_cpu_entry
100 get_csr_reg r1, r2, r3
102 ldr r6, =TEGRA_FLOW_CTRL_BASE
103 mov r5, #(CSR_IMMEDIATE_WAKE | CSR_ENABLE)
106 mov r0, #ARM_PSCI_RET_SUCCESS @ Return PSCI_RET_SUCCESS