Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Sep 2003 23:10:44 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 37846 for review
Message-ID:  <200309100610.h8A6AiOc057387@repoman.freebsd.org>

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

Change 37846 by marcel@marcel_nfs on 2003/09/09 23:10:12

	Add a new bus method: BUS_CONFIG_INTR() to allow bus
	drivers to configure interrupt signalling. This includes
	trigger mode and polarity. Update the ACPI driver to
	use the interrupt information in the _CRS object and
	configure the interrupt with the newly added bus method.
	
	Provide a bogus implementation for nexus so that we can
	see if things are really as we expect it. The real thing
	will follow soon.

Affected files ...

.. //depot/projects/ia64/sys/dev/acpica/acpi_resource.c#10 edit
.. //depot/projects/ia64/sys/dev/acpica/acpivar.h#20 edit
.. //depot/projects/ia64/sys/ia64/ia64/nexus.c#5 edit
.. //depot/projects/ia64/sys/kern/bus_if.m#8 edit
.. //depot/projects/ia64/sys/kern/subr_bus.c#24 edit
.. //depot/projects/ia64/sys/sys/bus.h#10 edit

Differences ...

==== //depot/projects/ia64/sys/dev/acpica/acpi_resource.c#10 (text+ko) ====

@@ -197,7 +197,8 @@
 	     * required"
 	     */
 	    set->set_irq(dev, context, res->Data.Irq.Interrupts,
-			 res->Data.Irq.NumberOfInterrupts);
+		res->Data.Irq.NumberOfInterrupts, res->Data.Irq.EdgeLevel,
+		res->Data.Irq.ActiveHighLow);
 	    break;
 	case ACPI_RSTYPE_DMA:
 	    /*
@@ -350,7 +351,9 @@
 	case ACPI_RSTYPE_EXT_IRQ:
 	    /* XXX special handling? */
 	    set->set_irq(dev, context,res->Data.ExtendedIrq.Interrupts,
-			 res->Data.ExtendedIrq.NumberOfInterrupts);
+		res->Data.ExtendedIrq.NumberOfInterrupts,
+		res->Data.ExtendedIrq.EdgeLevel,
+		res->Data.ExtendedIrq.ActiveHighLow);
 	    break;
 	case ACPI_RSTYPE_VENDOR:
 	    ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
@@ -383,7 +386,7 @@
 					 u_int32_t low, u_int32_t high, 
 					 u_int32_t length, u_int32_t align);
 static void	acpi_res_set_irq(device_t dev, void *context, u_int32_t *irq,
-				 int count);
+				 int count, int trig, int pol);
 static void	acpi_res_set_drq(device_t dev, void *context, u_int32_t *drq,
 				 int count);
 static void	acpi_res_set_start_dependant(device_t dev, void *context,
@@ -477,10 +480,11 @@
 }
 
 static void
-acpi_res_set_irq(device_t dev, void *context, u_int32_t *irq, int count)
+acpi_res_set_irq(device_t dev, void *context, u_int32_t *irq, int count,
+    int trig, int pol)
 {
     struct acpi_res_context	*cp = (struct acpi_res_context *)context;
-    
+
     if (cp == NULL || irq == NULL)
 	return;
 
@@ -489,6 +493,9 @@
 	return;
 
     bus_set_resource(dev, SYS_RES_IRQ, cp->ar_nirq++, *irq, 1);
+    BUS_CONFIG_INTR(dev, *irq, (trig == ACPI_EDGE_SENSITIVE) ?
+	INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL, (pol == ACPI_ACTIVE_HIGH) ?
+	INTR_POLARITY_HIGH : INTR_POLARITY_LOW);
 }
 
 static void

==== //depot/projects/ia64/sys/dev/acpica/acpivar.h#20 (text+ko) ====

@@ -203,7 +203,7 @@
 				   u_int32_t high, u_int32_t length,
 				   u_int32_t align);
     void	(*set_irq)(device_t dev, void *context, u_int32_t *irq,
-			   int cout);
+			   int count, int trig, int pol);
     void	(*set_drq)(device_t dev, void *context, u_int32_t *drq,
 			   int count);
     void	(*set_start_dependant)(device_t dev, void *context,

==== //depot/projects/ia64/sys/ia64/ia64/nexus.c#5 (text+ko) ====

@@ -95,8 +95,11 @@
 static	int nexus_teardown_intr(device_t, device_t, struct resource *,
 				void *);
 static	int nexus_set_resource(device_t, device_t, int, int, u_long, u_long);
-static	int nexus_get_resource(device_t, device_t, int, int, u_long *, u_long *);
+static	int nexus_get_resource(device_t, device_t, int, int, u_long *,
+			       u_long *);
 static void nexus_delete_resource(device_t, device_t, int, int);
+static	int nexus_config_intr(device_t, int, enum intr_trigger,
+			      enum intr_polarity);
 
 static device_method_t nexus_methods[] = {
 	/* Device interface */
@@ -121,6 +124,7 @@
 	DEVMETHOD(bus_set_resource,	nexus_set_resource),
 	DEVMETHOD(bus_get_resource,	nexus_get_resource),
 	DEVMETHOD(bus_delete_resource,	nexus_delete_resource),
+	DEVMETHOD(bus_config_intr,	nexus_config_intr),
 
 	{ 0, 0 }
 };
@@ -534,6 +538,15 @@
 	resource_list_delete(rl, type, rid);
 }
 
+static int
+nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
+    enum intr_polarity pol)
+{
+
+	printf("XXX: %s: irq=%d, trig=%d, pol=%d\n", __func__, irq, trig, pol);
+	return (EINVAL);
+}
+
 #if 0
 
 /*

==== //depot/projects/ia64/sys/kern/bus_if.m#8 (text+ko) ====

@@ -280,3 +280,14 @@
 	char		*_buf;
 	size_t		_buflen;
 };
+
+#
+# Allow (bus) drivers to specify the trigger mode and polarity of the
+# specified interrupt.
+#
+METHOD int config_intr {
+	device_t	_dev;
+	int		_irq;
+	enum intr_trigger _trig;
+	enum intr_polarity _pol;
+} DEFAULT bus_generic_config_intr;

==== //depot/projects/ia64/sys/kern/subr_bus.c#24 (text+ko) ====

@@ -1926,6 +1926,17 @@
 }
 
 int
+bus_generic_config_intr(device_t dev, int irq, enum intr_trigger trig,
+    enum intr_polarity pol)
+{
+
+	/* Propagate up the bus hierarchy until someone handles it. */
+	if (dev->parent)
+		return (BUS_CONFIG_INTR(dev->parent, irq, trig, pol));
+	return (EINVAL);
+}
+
+int
 bus_generic_rl_get_resource (device_t dev, device_t child, int type, int rid,
     u_long *startp, u_long *countp)
 {

==== //depot/projects/ia64/sys/sys/bus.h#10 (text+ko) ====

@@ -110,6 +110,16 @@
 	INTR_ENTROPY = 1024		/* this interrupt provides entropy */
 };
 
+enum intr_trigger {
+	INTR_TRIGGER_EDGE = 1,
+	INTR_TRIGGER_LEVEL = 2
+};
+
+enum intr_polarity {
+	INTR_POLARITY_HIGH = 1,
+	INTR_POLARITY_LOW = 2
+};
+
 typedef int (*devop_t)(void);
 
 struct driver {
@@ -219,6 +229,8 @@
 				   u_long count, u_int flags);
 int	bus_generic_attach(device_t dev);
 int	bus_generic_child_present(device_t dev, device_t child);
+int	bus_generic_config_intr(device_t, int, enum intr_trigger,
+				enum intr_polarity);
 int	bus_generic_deactivate_resource(device_t dev, device_t child, int type,
 					int rid, struct resource *r);
 int	bus_generic_detach(device_t dev);



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