1*91f16700Schasinglulu/* 2*91f16700Schasinglulu * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu#include <platform_def.h> 8*91f16700Schasinglulu 9*91f16700Schasinglulu#include <arch.h> 10*91f16700Schasinglulu#include <asm_macros.S> 11*91f16700Schasinglulu#include <common/bl_common.h> 12*91f16700Schasinglulu#include <cortex_a53.h> 13*91f16700Schasinglulu#include <cortex_a72.h> 14*91f16700Schasinglulu#include <plat_private.h> 15*91f16700Schasinglulu#include <plat_pmu_macros.S> 16*91f16700Schasinglulu 17*91f16700Schasinglulu .globl cpuson_entry_point 18*91f16700Schasinglulu .globl cpuson_flags 19*91f16700Schasinglulu .globl platform_cpu_warmboot 20*91f16700Schasinglulu .globl plat_secondary_cold_boot_setup 21*91f16700Schasinglulu .globl plat_report_exception 22*91f16700Schasinglulu .globl plat_is_my_cpu_primary 23*91f16700Schasinglulu .globl plat_my_core_pos 24*91f16700Schasinglulu .globl plat_reset_handler 25*91f16700Schasinglulu .globl plat_panic_handler 26*91f16700Schasinglulu 27*91f16700Schasinglulu /* 28*91f16700Schasinglulu * void plat_reset_handler(void); 29*91f16700Schasinglulu * 30*91f16700Schasinglulu * Determine the SOC type and call the appropriate reset 31*91f16700Schasinglulu * handler. 32*91f16700Schasinglulu * 33*91f16700Schasinglulu */ 34*91f16700Schasinglulufunc plat_reset_handler 35*91f16700Schasinglulu mrs x0, midr_el1 36*91f16700Schasinglulu ubfx x0, x0, MIDR_PN_SHIFT, #12 37*91f16700Schasinglulu cmp w0, #((CORTEX_A72_MIDR >> MIDR_PN_SHIFT) & MIDR_PN_MASK) 38*91f16700Schasinglulu b.eq handler_a72 39*91f16700Schasinglulu b handler_end 40*91f16700Schasingluluhandler_a72: 41*91f16700Schasinglulu /* 42*91f16700Schasinglulu * This handler does the following: 43*91f16700Schasinglulu * Set the L2 Data RAM latency for Cortex-A72. 44*91f16700Schasinglulu * Set the L2 Tag RAM latency to for Cortex-A72. 45*91f16700Schasinglulu */ 46*91f16700Schasinglulu mov x0, #((5 << CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT) | \ 47*91f16700Schasinglulu (0x1 << 5)) 48*91f16700Schasinglulu msr CORTEX_A72_L2CTLR_EL1, x0 49*91f16700Schasinglulu isb 50*91f16700Schasingluluhandler_end: 51*91f16700Schasinglulu ret 52*91f16700Schasingluluendfunc plat_reset_handler 53*91f16700Schasinglulu 54*91f16700Schasinglulufunc plat_my_core_pos 55*91f16700Schasinglulu mrs x0, mpidr_el1 56*91f16700Schasinglulu and x1, x0, #MPIDR_CPU_MASK 57*91f16700Schasinglulu and x0, x0, #MPIDR_CLUSTER_MASK 58*91f16700Schasinglulu add x0, x1, x0, LSR #PLAT_RK_CLST_TO_CPUID_SHIFT 59*91f16700Schasinglulu ret 60*91f16700Schasingluluendfunc plat_my_core_pos 61*91f16700Schasinglulu 62*91f16700Schasinglulu /* -------------------------------------------------------------------- 63*91f16700Schasinglulu * void plat_secondary_cold_boot_setup (void); 64*91f16700Schasinglulu * 65*91f16700Schasinglulu * This function performs any platform specific actions 66*91f16700Schasinglulu * needed for a secondary cpu after a cold reset e.g 67*91f16700Schasinglulu * mark the cpu's presence, mechanism to place it in a 68*91f16700Schasinglulu * holding pen etc. 69*91f16700Schasinglulu * -------------------------------------------------------------------- 70*91f16700Schasinglulu */ 71*91f16700Schasinglulufunc plat_secondary_cold_boot_setup 72*91f16700Schasinglulu /* rk3368 does not do cold boot for secondary CPU */ 73*91f16700Schasinglulucb_panic: 74*91f16700Schasinglulu b cb_panic 75*91f16700Schasingluluendfunc plat_secondary_cold_boot_setup 76*91f16700Schasinglulu 77*91f16700Schasinglulufunc plat_is_my_cpu_primary 78*91f16700Schasinglulu mrs x0, mpidr_el1 79*91f16700Schasinglulu and x0, x0, #(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK) 80*91f16700Schasinglulu cmp x0, #PLAT_RK_PRIMARY_CPU 81*91f16700Schasinglulu cset x0, eq 82*91f16700Schasinglulu ret 83*91f16700Schasingluluendfunc plat_is_my_cpu_primary 84*91f16700Schasinglulu 85*91f16700Schasinglulu /* -------------------------------------------------------------------- 86*91f16700Schasinglulu * void plat_panic_handler(void) 87*91f16700Schasinglulu * Call system reset function on panic. Set up an emergency stack so we 88*91f16700Schasinglulu * can run C functions (it only needs to last for a few calls until we 89*91f16700Schasinglulu * reboot anyway). 90*91f16700Schasinglulu * -------------------------------------------------------------------- 91*91f16700Schasinglulu */ 92*91f16700Schasinglulufunc plat_panic_handler 93*91f16700Schasinglulu msr spsel, #0 94*91f16700Schasinglulu bl plat_set_my_stack 95*91f16700Schasinglulu b rockchip_soc_soft_reset 96*91f16700Schasingluluendfunc plat_panic_handler 97*91f16700Schasinglulu 98*91f16700Schasinglulu /* -------------------------------------------------------------------- 99*91f16700Schasinglulu * void platform_cpu_warmboot (void); 100*91f16700Schasinglulu * cpus online or resume enterpoint 101*91f16700Schasinglulu * -------------------------------------------------------------------- 102*91f16700Schasinglulu */ 103*91f16700Schasinglulufunc platform_cpu_warmboot _align=16 104*91f16700Schasinglulu mrs x0, MPIDR_EL1 105*91f16700Schasinglulu and x19, x0, #MPIDR_CPU_MASK 106*91f16700Schasinglulu and x20, x0, #MPIDR_CLUSTER_MASK 107*91f16700Schasinglulu mov x0, x20 108*91f16700Schasinglulu func_rockchip_clst_warmboot 109*91f16700Schasinglulu /* -------------------------------------------------------------------- 110*91f16700Schasinglulu * big cluster id is 1 111*91f16700Schasinglulu * big cores id is from 0-3, little cores id 4-7 112*91f16700Schasinglulu * -------------------------------------------------------------------- 113*91f16700Schasinglulu */ 114*91f16700Schasinglulu add x21, x19, x20, lsr #PLAT_RK_CLST_TO_CPUID_SHIFT 115*91f16700Schasinglulu /* -------------------------------------------------------------------- 116*91f16700Schasinglulu * get per cpuup flag 117*91f16700Schasinglulu * -------------------------------------------------------------------- 118*91f16700Schasinglulu */ 119*91f16700Schasinglulu adr x4, cpuson_flags 120*91f16700Schasinglulu add x4, x4, x21, lsl #2 121*91f16700Schasinglulu ldr w1, [x4] 122*91f16700Schasinglulu /* -------------------------------------------------------------------- 123*91f16700Schasinglulu * check cpuon reason 124*91f16700Schasinglulu * -------------------------------------------------------------------- 125*91f16700Schasinglulu */ 126*91f16700Schasinglulu cmp w1, PMU_CPU_AUTO_PWRDN 127*91f16700Schasinglulu b.eq boot_entry 128*91f16700Schasinglulu cmp w1, PMU_CPU_HOTPLUG 129*91f16700Schasinglulu b.eq boot_entry 130*91f16700Schasinglulu /* -------------------------------------------------------------------- 131*91f16700Schasinglulu * If the boot core cpuson_flags or cpuson_entry_point is not 132*91f16700Schasinglulu * expection. force the core into wfe. 133*91f16700Schasinglulu * -------------------------------------------------------------------- 134*91f16700Schasinglulu */ 135*91f16700Schasingluluwfe_loop: 136*91f16700Schasinglulu wfe 137*91f16700Schasinglulu b wfe_loop 138*91f16700Schasingluluboot_entry: 139*91f16700Schasinglulu str wzr, [x4] 140*91f16700Schasinglulu /* -------------------------------------------------------------------- 141*91f16700Schasinglulu * get per cpuup boot addr 142*91f16700Schasinglulu * -------------------------------------------------------------------- 143*91f16700Schasinglulu */ 144*91f16700Schasinglulu adr x5, cpuson_entry_point 145*91f16700Schasinglulu ldr x2, [x5, x21, lsl #3] 146*91f16700Schasinglulu br x2 147*91f16700Schasingluluendfunc platform_cpu_warmboot 148*91f16700Schasinglulu 149*91f16700Schasinglulu /* -------------------------------------------------------------------- 150*91f16700Schasinglulu * Per-CPU Secure entry point - resume or power up 151*91f16700Schasinglulu * -------------------------------------------------------------------- 152*91f16700Schasinglulu */ 153*91f16700Schasinglulu .section .tzfw_coherent_mem, "a" 154*91f16700Schasinglulu .align 3 155*91f16700Schasinglulucpuson_entry_point: 156*91f16700Schasinglulu .rept PLATFORM_CORE_COUNT 157*91f16700Schasinglulu .quad 0 158*91f16700Schasinglulu .endr 159*91f16700Schasinglulucpuson_flags: 160*91f16700Schasinglulu .rept PLATFORM_CORE_COUNT 161*91f16700Schasinglulu .word 0 162*91f16700Schasinglulu .endr 163*91f16700Schasinglulurockchip_clst_warmboot_data 164