From owner-svn-src-head@FreeBSD.ORG Mon Jul 2 23:41:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1C1CF1065673; Mon, 2 Jul 2012 23:41:57 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1B228FC08; Mon, 2 Jul 2012 23:41:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q62Nfus4006744; Mon, 2 Jul 2012 23:41:56 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q62NfuPe006742; Mon, 2 Jul 2012 23:41:56 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201207022341.q62NfuPe006742@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 2 Jul 2012 23:41:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238042 - head/sys/powerpc/mpc85xx X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 02 Jul 2012 23:41:57 -0000 Author: marcel Date: Mon Jul 2 23:41:56 2012 New Revision: 238042 URL: http://svn.freebsd.org/changeset/base/238042 Log: Properly implement the bus_config_intr, bus_setup_intr and bus_teardown_intr methods so that MI drvers can depend on us doing the right thing instead of having to go around us and call MD code directly. See the FDT code for example (not for long though). Modified: head/sys/powerpc/mpc85xx/nexus.c Modified: head/sys/powerpc/mpc85xx/nexus.c ============================================================================== --- head/sys/powerpc/mpc85xx/nexus.c Mon Jul 2 22:19:02 2012 (r238041) +++ head/sys/powerpc/mpc85xx/nexus.c Mon Jul 2 23:41:56 2012 (r238042) @@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + /* * Device interface */ @@ -75,6 +77,13 @@ static int nexus_activate_resource(devic static int nexus_deactivate_resource(device_t, device_t, int, int, struct resource *); +static int nexus_config_intr(device_t, int, enum intr_trigger, + enum intr_polarity); +static int nexus_setup_intr(device_t, device_t, struct resource *, int, + driver_filter_t *, driver_intr_t *, void *, void **); +static int nexus_teardown_intr(device_t, device_t, struct resource *, + void *); + static device_method_t nexus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, nexus_probe), @@ -89,8 +98,9 @@ static device_method_t nexus_methods[] = DEVMETHOD(bus_probe_nomatch, NULL), DEVMETHOD(bus_read_ivar, NULL), DEVMETHOD(bus_write_ivar, NULL), - DEVMETHOD(bus_setup_intr, NULL), - DEVMETHOD(bus_teardown_intr, NULL), + DEVMETHOD(bus_config_intr, nexus_config_intr), + DEVMETHOD(bus_setup_intr, nexus_setup_intr), + DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), DEVMETHOD(bus_alloc_resource, NULL), DEVMETHOD(bus_activate_resource, nexus_activate_resource), DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), @@ -143,3 +153,49 @@ nexus_deactivate_resource(device_t bus, /* Not much to be done yet... */ return (rman_deactivate_resource(res)); } + +static int +nexus_config_intr(device_t bus, int irq, enum intr_trigger trig, + enum intr_polarity pol) +{ + + return (powerpc_config_intr(irq, trig, pol)); +} + +static int +nexus_setup_intr(device_t bus, device_t child, struct resource *res, int flags, + driver_filter_t *ifilt, driver_intr_t *ihand, void *arg, void **cookiep) +{ + int error; + + *cookiep = NULL; + + /* somebody tried to setup an irq that failed to allocate! */ + if (res == NULL) + return (EINVAL); + + if ((rman_get_flags(res) & RF_SHAREABLE) == 0) + flags |= INTR_EXCL; + + /* We depend on rman_activate_resource() being idempotent. */ + error = rman_activate_resource(res); + if (error) + return (error); + + error = powerpc_setup_intr(device_get_nameunit(child), + rman_get_start(res), ifilt, ihand, arg, flags, cookiep); + return (error); +} + +static int +nexus_teardown_intr(device_t bus, device_t child, struct resource *res, + void *cookie) +{ + int error; + + if (res == NULL) + return (EINVAL); + + error = powerpc_teardown_intr(cookie); + return (error); +}