xref: /rk3399_ARM-atf/drivers/arm/gic/v2/gicv2_private.h (revision eb68ea9b10c190c237216dee92166f9e7b2ce3d4)
1464ce2bbSSoby Mathew /*
2*eb68ea9bSJeenu 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 
7464ce2bbSSoby Mathew #ifndef __GICV2_PRIVATE_H__
8464ce2bbSSoby Mathew #define __GICV2_PRIVATE_H__
9464ce2bbSSoby Mathew 
10464ce2bbSSoby Mathew #include <gicv2.h>
11464ce2bbSSoby Mathew #include <mmio.h>
12464ce2bbSSoby Mathew #include <stdint.h>
13464ce2bbSSoby Mathew 
14464ce2bbSSoby Mathew /*******************************************************************************
15464ce2bbSSoby Mathew  * Private function prototypes
16464ce2bbSSoby Mathew  ******************************************************************************/
17464ce2bbSSoby Mathew void gicv2_spis_configure_defaults(uintptr_t gicd_base);
18464ce2bbSSoby Mathew void gicv2_secure_spis_configure(uintptr_t gicd_base,
19464ce2bbSSoby Mathew 				     unsigned int num_ints,
20464ce2bbSSoby Mathew 				     const unsigned int *sec_intr_list);
21464ce2bbSSoby Mathew void gicv2_secure_ppi_sgi_setup(uintptr_t gicd_base,
22464ce2bbSSoby Mathew 					unsigned int num_ints,
23464ce2bbSSoby Mathew 					const unsigned int *sec_intr_list);
24464ce2bbSSoby Mathew unsigned int gicv2_get_cpuif_id(uintptr_t base);
25464ce2bbSSoby Mathew 
26464ce2bbSSoby Mathew /*******************************************************************************
27464ce2bbSSoby Mathew  * GIC Distributor interface accessors for reading entire registers
28464ce2bbSSoby Mathew  ******************************************************************************/
29464ce2bbSSoby Mathew static inline unsigned int gicd_read_pidr2(uintptr_t base)
30464ce2bbSSoby Mathew {
31464ce2bbSSoby Mathew 	return mmio_read_32(base + GICD_PIDR2_GICV2);
32464ce2bbSSoby Mathew }
33464ce2bbSSoby Mathew 
34464ce2bbSSoby Mathew /*******************************************************************************
35464ce2bbSSoby Mathew  * GIC CPU interface accessors for reading entire registers
36464ce2bbSSoby Mathew  ******************************************************************************/
37464ce2bbSSoby Mathew 
38464ce2bbSSoby Mathew static inline unsigned int gicc_read_ctlr(uintptr_t base)
39464ce2bbSSoby Mathew {
40464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_CTLR);
41464ce2bbSSoby Mathew }
42464ce2bbSSoby Mathew 
43464ce2bbSSoby Mathew static inline unsigned int gicc_read_pmr(uintptr_t base)
44464ce2bbSSoby Mathew {
45464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_PMR);
46464ce2bbSSoby Mathew }
47464ce2bbSSoby Mathew 
48464ce2bbSSoby Mathew static inline unsigned int gicc_read_BPR(uintptr_t base)
49464ce2bbSSoby Mathew {
50464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_BPR);
51464ce2bbSSoby Mathew }
52464ce2bbSSoby Mathew 
53464ce2bbSSoby Mathew static inline unsigned int gicc_read_IAR(uintptr_t base)
54464ce2bbSSoby Mathew {
55464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_IAR);
56464ce2bbSSoby Mathew }
57464ce2bbSSoby Mathew 
58464ce2bbSSoby Mathew static inline unsigned int gicc_read_EOIR(uintptr_t base)
59464ce2bbSSoby Mathew {
60464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_EOIR);
61464ce2bbSSoby Mathew }
62464ce2bbSSoby Mathew 
63464ce2bbSSoby Mathew static inline unsigned int gicc_read_hppir(uintptr_t base)
64464ce2bbSSoby Mathew {
65464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_HPPIR);
66464ce2bbSSoby Mathew }
67464ce2bbSSoby Mathew 
68464ce2bbSSoby Mathew static inline unsigned int gicc_read_ahppir(uintptr_t base)
69464ce2bbSSoby Mathew {
70464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_AHPPIR);
71464ce2bbSSoby Mathew }
72464ce2bbSSoby Mathew 
73464ce2bbSSoby Mathew static inline unsigned int gicc_read_dir(uintptr_t base)
74464ce2bbSSoby Mathew {
75464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_DIR);
76464ce2bbSSoby Mathew }
77464ce2bbSSoby Mathew 
78464ce2bbSSoby Mathew static inline unsigned int gicc_read_iidr(uintptr_t base)
79464ce2bbSSoby Mathew {
80464ce2bbSSoby Mathew 	return mmio_read_32(base + GICC_IIDR);
81464ce2bbSSoby Mathew }
82464ce2bbSSoby Mathew 
83*eb68ea9bSJeenu Viswambharan static inline unsigned int gicc_read_rpr(uintptr_t base)
84*eb68ea9bSJeenu Viswambharan {
85*eb68ea9bSJeenu Viswambharan 	return mmio_read_32(base + GICC_RPR);
86*eb68ea9bSJeenu Viswambharan }
87*eb68ea9bSJeenu Viswambharan 
88464ce2bbSSoby Mathew /*******************************************************************************
89464ce2bbSSoby Mathew  * GIC CPU interface accessors for writing entire registers
90464ce2bbSSoby Mathew  ******************************************************************************/
91464ce2bbSSoby Mathew 
92464ce2bbSSoby Mathew static inline void gicc_write_ctlr(uintptr_t base, unsigned int val)
93464ce2bbSSoby Mathew {
94464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_CTLR, val);
95464ce2bbSSoby Mathew }
96464ce2bbSSoby Mathew 
97464ce2bbSSoby Mathew static inline void gicc_write_pmr(uintptr_t base, unsigned int val)
98464ce2bbSSoby Mathew {
99464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_PMR, val);
100464ce2bbSSoby Mathew }
101464ce2bbSSoby Mathew 
102464ce2bbSSoby Mathew static inline void gicc_write_BPR(uintptr_t base, unsigned int val)
103464ce2bbSSoby Mathew {
104464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_BPR, val);
105464ce2bbSSoby Mathew }
106464ce2bbSSoby Mathew 
107464ce2bbSSoby Mathew 
108464ce2bbSSoby Mathew static inline void gicc_write_IAR(uintptr_t base, unsigned int val)
109464ce2bbSSoby Mathew {
110464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_IAR, val);
111464ce2bbSSoby Mathew }
112464ce2bbSSoby Mathew 
113464ce2bbSSoby Mathew static inline void gicc_write_EOIR(uintptr_t base, unsigned int val)
114464ce2bbSSoby Mathew {
115464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_EOIR, val);
116464ce2bbSSoby Mathew }
117464ce2bbSSoby Mathew 
118464ce2bbSSoby Mathew static inline void gicc_write_hppir(uintptr_t base, unsigned int val)
119464ce2bbSSoby Mathew {
120464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_HPPIR, val);
121464ce2bbSSoby Mathew }
122464ce2bbSSoby Mathew 
123464ce2bbSSoby Mathew static inline void gicc_write_dir(uintptr_t base, unsigned int val)
124464ce2bbSSoby Mathew {
125464ce2bbSSoby Mathew 	mmio_write_32(base + GICC_DIR, val);
126464ce2bbSSoby Mathew }
127464ce2bbSSoby Mathew 
128464ce2bbSSoby Mathew #endif /* __GICV2_PRIVATE_H__ */
129