gic_common.h 3.27 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
8
#ifndef GIC_COMMON_H
#define GIC_COMMON_H
9

10
#include <lib/utils_def.h>
Jeenu Viswambharan's avatar
Jeenu Viswambharan committed
11

12
13
14
15
/*******************************************************************************
 * GIC Distributor interface general definitions
 ******************************************************************************/
/* Constants to categorise interrupts */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
16
17
18
19
20
#define MIN_SGI_ID		U(0)
#define MIN_SEC_SGI_ID		U(8)
#define MIN_PPI_ID		U(16)
#define MIN_SPI_ID		U(32)
#define MAX_SPI_ID		U(1019)
21

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
22
#define TOTAL_SPI_INTR_NUM	(MAX_SPI_ID - MIN_SPI_ID + U(1))
23
#define TOTAL_PCPU_INTR_NUM	(MIN_SPI_ID - MIN_SGI_ID)
24
25

/* Mask for the priority field common to all GIC interfaces */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
26
#define GIC_PRI_MASK			U(0xff)
27

28
/* Mask for the configuration field common to all GIC interfaces */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
29
#define GIC_CFG_MASK			U(0x3)
30

31
/* Constant to indicate a spurious interrupt in all GIC versions */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
32
#define GIC_SPURIOUS_INTERRUPT		U(1023)
33

34
35
36
/* Interrupt configurations: 2-bit fields with LSB reserved */
#define GIC_INTR_CFG_LEVEL		(0 << 1)
#define GIC_INTR_CFG_EDGE		(1 << 1)
37

38
/* Highest possible interrupt priorities */
Jeenu Viswambharan's avatar
Jeenu Viswambharan committed
39
40
#define GIC_HIGHEST_SEC_PRIORITY	U(0x00)
#define GIC_HIGHEST_NS_PRIORITY		U(0x80)
41
42
43
44

/*******************************************************************************
 * GIC Distributor interface register offsets that are common to GICv3 & GICv2
 ******************************************************************************/
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
45
46
47
48
49
50
51
52
53
54
55
56
57
#define GICD_CTLR		U(0x0)
#define GICD_TYPER		U(0x4)
#define GICD_IIDR		U(0x8)
#define GICD_IGROUPR		U(0x80)
#define GICD_ISENABLER		U(0x100)
#define GICD_ICENABLER		U(0x180)
#define GICD_ISPENDR		U(0x200)
#define GICD_ICPENDR		U(0x280)
#define GICD_ISACTIVER		U(0x300)
#define GICD_ICACTIVER		U(0x380)
#define GICD_IPRIORITYR		U(0x400)
#define GICD_ICFGR		U(0xc00)
#define GICD_NSACR		U(0xe00)
58
59
60

/* GICD_CTLR bit definitions */
#define CTLR_ENABLE_G0_SHIFT		0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
61
62
#define CTLR_ENABLE_G0_MASK		U(0x1)
#define CTLR_ENABLE_G0_BIT		BIT_32(CTLR_ENABLE_G0_SHIFT)
63
64
65
66
67
68


/*******************************************************************************
 * GIC Distributor interface register constants that are common to GICv3 & GICv2
 ******************************************************************************/
#define PIDR2_ARCH_REV_SHIFT	4
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
69
#define PIDR2_ARCH_REV_MASK	U(0xf)
70
71

/* GICv3 revision as reported by the PIDR2 register */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
72
#define ARCH_REV_GICV3		U(0x3)
73
/* GICv2 revision as reported by the PIDR2 register */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
74
#define ARCH_REV_GICV2		U(0x2)
75
/* GICv1 revision as reported by the PIDR2 register */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
76
#define ARCH_REV_GICV1		U(0x1)
77
78
79
80
81
82
83
84
85

#define IGROUPR_SHIFT		5
#define ISENABLER_SHIFT		5
#define ICENABLER_SHIFT		ISENABLER_SHIFT
#define ISPENDR_SHIFT		5
#define ICPENDR_SHIFT		ISPENDR_SHIFT
#define ISACTIVER_SHIFT		5
#define ICACTIVER_SHIFT		ISACTIVER_SHIFT
#define IPRIORITYR_SHIFT	2
86
#define ITARGETSR_SHIFT		2
87
88
89
90
#define ICFGR_SHIFT		4
#define NSACR_SHIFT		4

/* GICD_TYPER shifts and masks */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
91
92
#define TYPER_IT_LINES_NO_SHIFT	U(0)
#define TYPER_IT_LINES_NO_MASK	U(0x1f)
93
94
95
96
97
98
99
100

/* Value used to initialize Normal world interrupt priorities four at a time */
#define GICD_IPRIORITYR_DEF_VAL			\
	(GIC_HIGHEST_NS_PRIORITY	|	\
	(GIC_HIGHEST_NS_PRIORITY << 8)	|	\
	(GIC_HIGHEST_NS_PRIORITY << 16)	|	\
	(GIC_HIGHEST_NS_PRIORITY << 24))

101
#endif /* GIC_COMMON_H */