Module Name:    src
Committed By:   jakllsch
Date:           Sat Nov 24 22:18:58 UTC 2018

Modified Files:
        src/sys/arch/arm/fdt: gicv3_fdt.c

Log Message:
attach GICv3 ITS where applicable


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/gicv3_fdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/fdt/gicv3_fdt.c
diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.5 src/sys/arch/arm/fdt/gicv3_fdt.c:1.6
--- src/sys/arch/arm/fdt/gicv3_fdt.c:1.5	Mon Nov 19 13:54:15 2018
+++ src/sys/arch/arm/fdt/gicv3_fdt.c	Sat Nov 24 22:18:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill <[email protected]>
@@ -26,10 +26,12 @@
  * SUCH DAMAGE.
  */
 
+#include "pci.h"
+
 #define	_INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -44,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,
 #include <dev/fdt/fdtvar.h>
 
 #include <arm/cortex/gicv3.h>
+#include <arm/cortex/gicv3_its.h>
 #include <arm/cortex/gic_reg.h>
 
 #define	GICV3_MAXIRQ	1020
@@ -58,6 +61,9 @@ static int	gicv3_fdt_match(device_t, cfd
 static void	gicv3_fdt_attach(device_t, device_t, void *);
 
 static int	gicv3_fdt_map_registers(struct gicv3_fdt_softc *);
+#if NPCI > 0
+static void	gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int);
+#endif
 
 static int	gicv3_fdt_intr(void *);
 
@@ -152,6 +158,16 @@ gicv3_fdt_attach(device_t parent, device
 		return;
 	}
 
+#if NPCI > 0
+	for (int child = OF_child(phandle); child; child = OF_peer(child)) {
+		if (!fdtbus_status_okay(child))
+			continue;
+		const char * const its_compat[] = { "arm,gic-v3-its", NULL };
+		if (of_match_compatible(child, its_compat))
+			gicv3_fdt_attach_its(sc, faa->faa_bst, child);
+	}
+#endif
+
 	arm_fdt_irq_set_handler(gicv3_irq_handler);
 }
 
@@ -222,6 +238,31 @@ gicv3_fdt_map_registers(struct gicv3_fdt
 	return 0;
 }
 
+#if NPCI > 0
+static void
+gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle)
+{
+	bus_space_handle_t bsh;
+	bus_addr_t addr;
+	bus_size_t size;
+
+	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
+		aprint_error_dev(sc->sc_gic.sc_dev, "couldn't get ITS address\n");
+		return;
+	}
+
+	if (bus_space_map(bst, addr, size, 0, &bsh) != 0) {
+		aprint_error_dev(sc->sc_gic.sc_dev, "couldn't map ITS\n");
+		return;
+	}
+
+	gicv3_its_init(&sc->sc_gic, bsh, addr, 0);
+
+	aprint_verbose_dev(sc->sc_gic.sc_dev, "ITS @ %#" PRIxBUSADDR "\n",
+	    addr);
+}
+#endif
+
 static void *
 gicv3_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
     int (*func)(void *), void *arg)

Reply via email to