From owner-svn-src-head@FreeBSD.ORG Sun Dec 21 21:27:14 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AFAD144A; Sun, 21 Dec 2014 21:27:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9AD46318E; Sun, 21 Dec 2014 21:27:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBLLREnm073009; Sun, 21 Dec 2014 21:27:14 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBLLRDoR073003; Sun, 21 Dec 2014 21:27:13 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201412212127.sBLLRDoR073003@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Sun, 21 Dec 2014 21:27:13 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Dec 2014 21:27:14 -0000 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 __FBSDID("$FreeBSD$"); + #include #include #include @@ -47,10 +50,16 @@ __FBSDID("$FreeBSD$"); #include #include #include + #include #include #include +#ifdef FDT +#include +#include +#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 __FBSDID("$FreeBSD$"); @@ -60,10 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include "opt_platform.h" - #ifdef FDT -#include #include #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 +#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 */