1*91f16700Schasinglulu/* 2*91f16700Schasinglulu * Copyright (C) 2018 Marvell International Ltd. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu * https://spdx.org/licenses 6*91f16700Schasinglulu */ 7*91f16700Schasinglulu 8*91f16700Schasinglulu#ifndef MARVELL_MACROS_S 9*91f16700Schasinglulu#define MARVELL_MACROS_S 10*91f16700Schasinglulu 11*91f16700Schasinglulu#include <drivers/arm/cci.h> 12*91f16700Schasinglulu#include <drivers/arm/gic_common.h> 13*91f16700Schasinglulu#include <drivers/arm/gicv2.h> 14*91f16700Schasinglulu#include <drivers/arm/gicv3.h> 15*91f16700Schasinglulu#include <platform_def.h> 16*91f16700Schasinglulu 17*91f16700Schasinglulu/* 18*91f16700Schasinglulu * These Macros are required by ATF 19*91f16700Schasinglulu */ 20*91f16700Schasinglulu 21*91f16700Schasinglulu.section .rodata.gic_reg_name, "aS" 22*91f16700Schasinglulu/* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */ 23*91f16700Schasinglulugicc_regs: 24*91f16700Schasinglulu .asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", "" 25*91f16700Schasinglulu 26*91f16700Schasinglulu#ifdef USE_CCI 27*91f16700Schasinglulu/* Applicable only to GICv3 with SRE enabled */ 28*91f16700Schasingluluicc_regs: 29*91f16700Schasinglulu .asciz "icc_hppir0_el1", "icc_hppir1_el1", "icc_ctlr_el3", "" 30*91f16700Schasinglulu#endif 31*91f16700Schasinglulu/* Registers common to both GICv2 and GICv3 */ 32*91f16700Schasinglulugicd_pend_reg: 33*91f16700Schasinglulu .asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n" \ 34*91f16700Schasinglulu " Offset:\t\t\tvalue\n" 35*91f16700Schasinglulunewline: 36*91f16700Schasinglulu .asciz "\n" 37*91f16700Schasingluluspacer: 38*91f16700Schasinglulu .asciz ":\t\t0x" 39*91f16700Schasinglulu 40*91f16700Schasinglulu /* --------------------------------------------- 41*91f16700Schasinglulu * The below utility macro prints out relevant GIC 42*91f16700Schasinglulu * registers whenever an unhandled exception is 43*91f16700Schasinglulu * taken in BL31 on ARM standard platforms. 44*91f16700Schasinglulu * Expects: GICD base in x16, GICC base in x17 45*91f16700Schasinglulu * Clobbers: x0 - x10, sp 46*91f16700Schasinglulu * --------------------------------------------- 47*91f16700Schasinglulu */ 48*91f16700Schasinglulu .macro marvell_print_gic_regs 49*91f16700Schasinglulu /* Check for GICv3 system register access */ 50*91f16700Schasinglulu mrs x7, id_aa64pfr0_el1 51*91f16700Schasinglulu ubfx x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH 52*91f16700Schasinglulu cmp x7, #1 53*91f16700Schasinglulu b.ne print_gicv2 54*91f16700Schasinglulu 55*91f16700Schasinglulu /* Check for SRE enable */ 56*91f16700Schasinglulu mrs x8, ICC_SRE_EL3 57*91f16700Schasinglulu tst x8, #ICC_SRE_SRE_BIT 58*91f16700Schasinglulu b.eq print_gicv2 59*91f16700Schasinglulu 60*91f16700Schasinglulu#ifdef USE_CCI 61*91f16700Schasinglulu /* Load the icc reg list to x6 */ 62*91f16700Schasinglulu adr x6, icc_regs 63*91f16700Schasinglulu /* Load the icc regs to gp regs used by str_in_crash_buf_print */ 64*91f16700Schasinglulu mrs x8, ICC_HPPIR0_EL1 65*91f16700Schasinglulu mrs x9, ICC_HPPIR1_EL1 66*91f16700Schasinglulu mrs x10, ICC_CTLR_EL3 67*91f16700Schasinglulu /* Store to the crash buf and print to console */ 68*91f16700Schasinglulu bl str_in_crash_buf_print 69*91f16700Schasinglulu#endif 70*91f16700Schasinglulu b print_gic_common 71*91f16700Schasinglulu 72*91f16700Schasingluluprint_gicv2: 73*91f16700Schasinglulu /* Load the gicc reg list to x6 */ 74*91f16700Schasinglulu adr x6, gicc_regs 75*91f16700Schasinglulu /* Load the gicc regs to gp regs used by str_in_crash_buf_print */ 76*91f16700Schasinglulu ldr w8, [x17, #GICC_HPPIR] 77*91f16700Schasinglulu ldr w9, [x17, #GICC_AHPPIR] 78*91f16700Schasinglulu ldr w10, [x17, #GICC_CTLR] 79*91f16700Schasinglulu /* Store to the crash buf and print to console */ 80*91f16700Schasinglulu bl str_in_crash_buf_print 81*91f16700Schasinglulu 82*91f16700Schasingluluprint_gic_common: 83*91f16700Schasinglulu /* Print the GICD_ISPENDR regs */ 84*91f16700Schasinglulu add x7, x16, #GICD_ISPENDR 85*91f16700Schasinglulu adr x4, gicd_pend_reg 86*91f16700Schasinglulu bl asm_print_str 87*91f16700Schasinglulugicd_ispendr_loop: 88*91f16700Schasinglulu sub x4, x7, x16 89*91f16700Schasinglulu cmp x4, #0x280 90*91f16700Schasinglulu b.eq exit_print_gic_regs 91*91f16700Schasinglulu bl asm_print_hex 92*91f16700Schasinglulu 93*91f16700Schasinglulu adr x4, spacer 94*91f16700Schasinglulu bl asm_print_str 95*91f16700Schasinglulu 96*91f16700Schasinglulu ldr x4, [x7], #8 97*91f16700Schasinglulu bl asm_print_hex 98*91f16700Schasinglulu 99*91f16700Schasinglulu adr x4, newline 100*91f16700Schasinglulu bl asm_print_str 101*91f16700Schasinglulu b gicd_ispendr_loop 102*91f16700Schasingluluexit_print_gic_regs: 103*91f16700Schasinglulu .endm 104*91f16700Schasinglulu 105*91f16700Schasinglulu 106*91f16700Schasinglulu.section .rodata.cci_reg_name, "aS" 107*91f16700Schasinglulucci_iface_regs: 108*91f16700Schasinglulu .asciz "cci_snoop_ctrl_cluster0", "cci_snoop_ctrl_cluster1" , "" 109*91f16700Schasinglulu 110*91f16700Schasinglulu /* ------------------------------------------------ 111*91f16700Schasinglulu * The below required platform porting macro prints 112*91f16700Schasinglulu * out relevant interconnect registers whenever an 113*91f16700Schasinglulu * unhandled exception is taken in BL31. 114*91f16700Schasinglulu * Clobbers: x0 - x9, sp 115*91f16700Schasinglulu * ------------------------------------------------ 116*91f16700Schasinglulu */ 117*91f16700Schasinglulu .macro print_cci_regs 118*91f16700Schasinglulu#ifdef USE_CCI 119*91f16700Schasinglulu adr x6, cci_iface_regs 120*91f16700Schasinglulu /* Store in x7 the base address of the first interface */ 121*91f16700Schasinglulu mov_imm x7, (PLAT_MARVELL_CCI_BASE + SLAVE_IFACE_OFFSET( \ 122*91f16700Schasinglulu PLAT_MARVELL_CCI_CLUSTER0_SL_IFACE_IX)) 123*91f16700Schasinglulu ldr w8, [x7, #SNOOP_CTRL_REG] 124*91f16700Schasinglulu /* Store in x7 the base address of the second interface */ 125*91f16700Schasinglulu mov_imm x7, (PLAT_MARVELL_CCI_BASE + SLAVE_IFACE_OFFSET( \ 126*91f16700Schasinglulu PLAT_MARVELL_CCI_CLUSTER1_SL_IFACE_IX)) 127*91f16700Schasinglulu ldr w9, [x7, #SNOOP_CTRL_REG] 128*91f16700Schasinglulu /* Store to the crash buf and print to console */ 129*91f16700Schasinglulu bl str_in_crash_buf_print 130*91f16700Schasinglulu#endif 131*91f16700Schasinglulu .endm 132*91f16700Schasinglulu 133*91f16700Schasinglulu 134*91f16700Schasinglulu#endif /* MARVELL_MACROS_S */ 135