PERFORCE change 98415 for review

Warner Losh imp at FreeBSD.org
Sat Jun 3 19:22:58 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=98415

Change 98415 by imp at imp_lighthouse on 2006/06/03 19:20:23

	Establish pci interrupts.

Affected files ...

.. //depot/projects/arm/src/sys/dev/sdhc/sdhc.c#4 edit
.. //depot/projects/arm/src/sys/dev/sdhc/sdhc_pci.c#8 edit
.. //depot/projects/arm/src/sys/dev/sdhc/sdhcvar.h#4 edit

Differences ...

==== //depot/projects/arm/src/sys/dev/sdhc/sdhc.c#4 (text+ko) ====

@@ -131,6 +131,10 @@
 		device_delete_child(dev, devlist[tmp]);
 	free(devlist, M_TEMP);
 
+	if (sc->intrhand)
+		bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
+	if (sc->irq_res)
+		bus_free_resource(dev, SYS_RES_IRQ, sc->irq_res);
 	return (0);
 }
 

==== //depot/projects/arm/src/sys/dev/sdhc/sdhc_pci.c#8 (text+ko) ====

@@ -49,6 +49,8 @@
 #include <dev/sdhc/sdhcvar.h>
 #include <dev/sdhc/sdhcreg.h>
 
+static void sdhc_pci_intr(void *arg);
+
 static int
 sdhc_pci_probe(device_t dev)
 {
@@ -66,10 +68,19 @@
 	device_t child;
 	struct sdhc_ivars *ivars;
 	struct resource *res;
-	int i;
+	int i, rid, err;
 
 	if (pci_get_progif(dev) == SDHC_PCI_INTERFACE_DMA)
 		sc->flags |= SDHC_FLAG_HASDMA;
+	/* Map and establish the interrupt. */
+	rid = 0;
+	sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
+	    RF_SHAREABLE | RF_ACTIVE);
+	if (sc->irq_res == NULL) {
+		device_printf(dev, "Unable to map IRQ...\n");
+		goto errout;
+	}
+
 	for (i = SDHC_RID_MIN; i <= SDHC_RID_MAX; i += sizeof(uint32_t)) {
 		res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, RF_ACTIVE);
 		if (res == NULL)
@@ -88,7 +99,24 @@
 		device_set_ivars(child, ivars);
 	}
 
-	return (sdhc_attach(dev));
+	err = sdhc_attach(dev);
+	if (err)
+		goto errout;
+
+	if (bus_setup_intr(dev, sc->irq_res, INTR_TYPE_AV | INTR_MPSAFE,
+	    sdhc_pci_intr, sc, &sc->intrhand)) {
+		device_printf(dev, "couldn't establish interrupt");
+		goto errout;
+	}
+	return (0);
+errout:;
+	sdhc_detach(dev);
+	return (ENXIO);
+}
+
+static void
+sdhc_pci_intr(void *arg)
+{
 }
 
 static device_method_t sdhc_pci_methods[] = {

==== //depot/projects/arm/src/sys/dev/sdhc/sdhcvar.h#4 (text+ko) ====

@@ -35,6 +35,8 @@
 #define SDHC_FLAG_HASDMA	1
 	int nres;
 	struct resource *res[SDHC_MAX_RES];
+	struct resource *irq_res;
+	void *intrhand;
 };
 
 struct sdhc_ivars


More information about the p4-projects mailing list