Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 May 2014 01:53:21 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r266000 - in stable/10/sys: arm/arm arm/broadcom/bcm2835 arm/freescale/imx arm/mv conf dev/fdt dev/mii dev/ofw mips/mips powerpc/booke powerpc/mpc85xx
Message-ID:  <201405140153.s4E1rLEI029563@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Wed May 14 01:53:20 2014
New Revision: 266000
URL: http://svnweb.freebsd.org/changeset/base/266000

Log:
  MFC r257702, r257745, r257746, r257747, r257751, r257791, r257793,
      r257794, r257795, r257992
  
    Teach nexus(4) about Open Firmware (e.g. FDT) on ARM and MIPS, retiring
    fdtbus in most cases.
  
    Make OF_nextprop() work correctly for FDT by using the libfdt
    fdt_next_property_offset() API.
  
    Do not panic if pmap_mincore() is called.
  
    An addendum: it is possible, though of questionable utility, for a node
    to have no properties at all.
    Add definition for the Atheros 8021 gigabit PHY.
  
    Consolidate Apple firmware hacks and improve them by switching on the
    presence of mac-io devices in the tree, which uniquely identifies Apple
    hardware.
  
    Allow OF_decode_addr() to also be able to map resources on big-endian
    devices.
  
    Make tsec work with the device tree present on the RB800.
  
    Be more flexible about which compatible strings to accept.  This brings up
    the PCI Express bus on the RB800 using the firmware device tree.
  
    Rename the "bare" platform "mpc85xx", which is what it actually is, and
    add actual platform probing based on PVR.

Modified:
  stable/10/sys/arm/arm/nexus.c
  stable/10/sys/arm/broadcom/bcm2835/bcm2835_fb.c
  stable/10/sys/arm/freescale/imx/tzic.c
  stable/10/sys/arm/mv/mv_localbus.c
  stable/10/sys/arm/mv/mv_pci.c
  stable/10/sys/conf/files
  stable/10/sys/dev/fdt/simplebus.c
  stable/10/sys/dev/mii/atphy.c
  stable/10/sys/dev/mii/miidevs
  stable/10/sys/dev/ofw/ofw_fdt.c
  stable/10/sys/mips/mips/nexus.c
  stable/10/sys/powerpc/booke/pmap.c
  stable/10/sys/powerpc/mpc85xx/lbc.c
  stable/10/sys/powerpc/mpc85xx/pci_mpc85xx.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/arm/nexus.c
==============================================================================
--- stable/10/sys/arm/arm/nexus.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/arm/arm/nexus.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/arm/broadcom/bcm2835/bcm2835_fb.c
==============================================================================
--- stable/10/sys/arm/broadcom/bcm2835/bcm2835_fb.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/arm/broadcom/bcm2835/bcm2835_fb.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/arm/freescale/imx/tzic.c
==============================================================================
--- stable/10/sys/arm/freescale/imx/tzic.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/arm/freescale/imx/tzic.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/arm/mv/mv_localbus.c
==============================================================================
--- stable/10/sys/arm/mv/mv_localbus.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/arm/mv/mv_localbus.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/arm/mv/mv_pci.c
==============================================================================
--- stable/10/sys/arm/mv/mv_pci.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/arm/mv/mv_pci.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/conf/files
==============================================================================
--- stable/10/sys/conf/files	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/conf/files	Wed May 14 01:53:20 2014	(r266000)
@@ -1409,7 +1409,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: stable/10/sys/dev/fdt/simplebus.c
==============================================================================
--- stable/10/sys/dev/fdt/simplebus.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/dev/fdt/simplebus.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/dev/mii/atphy.c
==============================================================================
--- stable/10/sys/dev/mii/atphy.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/dev/mii/atphy.c	Wed May 14 01:53:20 2014	(r266000)
@@ -80,6 +80,7 @@ static int	atphy_setmedia(struct mii_sof
 static const struct mii_phydesc atphys[] = {
 	MII_PHY_DESC(xxATHEROS, F1),
 	MII_PHY_DESC(xxATHEROS, F1_7),
+	MII_PHY_DESC(xxATHEROS, AR8021),
 	MII_PHY_DESC(xxATHEROS, F2),
 	MII_PHY_END
 };

Modified: stable/10/sys/dev/mii/miidevs
==============================================================================
--- stable/10/sys/dev/mii/miidevs	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/dev/mii/miidevs	Wed May 14 01:53:20 2014	(r266000)
@@ -136,6 +136,7 @@ model yyAMD 79c901home		0x0039 Am79C901 
 /* Atheros Communications/Attansic PHYs */
 model xxATHEROS F1		0x0001 Atheros F1 10/100/1000 PHY
 model xxATHEROS F2		0x0002 Atheros F2 10/100 PHY
+model xxATHEROS AR8021		0x0004 Atheros AR8021 10/100/1000 PHY
 model xxATHEROS F1_7		0x0007 Atheros F1 10/100/1000 PHY
 
 /* Asix semiconductor PHYs */

Modified: stable/10/sys/dev/ofw/ofw_fdt.c
==============================================================================
--- stable/10/sys/dev/ofw/ofw_fdt.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/dev/ofw/ofw_fdt.c	Wed May 14 01:53:20 2014	(r266000)
@@ -137,26 +137,6 @@ fdt_phandle_offset(phandle_t p)
 	return (pint - dtoff);
 }
 
-static int
-fdt_pointer_offset(const void *ptr)
-{
-	uintptr_t dt_struct, p;
-	int offset;
-
-	p = (uintptr_t)ptr;
-	dt_struct = (uintptr_t)fdtp + fdt_off_dt_struct(fdtp);
-
-	if ((p < dt_struct) ||
-	    p > (dt_struct + fdt_size_dt_struct(fdtp)))
-		return (-1);
-
-	offset = p - dt_struct;
-	if (offset < 0)
-		return (-1);
-
-	return (offset);
-}
-
 /* Return the next sibling of this node or 0. */
 static phandle_t
 ofw_fdt_peer(ofw_t ofw, phandle_t node)
@@ -285,41 +265,6 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t pac
 	return (len);
 }
 
-static int
-fdt_nextprop(int offset, char *buf, size_t size)
-{
-	const struct fdt_property *prop;
-	const char *name;
-	uint32_t tag;
-	int nextoffset, depth;
-
-	depth = 0;
-	tag = fdt_next_tag(fdtp, offset, &nextoffset);
-
-	/* Find the next prop */
-	do {
-		offset = nextoffset;
-		tag = fdt_next_tag(fdtp, offset, &nextoffset);
-
-		if (tag == FDT_BEGIN_NODE)
-			depth++;
-		else if (tag == FDT_END_NODE)
-			depth--;
-		else if ((tag == FDT_PROP) && (depth == 0)) {
-			prop =
-			    (const struct fdt_property *)fdt_offset_ptr(fdtp,
-			    offset, sizeof(*prop));
-			name = fdt_string(fdtp,
-			    fdt32_to_cpu(prop->nameoff));
-			strncpy(buf, name, size);
-			return (strlen(name));
-		} else
-			depth = -1;
-	} while (depth >= 0);
-
-	return (0);
-}
-
 /*
  * Get the next property of a package. Return the actual len of retrieved
  * prop name.
@@ -329,26 +274,42 @@ ofw_fdt_nextprop(ofw_t ofw, phandle_t pa
     size_t size)
 {
 	const struct fdt_property *prop;
-	int offset, rv;
+	const char *name;
+	int offset;
 
 	offset = fdt_phandle_offset(package);
 	if (offset < 0)
 		return (-1);
 
-	if (previous == NULL)
-		/* Find the first prop in the node */
-		return (fdt_nextprop(offset, buf, size));
+	/* Find the first prop in the node */
+	offset = fdt_first_property_offset(fdtp, offset);
+	if (offset < 0)
+		return (0); /* No properties */
 
-	/*
-	 * Advance to the previous prop
-	 */
-	prop = fdt_get_property(fdtp, offset, previous, NULL);
+	if (previous != NULL) {
+		while (offset >= 0) {
+			prop = fdt_get_property_by_offset(fdtp, offset, NULL);
+			if (prop == NULL)
+				return (-1); /* Internal error */
+
+			offset = fdt_next_property_offset(fdtp, offset);
+			if (offset < 0)
+				return (0); /* No more properties */
+
+			/* Check if the last one was the one we wanted */
+			name = fdt_string(fdtp, fdt32_to_cpu(prop->nameoff));
+			if (strcmp(name, previous) == 0)
+				break;
+		}
+	}
+
+	prop = fdt_get_property_by_offset(fdtp, offset, &offset);
 	if (prop == NULL)
-		return (-1);
+		return (-1); /* Internal error */
 
-	offset = fdt_pointer_offset(prop);
-	rv = fdt_nextprop(offset, buf, size);
-	return (rv);
+	strncpy(buf, fdt_string(fdtp, fdt32_to_cpu(prop->nameoff)), size);
+
+	return (strlen(buf));
 }
 
 /* Set the value of a property of a package. */

Modified: stable/10/sys/mips/mips/nexus.c
==============================================================================
--- stable/10/sys/mips/mips/nexus.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/mips/mips/nexus.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/powerpc/booke/pmap.c
==============================================================================
--- stable/10/sys/powerpc/booke/pmap.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/powerpc/booke/pmap.c	Wed May 14 01:53:20 2014	(r266000)
@@ -2759,7 +2759,7 @@ mmu_booke_mincore(mmu_t mmu, pmap_t pmap
     vm_paddr_t *locked_pa)
 {
 
-	TODO;
+	/* XXX: this should be implemented at some point */
 	return (0);
 }
 

Modified: stable/10/sys/powerpc/mpc85xx/lbc.c
==============================================================================
--- stable/10/sys/powerpc/mpc85xx/lbc.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/powerpc/mpc85xx/lbc.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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: stable/10/sys/powerpc/mpc85xx/pci_mpc85xx.c
==============================================================================
--- stable/10/sys/powerpc/mpc85xx/pci_mpc85xx.c	Wed May 14 01:35:43 2014	(r265999)
+++ stable/10/sys/powerpc/mpc85xx/pci_mpc85xx.c	Wed May 14 01:53:20 2014	(r266000)
@@ -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)



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