Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2007 15:36:03 GMT
From:      Bruce M Simpson <bms@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 119561 for review
Message-ID:  <200705091536.l49Fa3xY091941@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=119561

Change 119561 by bms@bms_anglepoise on 2007/05/09 15:35:21

	Add instance variables and devinfo for child devices.
	Add a skeleton siba child driver for the ChipCommon core which
	doesn't do anything yet.
	Be sure to free the window for the entire SiBa system bus range
	in MIPS memory space before we attach children, as their allocations
	will ultimately be proxied to nexus (when Siba is used as a system
	bus).

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/files.sentry5#5 edit
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba.c#3 edit
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_cc.c#1 add
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/sibavar.h#2 edit

Differences ...

==== //depot/projects/mips2/src/sys/mips/mips32/sentry5/files.sentry5#5 (text+ko) ====

@@ -2,3 +2,4 @@
 
 #mips/mips32/sentry5/s5_machdep.c		standard
 mips/mips32/sentry5/siba.c			optional siba
+mips/mips32/sentry5/siba_cc.c			optional siba

==== //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba.c#3 (text+ko) ====

@@ -100,8 +100,10 @@
 static uint8_t	siba_getncores(uint16_t);
 static int	siba_print_child(device_t, device_t);
 static int	siba_probe(device_t);
+int		siba_read_ivar(device_t, device_t, int, uintptr_t *);
 static struct siba_devinfo *
 		siba_setup_devinfo(device_t, uint8_t);
+int		siba_write_ivar(device_t, device_t, int, uintptr_t);
 
 /*
  * Earlier ChipCommon revisions have hardcoded number of cores
@@ -229,6 +231,11 @@
 	uint32_t total;
 	total = sc->sc_ncores * SIBA_CORE_LEN;
 
+	/* XXX Don't allocate the entire window until we
+	 * enumerate the bus. Once the bus has been enumerated,
+	 * and instance variables/children instantiated + populated,
+	 * release the resource so children may attach.
+	 */
 	sc->sc_mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
 	    sc->sc_maddr, sc->sc_maddr + total - 1, total, RF_ACTIVE);
 	if (sc->sc_mem == NULL) {
@@ -314,15 +321,28 @@
 		} else {
 			device_printf(dev, "child is %p\n", child);
 			device_set_ivars(child, sdi);
-			#ifdef notyet
+
+			/* Set memory window for immediate child. */
 			bus_addr_t baseaddr;
 			baseaddr = sc->sc_maddr + (idx * SIBA_CORE_LEN);
 			bus_set_resource(child, SYS_RES_MEMORY, MIPS_MEM_RID,
 			    baseaddr, baseaddr + SIBA_CORE_LEN - 1);
-			#endif
 		}
 	}
 
+	/*
+	 * Release our memory window before children are attached.
+	 */
+	int result;
+	int rid;
+	rid = MIPS_MEM_RID;
+	result = bus_release_resource(dev, SYS_RES_MEMORY, rid,
+	    sc->sc_mem);
+	if (result != 0) {
+		device_printf(dev, "error %d releasing resource\n", result);
+		return (ENXIO);
+	}
+
 	return (bus_generic_attach(dev));
 }
 
@@ -423,6 +443,37 @@
 #endif
 }
 
+int
+siba_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
+{
+	struct siba_devinfo *sdi;
+
+	sdi = device_get_ivars(child);
+
+	switch (which) {
+	case SIBA_IVAR_VENDOR:
+		*result = sdi->sdi_vid;
+		break;
+	case SIBA_IVAR_DEVICE:
+		*result = sdi->sdi_devid;
+		break;
+	case SIBA_IVAR_REVID:
+		*result = sdi->sdi_rev;
+		break;
+	default:
+		return (ENOENT);
+	}
+
+	return (0);
+}
+
+int
+siba_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+
+	return (EINVAL);
+}
+
 static device_method_t siba_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_attach,	siba_attach),
@@ -437,8 +488,10 @@
 	DEVMETHOD(bus_add_child,	siba_add_child),
 	DEVMETHOD(bus_alloc_resource,	siba_alloc_resource),
 	DEVMETHOD(bus_print_child,	siba_print_child),
+	DEVMETHOD(bus_read_ivar,	siba_read_ivar),
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),
+	DEVMETHOD(bus_write_ivar,	siba_write_ivar),
 
 	{0, 0},
 };

==== //depot/projects/mips2/src/sys/mips/mips32/sentry5/sibavar.h#2 (text+ko) ====

@@ -41,11 +41,6 @@
 	uint8_t			 sc_ncores;
 };
 
-enum siba_device_ivars {
-	SIBA_IVAR_VENDOR,
-	SIBA_IVAR_DEVICE,
-	SIBA_IVAR_REVID
-};
 
 struct siba_devinfo {
 	struct resource_list	 sdi_rl;
@@ -76,4 +71,19 @@
 	bus_space_write_4((sc)->sc_bt, (sc)->sc_bh,		\
 			 (core * SIBA_CORE_LEN) + (reg), (val))
 
+enum siba_device_ivars {
+	SIBA_IVAR_VENDOR,
+	SIBA_IVAR_DEVICE,
+	SIBA_IVAR_REVID
+};
+
+#define	SIBA_ACCESSOR(var, ivar, type)				\
+	__BUS_ACCESSOR(siba, var, SIBA, ivar, type)
+
+SIBA_ACCESSOR(vendor,	VENDOR,	uint16_t)
+SIBA_ACCESSOR(device,	DEVICE,	uint16_t)
+SIBA_ACCESSOR(revid,	REVID,	uint8_t)
+
+#undef SIBA_ACCESSOR
+
 #endif /* _SIBAVAR_H_ */



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