blob: 70f05976868d90c546ad01bf6621ad298e007bd0 [file] [log] [blame]
Soby Mathew464ce2b2015-10-07 09:45:27 +01001/*
Jeenu Viswambharaneb68ea92017-09-22 08:32:09 +01002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Soby Mathew464ce2b2015-10-07 09:45:27 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathew464ce2b2015-10-07 09:45:27 +01005 */
6
7#ifndef __GICV2_PRIVATE_H__
8#define __GICV2_PRIVATE_H__
9
10#include <gicv2.h>
11#include <mmio.h>
12#include <stdint.h>
13
14/*******************************************************************************
15 * Private function prototypes
16 ******************************************************************************/
17void gicv2_spis_configure_defaults(uintptr_t gicd_base);
18void gicv2_secure_spis_configure(uintptr_t gicd_base,
19 unsigned int num_ints,
20 const unsigned int *sec_intr_list);
21void gicv2_secure_ppi_sgi_setup(uintptr_t gicd_base,
22 unsigned int num_ints,
23 const unsigned int *sec_intr_list);
24unsigned int gicv2_get_cpuif_id(uintptr_t base);
25
26/*******************************************************************************
27 * GIC Distributor interface accessors for reading entire registers
28 ******************************************************************************/
29static inline unsigned int gicd_read_pidr2(uintptr_t base)
30{
31 return mmio_read_32(base + GICD_PIDR2_GICV2);
32}
33
34/*******************************************************************************
Jeenu Viswambharan8db978b2017-09-22 08:32:09 +010035 * GIC Distributor interface accessors for writing entire registers
36 ******************************************************************************/
Jeenu Viswambharanfc529fe2017-09-22 08:32:09 +010037static inline unsigned int gicd_get_itargetsr(uintptr_t base, unsigned int id)
38{
39 return mmio_read_8(base + GICD_ITARGETSR + id);
40}
41
42static inline void gicd_set_itargetsr(uintptr_t base, unsigned int id,
43 unsigned int target)
44{
45 mmio_write_8(base + GICD_ITARGETSR + id, target & GIC_TARGET_CPU_MASK);
46}
47
Jeenu Viswambharan8db978b2017-09-22 08:32:09 +010048static inline void gicd_write_sgir(uintptr_t base, unsigned int val)
49{
50 mmio_write_32(base + GICD_SGIR, val);
51}
52
53/*******************************************************************************
Soby Mathew464ce2b2015-10-07 09:45:27 +010054 * GIC CPU interface accessors for reading entire registers
55 ******************************************************************************/
56
57static inline unsigned int gicc_read_ctlr(uintptr_t base)
58{
59 return mmio_read_32(base + GICC_CTLR);
60}
61
62static inline unsigned int gicc_read_pmr(uintptr_t base)
63{
64 return mmio_read_32(base + GICC_PMR);
65}
66
67static inline unsigned int gicc_read_BPR(uintptr_t base)
68{
69 return mmio_read_32(base + GICC_BPR);
70}
71
72static inline unsigned int gicc_read_IAR(uintptr_t base)
73{
74 return mmio_read_32(base + GICC_IAR);
75}
76
77static inline unsigned int gicc_read_EOIR(uintptr_t base)
78{
79 return mmio_read_32(base + GICC_EOIR);
80}
81
82static inline unsigned int gicc_read_hppir(uintptr_t base)
83{
84 return mmio_read_32(base + GICC_HPPIR);
85}
86
87static inline unsigned int gicc_read_ahppir(uintptr_t base)
88{
89 return mmio_read_32(base + GICC_AHPPIR);
90}
91
92static inline unsigned int gicc_read_dir(uintptr_t base)
93{
94 return mmio_read_32(base + GICC_DIR);
95}
96
97static inline unsigned int gicc_read_iidr(uintptr_t base)
98{
99 return mmio_read_32(base + GICC_IIDR);
100}
101
Jeenu Viswambharaneb68ea92017-09-22 08:32:09 +0100102static inline unsigned int gicc_read_rpr(uintptr_t base)
103{
104 return mmio_read_32(base + GICC_RPR);
105}
106
Soby Mathew464ce2b2015-10-07 09:45:27 +0100107/*******************************************************************************
108 * GIC CPU interface accessors for writing entire registers
109 ******************************************************************************/
110
111static inline void gicc_write_ctlr(uintptr_t base, unsigned int val)
112{
113 mmio_write_32(base + GICC_CTLR, val);
114}
115
116static inline void gicc_write_pmr(uintptr_t base, unsigned int val)
117{
118 mmio_write_32(base + GICC_PMR, val);
119}
120
121static inline void gicc_write_BPR(uintptr_t base, unsigned int val)
122{
123 mmio_write_32(base + GICC_BPR, val);
124}
125
126
127static inline void gicc_write_IAR(uintptr_t base, unsigned int val)
128{
129 mmio_write_32(base + GICC_IAR, val);
130}
131
132static inline void gicc_write_EOIR(uintptr_t base, unsigned int val)
133{
134 mmio_write_32(base + GICC_EOIR, val);
135}
136
137static inline void gicc_write_hppir(uintptr_t base, unsigned int val)
138{
139 mmio_write_32(base + GICC_HPPIR, val);
140}
141
142static inline void gicc_write_dir(uintptr_t base, unsigned int val)
143{
144 mmio_write_32(base + GICC_DIR, val);
145}
146
147#endif /* __GICV2_PRIVATE_H__ */