TF-A: Add GICv4 extension for GIC driver

This patch adds support for GICv4 extension.
New `GIC_ENABLE_V4_EXTN` option passed to gicv3.mk makefile
was added, and enables GICv4 related changes when set to 1.
This option defaults to 0.

Change-Id: I30ebe1b7a98d3a54863900f37eda4589c707a288
Signed-off-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
diff --git a/drivers/arm/gic/v3/gicv3_main.c b/drivers/arm/gic/v3/gicv3_main.c
index aefaa35..8c27efd 100644
--- a/drivers/arm/gic/v3/gicv3_main.c
+++ b/drivers/arm/gic/v3/gicv3_main.c
@@ -116,12 +116,20 @@
 			(ID_AA64PFR0_GIC_MASK << ID_AA64PFR0_GIC_SHIFT)) != 0U);
 #endif /* !__aarch64__ */
 
-	/* The GIC version should be 3 */
 	gic_version = gicd_read_pidr2(plat_driver_data->gicd_base);
 	gic_version >>= PIDR2_ARCH_REV_SHIFT;
 	gic_version &= PIDR2_ARCH_REV_MASK;
-	assert(gic_version == ARCH_REV_GICV3);
 
+	/* Check GIC version */
+#if GIC_ENABLE_V4_EXTN
+	assert(gic_version == ARCH_REV_GICV4);
+
+	/* GICv4 supports Direct Virtual LPI injection */
+	assert((gicd_read_typer(plat_driver_data->gicd_base)
+					& TYPER_DVIS) != 0);
+#else
+	assert(gic_version == ARCH_REV_GICV3);
+#endif
 	/*
 	 * Find out whether the GIC supports the GICv2 compatibility mode.
 	 * The ARE_S bit resets to 0 if supported
@@ -165,10 +173,9 @@
 	flush_dcache_range((uintptr_t)gicv3_driver_data,
 		sizeof(*gicv3_driver_data));
 #endif
-
-	INFO("GICv3 with%s legacy support detected."
-			" ARM GICv3 driver initialized in EL3\n",
-			(gicv2_compat == 0U) ? "" : "out");
+	INFO("GICv%u with%s legacy support detected.\n", gic_version,
+				(gicv2_compat == 0U) ? "" : "out");
+	INFO("ARM GICv%u driver initialized in EL3\n", gic_version);
 }
 
 /*******************************************************************************