aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHeyi Guo <guoheyi@linux.alibaba.com>2021-01-20 18:50:16 +0800
committerHeyi Guo <guoheyi@linux.alibaba.com>2021-06-16 09:24:31 +0800
commit30524ff80a7b8a77393622349df9041cc786c96f (patch)
treeb3e2385e5103b2700249e08e7e54268014c16fc7 /drivers
parented0f0a096845d8b0c0ee9db7a2d6a6486e3ddb44 (diff)
downloadtrusted-firmware-a-30524ff80a7b8a77393622349df9041cc786c96f.tar.gz
refactor(gicv3): add helper function to get the limit of ESPI INTID
Add helper function gicv3_get_espi_limit() to get the value of (maximum extended SPI INTID + 1), so that some duplicated code can be removed later. Signed-off-by: Heyi Guo <guoheyi@linux.alibaba.com> Change-Id: I0355ca2647f872e8189add259f6c47d415494cce
Diffstat (limited to 'drivers')
-rw-r--r--drivers/arm/gic/v3/gicv3_helpers.c22
-rw-r--r--drivers/arm/gic/v3/gicv3_private.h1
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/arm/gic/v3/gicv3_helpers.c b/drivers/arm/gic/v3/gicv3_helpers.c
index 23a1dfaecd..ad7ff22d5f 100644
--- a/drivers/arm/gic/v3/gicv3_helpers.c
+++ b/drivers/arm/gic/v3/gicv3_helpers.c
@@ -110,6 +110,28 @@ unsigned int gicv3_get_spi_limit(uintptr_t gicd_base)
return spi_limit;
}
+#if GIC_EXT_INTID
+/*******************************************************************************
+ * Helper function to get the maximum ESPI INTID + 1.
+ ******************************************************************************/
+unsigned int gicv3_get_espi_limit(uintptr_t gicd_base)
+{
+ unsigned int typer_reg = gicd_read_typer(gicd_base);
+
+ /* Check if extended SPI range is implemented */
+ if ((typer_reg & TYPER_ESPI) != 0U) {
+ /*
+ * (maximum ESPI INTID + 1) is equal to
+ * 32 * (GICD_TYPER.ESPI_range + 1) + 4096
+ */
+ return ((((typer_reg >> TYPER_ESPI_RANGE_SHIFT) &
+ TYPER_ESPI_RANGE_MASK) + 1U) << 5) + MIN_ESPI_ID;
+ }
+
+ return 0U;
+}
+#endif /* GIC_EXT_INTID */
+
/*******************************************************************************
* Helper function to configure the default attributes of (E)SPIs.
******************************************************************************/
diff --git a/drivers/arm/gic/v3/gicv3_private.h b/drivers/arm/gic/v3/gicv3_private.h
index 7965f40918..93ee1a18de 100644
--- a/drivers/arm/gic/v3/gicv3_private.h
+++ b/drivers/arm/gic/v3/gicv3_private.h
@@ -234,6 +234,7 @@ void gicr_set_icfgr(uintptr_t base, unsigned int id, unsigned int cfg);
* Private GICv3 helper function prototypes
******************************************************************************/
unsigned int gicv3_get_spi_limit(uintptr_t gicd_base);
+unsigned int gicv3_get_espi_limit(uintptr_t gicd_base);
void gicv3_spis_config_defaults(uintptr_t gicd_base);
void gicv3_ppi_sgi_config_defaults(uintptr_t gicr_base);
unsigned int gicv3_secure_ppi_sgi_config_props(uintptr_t gicr_base,