| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012, NVIDIA Corporation. All rights reserved. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 5 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 6 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 11 | | - * more details. |
|---|
| 12 | | - * |
|---|
| 13 | | - * You should have received a copy of the GNU General Public License |
|---|
| 14 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | |
|---|
| 17 | 6 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 20 | 9 | #include <soc/tegra/flowctrl.h> |
|---|
| 21 | 10 | #include <soc/tegra/fuse.h> |
|---|
| 22 | 11 | |
|---|
| 12 | +#include <asm/assembler.h> |
|---|
| 23 | 13 | #include <asm/asm-offsets.h> |
|---|
| 24 | 14 | #include <asm/cache.h> |
|---|
| 25 | 15 | |
|---|
| .. | .. |
|---|
| 28 | 18 | #include "sleep.h" |
|---|
| 29 | 19 | |
|---|
| 30 | 20 | #define PMC_SCRATCH41 0x140 |
|---|
| 31 | | - |
|---|
| 32 | | -#define RESET_DATA(x) ((TEGRA_RESET_##x)*4) |
|---|
| 33 | 21 | |
|---|
| 34 | 22 | #ifdef CONFIG_PM_SLEEP |
|---|
| 35 | 23 | /* |
|---|
| .. | .. |
|---|
| 78 | 66 | orr r1, r1, #1 |
|---|
| 79 | 67 | str r1, [r0] |
|---|
| 80 | 68 | #endif |
|---|
| 69 | + bl tegra_resume_trusted_foundations |
|---|
| 81 | 70 | |
|---|
| 82 | 71 | #ifdef CONFIG_CACHE_L2X0 |
|---|
| 83 | 72 | /* L2 cache resume & re-enable */ |
|---|
| .. | .. |
|---|
| 90 | 79 | |
|---|
| 91 | 80 | b cpu_resume |
|---|
| 92 | 81 | ENDPROC(tegra_resume) |
|---|
| 82 | + |
|---|
| 83 | +/* |
|---|
| 84 | + * tegra_resume_trusted_foundations |
|---|
| 85 | + * |
|---|
| 86 | + * Trusted Foundations firmware initialization. |
|---|
| 87 | + * |
|---|
| 88 | + * Doesn't return if firmware presents. |
|---|
| 89 | + * Corrupted registers: r1, r2 |
|---|
| 90 | + */ |
|---|
| 91 | +ENTRY(tegra_resume_trusted_foundations) |
|---|
| 92 | + /* Check whether Trusted Foundations firmware presents. */ |
|---|
| 93 | + mov32 r2, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET |
|---|
| 94 | + ldr r1, =__tegra_cpu_reset_handler_data_offset + \ |
|---|
| 95 | + RESET_DATA(TF_PRESENT) |
|---|
| 96 | + ldr r1, [r2, r1] |
|---|
| 97 | + cmp r1, #0 |
|---|
| 98 | + reteq lr |
|---|
| 99 | + |
|---|
| 100 | + .arch_extension sec |
|---|
| 101 | + /* |
|---|
| 102 | + * First call after suspend wakes firmware. No arguments required |
|---|
| 103 | + * for some firmware versions. Downstream kernel of ASUS TF300T uses |
|---|
| 104 | + * r0=3 for the wake-up notification. |
|---|
| 105 | + */ |
|---|
| 106 | + mov r0, #3 |
|---|
| 107 | + smc #0 |
|---|
| 108 | + |
|---|
| 109 | + b cpu_resume |
|---|
| 110 | +ENDPROC(tegra_resume_trusted_foundations) |
|---|
| 93 | 111 | #endif |
|---|
| 94 | 112 | |
|---|
| 95 | 113 | .align L1_CACHE_SHIFT |
|---|
| .. | .. |
|---|
| 115 | 133 | * must be position-independent. |
|---|
| 116 | 134 | */ |
|---|
| 117 | 135 | |
|---|
| 136 | + .arm |
|---|
| 118 | 137 | .align L1_CACHE_SHIFT |
|---|
| 119 | 138 | ENTRY(__tegra_cpu_reset_handler) |
|---|
| 120 | 139 | |
|---|
| 121 | 140 | cpsid aif, 0x13 @ SVC mode, interrupts disabled |
|---|
| 122 | 141 | |
|---|
| 123 | 142 | tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 |
|---|
| 143 | + |
|---|
| 144 | + adr r12, __tegra_cpu_reset_handler_data |
|---|
| 145 | + ldr r5, [r12, #RESET_DATA(TF_PRESENT)] |
|---|
| 146 | + cmp r5, #0 |
|---|
| 147 | + bne after_errata |
|---|
| 148 | + |
|---|
| 124 | 149 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC |
|---|
| 125 | 150 | t20_check: |
|---|
| 126 | 151 | cmp r6, #TEGRA20 |
|---|
| .. | .. |
|---|
| 155 | 180 | and r10, r10, #0x3 @ R10 = CPU number |
|---|
| 156 | 181 | mov r11, #1 |
|---|
| 157 | 182 | mov r11, r11, lsl r10 @ R11 = CPU mask |
|---|
| 158 | | - adr r12, __tegra_cpu_reset_handler_data |
|---|
| 159 | 183 | |
|---|
| 160 | 184 | #ifdef CONFIG_SMP |
|---|
| 161 | 185 | /* Does the OS know about this CPU? */ |
|---|
| 162 | 186 | ldr r7, [r12, #RESET_DATA(MASK_PRESENT)] |
|---|
| 163 | 187 | tst r7, r11 @ if !present |
|---|
| 164 | 188 | bleq __die @ CPU not present (to OS) |
|---|
| 165 | | -#endif |
|---|
| 166 | | - |
|---|
| 167 | | -#ifdef CONFIG_ARCH_TEGRA_2x_SOC |
|---|
| 168 | | - /* Are we on Tegra20? */ |
|---|
| 169 | | - cmp r6, #TEGRA20 |
|---|
| 170 | | - bne 1f |
|---|
| 171 | | - /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */ |
|---|
| 172 | | - mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET |
|---|
| 173 | | - mov r0, #CPU_NOT_RESETTABLE |
|---|
| 174 | | - cmp r10, #0 |
|---|
| 175 | | - strneb r0, [r5, #__tegra20_cpu1_resettable_status_offset] |
|---|
| 176 | | -1: |
|---|
| 177 | 189 | #endif |
|---|
| 178 | 190 | |
|---|
| 179 | 191 | /* Waking up from LP1? */ |
|---|
| .. | .. |
|---|
| 277 | 289 | .align L1_CACHE_SHIFT |
|---|
| 278 | 290 | .type __tegra_cpu_reset_handler_data, %object |
|---|
| 279 | 291 | .globl __tegra_cpu_reset_handler_data |
|---|
| 280 | | -__tegra_cpu_reset_handler_data: |
|---|
| 281 | | - .rept TEGRA_RESET_DATA_SIZE |
|---|
| 282 | | - .long 0 |
|---|
| 283 | | - .endr |
|---|
| 284 | | - .globl __tegra20_cpu1_resettable_status_offset |
|---|
| 285 | | - .equ __tegra20_cpu1_resettable_status_offset, \ |
|---|
| 292 | + .globl __tegra_cpu_reset_handler_data_offset |
|---|
| 293 | + .equ __tegra_cpu_reset_handler_data_offset, \ |
|---|
| 286 | 294 | . - __tegra_cpu_reset_handler_start |
|---|
| 287 | | - .byte 0 |
|---|
| 295 | +__tegra_cpu_reset_handler_data: |
|---|
| 296 | + .rept TEGRA_RESET_DATA_SIZE |
|---|
| 297 | + .long 0 |
|---|
| 298 | + .endr |
|---|
| 288 | 299 | .align L1_CACHE_SHIFT |
|---|
| 289 | 300 | |
|---|
| 290 | 301 | ENTRY(__tegra_cpu_reset_handler_end) |
|---|