svn commit: r257702 - in head/sys: arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv conf dev/fdt mips/mips powerpc/mpc85xx

Nathan Whitehorn nwhitehorn at FreeBSD.org
Tue Nov 5 13:48:36 UTC 2013


Author: nwhitehorn
Date: Tue Nov  5 13:48:34 2013
New Revision: 257702
URL: http://svnweb.freebsd.org/changeset/base/257702

Log:
  Teach nexus(4) about Open Firmware (e.g. FDT) on ARM and MIPS, retiring
  fdtbus in most cases. This brings ARM and MIPS more in line with existing
  Open Firmware platforms like sparc64 and powerpc, as well as preventing
  double-enumeration of the OF tree on embedded PowerPC (first through nexus,
  then through fdtbus).
  
  This change is also designed to simplify resource management on FDT platforms
  by letting there exist a platform-defined root bus resource_activate() call
  instead of replying on fdtbus to do the right thing through fdt_bs_tag.
  The OFW_BUS_MAP_INTR() and OFW_BUS_CONFIG_INTR() kobj methods are also
  available to implement for similar purposes.
  
  Discussed on:	-arm, -mips
  Tested by:	zbb, brooks, imp, and others
  MFC after:	6 weeks

Modified:
  head/sys/arm/arm/nexus.c
  head/sys/arm/broadcom/bcm2835/bcm2835_fb.c
  head/sys/arm/freescale/imx/tzic.c
  head/sys/arm/mv/mv_localbus.c
  head/sys/arm/mv/mv_pci.c
  head/sys/conf/files
  head/sys/dev/fdt/simplebus.c
  head/sys/mips/mips/nexus.c
  head/sys/powerpc/mpc85xx/lbc.c
  head/sys/powerpc/mpc85xx/pci_mpc85xx.c

Modified: head/sys/arm/arm/nexus.c
==============================================================================
--- head/sys/arm/arm/nexus.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/arm/arm/nexus.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -60,6 +60,12 @@ __FBSDID("$FreeBSD$");
 #include <machine/resource.h>
 #include <machine/intr.h>
 
+#include "opt_platform.h"
+
+#ifdef FDT
+#include <dev/ofw/ofw_nexus.h>
+#include <machine/fdt.h>
+#else
 static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
 
 struct nexus_device {
@@ -76,13 +82,18 @@ static	int nexus_print_child(device_t, d
 static	device_t nexus_add_child(device_t, u_int, const char *, int);
 static	struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
     u_long, u_long, u_long, u_int);
+#endif
 static	int nexus_activate_resource(device_t, device_t, int, int,
     struct resource *);
+static	int nexus_deactivate_resource(device_t, device_t, int, int,
+    struct resource *);
+
 static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
     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 *);
 
 static device_method_t nexus_methods[] = {
+#ifndef FDT
 	/* Device interface */
 	DEVMETHOD(device_probe,		nexus_probe),
 	DEVMETHOD(device_attach,	nexus_attach),
@@ -90,19 +101,28 @@ static device_method_t nexus_methods[] =
 	DEVMETHOD(bus_print_child,	nexus_print_child),
 	DEVMETHOD(bus_add_child,	nexus_add_child),
 	DEVMETHOD(bus_alloc_resource,	nexus_alloc_resource),
+#endif
 	DEVMETHOD(bus_activate_resource,	nexus_activate_resource),
+	DEVMETHOD(bus_deactivate_resource,	nexus_deactivate_resource),
 	DEVMETHOD(bus_setup_intr,	nexus_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	nexus_teardown_intr),
 	{ 0, 0 }
 };
 
+static devclass_t nexus_devclass;
+#ifndef FDT
 static driver_t nexus_driver = {
 	"nexus",
 	nexus_methods,
 	1			/* no softc */
 };
-static devclass_t nexus_devclass;
+#else
+DEFINE_CLASS_1(nexus, nexus_driver, nexus_methods,
+    sizeof(struct ofw_nexus_softc), ofw_nexus_driver);
+#endif
+DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);
 
+#ifndef FDT
 static int
 nexus_probe(device_t dev)
 {
@@ -113,30 +133,6 @@ nexus_probe(device_t dev)
 }
 
 static int
-nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
-    driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep)
-{
-	int irq;
-
-	if ((rman_get_flags(res) & RF_SHAREABLE) == 0)
-		flags |= INTR_EXCL;
-
-	for (irq = rman_get_start(res); irq <= rman_get_end(res); irq++) {
-		arm_setup_irqhandler(device_get_nameunit(child),
-		    filt, intr, arg, irq, flags, cookiep);
-		arm_unmask_irq(irq);
-	}
-	return (0);
-}
-
-static int
-nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
-{
-
-	return (arm_remove_irqhandler(rman_get_start(r), ih));
-}
-
-static int
 nexus_attach(device_t dev)
 {
 
@@ -156,7 +152,6 @@ nexus_attach(device_t dev)
 	return (0);
 }
 
-
 static int
 nexus_print_child(device_t bus, device_t child)
 {
@@ -193,7 +188,6 @@ nexus_add_child(device_t bus, u_int orde
  * child of one of our descendants, not a direct child of nexus0.
  * (Exceptions include footbridge.)
  */
-#define ARM_BUS_SPACE_MEM 1
 static struct resource *
 nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
     u_long start, u_long end, u_long count, u_int flags)
@@ -204,6 +198,7 @@ nexus_alloc_resource(device_t bus, devic
 
 	switch (type) {
 	case SYS_RES_MEMORY:
+	case SYS_RES_IOPORT:
 		rm = &mem_rman;
 		break;
 
@@ -216,7 +211,6 @@ nexus_alloc_resource(device_t bus, devic
 		return (0);
 
 	rman_set_rid(rv, *rid);
-	rman_set_bustag(rv, (void*)ARM_BUS_SPACE_MEM);
 	rman_set_bushandle(rv, rman_get_start(rv));
 
 	if (needactivate) {
@@ -228,6 +222,31 @@ nexus_alloc_resource(device_t bus, devic
 
 	return (rv);
 }
+#endif
+
+static int
+nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
+    driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep)
+{
+	int irq;
+
+	if ((rman_get_flags(res) & RF_SHAREABLE) == 0)
+		flags |= INTR_EXCL;
+
+	for (irq = rman_get_start(res); irq <= rman_get_end(res); irq++) {
+		arm_setup_irqhandler(device_get_nameunit(child),
+		    filt, intr, arg, irq, flags, cookiep);
+		arm_unmask_irq(irq);
+	}
+	return (0);
+}
+
+static int
+nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
+{
+
+	return (arm_remove_irqhandler(rman_get_start(r), ih));
+}
 
 
 static int
@@ -237,7 +256,7 @@ nexus_activate_resource(device_t bus, de
 	/*
 	 * If this is a memory resource, map it into the kernel.
 	 */
-	if (rman_get_bustag(r) == (void*)ARM_BUS_SPACE_MEM) {
+	if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) {
 		caddr_t vaddr = 0;
 		u_int32_t paddr;
 		u_int32_t psize;
@@ -248,9 +267,21 @@ nexus_activate_resource(device_t bus, de
 		poffs = paddr - trunc_page(paddr);
 		vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
 		rman_set_virtual(r, vaddr);
+#ifdef FDT
+		rman_set_bustag(r, fdtbus_bs_tag);
+#else
+		rman_set_bustag(r, (void *)1);
+#endif
 		rman_set_bushandle(r, (bus_space_handle_t) vaddr);
 	}
 	return (rman_activate_resource(r));
 }
 
-DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);
+static int
+nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *res)
+{
+
+	return (rman_deactivate_resource(res));
+}
+

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_fb.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_fb.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_fb.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -361,7 +361,7 @@ static driver_t bcm_fb_driver = {
 	sizeof(struct bcmsc_softc),
 };
 
-DRIVER_MODULE(bcm2835fb, fdtbus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
+DRIVER_MODULE(bcm2835fb, nexus, bcm_fb_driver, bcm_fb_devclass, 0, 0);
 
 /*
  * Video driver routines and glue.

Modified: head/sys/arm/freescale/imx/tzic.c
==============================================================================
--- head/sys/arm/freescale/imx/tzic.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/arm/freescale/imx/tzic.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -142,9 +142,9 @@ static devclass_t tzic_devclass;
 
 /*
  * Memory space of controller located outside of device range, so let him to
- * attach not only to simplebus, but fdtbus also.
+ * attach not only to simplebus, but nexus also.
  */
-EARLY_DRIVER_MODULE(tzic, fdtbus, tzic_driver, tzic_devclass, 0, 0,
+EARLY_DRIVER_MODULE(tzic, nexus, tzic_driver, tzic_devclass, 0, 0,
     BUS_PASS_INTERRUPT);
 EARLY_DRIVER_MODULE(tzic, simplebus, tzic_driver, tzic_devclass, 0, 0,
     BUS_PASS_INTERRUPT);

Modified: head/sys/arm/mv/mv_localbus.c
==============================================================================
--- head/sys/arm/mv/mv_localbus.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/arm/mv/mv_localbus.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -156,7 +156,7 @@ static struct localbus_bank localbus_ban
 
 devclass_t localbus_devclass;
 
-DRIVER_MODULE(localbus, fdtbus, localbus_driver, localbus_devclass, 0, 0);
+DRIVER_MODULE(localbus, nexus, localbus_driver, localbus_devclass, 0, 0);
 
 static int
 fdt_localbus_reg_decode(phandle_t node, struct localbus_softc *sc,

Modified: head/sys/arm/mv/mv_pci.c
==============================================================================
--- head/sys/arm/mv/mv_pci.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/arm/mv/mv_pci.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -230,7 +230,7 @@ static driver_t mv_pcib_driver = {
 
 devclass_t pcib_devclass;
 
-DRIVER_MODULE(pcib, fdtbus, mv_pcib_driver, pcib_devclass, 0, 0);
+DRIVER_MODULE(pcib, nexus, mv_pcib_driver, pcib_devclass, 0, 0);
 
 static struct mtx pcicfg_mtx;
 

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/conf/files	Tue Nov  5 13:48:34 2013	(r257702)
@@ -1401,7 +1401,7 @@ dev/fdt/fdt_pci.c		optional fdt pci
 dev/fdt/fdt_slicer.c		optional fdt cfi | fdt nand
 dev/fdt/fdt_static_dtb.S	optional fdt fdt_dtb_static \
 	dependency	"$S/boot/fdt/dts/${FDT_DTS_FILE}"
-dev/fdt/fdtbus.c		optional fdt
+dev/fdt/fdtbus.c		optional fdtbus
 dev/fdt/simplebus.c		optional fdt
 dev/fe/if_fe.c			optional fe
 dev/fe/if_fe_pccard.c		optional fe pccard

Modified: head/sys/dev/fdt/simplebus.c
==============================================================================
--- head/sys/dev/fdt/simplebus.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/dev/fdt/simplebus.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -138,7 +138,7 @@ static driver_t simplebus_driver = {
 
 devclass_t simplebus_devclass;
 
-DRIVER_MODULE(simplebus, fdtbus, simplebus_driver, simplebus_devclass, 0, 0);
+DRIVER_MODULE(simplebus, nexus, simplebus_driver, simplebus_devclass, 0, 0);
 DRIVER_MODULE(simplebus, simplebus, simplebus_driver, simplebus_devclass, 0,
     0);
 

Modified: head/sys/mips/mips/nexus.c
==============================================================================
--- head/sys/mips/mips/nexus.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/mips/mips/nexus.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -58,6 +58,12 @@ __FBSDID("$FreeBSD$");
 #include <machine/resource.h>
 #include <machine/vmparam.h>
 
+#include "opt_platform.h"
+
+#ifdef FDT
+#include <dev/ofw/ofw_nexus.h>
+#endif
+
 #undef NEXUS_DEBUG
 #ifdef NEXUS_DEBUG
 #define dprintf printf
@@ -65,6 +71,9 @@ __FBSDID("$FreeBSD$");
 #define dprintf(x, arg...)
 #endif  /* NEXUS_DEBUG */
 
+#define NUM_MIPS_IRQS	6
+
+#ifndef FDT
 static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
 
 struct nexus_device {
@@ -72,7 +81,6 @@ struct nexus_device {
 };
 
 #define DEVTONX(dev)	((struct nexus_device *)device_get_ivars(dev))
-#define NUM_MIPS_IRQS	6
 
 static struct rman irq_rman;
 static struct rman mem_rman;
@@ -80,18 +88,13 @@ static struct rman mem_rman;
 static struct resource *
 		nexus_alloc_resource(device_t, device_t, int, int *, u_long,
 		    u_long, u_long, u_int);
-static int	nexus_activate_resource(device_t, device_t, int, int,
-		    struct resource *);
 static device_t	nexus_add_child(device_t, u_int, const char *, int);
 static int	nexus_attach(device_t);
-static int	nexus_deactivate_resource(device_t, device_t, int, int,
-		    struct resource *);
 static void	nexus_delete_resource(device_t, device_t, int, int);
 static struct resource_list *
 		nexus_get_reslist(device_t, device_t);
 static int	nexus_get_resource(device_t, device_t, int, int, u_long *,
 		    u_long *);
-static void	nexus_hinted_child(device_t, const char *, int);
 static int	nexus_print_child(device_t, device_t);
 static int	nexus_print_all_resources(device_t dev);
 static int	nexus_probe(device_t);
@@ -99,6 +102,12 @@ static int	nexus_release_resource(device
 		    struct resource *);
 static int	nexus_set_resource(device_t, device_t, int, int, u_long,
 		    u_long);
+#endif
+static int	nexus_activate_resource(device_t, device_t, int, int,
+		    struct resource *);
+static int	nexus_deactivate_resource(device_t, device_t, int, int,
+		    struct resource *);
+static void	nexus_hinted_child(device_t, const char *, int);
 static int	nexus_setup_intr(device_t dev, device_t child,
 		    struct resource *res, int flags, driver_filter_t *filt,
 		    driver_intr_t *intr, void *arg, void **cookiep);
@@ -106,35 +115,43 @@ static int	nexus_teardown_intr(device_t,
 		    void *);
 
 static device_method_t nexus_methods[] = {
+#ifndef FDT
 	/* Device interface */
 	DEVMETHOD(device_probe,		nexus_probe),
 	DEVMETHOD(device_attach,	nexus_attach),
 
 	/* Bus interface */
 	DEVMETHOD(bus_add_child,	nexus_add_child),
-	DEVMETHOD(bus_activate_resource,nexus_activate_resource),
 	DEVMETHOD(bus_alloc_resource,	nexus_alloc_resource),
-	DEVMETHOD(bus_deactivate_resource,	nexus_deactivate_resource),
 	DEVMETHOD(bus_delete_resource,	nexus_delete_resource),
 	DEVMETHOD(bus_get_resource,	nexus_get_resource),
 	DEVMETHOD(bus_get_resource_list,	nexus_get_reslist),
-	DEVMETHOD(bus_hinted_child,	nexus_hinted_child),
 	DEVMETHOD(bus_print_child,	nexus_print_child),
 	DEVMETHOD(bus_release_resource,	nexus_release_resource),
 	DEVMETHOD(bus_set_resource,	nexus_set_resource),
+#endif
 	DEVMETHOD(bus_setup_intr,	nexus_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	nexus_teardown_intr),
+	DEVMETHOD(bus_activate_resource,nexus_activate_resource),
+	DEVMETHOD(bus_deactivate_resource,	nexus_deactivate_resource),
+	DEVMETHOD(bus_hinted_child,	nexus_hinted_child),
 
 	{ 0, 0 }
 };
 
+#ifndef FDT
 static driver_t nexus_driver = {
 	"nexus",
 	nexus_methods,
 	1			/* no softc */
 };
+#else
+DEFINE_CLASS_1(nexus, nexus_driver, nexus_methods,
+    sizeof(struct ofw_nexus_softc), ofw_nexus_driver);
+#endif
 static devclass_t nexus_devclass;
 
+#ifndef FDT
 static int
 nexus_probe(device_t dev)
 {
@@ -163,34 +180,6 @@ nexus_probe(device_t dev)
 }
 
 static int
-nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
-    driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep)
-{
-	register_t s;
-	int irq;
-
-	s = intr_disable();
-	irq = rman_get_start(res);
-	if (irq >= NUM_MIPS_IRQS) {
-		intr_restore(s);
-		return (0);
-	}
-
-	cpu_establish_hardintr(device_get_nameunit(child), filt, intr, arg,
-	    irq, flags, cookiep);
-	intr_restore(s);
-	return (0);
-}
-
-static int
-nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
-{
-
-	printf("Unimplemented %s at %s:%d\n", __func__, __FILE__, __LINE__);
-	return (0);
-}
-
-static int
 nexus_attach(device_t dev)
 {
 
@@ -231,59 +220,6 @@ nexus_print_all_resources(device_t dev)
 	return (retval);
 }
 
-static void
-nexus_hinted_child(device_t bus, const char *dname, int dunit)
-{
-	device_t child;
-	long	maddr;
-	int	msize;
-	int	order;
-	int	result;
-	int	irq;
-	int	mem_hints_count;
-
-	if ((resource_int_value(dname, dunit, "order", &order)) != 0)
-		order = 1000;
-	child = BUS_ADD_CHILD(bus, order, dname, dunit);
-	if (child == NULL)
-		return;
-
-	/*
-	 * Set hard-wired resources for hinted child using
-	 * specific RIDs.
-	 */
-	mem_hints_count = 0;
-	if (resource_long_value(dname, dunit, "maddr", &maddr) == 0)
-		mem_hints_count++;
-	if (resource_int_value(dname, dunit, "msize", &msize) == 0)
-		mem_hints_count++;
-
-	/* check if all info for mem resource has been provided */
-	if ((mem_hints_count > 0) && (mem_hints_count < 2)) {
-		printf("Either maddr or msize hint is missing for %s%d\n",
-		    dname, dunit);
-	} 
-	else if (mem_hints_count) {
-		dprintf("%s: discovered hinted child %s at maddr %p(%d)\n",
-		    __func__, device_get_nameunit(child),
-		    (void *)(intptr_t)maddr, msize);
-
-		result = bus_set_resource(child, SYS_RES_MEMORY, 0, maddr, 
-		    msize);
-		if (result != 0) {
-			device_printf(bus, 
-			    "warning: bus_set_resource() failed\n");
-		}
-	}
-
-	if (resource_int_value(dname, dunit, "irq", &irq) == 0) {
-		result = bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
-		if (result != 0)
-			device_printf(bus,
-			    "warning: bus_set_resource() failed\n");
-	}
-}
-
 static device_t
 nexus_add_child(device_t bus, u_int order, const char *name, int unit)
 {
@@ -381,30 +317,6 @@ nexus_alloc_resource(device_t bus, devic
 	return (rv);
 }
 
-static int
-nexus_activate_resource(device_t bus, device_t child, int type, int rid,
-    struct resource *r)
-{
-	void *vaddr;
-	vm_paddr_t paddr;
-	vm_size_t psize;
-
-	/*
-	 * If this is a memory resource, use pmap_mapdev to map it.
-	 */
-	if (type == SYS_RES_MEMORY) {
-		paddr = rman_get_start(r);
-		psize = rman_get_size(r);
-		vaddr = pmap_mapdev(paddr, psize);
-
-		rman_set_virtual(r, vaddr);
-		rman_set_bustag(r, mips_bus_space_generic);
-		rman_set_bushandle(r, (bus_space_handle_t)(uintptr_t)vaddr);
-	}
-
-	return (rman_activate_resource(r));
-}
-
 static struct resource_list *
 nexus_get_reslist(device_t dev, device_t child)
 {
@@ -475,6 +387,31 @@ nexus_release_resource(device_t bus, dev
 
 	return (rman_release_resource(r));
 }
+#endif
+
+static int
+nexus_activate_resource(device_t bus, device_t child, int type, int rid,
+    struct resource *r)
+{
+	void *vaddr;
+	vm_paddr_t paddr;
+	vm_size_t psize;
+
+	/*
+	 * If this is a memory resource, use pmap_mapdev to map it.
+	 */
+	if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) {
+		paddr = rman_get_start(r);
+		psize = rman_get_size(r);
+		vaddr = pmap_mapdev(paddr, psize);
+
+		rman_set_virtual(r, vaddr);
+		rman_set_bustag(r, mips_bus_space_generic);
+		rman_set_bushandle(r, (bus_space_handle_t)(uintptr_t)vaddr);
+	}
+
+	return (rman_activate_resource(r));
+}
 
 static int
 nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
@@ -490,4 +427,85 @@ nexus_deactivate_resource(device_t bus, 
 	return (rman_deactivate_resource(r));
 }
 
+static int
+nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
+    driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep)
+{
+	register_t s;
+	int irq;
+
+	s = intr_disable();
+	irq = rman_get_start(res);
+	if (irq >= NUM_MIPS_IRQS) {
+		intr_restore(s);
+		return (0);
+	}
+
+	cpu_establish_hardintr(device_get_nameunit(child), filt, intr, arg,
+	    irq, flags, cookiep);
+	intr_restore(s);
+	return (0);
+}
+
+static int
+nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
+{
+
+	printf("Unimplemented %s at %s:%d\n", __func__, __FILE__, __LINE__);
+	return (0);
+}
+
+static void
+nexus_hinted_child(device_t bus, const char *dname, int dunit)
+{
+	device_t child;
+	long	maddr;
+	int	msize;
+	int	order;
+	int	result;
+	int	irq;
+	int	mem_hints_count;
+
+	if ((resource_int_value(dname, dunit, "order", &order)) != 0)
+		order = 1000;
+	child = BUS_ADD_CHILD(bus, order, dname, dunit);
+	if (child == NULL)
+		return;
+
+	/*
+	 * Set hard-wired resources for hinted child using
+	 * specific RIDs.
+	 */
+	mem_hints_count = 0;
+	if (resource_long_value(dname, dunit, "maddr", &maddr) == 0)
+		mem_hints_count++;
+	if (resource_int_value(dname, dunit, "msize", &msize) == 0)
+		mem_hints_count++;
+
+	/* check if all info for mem resource has been provided */
+	if ((mem_hints_count > 0) && (mem_hints_count < 2)) {
+		printf("Either maddr or msize hint is missing for %s%d\n",
+		    dname, dunit);
+	} 
+	else if (mem_hints_count) {
+		dprintf("%s: discovered hinted child %s at maddr %p(%d)\n",
+		    __func__, device_get_nameunit(child),
+		    (void *)(intptr_t)maddr, msize);
+
+		result = bus_set_resource(child, SYS_RES_MEMORY, 0, maddr, 
+		    msize);
+		if (result != 0) {
+			device_printf(bus, 
+			    "warning: bus_set_resource() failed\n");
+		}
+	}
+
+	if (resource_int_value(dname, dunit, "irq", &irq) == 0) {
+		result = bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
+		if (result != 0)
+			device_printf(bus,
+			    "warning: bus_set_resource() failed\n");
+	}
+}
+
 DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);

Modified: head/sys/powerpc/mpc85xx/lbc.c
==============================================================================
--- head/sys/powerpc/mpc85xx/lbc.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/powerpc/mpc85xx/lbc.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -113,7 +113,7 @@ static driver_t lbc_driver = {
 
 devclass_t lbc_devclass;
 
-DRIVER_MODULE(lbc, fdtbus, lbc_driver, lbc_devclass, 0, 0);
+DRIVER_MODULE(lbc, nexus, lbc_driver, lbc_devclass, 0, 0);
 
 /*
  * Calculate address mask used by OR(n) registers. Use memory region size to

Modified: head/sys/powerpc/mpc85xx/pci_mpc85xx.c
==============================================================================
--- head/sys/powerpc/mpc85xx/pci_mpc85xx.c	Tue Nov  5 13:36:05 2013	(r257701)
+++ head/sys/powerpc/mpc85xx/pci_mpc85xx.c	Tue Nov  5 13:48:34 2013	(r257702)
@@ -170,7 +170,7 @@ static devclass_t fsl_pcib_devclass;
 
 DEFINE_CLASS_1(pcib, fsl_pcib_driver, fsl_pcib_methods,
     sizeof(struct fsl_pcib_softc), ofw_pci_driver);
-DRIVER_MODULE(pcib, fdtbus, fsl_pcib_driver, fsl_pcib_devclass, 0, 0);
+DRIVER_MODULE(pcib, nexus, fsl_pcib_driver, fsl_pcib_devclass, 0, 0);
 
 static int
 fsl_pcib_probe(device_t dev)


More information about the svn-src-head mailing list