Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gic.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Stephanos Ioannidis <root@stephanos.io>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
15
16#ifndef ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_GIC_H_
17#define ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_GIC_H_
18
19/*
20 * GIC Register Interface Base Addresses
21 */
22
23#define GIC_DIST_BASE DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 0)
24#define GIC_CPU_BASE DT_REG_ADDR_BY_IDX(DT_INST(0, arm_gic), 1)
25
26/*
27 * GIC Distributor Interface
28 */
29
36#define GICD_CTLR (GIC_DIST_BASE + 0x0)
37
44#define GICD_TYPER (GIC_DIST_BASE + 0x4)
45
52#define GICD_IIDR (GIC_DIST_BASE + 0x8)
53
60#define GICD_IGROUPRn (GIC_DIST_BASE + 0x80)
61
67#define GICD_IGROUPRnE (GIC_DIST_BASE + 0x1000)
68
75#define GICD_ISENABLERn (GIC_DIST_BASE + 0x100)
76
82#define GICD_ISENABLERnE (GIC_DIST_BASE + 0x1200)
83
90#define GICD_ICENABLERn (GIC_DIST_BASE + 0x180)
91
97#define GICD_ICENABLERnE (GIC_DIST_BASE + 0x1400)
98
105#define GICD_ISPENDRn (GIC_DIST_BASE + 0x200)
106
112#define GICD_ISPENDRnE (GIC_DIST_BASE + 0x1600)
113
120#define GICD_ICPENDRn (GIC_DIST_BASE + 0x280)
121
127#define GICD_ICPENDRnE (GIC_DIST_BASE + 0x1800)
128
135#define GICD_ISACTIVERn (GIC_DIST_BASE + 0x300)
136
142#define GICD_ISACTIVERnE (GIC_DIST_BASE + 0x1A00)
143
144#if (CONFIG_GIC_VER >= 2) || defined(__DOXYGEN__)
150#define GICD_ICACTIVERn (GIC_DIST_BASE + 0x380)
151
157#define GICD_ICACTIVERnE (GIC_DIST_BASE + 0x1C00)
158#endif /* CONFIG_GIC_VER >= 2 */
159
166#define GICD_IPRIORITYRn (GIC_DIST_BASE + 0x400)
167
173#define GICD_IPRIORITYRnE (GIC_DIST_BASE + 0x2000)
174
181#define GICD_ITARGETSRn (GIC_DIST_BASE + 0x800)
182
189#define GICD_ICFGRn (GIC_DIST_BASE + 0xc00)
190
196#define GICD_ICFGRnE (GIC_DIST_BASE + 0x3000)
197
204#define GICD_SGIR (GIC_DIST_BASE + 0xf00)
205
211#define GICD_CTLR_DS BIT(6)
212
213/*
214 * GIC CPU Interface
215 */
216
217#if (CONFIG_GIC_VER <= 2) || defined(__DOXYGEN__)
218
225#define GICC_CTLR (GIC_CPU_BASE + 0x0)
226
233#define GICC_PMR (GIC_CPU_BASE + 0x4)
234
241#define GICC_BPR (GIC_CPU_BASE + 0x8)
242
249#define GICC_IAR (GIC_CPU_BASE + 0xc)
250
257#define GICC_EOIR (GIC_CPU_BASE + 0x10)
258
259/*
260 * Helper Constants
261 */
262
264
265/* GICC_CTLR */
266#define GICC_CTLR_ENABLEGRP0 BIT(0)
267#define GICC_CTLR_ENABLEGRP1 BIT(1)
268
269#define GICC_CTLR_ENABLE_MASK (GICC_CTLR_ENABLEGRP0 | GICC_CTLR_ENABLEGRP1)
270
271#if defined(CONFIG_GIC_V2)
272
273#define GICC_CTLR_FIQBYPDISGRP0 BIT(5)
274#define GICC_CTLR_IRQBYPDISGRP0 BIT(6)
275#define GICC_CTLR_FIQBYPDISGRP1 BIT(7)
276#define GICC_CTLR_IRQBYPDISGRP1 BIT(8)
277
278#define GICC_CTLR_BYPASS_MASK \
279 (GICC_CTLR_FIQBYPDISGRP0 | GICC_CTLR_IRQBYPDISGRP1 | GICC_CTLR_FIQBYPDISGRP1 | \
280 GICC_CTLR_IRQBYPDISGRP1)
281
282#endif /* CONFIG_GIC_V2 */
283
284/* GICD_SGIR */
285#define GICD_SGIR_TGTFILT(x) ((x) << 24)
286#define GICD_SGIR_TGTFILT_CPULIST GICD_SGIR_TGTFILT(0b00)
287#define GICD_SGIR_TGTFILT_ALLBUTREQ GICD_SGIR_TGTFILT(0b01)
288#define GICD_SGIR_TGTFILT_REQONLY GICD_SGIR_TGTFILT(0b10)
289
290#define GICD_SGIR_CPULIST(x) ((x) << 16)
291#define GICD_SGIR_CPULIST_CPU(n) GICD_SGIR_CPULIST(BIT(n))
292#define GICD_SGIR_CPULIST_MASK 0xff
293
294#define GICD_SGIR_NSATT BIT(15)
295
296#define GICD_SGIR_SGIINTID(x) (x)
297
299
300#endif /* CONFIG_GIC_VER <= 2 */
301
303
304/* GICD_ICFGR */
305#define GICD_ICFGR_MASK BIT_MASK(2)
306#define GICD_ICFGR_TYPE BIT(1)
307
308/* GICD_TYPER.ITLinesNumber 0:4 */
309#define GICD_TYPER_ITLINESNUM_MASK 0x1f
310
311/* GICD_TYPER.ESPI [8] */
312#define GICD_TYPER_ESPI_MASK BIT(8)
313
314/* GICD_TYPER.IDbits */
315#define GICD_TYPER_IDBITS(typer) ((((typer) >> 19) & 0x1f) + 1)
316
318
319/*
320 * Common Helper Constants
321 */
322
324#define GIC_SGI_INT_BASE 0
325
327#define GIC_PPI_INT_BASE 16
328
329#define GIC_IS_SGI(intid) (((intid) >= GIC_SGI_INT_BASE) && ((intid) < GIC_PPI_INT_BASE))
330
332#define GIC_SPI_INT_BASE 32
333
335#define GIC_SPI_MAX_INTID 1019
336
338
339#define GIC_IS_SPI(intid) (((intid) >= GIC_SPI_INT_BASE) && ((intid) <= GIC_SPI_MAX_INTID))
340
341#define GIC_NUM_INTR_PER_REG 32
342
343#define GIC_NUM_CFG_PER_REG 16
344
345#define GIC_NUM_PRI_PER_REG 4
346
348
350#define GIC_IDLE_PRIO 0xff
351
353#define GIC_PRI_MASK 0xff
354
364#define GIC_INT_DEF_PRI_X4 0xa0a0a0a0
365
367#define GIC_INTID_SPURIOUS 1023
368
375#define GIC_NUM_CPU_IF CONFIG_MP_MAX_NUM_CPUS
376
377#ifndef _ASMLANGUAGE
378
379#include <zephyr/types.h>
380#include <zephyr/device.h>
381
382/*
383 * GIC Driver Interface Functions
384 */
385
391void arm_gic_irq_enable(unsigned int irq);
392
398void arm_gic_irq_disable(unsigned int irq);
399
406bool arm_gic_irq_is_enabled(unsigned int irq);
407
414bool arm_gic_irq_is_pending(unsigned int irq);
415
421void arm_gic_irq_set_pending(unsigned int irq);
422
428void arm_gic_irq_clear_pending(unsigned int irq);
429
437void arm_gic_irq_set_priority(unsigned int irq, unsigned int prio, unsigned int flags);
438
462void arm_gic_irq_set_affinity(unsigned int irq, uint64_t mpidr);
463
469unsigned int arm_gic_get_active(void);
470
476void arm_gic_eoi(unsigned int irq);
477
478#if defined(CONFIG_SMP) || defined(__DOXYGEN__)
483#endif
484
493void gic_raise_sgi(unsigned int sgi_id, uint64_t target_aff, uint16_t target_list);
494
495#endif /* !_ASMLANGUAGE */
496
497#endif /* ZEPHYR_INCLUDE_DRIVERS_INTERRUPT_CONTROLLER_GIC_H_ */
APIs and macros for the Zephyr device model.
void gic_raise_sgi(unsigned int sgi_id, uint64_t target_aff, uint16_t target_list)
raise SGI to target cores
void arm_gic_irq_clear_pending(unsigned int irq)
Clear the pending irq.
void arm_gic_secondary_init(void)
Initialize GIC of secondary cores.
void arm_gic_irq_disable(unsigned int irq)
Disable interrupt.
void arm_gic_eoi(unsigned int irq)
Signal end-of-interrupt.
void arm_gic_irq_enable(unsigned int irq)
Enable interrupt.
void arm_gic_irq_set_affinity(unsigned int irq, uint64_t mpidr)
Route an SPI/extended-SPI interrupt to a specific core.
void arm_gic_irq_set_pending(unsigned int irq)
Set interrupt as pending.
bool arm_gic_irq_is_enabled(unsigned int irq)
Check if an interrupt is enabled.
bool arm_gic_irq_is_pending(unsigned int irq)
Check if an interrupt is pending.
void arm_gic_irq_set_priority(unsigned int irq, unsigned int prio, unsigned int flags)
Set interrupt priority.
unsigned int arm_gic_get_active(void)
Get active interrupt ID.
flags
Definition parser.h:86
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT16_TYPE__ uint16_t
Definition stdint.h:89