mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
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.
This commit is contained in:
parent
36ad8372d4
commit
949883bd72
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=301539
@ -79,22 +79,47 @@ static int gpiobus_pin_toggle(device_t, device_t, uint32_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;
|
||||
int rv;
|
||||
u_int irq;
|
||||
struct intr_map_data_gpio *gpio_data;
|
||||
struct resource *res;
|
||||
|
||||
/*
|
||||
* 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)
|
||||
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 *
|
||||
|
@ -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 */
|
||||
|
@ -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 *isrc, u_int cpu)
|
||||
}
|
||||
#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 irq, enum intr_polarity pol,
|
||||
}
|
||||
#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.
|
||||
|
@ -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_polarity,
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user