svn commit: r301539 - in head/sys: dev/gpio kern sys
Michal Meloun
mmel at FreeBSD.org
Tue Jun 7 05:08:26 UTC 2016
Author: mmel
Date: Tue Jun 7 05:08:24 2016
New Revision: 301539
URL: https://svnweb.freebsd.org/changeset/base/301539
Log:
INTRNG: As follow up of r301451, implement mapping and configuration
of gpio pin interrupts by new way.
Note: This removes last consumer of intr_ddata machinery and we remove it
in separate commit.
Modified:
head/sys/dev/gpio/gpiobus.c
head/sys/dev/gpio/gpiobusvar.h
head/sys/kern/subr_intr.c
head/sys/sys/intr.h
Modified: head/sys/dev/gpio/gpiobus.c
==============================================================================
--- head/sys/dev/gpio/gpiobus.c Tue Jun 7 04:51:50 2016 (r301538)
+++ head/sys/dev/gpio/gpiobus.c Tue Jun 7 05:08:24 2016 (r301539)
@@ -79,22 +79,47 @@ static int gpiobus_pin_toggle(device_t,
* data will be moved into struct resource.
*/
#ifdef INTRNG
+static void
+gpio_destruct_map_data(struct intr_map_data *map_data)
+{
+
+ KASSERT(map_data->type == INTR_MAP_DATA_GPIO,
+ ("%s: bad map_data type %d", __func__, map_data->type));
+
+ free(map_data, M_DEVBUF);
+}
+
struct resource *
gpio_alloc_intr_resource(device_t consumer_dev, int *rid, u_int alloc_flags,
gpio_pin_t pin, uint32_t intr_mode)
{
- u_int irqnum;
-
- /*
- * Allocate new fictitious interrupt number and store configuration
- * into it.
- */
- irqnum = intr_gpio_map_irq(pin->dev, pin->pin, pin->flags, intr_mode);
- if (irqnum == INTR_IRQ_INVALID)
+ int rv;
+ u_int irq;
+ struct intr_map_data_gpio *gpio_data;
+ struct resource *res;
+
+ gpio_data = malloc(sizeof(*gpio_data), M_DEVBUF, M_WAITOK | M_ZERO);
+ gpio_data->hdr.type = INTR_MAP_DATA_GPIO;
+ gpio_data->hdr.destruct = gpio_destruct_map_data;
+ gpio_data->gpio_pin_num = pin->pin;
+ gpio_data->gpio_pin_flags = pin->flags;
+ gpio_data->gpio_intr_mode = intr_mode;
+
+ rv = intr_map_irq(pin->dev, 0, (struct intr_map_data *)gpio_data,
+ &irq);
+ if (rv != 0) {
+ gpio_destruct_map_data((struct intr_map_data *)gpio_data);
return (NULL);
+ }
- return (bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid,
- irqnum, irqnum, 1, alloc_flags));
+ res = bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid, irq, irq, 1,
+ alloc_flags);
+ if (res == NULL) {
+ gpio_destruct_map_data((struct intr_map_data *)gpio_data);
+ return (NULL);
+ }
+ rman_set_virtual(res, gpio_data);
+ return (res);
}
#else
struct resource *
Modified: head/sys/dev/gpio/gpiobusvar.h
==============================================================================
--- head/sys/dev/gpio/gpiobusvar.h Tue Jun 7 04:51:50 2016 (r301538)
+++ head/sys/dev/gpio/gpiobusvar.h Tue Jun 7 05:08:24 2016 (r301539)
@@ -70,6 +70,13 @@ struct gpiobus_pin_data
char *name; /* pin name. */
};
+struct intr_map_data_gpio {
+ struct intr_map_data hdr;
+ u_int gpio_pin_num;
+ u_int gpio_pin_flags;
+ u_int gpio_intr_mode;
+};
+
struct gpiobus_softc
{
struct mtx sc_mtx; /* bus mutex */
Modified: head/sys/kern/subr_intr.c
==============================================================================
--- head/sys/kern/subr_intr.c Tue Jun 7 04:51:50 2016 (r301538)
+++ head/sys/kern/subr_intr.c Tue Jun 7 05:08:24 2016 (r301539)
@@ -147,7 +147,9 @@ struct intr_dev_data {
};
static struct intr_dev_data *intr_ddata_tab[2 * NIRQ];
+#if 0
static u_int intr_ddata_first_unused;
+#endif
#define IRQ_DDATA_BASE 10000
CTASSERT(IRQ_DDATA_BASE > nitems(irq_sources));
@@ -534,6 +536,7 @@ intr_isrc_init_on_cpu(struct intr_irqsrc
}
#endif
+#if 0
static struct intr_dev_data *
intr_ddata_alloc(u_int extsize)
{
@@ -556,6 +559,7 @@ intr_ddata_alloc(u_int extsize)
ddata->idd_data = (struct intr_map_data *)((uintptr_t)ddata + size);
return (ddata);
}
+#endif
static struct intr_irqsrc *
intr_ddata_lookup(u_int irq, struct intr_map_data **datap)
@@ -620,30 +624,6 @@ intr_acpi_map_irq(device_t dev, u_int ir
}
#endif
-/*
- * Store GPIO interrupt decription in framework and return unique interrupt
- * number (resource handle) associated with it.
- */
-u_int
-intr_gpio_map_irq(device_t dev, u_int pin_num, u_int pin_flags, u_int intr_mode)
-{
- struct intr_dev_data *ddata;
- struct intr_map_data_gpio *dag;
-
- ddata = intr_ddata_alloc(sizeof(struct intr_map_data_gpio));
- if (ddata == NULL)
- return (INTR_IRQ_INVALID); /* no space left */
-
- ddata->idd_dev = dev;
- ddata->idd_data->type = INTR_MAP_DATA_GPIO;
-
- dag = (struct intr_map_data_gpio *)ddata->idd_data;
- dag->gpio_pin_num = pin_num;
- dag->gpio_pin_flags = pin_flags;
- dag->gpio_intr_mode = intr_mode;
- return (ddata->idd_irq);
-}
-
#ifdef INTR_SOLO
/*
* Setup filter into interrupt source.
Modified: head/sys/sys/intr.h
==============================================================================
--- head/sys/sys/intr.h Tue Jun 7 04:51:50 2016 (r301538)
+++ head/sys/sys/intr.h Tue Jun 7 05:08:24 2016 (r301539)
@@ -43,13 +43,6 @@ struct intr_map_data_acpi {
};
#endif
-struct intr_map_data_gpio {
- struct intr_map_data hdr;
- u_int gpio_pin_num;
- u_int gpio_pin_flags;
- u_int gpio_intr_mode;
-};
-
#ifdef notyet
#define INTR_SOLO INTR_MD1
typedef int intr_irq_filter_t(void *arg, struct trapframe *tf);
@@ -129,9 +122,6 @@ u_int intr_acpi_map_irq(device_t, u_int,
enum intr_trigger);
#endif
-u_int intr_gpio_map_irq(device_t dev, u_int pin_num, u_int pin_flags,
- u_int intr_mode);
-
#ifdef SMP
int intr_bind_irq(device_t, struct resource *, int);
More information about the svn-src-all
mailing list