From owner-svn-src-all@FreeBSD.ORG Mon Oct 21 13:57:35 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 96CD2EC6; Mon, 21 Oct 2013 13:57:35 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) 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 69ACD29FC; Mon, 21 Oct 2013 13:57:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9LDvZlu020636; Mon, 21 Oct 2013 13:57:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9LDvZP7020634; Mon, 21 Oct 2013 13:57:35 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201310211357.r9LDvZP7020634@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 21 Oct 2013 13:57:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256846 - head/sys/powerpc/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2013 13:57:35 -0000 Author: nwhitehorn Date: Mon Oct 21 13:57:34 2013 New Revision: 256846 URL: http://svnweb.freebsd.org/changeset/base/256846 Log: Provide an interface for PCI bus drivers that need some of ofw_pci's metadata during attach. Modified: head/sys/powerpc/ofw/ofw_pci.c head/sys/powerpc/ofw/ofw_pci.h Modified: head/sys/powerpc/ofw/ofw_pci.c ============================================================================== --- head/sys/powerpc/ofw/ofw_pci.c Mon Oct 21 13:09:09 2013 (r256845) +++ head/sys/powerpc/ofw/ofw_pci.c Mon Oct 21 13:57:34 2013 (r256846) @@ -124,7 +124,7 @@ static device_method_t ofw_pci_methods[] DEFINE_CLASS_0(ofw_pci, ofw_pci_driver, ofw_pci_methods, 0); int -ofw_pci_attach(device_t dev) +ofw_pci_init(device_t dev) { struct ofw_pci_softc *sc; phandle_t node; @@ -134,6 +134,7 @@ ofw_pci_attach(device_t dev) node = ofw_bus_get_node(dev); sc = device_get_softc(dev); + sc->sc_initialized = 1; if (OF_getprop(node, "reg", &sc->sc_pcir, sizeof(sc->sc_pcir)) == -1) return (ENXIO); @@ -217,13 +218,28 @@ ofw_pci_attach(device_t dev) "error = %d\n", rp->pci_hi & OFW_PCI_PHYS_HI_SPACEMASK, rp->pci, rp->pci + rp->size - 1, error); - panic("AHOY"); return (error); } } ofw_bus_setup_iinfo(node, &sc->sc_pci_iinfo, sizeof(cell_t)); + return (error); +} + +int +ofw_pci_attach(device_t dev) +{ + struct ofw_pci_softc *sc; + int error; + + sc = device_get_softc(dev); + if (!sc->sc_initialized) { + error = ofw_pci_init(dev); + if (error) + return (error); + } + device_add_child(dev, "pci", device_get_unit(dev)); return (bus_generic_attach(dev)); } Modified: head/sys/powerpc/ofw/ofw_pci.h ============================================================================== --- head/sys/powerpc/ofw/ofw_pci.h Mon Oct 21 13:09:09 2013 (r256845) +++ head/sys/powerpc/ofw/ofw_pci.h Mon Oct 21 13:57:34 2013 (r256846) @@ -52,6 +52,7 @@ struct ofw_pci_softc { device_t sc_dev; phandle_t sc_node; int sc_bus; + int sc_initialized; int sc_quirks; @@ -68,6 +69,7 @@ struct ofw_pci_softc { struct ofw_bus_iinfo sc_pci_iinfo; }; +int ofw_pci_init(device_t dev); int ofw_pci_attach(device_t dev); #endif // POWERPC_OFW_OFW_PCI_H