From b3e640cf3f01dd8d477fb83307641f6e927c6c7f Mon Sep 17 00:00:00 2001 From: wangming9 Date: Tue, 2 Jan 2024 22:13:53 +0800 Subject: [PATCH] arch/arm64: GICv2 detection is compatible with different qemu versions Summary: - GICv2 cannot be detected on the golsfish platform - Golsfish uses version 2.12.0 of qemu with a GICC_IIDR value of 0, read ICPIDR2 to determine the GIC version Signed-off-by: wangming9 --- arch/arm64/src/common/arm64_gicv2.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/arm64/src/common/arm64_gicv2.c b/arch/arm64/src/common/arm64_gicv2.c index 06d85292b7..6f466a1404 100644 --- a/arch/arm64/src/common/arm64_gicv2.c +++ b/arch/arm64/src/common/arm64_gicv2.c @@ -786,14 +786,24 @@ static int gic_validate_dist_version(void) if (reg == (0x2 << GIC_ICCIDR_ARCHNO_SHIFT)) { sinfo("GICv2 detected\n"); - } - else - { - sinfo("GICv2 not detected\n"); - return -ENODEV; + return 0; } - return 0; + /* Read the Peripheral ID2 Register (ICPIDR2) */ + + reg = getreg32(GIC_ICDPIDR(GIC_ICPIDR2)) & GICD_PIDR2_ARCH_MASK; + + /* GIC Version should be 2 */ + + if (reg == GICD_PIDR2_ARCH_GICV2) + { + sinfo("GICv2 detected\n"); + return 0; + } + + sinfo("GICv2 not detected\n"); + + return -ENODEV; } /****************************************************************************