1*1bb92983SJerome Forissier/* SPDX-License-Identifier: BSD-2-Clause */ 257f3d625Syanyan-wrs/* 357f3d625Syanyan-wrs * Copyright (c) 2014, STMicroelectronics International N.V. 457f3d625Syanyan-wrs * All rights reserved. 557f3d625Syanyan-wrs * Copyright (c) 2016, Wind River Systems. 657f3d625Syanyan-wrs * All rights reserved. 757f3d625Syanyan-wrs * 857f3d625Syanyan-wrs * Redistribution and use in source and binary forms, with or without 957f3d625Syanyan-wrs * modification, are permitted provided that the following conditions are met: 1057f3d625Syanyan-wrs * 1157f3d625Syanyan-wrs * 1. Redistributions of source code must retain the above copyright notice, 1257f3d625Syanyan-wrs * this list of conditions and the following disclaimer. 1357f3d625Syanyan-wrs * 1457f3d625Syanyan-wrs * 2. Redistributions in binary form must reproduce the above copyright notice, 1557f3d625Syanyan-wrs * this list of conditions and the following disclaimer in the documentation 1657f3d625Syanyan-wrs * and/or other materials provided with the distribution. 1757f3d625Syanyan-wrs * 1857f3d625Syanyan-wrs * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1957f3d625Syanyan-wrs * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2057f3d625Syanyan-wrs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2157f3d625Syanyan-wrs * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 2257f3d625Syanyan-wrs * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2357f3d625Syanyan-wrs * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2457f3d625Syanyan-wrs * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2557f3d625Syanyan-wrs * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2657f3d625Syanyan-wrs * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2757f3d625Syanyan-wrs * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2857f3d625Syanyan-wrs * POSSIBILITY OF SUCH DAMAGE. 2957f3d625Syanyan-wrs */ 3057f3d625Syanyan-wrs 3157f3d625Syanyan-wrs/* 3257f3d625Syanyan-wrs * Entry points for the A9 inits, A9 revision specific or not. 3357f3d625Syanyan-wrs * It is assume no stack is available when these routines are called. 3457f3d625Syanyan-wrs * It is assume each routine is called with return address in LR 3557f3d625Syanyan-wrs * and with ARM registers R0, R1, R2, R3 being scratchable. 3657f3d625Syanyan-wrs */ 3757f3d625Syanyan-wrs 3857f3d625Syanyan-wrs#include <arm32.h> 3957f3d625Syanyan-wrs#include <arm32_macros.S> 4057f3d625Syanyan-wrs#include <arm32_macros_cortex_a9.S> 4157f3d625Syanyan-wrs#include <asm.S> 4257f3d625Syanyan-wrs#include <kernel/tz_ssvce_def.h> 4357f3d625Syanyan-wrs#include <platform_config.h> 4457f3d625Syanyan-wrs 4557f3d625Syanyan-wrs#define ZYNQ_SLCR_L2C_RAM 0xF8000A1C 4657f3d625Syanyan-wrs 4757f3d625Syanyan-wrs.section .text 4857f3d625Syanyan-wrs.balign 4 4957f3d625Syanyan-wrs.code 32 5057f3d625Syanyan-wrs 5157f3d625Syanyan-wrs/* 5257f3d625Syanyan-wrs * Cortex A9 early configuration 5357f3d625Syanyan-wrs * 5457f3d625Syanyan-wrs * Use registers R0-R3. 5557f3d625Syanyan-wrs * No stack usage. 5657f3d625Syanyan-wrs * LR store return address. 5757f3d625Syanyan-wrs * Trap CPU in case of error. 5857f3d625Syanyan-wrs */ 5957f3d625Syanyan-wrsFUNC plat_cpu_reset_early , : 6057f3d625Syanyan-wrs /* 6157f3d625Syanyan-wrs * Disallow NSec to mask FIQ [bit4: FW=0] 6257f3d625Syanyan-wrs * Allow NSec to manage Imprecise Abort [bit5: AW=1] 6357f3d625Syanyan-wrs * Imprecise Abort trapped to Abort Mode [bit3: EA=0] 6457f3d625Syanyan-wrs * In Sec world, FIQ trapped to FIQ Mode [bit2: FIQ=0] 6557f3d625Syanyan-wrs * IRQ always trapped to IRQ Mode [bit1: IRQ=0] 6657f3d625Syanyan-wrs * Secure World [bit0: NS=0] 6757f3d625Syanyan-wrs */ 6857f3d625Syanyan-wrs mov r0, #SCR_AW 6957f3d625Syanyan-wrs write_scr r0 /* write Secure Configuration Register */ 7057f3d625Syanyan-wrs 7157f3d625Syanyan-wrs /* 7257f3d625Syanyan-wrs * Mandated HW config loaded 7357f3d625Syanyan-wrs * 7457f3d625Syanyan-wrs * SCTLR = 0x00004000 7557f3d625Syanyan-wrs * - Round-Robin replac. for icache, btac, i/duTLB (bit14: RoundRobin) 7657f3d625Syanyan-wrs * 7757f3d625Syanyan-wrs * ACTRL = 0x00000041 7857f3d625Syanyan-wrs * - core always in full SMP (FW bit0=1, SMP bit6=1) 7957f3d625Syanyan-wrs * - L2 write full line of zero disabled (bit3=0) 8057f3d625Syanyan-wrs * (keep WFLZ low. Will be set once outer L2 is ready) 8157f3d625Syanyan-wrs * 8257f3d625Syanyan-wrs * NSACR = 0x00020C00 8357f3d625Syanyan-wrs * - NSec cannot change ACTRL.SMP (NS_SMP bit18=0) 8457f3d625Syanyan-wrs * - Nsec can lockdown TLB (TL bit17=1) 8557f3d625Syanyan-wrs * - NSec cannot access PLE (PLE bit16=0) 8657f3d625Syanyan-wrs * - NSec can use SIMD/VFP (CP10/CP11) (bit15:14=2b00, bit11:10=2b11) 8757f3d625Syanyan-wrs * 8857f3d625Syanyan-wrs * PCR = 0x00000001 8957f3d625Syanyan-wrs * - no change latency, enable clk gating 9057f3d625Syanyan-wrs */ 91234b9045SEtienne Carriere mov_imm r0, 0x00004000 9257f3d625Syanyan-wrs write_sctlr r0 9357f3d625Syanyan-wrs 94234b9045SEtienne Carriere mov_imm r0, 0x00000041 9557f3d625Syanyan-wrs write_actlr r0 9657f3d625Syanyan-wrs 97a0c170d0SEtienne Carriere mov_imm r0, 0x00020C00 9857f3d625Syanyan-wrs write_nsacr r0 9957f3d625Syanyan-wrs 100234b9045SEtienne Carriere mov_imm r0, 0x00000001 10157f3d625Syanyan-wrs write_pcr r0 10257f3d625Syanyan-wrs 10357f3d625Syanyan-wrs mov pc, lr 10457f3d625Syanyan-wrsEND_FUNC plat_cpu_reset_early 105