From da13b8f9fe4db1c3bed3f539bf6cc9a15df55b5b Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Wed, 10 Sep 2003 21:37:10 +0000 Subject: [PATCH] Introduce BUS_CONFIG_INTR(). The method allows devices to tell parents about interrupt trigger mode and interrupt polarity. This allows ACPI for example to pass interrupt resource information up the hierarchy. The default implementation of the method therefore is to pass the request to the parent. Reviewed by: jhb, njl --- sys/kern/bus_if.m | 11 +++++++++++ sys/kern/subr_bus.c | 11 +++++++++++ sys/sys/bus.h | 14 ++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index 81d05eadbda5..fb8301391e0a 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -280,3 +280,14 @@ METHOD int child_location_str { 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; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index e5f9a98d0c22..7bb7704e0694 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1925,6 +1925,17 @@ bus_generic_deactivate_resource(device_t dev, device_t child, int type, return (EINVAL); } +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) diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 9de2a4c193cc..e5bdd85557cc 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -110,6 +110,18 @@ enum intr_type { INTR_ENTROPY = 1024 /* this interrupt provides entropy */ }; +enum intr_trigger { + INTR_TRIGGER_CONFORM = 0, + INTR_TRIGGER_EDGE = 1, + INTR_TRIGGER_LEVEL = 2 +}; + +enum intr_polarity { + INTR_POLARITY_CONFORM = 0, + INTR_POLARITY_HIGH = 1, + INTR_POLARITY_LOW = 2 +}; + typedef int (*devop_t)(void); struct driver { @@ -219,6 +231,8 @@ struct resource * 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);