1*464ce2bbSSoby Mathew /* 2*464ce2bbSSoby Mathew * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. 3*464ce2bbSSoby Mathew * 4*464ce2bbSSoby Mathew * Redistribution and use in source and binary forms, with or without 5*464ce2bbSSoby Mathew * modification, are permitted provided that the following conditions are met: 6*464ce2bbSSoby Mathew * 7*464ce2bbSSoby Mathew * Redistributions of source code must retain the above copyright notice, this 8*464ce2bbSSoby Mathew * list of conditions and the following disclaimer. 9*464ce2bbSSoby Mathew * 10*464ce2bbSSoby Mathew * Redistributions in binary form must reproduce the above copyright notice, 11*464ce2bbSSoby Mathew * this list of conditions and the following disclaimer in the documentation 12*464ce2bbSSoby Mathew * and/or other materials provided with the distribution. 13*464ce2bbSSoby Mathew * 14*464ce2bbSSoby Mathew * Neither the name of ARM nor the names of its contributors may be used 15*464ce2bbSSoby Mathew * to endorse or promote products derived from this software without specific 16*464ce2bbSSoby Mathew * prior written permission. 17*464ce2bbSSoby Mathew * 18*464ce2bbSSoby Mathew * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19*464ce2bbSSoby Mathew * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20*464ce2bbSSoby Mathew * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21*464ce2bbSSoby Mathew * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22*464ce2bbSSoby Mathew * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23*464ce2bbSSoby Mathew * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24*464ce2bbSSoby Mathew * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25*464ce2bbSSoby Mathew * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26*464ce2bbSSoby Mathew * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27*464ce2bbSSoby Mathew * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28*464ce2bbSSoby Mathew * POSSIBILITY OF SUCH DAMAGE. 29*464ce2bbSSoby Mathew */ 30*464ce2bbSSoby Mathew 31*464ce2bbSSoby Mathew #ifndef __GICV2_PRIVATE_H__ 32*464ce2bbSSoby Mathew #define __GICV2_PRIVATE_H__ 33*464ce2bbSSoby Mathew 34*464ce2bbSSoby Mathew #include <gicv2.h> 35*464ce2bbSSoby Mathew #include <mmio.h> 36*464ce2bbSSoby Mathew #include <stdint.h> 37*464ce2bbSSoby Mathew 38*464ce2bbSSoby Mathew /******************************************************************************* 39*464ce2bbSSoby Mathew * Private function prototypes 40*464ce2bbSSoby Mathew ******************************************************************************/ 41*464ce2bbSSoby Mathew void gicv2_spis_configure_defaults(uintptr_t gicd_base); 42*464ce2bbSSoby Mathew void gicv2_secure_spis_configure(uintptr_t gicd_base, 43*464ce2bbSSoby Mathew unsigned int num_ints, 44*464ce2bbSSoby Mathew const unsigned int *sec_intr_list); 45*464ce2bbSSoby Mathew void gicv2_secure_ppi_sgi_setup(uintptr_t gicd_base, 46*464ce2bbSSoby Mathew unsigned int num_ints, 47*464ce2bbSSoby Mathew const unsigned int *sec_intr_list); 48*464ce2bbSSoby Mathew unsigned int gicv2_get_cpuif_id(uintptr_t base); 49*464ce2bbSSoby Mathew 50*464ce2bbSSoby Mathew /******************************************************************************* 51*464ce2bbSSoby Mathew * GIC Distributor interface accessors for reading entire registers 52*464ce2bbSSoby Mathew ******************************************************************************/ 53*464ce2bbSSoby Mathew static inline unsigned int gicd_read_pidr2(uintptr_t base) 54*464ce2bbSSoby Mathew { 55*464ce2bbSSoby Mathew return mmio_read_32(base + GICD_PIDR2_GICV2); 56*464ce2bbSSoby Mathew } 57*464ce2bbSSoby Mathew 58*464ce2bbSSoby Mathew /******************************************************************************* 59*464ce2bbSSoby Mathew * GIC CPU interface accessors for reading entire registers 60*464ce2bbSSoby Mathew ******************************************************************************/ 61*464ce2bbSSoby Mathew 62*464ce2bbSSoby Mathew static inline unsigned int gicc_read_ctlr(uintptr_t base) 63*464ce2bbSSoby Mathew { 64*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_CTLR); 65*464ce2bbSSoby Mathew } 66*464ce2bbSSoby Mathew 67*464ce2bbSSoby Mathew static inline unsigned int gicc_read_pmr(uintptr_t base) 68*464ce2bbSSoby Mathew { 69*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_PMR); 70*464ce2bbSSoby Mathew } 71*464ce2bbSSoby Mathew 72*464ce2bbSSoby Mathew static inline unsigned int gicc_read_BPR(uintptr_t base) 73*464ce2bbSSoby Mathew { 74*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_BPR); 75*464ce2bbSSoby Mathew } 76*464ce2bbSSoby Mathew 77*464ce2bbSSoby Mathew static inline unsigned int gicc_read_IAR(uintptr_t base) 78*464ce2bbSSoby Mathew { 79*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_IAR); 80*464ce2bbSSoby Mathew } 81*464ce2bbSSoby Mathew 82*464ce2bbSSoby Mathew static inline unsigned int gicc_read_EOIR(uintptr_t base) 83*464ce2bbSSoby Mathew { 84*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_EOIR); 85*464ce2bbSSoby Mathew } 86*464ce2bbSSoby Mathew 87*464ce2bbSSoby Mathew static inline unsigned int gicc_read_hppir(uintptr_t base) 88*464ce2bbSSoby Mathew { 89*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_HPPIR); 90*464ce2bbSSoby Mathew } 91*464ce2bbSSoby Mathew 92*464ce2bbSSoby Mathew static inline unsigned int gicc_read_ahppir(uintptr_t base) 93*464ce2bbSSoby Mathew { 94*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_AHPPIR); 95*464ce2bbSSoby Mathew } 96*464ce2bbSSoby Mathew 97*464ce2bbSSoby Mathew static inline unsigned int gicc_read_dir(uintptr_t base) 98*464ce2bbSSoby Mathew { 99*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_DIR); 100*464ce2bbSSoby Mathew } 101*464ce2bbSSoby Mathew 102*464ce2bbSSoby Mathew static inline unsigned int gicc_read_iidr(uintptr_t base) 103*464ce2bbSSoby Mathew { 104*464ce2bbSSoby Mathew return mmio_read_32(base + GICC_IIDR); 105*464ce2bbSSoby Mathew } 106*464ce2bbSSoby Mathew 107*464ce2bbSSoby Mathew /******************************************************************************* 108*464ce2bbSSoby Mathew * GIC CPU interface accessors for writing entire registers 109*464ce2bbSSoby Mathew ******************************************************************************/ 110*464ce2bbSSoby Mathew 111*464ce2bbSSoby Mathew static inline void gicc_write_ctlr(uintptr_t base, unsigned int val) 112*464ce2bbSSoby Mathew { 113*464ce2bbSSoby Mathew mmio_write_32(base + GICC_CTLR, val); 114*464ce2bbSSoby Mathew } 115*464ce2bbSSoby Mathew 116*464ce2bbSSoby Mathew static inline void gicc_write_pmr(uintptr_t base, unsigned int val) 117*464ce2bbSSoby Mathew { 118*464ce2bbSSoby Mathew mmio_write_32(base + GICC_PMR, val); 119*464ce2bbSSoby Mathew } 120*464ce2bbSSoby Mathew 121*464ce2bbSSoby Mathew static inline void gicc_write_BPR(uintptr_t base, unsigned int val) 122*464ce2bbSSoby Mathew { 123*464ce2bbSSoby Mathew mmio_write_32(base + GICC_BPR, val); 124*464ce2bbSSoby Mathew } 125*464ce2bbSSoby Mathew 126*464ce2bbSSoby Mathew 127*464ce2bbSSoby Mathew static inline void gicc_write_IAR(uintptr_t base, unsigned int val) 128*464ce2bbSSoby Mathew { 129*464ce2bbSSoby Mathew mmio_write_32(base + GICC_IAR, val); 130*464ce2bbSSoby Mathew } 131*464ce2bbSSoby Mathew 132*464ce2bbSSoby Mathew static inline void gicc_write_EOIR(uintptr_t base, unsigned int val) 133*464ce2bbSSoby Mathew { 134*464ce2bbSSoby Mathew mmio_write_32(base + GICC_EOIR, val); 135*464ce2bbSSoby Mathew } 136*464ce2bbSSoby Mathew 137*464ce2bbSSoby Mathew static inline void gicc_write_hppir(uintptr_t base, unsigned int val) 138*464ce2bbSSoby Mathew { 139*464ce2bbSSoby Mathew mmio_write_32(base + GICC_HPPIR, val); 140*464ce2bbSSoby Mathew } 141*464ce2bbSSoby Mathew 142*464ce2bbSSoby Mathew static inline void gicc_write_dir(uintptr_t base, unsigned int val) 143*464ce2bbSSoby Mathew { 144*464ce2bbSSoby Mathew mmio_write_32(base + GICC_DIR, val); 145*464ce2bbSSoby Mathew } 146*464ce2bbSSoby Mathew 147*464ce2bbSSoby Mathew #endif /* __GICV2_PRIVATE_H__ */ 148