Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2013 13:57:35 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r256846 - head/sys/powerpc/ofw
Message-ID:  <201310211357.r9LDvZP7020634@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



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