1464ce2bbSSoby Mathew /*
2eb68ea9bSJeenu Viswambharan * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3464ce2bbSSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5464ce2bbSSoby Mathew */
6464ce2bbSSoby Mathew
7c3cf06f1SAntonio Nino Diaz #ifndef GICV2_PRIVATE_H
8c3cf06f1SAntonio Nino Diaz #define GICV2_PRIVATE_H
9464ce2bbSSoby Mathew
10464ce2bbSSoby Mathew #include <stdint.h>
11464ce2bbSSoby Mathew
12*09d40e0eSAntonio Nino Diaz #include <drivers/arm/gicv2.h>
13*09d40e0eSAntonio Nino Diaz #include <lib/mmio.h>
14*09d40e0eSAntonio Nino Diaz
15464ce2bbSSoby Mathew /*******************************************************************************
16464ce2bbSSoby Mathew * Private function prototypes
17464ce2bbSSoby Mathew ******************************************************************************/
18464ce2bbSSoby Mathew void gicv2_spis_configure_defaults(uintptr_t gicd_base);
19c639e8ebSJeenu Viswambharan void gicv2_secure_spis_configure_props(uintptr_t gicd_base,
20c639e8ebSJeenu Viswambharan const interrupt_prop_t *interrupt_props,
21c639e8ebSJeenu Viswambharan unsigned int interrupt_props_num);
22c639e8ebSJeenu Viswambharan void gicv2_secure_ppi_sgi_setup_props(uintptr_t gicd_base,
23c639e8ebSJeenu Viswambharan const interrupt_prop_t *interrupt_props,
24c639e8ebSJeenu Viswambharan unsigned int interrupt_props_num);
25464ce2bbSSoby Mathew unsigned int gicv2_get_cpuif_id(uintptr_t base);
26464ce2bbSSoby Mathew
27464ce2bbSSoby Mathew /*******************************************************************************
28464ce2bbSSoby Mathew * GIC Distributor interface accessors for reading entire registers
29464ce2bbSSoby Mathew ******************************************************************************/
gicd_read_pidr2(uintptr_t base)30464ce2bbSSoby Mathew static inline unsigned int gicd_read_pidr2(uintptr_t base)
31464ce2bbSSoby Mathew {
32464ce2bbSSoby Mathew return mmio_read_32(base + GICD_PIDR2_GICV2);
33464ce2bbSSoby Mathew }
34464ce2bbSSoby Mathew
35464ce2bbSSoby Mathew /*******************************************************************************
368db978b5SJeenu Viswambharan * GIC Distributor interface accessors for writing entire registers
378db978b5SJeenu Viswambharan ******************************************************************************/
gicd_get_itargetsr(uintptr_t base,unsigned int id)38fc529feeSJeenu Viswambharan static inline unsigned int gicd_get_itargetsr(uintptr_t base, unsigned int id)
39fc529feeSJeenu Viswambharan {
40fc529feeSJeenu Viswambharan return mmio_read_8(base + GICD_ITARGETSR + id);
41fc529feeSJeenu Viswambharan }
42fc529feeSJeenu Viswambharan
gicd_set_itargetsr(uintptr_t base,unsigned int id,unsigned int target)43fc529feeSJeenu Viswambharan static inline void gicd_set_itargetsr(uintptr_t base, unsigned int id,
44fc529feeSJeenu Viswambharan unsigned int target)
45fc529feeSJeenu Viswambharan {
463fea9c8bSAntonio Nino Diaz uint8_t val = target & GIC_TARGET_CPU_MASK;
473fea9c8bSAntonio Nino Diaz
483fea9c8bSAntonio Nino Diaz mmio_write_8(base + GICD_ITARGETSR + id, val);
49fc529feeSJeenu Viswambharan }
50fc529feeSJeenu Viswambharan
gicd_write_sgir(uintptr_t base,unsigned int val)518db978b5SJeenu Viswambharan static inline void gicd_write_sgir(uintptr_t base, unsigned int val)
528db978b5SJeenu Viswambharan {
538db978b5SJeenu Viswambharan mmio_write_32(base + GICD_SGIR, val);
548db978b5SJeenu Viswambharan }
558db978b5SJeenu Viswambharan
568db978b5SJeenu Viswambharan /*******************************************************************************
57464ce2bbSSoby Mathew * GIC CPU interface accessors for reading entire registers
58464ce2bbSSoby Mathew ******************************************************************************/
59464ce2bbSSoby Mathew
gicc_read_ctlr(uintptr_t base)60464ce2bbSSoby Mathew static inline unsigned int gicc_read_ctlr(uintptr_t base)
61464ce2bbSSoby Mathew {
62464ce2bbSSoby Mathew return mmio_read_32(base + GICC_CTLR);
63464ce2bbSSoby Mathew }
64464ce2bbSSoby Mathew
gicc_read_pmr(uintptr_t base)65464ce2bbSSoby Mathew static inline unsigned int gicc_read_pmr(uintptr_t base)
66464ce2bbSSoby Mathew {
67464ce2bbSSoby Mathew return mmio_read_32(base + GICC_PMR);
68464ce2bbSSoby Mathew }
69464ce2bbSSoby Mathew
gicc_read_BPR(uintptr_t base)70464ce2bbSSoby Mathew static inline unsigned int gicc_read_BPR(uintptr_t base)
71464ce2bbSSoby Mathew {
72464ce2bbSSoby Mathew return mmio_read_32(base + GICC_BPR);
73464ce2bbSSoby Mathew }
74464ce2bbSSoby Mathew
gicc_read_IAR(uintptr_t base)75464ce2bbSSoby Mathew static inline unsigned int gicc_read_IAR(uintptr_t base)
76464ce2bbSSoby Mathew {
77464ce2bbSSoby Mathew return mmio_read_32(base + GICC_IAR);
78464ce2bbSSoby Mathew }
79464ce2bbSSoby Mathew
gicc_read_EOIR(uintptr_t base)80464ce2bbSSoby Mathew static inline unsigned int gicc_read_EOIR(uintptr_t base)
81464ce2bbSSoby Mathew {
82464ce2bbSSoby Mathew return mmio_read_32(base + GICC_EOIR);
83464ce2bbSSoby Mathew }
84464ce2bbSSoby Mathew
gicc_read_hppir(uintptr_t base)85464ce2bbSSoby Mathew static inline unsigned int gicc_read_hppir(uintptr_t base)
86464ce2bbSSoby Mathew {
87464ce2bbSSoby Mathew return mmio_read_32(base + GICC_HPPIR);
88464ce2bbSSoby Mathew }
89464ce2bbSSoby Mathew
gicc_read_ahppir(uintptr_t base)90464ce2bbSSoby Mathew static inline unsigned int gicc_read_ahppir(uintptr_t base)
91464ce2bbSSoby Mathew {
92464ce2bbSSoby Mathew return mmio_read_32(base + GICC_AHPPIR);
93464ce2bbSSoby Mathew }
94464ce2bbSSoby Mathew
gicc_read_dir(uintptr_t base)95464ce2bbSSoby Mathew static inline unsigned int gicc_read_dir(uintptr_t base)
96464ce2bbSSoby Mathew {
97464ce2bbSSoby Mathew return mmio_read_32(base + GICC_DIR);
98464ce2bbSSoby Mathew }
99464ce2bbSSoby Mathew
gicc_read_iidr(uintptr_t base)100464ce2bbSSoby Mathew static inline unsigned int gicc_read_iidr(uintptr_t base)
101464ce2bbSSoby Mathew {
102464ce2bbSSoby Mathew return mmio_read_32(base + GICC_IIDR);
103464ce2bbSSoby Mathew }
104464ce2bbSSoby Mathew
gicc_read_rpr(uintptr_t base)105eb68ea9bSJeenu Viswambharan static inline unsigned int gicc_read_rpr(uintptr_t base)
106eb68ea9bSJeenu Viswambharan {
107eb68ea9bSJeenu Viswambharan return mmio_read_32(base + GICC_RPR);
108eb68ea9bSJeenu Viswambharan }
109eb68ea9bSJeenu Viswambharan
110464ce2bbSSoby Mathew /*******************************************************************************
111464ce2bbSSoby Mathew * GIC CPU interface accessors for writing entire registers
112464ce2bbSSoby Mathew ******************************************************************************/
113464ce2bbSSoby Mathew
gicc_write_ctlr(uintptr_t base,unsigned int val)114464ce2bbSSoby Mathew static inline void gicc_write_ctlr(uintptr_t base, unsigned int val)
115464ce2bbSSoby Mathew {
116464ce2bbSSoby Mathew mmio_write_32(base + GICC_CTLR, val);
117464ce2bbSSoby Mathew }
118464ce2bbSSoby Mathew
gicc_write_pmr(uintptr_t base,unsigned int val)119464ce2bbSSoby Mathew static inline void gicc_write_pmr(uintptr_t base, unsigned int val)
120464ce2bbSSoby Mathew {
121464ce2bbSSoby Mathew mmio_write_32(base + GICC_PMR, val);
122464ce2bbSSoby Mathew }
123464ce2bbSSoby Mathew
gicc_write_BPR(uintptr_t base,unsigned int val)124464ce2bbSSoby Mathew static inline void gicc_write_BPR(uintptr_t base, unsigned int val)
125464ce2bbSSoby Mathew {
126464ce2bbSSoby Mathew mmio_write_32(base + GICC_BPR, val);
127464ce2bbSSoby Mathew }
128464ce2bbSSoby Mathew
129464ce2bbSSoby Mathew
gicc_write_IAR(uintptr_t base,unsigned int val)130464ce2bbSSoby Mathew static inline void gicc_write_IAR(uintptr_t base, unsigned int val)
131464ce2bbSSoby Mathew {
132464ce2bbSSoby Mathew mmio_write_32(base + GICC_IAR, val);
133464ce2bbSSoby Mathew }
134464ce2bbSSoby Mathew
gicc_write_EOIR(uintptr_t base,unsigned int val)135464ce2bbSSoby Mathew static inline void gicc_write_EOIR(uintptr_t base, unsigned int val)
136464ce2bbSSoby Mathew {
137464ce2bbSSoby Mathew mmio_write_32(base + GICC_EOIR, val);
138464ce2bbSSoby Mathew }
139464ce2bbSSoby Mathew
gicc_write_hppir(uintptr_t base,unsigned int val)140464ce2bbSSoby Mathew static inline void gicc_write_hppir(uintptr_t base, unsigned int val)
141464ce2bbSSoby Mathew {
142464ce2bbSSoby Mathew mmio_write_32(base + GICC_HPPIR, val);
143464ce2bbSSoby Mathew }
144464ce2bbSSoby Mathew
gicc_write_dir(uintptr_t base,unsigned int val)145464ce2bbSSoby Mathew static inline void gicc_write_dir(uintptr_t base, unsigned int val)
146464ce2bbSSoby Mathew {
147464ce2bbSSoby Mathew mmio_write_32(base + GICC_DIR, val);
148464ce2bbSSoby Mathew }
149464ce2bbSSoby Mathew
150c3cf06f1SAntonio Nino Diaz #endif /* GICV2_PRIVATE_H */
151