Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2007 16:21:01 GMT
From:      Bruce M Simpson <bms@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 119565 for review
Message-ID:  <200705091621.l49GL1Xo099981@repoman.freebsd.org>

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

Change 119565 by bms@bms_anglepoise on 2007/05/09 16:20:00

	Begin attaching child drivers.
	Add child drivers. They don't do anything yet - a resource manager
	will be needed for the siba configuration space.

Affected files ...

.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/files.sentry5#6 edit
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba.c#4 edit
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_cc.c#2 edit
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_mips.c#1 add
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_pcib.c#1 add
.. //depot/projects/mips2/src/sys/mips/mips32/sentry5/siba_sdram.c#1 add

Differences ...

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

@@ -1,5 +1,14 @@
 # $FreeBSD$
 
 #mips/mips32/sentry5/s5_machdep.c		standard
+
+# TODO: Add attachment elsehwere in the tree
+# for USB 1.1 OHCI, Ethernet and IPSEC cores
+# which are believed to be devices we have drivers for
+# which just need to be tweaked for attachment to an SSB system bus.
+# TODO: Add pci host bridge support.
 mips/mips32/sentry5/siba.c			optional siba
 mips/mips32/sentry5/siba_cc.c			optional siba
+mips/mips32/sentry5/siba_mips.c			optional siba
+mips/mips32/sentry5/siba_sdram.c		optional siba
+mips/mips32/sentry5/siba_pcib.c			optional siba

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

@@ -98,8 +98,10 @@
 static struct siba_devid *
 		siba_dev_match(uint16_t, uint16_t, uint8_t);
 static uint8_t	siba_getncores(uint16_t);
+static int	siba_print_all_resources(device_t dev);
 static int	siba_print_child(device_t, device_t);
 static int	siba_probe(device_t);
+static void	siba_probe_nomatch(device_t, device_t);
 int		siba_read_ivar(device_t, device_t, int, uintptr_t *);
 static struct siba_devinfo *
 		siba_setup_devinfo(device_t, uint8_t);
@@ -298,6 +300,9 @@
 		sdi->sdi_irq = 0;	/* XXX notyet */
 
 		sd = siba_dev_match(vendorid, ccid, rev);
+		(void)sd;
+#if 0
+		/* we do this the newbus way now */
 		if (sd != NULL) {
 			device_printf(dev, "core %d: %s rev %02x\n",
 			    idx, sd->sd_desc, rev);
@@ -306,6 +311,7 @@
 			    "core %d: vid %04x pid %04x rev %02x\n",
 			    idx, vendorid, ccid, rev);
 		}
+#endif
 
 		/*
 		 * Try to attach the child.
@@ -316,13 +322,12 @@
 		device_t child;
 		child = device_add_child(dev, NULL, -1);
 		if (child == NULL) {
+			/* XXX should panic */
 			device_printf(dev, "could not add child\n");
 			siba_destroy_devinfo(sdi);
 		} else {
-			device_printf(dev, "child is %p\n", child);
+			/* Set memory window for immediate child. */
 			device_set_ivars(child, sdi);
-
-			/* 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,
@@ -373,6 +378,9 @@
 	int retval = 0;
 
 	retval += bus_print_child_header(bus, child);
+	retval += siba_print_all_resources(child);
+	if (device_get_flags(child))
+		retval += printf(" flags %#x", device_get_flags(child));
 	retval += printf(" on %s\n", device_get_nameunit(bus));
 
 	return (retval);
@@ -474,6 +482,38 @@
 	return (EINVAL);
 }
 
+static void
+siba_probe_nomatch(device_t dev, device_t child)
+{
+	struct siba_devid *sd;
+
+	sd = siba_dev_match(siba_get_vendor(child), siba_get_device(child),
+	    SIBA_REV_ANY);
+	device_printf(dev, "<0x%04x, 0x%04x \"%s\"> not attached\n",
+	    siba_get_vendor(child), siba_get_device(child),
+	    sd != NULL ? sd->sd_desc : "unknown");
+}
+
+static int
+siba_print_all_resources(device_t dev)
+{
+#if 0
+	struct siba_device *ndev = DEVTONX(dev);
+	struct resource_list *rl = &ndev->nx_resources;
+	int retval = 0;
+
+	if (STAILQ_FIRST(rl))
+		retval += printf(" at");
+
+	retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#lx");
+	retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
+
+	return (retval);
+#else
+	return (0);
+#endif
+}
+
 static device_method_t siba_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_attach,	siba_attach),
@@ -488,6 +528,7 @@
 	DEVMETHOD(bus_add_child,	siba_add_child),
 	DEVMETHOD(bus_alloc_resource,	siba_alloc_resource),
 	DEVMETHOD(bus_print_child,	siba_print_child),
+	DEVMETHOD(bus_probe_nomatch,	siba_probe_nomatch),
 	DEVMETHOD(bus_read_ivar,	siba_read_ivar),
 	DEVMETHOD(bus_setup_intr,	bus_generic_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	bus_generic_teardown_intr),

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

@@ -52,25 +52,44 @@
 siba_cc_probe(device_t dev)
 {
 
-	printf("%s: entry\n", __func__);
-
 	if (siba_get_vendor(dev) == SIBA_VID_BROADCOM &&
 	    siba_get_device(dev) == SIBA_DEVID_CHIPCOMMON) {
-		device_set_desc(dev, "ChipCommon core");
 		return (BUS_PROBE_DEFAULT);
 	}
 
 	return (ENXIO);
 }
 
+struct siba_cc_softc {
+	void *notused;
+};
+
 static int
 siba_cc_attach(device_t dev)
 {
+	//struct siba_cc_softc *sc = device_get_softc(dev);
+	struct resource *mem;
+	int rid;
 
-	/* TODO: get softc and resources */
-	printf("%s: entry\n", __func__);
+	/*
+	 * Allocate the resources which the parent bus has already
+	 * determined for us.
+	 * TODO: interrupt routing
+	 */
+#define MIPS_MEM_RID 0x20
+	rid = MIPS_MEM_RID;
+	mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+	    RF_ACTIVE);
+	if (mem == NULL) {
+		device_printf(dev, "unable to allocate memory\n");
+		return (ENXIO);
+	}
+	device_printf(dev, "start %08lx size %04lx\n",
+	    rman_get_start(mem), rman_get_size(mem));
+
+	device_set_desc(dev, "ChipCommon core");
 
-	return (ENXIO);
+	return (0);
 }
 
 static device_method_t siba_cc_methods[] = {



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