Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Dec 2014 21:27:13 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r276032 - in head/sys/arm: arm include
Message-ID:  <201412212127.sBLLRDoR073003@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Sun Dec 21 21:27:12 2014
New Revision: 276032
URL: https://svnweb.freebsd.org/changeset/base/276032

Log:
  Pull out the fdt mapping code into intr.c. The arm_intrng branch also
  defines this function allowing the mapping method to change when we move
  to it.

Modified:
  head/sys/arm/arm/intr.c
  head/sys/arm/arm/nexus.c
  head/sys/arm/include/intr.h

Modified: head/sys/arm/arm/intr.c
==============================================================================
--- head/sys/arm/arm/intr.c	Sun Dec 21 21:24:19 2014	(r276031)
+++ head/sys/arm/arm/intr.c	Sun Dec 21 21:27:12 2014	(r276032)
@@ -36,8 +36,11 @@
  * Soft interrupt and other generic interrupt functions.
  */
 
+#include "opt_platform.h"
+
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/syslog.h>
@@ -47,10 +50,16 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/interrupt.h>
 #include <sys/conf.h>
+
 #include <machine/atomic.h>
 #include <machine/intr.h>
 #include <machine/cpu.h>
 
+#ifdef FDT
+#include <dev/fdt/fdt_common.h>
+#include <machine/fdt.h>
+#endif
+
 #define	INTRNAME_LEN	(MAXCOMLEN + 1)
 
 typedef void (*mask_fn)(void *);
@@ -89,6 +98,36 @@ intr_init(void *unused)
 
 SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL);
 
+#ifdef FDT
+int
+arm_fdt_map_irq(phandle_t iparent, pcell_t *intr, int icells)
+{
+	fdt_pic_decode_t intr_decode;
+	phandle_t intr_parent;
+	int i, rv, interrupt, trig, pol;
+
+	intr_parent = OF_node_from_xref(iparent);
+	for (i = 0; i < icells; i++)
+		intr[i] = cpu_to_fdt32(intr[i]);
+
+	for (i = 0; fdt_pic_table[i] != NULL; i++) {
+		intr_decode = fdt_pic_table[i];
+		rv = intr_decode(intr_parent, intr, &interrupt, &trig, &pol);
+
+		if (rv == 0) {
+			/* This was recognized as our PIC and decoded. */
+			interrupt = FDT_MAP_IRQ(intr_parent, interrupt);
+			return (interrupt);
+		}
+	}
+
+	/* Not in table, so guess */
+	interrupt = FDT_MAP_IRQ(intr_parent, fdt32_to_cpu(intr[0]));
+
+	return (interrupt);
+}
+#endif
+
 void
 arm_setup_irqhandler(const char *name, driver_filter_t *filt,
     void (*hand)(void*), void *arg, int irq, int flags, void **cookiep)

Modified: head/sys/arm/arm/nexus.c
==============================================================================
--- head/sys/arm/arm/nexus.c	Sun Dec 21 21:24:19 2014	(r276031)
+++ head/sys/arm/arm/nexus.c	Sun Dec 21 21:27:12 2014	(r276032)
@@ -39,6 +39,8 @@
  * and I/O memory address space.
  */
 
+#include "opt_platform.h"
+
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
@@ -60,10 +62,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/resource.h>
 #include <machine/intr.h>
 
-#include "opt_platform.h"
-
 #ifdef FDT
-#include <dev/fdt/fdt_common.h>
 #include <machine/fdt.h>
 #include "ofw_bus_if.h"
 #endif
@@ -351,28 +350,7 @@ static int
 nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
     pcell_t *intr)
 {
-	fdt_pic_decode_t intr_decode;
-	phandle_t intr_parent;
-	int i, rv, interrupt, trig, pol;
-
-	intr_parent = OF_node_from_xref(iparent);
-	for (i = 0; i < icells; i++)
-		intr[i] = cpu_to_fdt32(intr[i]);
-
-	for (i = 0; fdt_pic_table[i] != NULL; i++) {
-		intr_decode = fdt_pic_table[i];
-		rv = intr_decode(intr_parent, intr, &interrupt, &trig, &pol);
-
-		if (rv == 0) {
-			/* This was recognized as our PIC and decoded. */
-			interrupt = FDT_MAP_IRQ(intr_parent, interrupt);
-			return (interrupt);
-		}
-	}
-
-	/* Not in table, so guess */
-	interrupt = FDT_MAP_IRQ(intr_parent, fdt32_to_cpu(intr[0]));
 
-	return (interrupt);
+	return (arm_fdt_map_irq(iparent, intr, icells));
 }
 #endif

Modified: head/sys/arm/include/intr.h
==============================================================================
--- head/sys/arm/include/intr.h	Sun Dec 21 21:24:19 2014	(r276031)
+++ head/sys/arm/include/intr.h	Sun Dec 21 21:27:12 2014	(r276032)
@@ -39,6 +39,10 @@
 #ifndef _MACHINE_INTR_H_
 #define _MACHINE_INTR_H_
 
+#ifdef FDT
+#include <dev/ofw/openfirm.h>
+#endif
+
 /* XXX move to std.* files? */
 #ifdef CPU_XSCALE_81342
 #define NIRQ		128
@@ -85,4 +89,8 @@ void gic_init_secondary(void);
 int  gic_decode_fdt(uint32_t iparentnode, uint32_t *intrcells, int *interrupt,
     int *trig, int *pol);
 
+#ifdef FDT
+int arm_fdt_map_irq(phandle_t, pcell_t *, int);
+#endif
+
 #endif	/* _MACHINE_INTR_H */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412212127.sBLLRDoR073003>