blob: 1ab1bdbef7cd9f563f220679dadd8e2beee34166 [file] [log] [blame]
Soby Mathew50f6fe42016-02-01 17:59:22 +00001/*
Roberto Vargas05712702018-02-12 12:36:17 +00002 * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
Soby Mathew50f6fe42016-02-01 17:59:22 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathew50f6fe42016-02-01 17:59:22 +00005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef GIC_COMMON_PRIVATE_H
8#define GIC_COMMON_PRIVATE_H
Soby Mathew50f6fe42016-02-01 17:59:22 +00009
Soby Mathew50f6fe42016-02-01 17:59:22 +000010#include <stdint.h>
11
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <drivers/arm/gic_common.h>
13#include <lib/mmio.h>
14
Soby Mathew50f6fe42016-02-01 17:59:22 +000015/*******************************************************************************
16 * GIC Distributor interface register accessors that are common to GICv3 & GICv2
17 ******************************************************************************/
18static inline unsigned int gicd_read_ctlr(uintptr_t base)
19{
20 return mmio_read_32(base + GICD_CTLR);
21}
22
23static inline unsigned int gicd_read_typer(uintptr_t base)
24{
25 return mmio_read_32(base + GICD_TYPER);
26}
27
28static inline unsigned int gicd_read_iidr(uintptr_t base)
29{
30 return mmio_read_32(base + GICD_IIDR);
31}
32
33static inline void gicd_write_ctlr(uintptr_t base, unsigned int val)
34{
35 mmio_write_32(base + GICD_CTLR, val);
36}
37
38/*******************************************************************************
39 * GIC Distributor function prototypes for accessing entire registers.
40 * Note: The raw register values correspond to multiple interrupt IDs and
41 * the number of interrupt IDs involved depends on the register accessed.
42 ******************************************************************************/
43unsigned int gicd_read_igroupr(uintptr_t base, unsigned int id);
44unsigned int gicd_read_isenabler(uintptr_t base, unsigned int id);
45unsigned int gicd_read_icenabler(uintptr_t base, unsigned int id);
46unsigned int gicd_read_ispendr(uintptr_t base, unsigned int id);
47unsigned int gicd_read_icpendr(uintptr_t base, unsigned int id);
48unsigned int gicd_read_isactiver(uintptr_t base, unsigned int id);
49unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id);
50unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id);
51unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id);
52unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id);
Roberto Vargas05712702018-02-12 12:36:17 +000053unsigned int gicd_read_spendsgir(uintptr_t base, unsigned int id);
54unsigned int gicd_read_cpendsgir(uintptr_t base, unsigned int id);
55unsigned int gicd_read_itargetsr(uintptr_t base, unsigned int id);
Soby Mathew50f6fe42016-02-01 17:59:22 +000056void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val);
57void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val);
58void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val);
59void gicd_write_ispendr(uintptr_t base, unsigned int id, unsigned int val);
60void gicd_write_icpendr(uintptr_t base, unsigned int id, unsigned int val);
61void gicd_write_isactiver(uintptr_t base, unsigned int id, unsigned int val);
62void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val);
63void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val);
64void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val);
65void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val);
Roberto Vargas05712702018-02-12 12:36:17 +000066void gicd_write_spendsgir(uintptr_t base, unsigned int id, unsigned int val);
67void gicd_write_cpendsgir(uintptr_t base, unsigned int id, unsigned int val);
68void gicd_write_itargetsr(uintptr_t base, unsigned int id, unsigned int val);
Soby Mathew50f6fe42016-02-01 17:59:22 +000069
70/*******************************************************************************
71 * GIC Distributor function prototypes for accessing the GIC registers
72 * corresponding to a single interrupt ID. These functions use bitwise
73 * operations or appropriate register accesses to modify or return
74 * the bit-field corresponding the single interrupt ID.
75 ******************************************************************************/
76unsigned int gicd_get_igroupr(uintptr_t base, unsigned int id);
77void gicd_set_igroupr(uintptr_t base, unsigned int id);
78void gicd_clr_igroupr(uintptr_t base, unsigned int id);
79void gicd_set_isenabler(uintptr_t base, unsigned int id);
80void gicd_set_icenabler(uintptr_t base, unsigned int id);
81void gicd_set_ispendr(uintptr_t base, unsigned int id);
82void gicd_set_icpendr(uintptr_t base, unsigned int id);
Jeenu Viswambharan24e70292017-09-22 08:32:09 +010083unsigned int gicd_get_isactiver(uintptr_t base, unsigned int id);
Soby Mathew50f6fe42016-02-01 17:59:22 +000084void gicd_set_isactiver(uintptr_t base, unsigned int id);
85void gicd_set_icactiver(uintptr_t base, unsigned int id);
86void gicd_set_ipriorityr(uintptr_t base, unsigned int id, unsigned int pri);
Jeenu Viswambharan4684bce2017-09-22 08:32:09 +010087void gicd_set_icfgr(uintptr_t base, unsigned int id, unsigned int cfg);
Soby Mathew50f6fe42016-02-01 17:59:22 +000088
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000089#endif /* GIC_COMMON_PRIVATE_H */