Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 1 | /* |
Alexei Fedorov | 1970593 | 2020-04-06 19:00:35 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef GIC_COMMON_H |
| 8 | #define GIC_COMMON_H |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <lib/utils_def.h> |
Jeenu Viswambharan | 837cc9c | 2018-08-02 10:14:12 +0100 | [diff] [blame] | 11 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 12 | /******************************************************************************* |
| 13 | * GIC Distributor interface general definitions |
| 14 | ******************************************************************************/ |
| 15 | /* Constants to categorise interrupts */ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 16 | #define MIN_SGI_ID U(0) |
| 17 | #define MIN_SEC_SGI_ID U(8) |
| 18 | #define MIN_PPI_ID U(16) |
| 19 | #define MIN_SPI_ID U(32) |
| 20 | #define MAX_SPI_ID U(1019) |
Soby Mathew | 327548c | 2017-07-13 15:19:51 +0100 | [diff] [blame] | 21 | |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 22 | #define TOTAL_SPI_INTR_NUM (MAX_SPI_ID - MIN_SPI_ID + U(1)) |
Soby Mathew | 327548c | 2017-07-13 15:19:51 +0100 | [diff] [blame] | 23 | #define TOTAL_PCPU_INTR_NUM (MIN_SPI_ID - MIN_SGI_ID) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 24 | |
| 25 | /* Mask for the priority field common to all GIC interfaces */ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 26 | #define GIC_PRI_MASK U(0xff) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 27 | |
Jeenu Viswambharan | 4684bce | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 28 | /* Mask for the configuration field common to all GIC interfaces */ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 29 | #define GIC_CFG_MASK U(0x3) |
Jeenu Viswambharan | 4684bce | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 30 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 31 | /* Constant to indicate a spurious interrupt in all GIC versions */ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 32 | #define GIC_SPURIOUS_INTERRUPT U(1023) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 33 | |
Jeenu Viswambharan | b6982c0 | 2018-03-22 08:57:52 +0000 | [diff] [blame] | 34 | /* Interrupt configurations: 2-bit fields with LSB reserved */ |
| 35 | #define GIC_INTR_CFG_LEVEL (0 << 1) |
| 36 | #define GIC_INTR_CFG_EDGE (1 << 1) |
Jeenu Viswambharan | aeb267c | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 37 | |
Jeenu Viswambharan | 83a189e | 2018-11-07 11:46:36 +0000 | [diff] [blame] | 38 | /* Highest possible interrupt priorities */ |
Jeenu Viswambharan | 837cc9c | 2018-08-02 10:14:12 +0100 | [diff] [blame] | 39 | #define GIC_HIGHEST_SEC_PRIORITY U(0x00) |
Jeenu Viswambharan | 837cc9c | 2018-08-02 10:14:12 +0100 | [diff] [blame] | 40 | #define GIC_HIGHEST_NS_PRIORITY U(0x80) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 41 | |
| 42 | /******************************************************************************* |
Alexei Fedorov | 1970593 | 2020-04-06 19:00:35 +0100 | [diff] [blame] | 43 | * Common GIC Distributor interface register offsets |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 44 | ******************************************************************************/ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 45 | #define GICD_CTLR U(0x0) |
| 46 | #define GICD_TYPER U(0x4) |
| 47 | #define GICD_IIDR U(0x8) |
| 48 | #define GICD_IGROUPR U(0x80) |
| 49 | #define GICD_ISENABLER U(0x100) |
| 50 | #define GICD_ICENABLER U(0x180) |
| 51 | #define GICD_ISPENDR U(0x200) |
| 52 | #define GICD_ICPENDR U(0x280) |
| 53 | #define GICD_ISACTIVER U(0x300) |
| 54 | #define GICD_ICACTIVER U(0x380) |
| 55 | #define GICD_IPRIORITYR U(0x400) |
| 56 | #define GICD_ICFGR U(0xc00) |
| 57 | #define GICD_NSACR U(0xe00) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 58 | |
| 59 | /* GICD_CTLR bit definitions */ |
| 60 | #define CTLR_ENABLE_G0_SHIFT 0 |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 61 | #define CTLR_ENABLE_G0_MASK U(0x1) |
| 62 | #define CTLR_ENABLE_G0_BIT BIT_32(CTLR_ENABLE_G0_SHIFT) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 63 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 64 | /******************************************************************************* |
Alexei Fedorov | 1970593 | 2020-04-06 19:00:35 +0100 | [diff] [blame] | 65 | * Common GIC Distributor interface register constants |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 66 | ******************************************************************************/ |
| 67 | #define PIDR2_ARCH_REV_SHIFT 4 |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 68 | #define PIDR2_ARCH_REV_MASK U(0xf) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 69 | |
Alexei Fedorov | 1970593 | 2020-04-06 19:00:35 +0100 | [diff] [blame] | 70 | /* GIC revision as reported by PIDR2.ArchRev register field */ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 71 | #define ARCH_REV_GICV1 U(0x1) |
Alexei Fedorov | 1970593 | 2020-04-06 19:00:35 +0100 | [diff] [blame] | 72 | #define ARCH_REV_GICV2 U(0x2) |
| 73 | #define ARCH_REV_GICV3 U(0x3) |
| 74 | #define ARCH_REV_GICV4 U(0x4) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 75 | |
| 76 | #define IGROUPR_SHIFT 5 |
| 77 | #define ISENABLER_SHIFT 5 |
| 78 | #define ICENABLER_SHIFT ISENABLER_SHIFT |
| 79 | #define ISPENDR_SHIFT 5 |
| 80 | #define ICPENDR_SHIFT ISPENDR_SHIFT |
| 81 | #define ISACTIVER_SHIFT 5 |
| 82 | #define ICACTIVER_SHIFT ISACTIVER_SHIFT |
| 83 | #define IPRIORITYR_SHIFT 2 |
Jeenu Viswambharan | dce70b3 | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 84 | #define ITARGETSR_SHIFT 2 |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 85 | #define ICFGR_SHIFT 4 |
| 86 | #define NSACR_SHIFT 4 |
| 87 | |
| 88 | /* GICD_TYPER shifts and masks */ |
Antonio Nino Diaz | 2e59071 | 2018-08-24 11:46:33 +0100 | [diff] [blame] | 89 | #define TYPER_IT_LINES_NO_SHIFT U(0) |
| 90 | #define TYPER_IT_LINES_NO_MASK U(0x1f) |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 91 | |
| 92 | /* Value used to initialize Normal world interrupt priorities four at a time */ |
| 93 | #define GICD_IPRIORITYR_DEF_VAL \ |
| 94 | (GIC_HIGHEST_NS_PRIORITY | \ |
| 95 | (GIC_HIGHEST_NS_PRIORITY << 8) | \ |
| 96 | (GIC_HIGHEST_NS_PRIORITY << 16) | \ |
| 97 | (GIC_HIGHEST_NS_PRIORITY << 24)) |
| 98 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 99 | #endif /* GIC_COMMON_H */ |