From owner-svn-src-head@FreeBSD.ORG Sat Jan 4 20:59:04 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A911921; Sat, 4 Jan 2014 20:59:04 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2C60A10D3; Sat, 4 Jan 2014 20:59:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s04Kx4Ae097425; Sat, 4 Jan 2014 20:59:04 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s04Kx3H2097424; Sat, 4 Jan 2014 20:59:04 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201401042059.s04Kx3H2097424@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 4 Jan 2014 20:59:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260281 - head/sys/arm/arm 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.17 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: Sat, 04 Jan 2014 20:59:04 -0000 Author: nwhitehorn Date: Sat Jan 4 20:59:03 2014 New Revision: 260281 URL: http://svnweb.freebsd.org/changeset/base/260281 Log: Implement OFW_BUS_MAP_INTR() in terms of the FDT PIC table, which will become an ARM-specific quirk. Modified: head/sys/arm/arm/nexus.c Modified: head/sys/arm/arm/nexus.c ============================================================================== --- head/sys/arm/arm/nexus.c Sat Jan 4 19:51:57 2014 (r260280) +++ head/sys/arm/arm/nexus.c Sat Jan 4 20:59:03 2014 (r260281) @@ -64,7 +64,9 @@ __FBSDID("$FreeBSD$"); #ifdef FDT #include +#include #include +#include "ofw_bus_if.h" #else static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device"); @@ -94,6 +96,11 @@ static int nexus_setup_intr(device_t dev int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep); static int nexus_teardown_intr(device_t, device_t, struct resource *, void *); +#ifdef FDT +static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, + int irq); +#endif + static device_method_t nexus_methods[] = { #ifndef FDT /* Device interface */ @@ -109,6 +116,9 @@ static device_method_t nexus_methods[] = DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), DEVMETHOD(bus_setup_intr, nexus_setup_intr), DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), +#ifdef FDT + DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr), +#endif { 0, 0 } }; @@ -300,3 +310,33 @@ nexus_deactivate_resource(device_t bus, return (rman_deactivate_resource(res)); } +#ifdef FDT +static int +nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int irq) +{ + pcell_t intr[2]; + fdt_pic_decode_t intr_decode; + phandle_t intr_offset; + int i, rv, interrupt, trig, pol; + + intr_offset = OF_xref_phandle(iparent); + intr[0] = cpu_to_fdt32(irq); + + for (i = 0; fdt_pic_table[i] != NULL; i++) { + intr_decode = fdt_pic_table[i]; + rv = intr_decode(intr_offset, 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)); + + return (interrupt); +} +#endif +