blob: 2919b7f87f63290bde41f34a8768f4e2db07eeac [file] [log] [blame]
Soby Mathew50f6fe42016-02-01 17:59:22 +00001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef GIC_COMMON_PRIVATE_H_
32#define GIC_COMMON_PRIVATE_H_
33
34#include <gic_common.h>
35#include <mmio.h>
36#include <stdint.h>
37
38/*******************************************************************************
39 * GIC Distributor interface register accessors that are common to GICv3 & GICv2
40 ******************************************************************************/
41static inline unsigned int gicd_read_ctlr(uintptr_t base)
42{
43 return mmio_read_32(base + GICD_CTLR);
44}
45
46static inline unsigned int gicd_read_typer(uintptr_t base)
47{
48 return mmio_read_32(base + GICD_TYPER);
49}
50
51static inline unsigned int gicd_read_iidr(uintptr_t base)
52{
53 return mmio_read_32(base + GICD_IIDR);
54}
55
56static inline void gicd_write_ctlr(uintptr_t base, unsigned int val)
57{
58 mmio_write_32(base + GICD_CTLR, val);
59}
60
61/*******************************************************************************
62 * GIC Distributor function prototypes for accessing entire registers.
63 * Note: The raw register values correspond to multiple interrupt IDs and
64 * the number of interrupt IDs involved depends on the register accessed.
65 ******************************************************************************/
66unsigned int gicd_read_igroupr(uintptr_t base, unsigned int id);
67unsigned int gicd_read_isenabler(uintptr_t base, unsigned int id);
68unsigned int gicd_read_icenabler(uintptr_t base, unsigned int id);
69unsigned int gicd_read_ispendr(uintptr_t base, unsigned int id);
70unsigned int gicd_read_icpendr(uintptr_t base, unsigned int id);
71unsigned int gicd_read_isactiver(uintptr_t base, unsigned int id);
72unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id);
73unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id);
74unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id);
75unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id);
76void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val);
77void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val);
78void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val);
79void gicd_write_ispendr(uintptr_t base, unsigned int id, unsigned int val);
80void gicd_write_icpendr(uintptr_t base, unsigned int id, unsigned int val);
81void gicd_write_isactiver(uintptr_t base, unsigned int id, unsigned int val);
82void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val);
83void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val);
84void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val);
85void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val);
86
87/*******************************************************************************
88 * GIC Distributor function prototypes for accessing the GIC registers
89 * corresponding to a single interrupt ID. These functions use bitwise
90 * operations or appropriate register accesses to modify or return
91 * the bit-field corresponding the single interrupt ID.
92 ******************************************************************************/
93unsigned int gicd_get_igroupr(uintptr_t base, unsigned int id);
94void gicd_set_igroupr(uintptr_t base, unsigned int id);
95void gicd_clr_igroupr(uintptr_t base, unsigned int id);
96void gicd_set_isenabler(uintptr_t base, unsigned int id);
97void gicd_set_icenabler(uintptr_t base, unsigned int id);
98void gicd_set_ispendr(uintptr_t base, unsigned int id);
99void gicd_set_icpendr(uintptr_t base, unsigned int id);
100void gicd_set_isactiver(uintptr_t base, unsigned int id);
101void gicd_set_icactiver(uintptr_t base, unsigned int id);
102void gicd_set_ipriorityr(uintptr_t base, unsigned int id, unsigned int pri);
103
104#endif /* GIC_COMMON_PRIVATE_H_ */