INTRNG - redefine struct intr_map_data to avoid headers pollution. Each
struct associated with some type defined in enum intr_map_data_type must have struct intr_map_data on the top of its own definition now. When such structs are used, correct type and size must be filled in. There are three such structs defined in sys/intr.h now. Their definitions should be moved to corresponding headers by follow-up commits. While this change was propagated to all INTRNG like PICs, pic_map_intr() method implementations were corrected on some places. For this specific method, it's ensured by a caller that the 'data' argument passed to this method is never NULL. Also, the return error values were standardized there.
This commit is contained in:
parent
15adccc687
commit
cd642c88a1
@ -298,14 +298,18 @@ static int
|
||||
a10_intr_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct a10_aintc_softc *sc;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT || data->fdt.ncells != 1 ||
|
||||
data->fdt.cells[0] >= A10_INTR_MAX_NIRQS)
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
if (daf->ncells != 1 || daf->cells[0] >= A10_INTR_MAX_NIRQS)
|
||||
return (EINVAL);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
*isrcp = &sc->isrcs[data->fdt.cells[0]].isrc;
|
||||
*isrcp = &sc->isrcs[daf->cells[0]].isrc;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -188,16 +188,18 @@ static int
|
||||
aw_nmi_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct aw_nmi_softc *sc;
|
||||
int error;
|
||||
u_int irq;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
error = aw_nmi_map_fdt(dev, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
NULL, NULL);
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
error = aw_nmi_map_fdt(dev, daf->ncells, daf->cells, &irq, NULL, NULL);
|
||||
if (error == 0)
|
||||
*isrcp = &sc->intr.isrc;
|
||||
|
||||
@ -208,6 +210,7 @@ static int
|
||||
aw_nmi_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
struct resource *res, struct intr_map_data *data)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct aw_nmi_softc *sc;
|
||||
struct aw_nmi_intr *nmi_intr;
|
||||
int error, icfg;
|
||||
@ -215,14 +218,15 @@ aw_nmi_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
enum intr_trigger trig;
|
||||
enum intr_polarity pol;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
nmi_intr = (struct aw_nmi_intr *)isrc;
|
||||
|
||||
/* Get config for interrupt. */
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
error = aw_nmi_map_fdt(dev, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
&pol, &trig);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
nmi_intr = (struct aw_nmi_intr *)isrc;
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
error = aw_nmi_map_fdt(dev, daf->ncells, daf->cells, &irq, &pol, &trig);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (nmi_intr->irq != irq)
|
||||
|
@ -1006,18 +1006,22 @@ gic_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
|
||||
enum intr_polarity pol;
|
||||
enum intr_trigger trig;
|
||||
struct arm_gic_softc *sc;
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
#endif
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
switch (data->type) {
|
||||
#ifdef FDT
|
||||
case INTR_MAP_DATA_FDT:
|
||||
if (gic_map_fdt(dev, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
&pol, &trig) != 0)
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
if (gic_map_fdt(dev, daf->ncells, daf->cells, &irq, &pol,
|
||||
&trig) != 0)
|
||||
return (EINVAL);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return (EINVAL);
|
||||
return (ENOTSUP);
|
||||
}
|
||||
|
||||
if (irq >= sc->nirqs)
|
||||
|
@ -1078,14 +1078,16 @@ bcm_gpio_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
{
|
||||
int error;
|
||||
u_int irq;
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct bcm_gpio_softc *sc;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
error = bcm_gpio_pic_map_fdt(sc, data->fdt.ncells, data->fdt.cells,
|
||||
&irq, NULL);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
error = bcm_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq, NULL);
|
||||
if (error == 0)
|
||||
*isrcp = &sc->sc_isrcs[irq].bgi_isrc;
|
||||
return (error);
|
||||
@ -1127,15 +1129,17 @@ bcm_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
uint32_t bank, reg;
|
||||
struct bcm_gpio_softc *sc;
|
||||
struct bcm_gpio_irqsrc *bgi;
|
||||
struct intr_map_data_fdt *daf;
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
bgi = (struct bcm_gpio_irqsrc *)isrc;
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
/* Get and check config for an interrupt. */
|
||||
if (bcm_gpio_pic_map_fdt(sc, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
if (bcm_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq,
|
||||
®) != 0 || bgi->bgi_irq != irq)
|
||||
return (EINVAL);
|
||||
|
||||
|
@ -268,14 +268,17 @@ bcm_intc_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
u_int irq;
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct bcm_intc_softc *sc;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
if (data->fdt.ncells == 1)
|
||||
irq = data->fdt.cells[0];
|
||||
else if (data->fdt.ncells == 2)
|
||||
irq = data->fdt.cells[0] * 32 + data->fdt.cells[1];
|
||||
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
if (daf->ncells == 1)
|
||||
irq = daf->cells[0];
|
||||
else if (daf->ncells == 2)
|
||||
irq = daf->cells[0] * 32 + daf->cells[1];
|
||||
else
|
||||
return (EINVAL);
|
||||
|
||||
|
@ -461,15 +461,18 @@ static int
|
||||
bcm_lintc_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct bcm_lintc_softc *sc;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
if (data->fdt.ncells != 1 || data->fdt.cells[0] >= BCM_LINTC_NIRQS)
|
||||
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
if (daf->ncells != 1 || daf->cells[0] >= BCM_LINTC_NIRQS)
|
||||
return (EINVAL);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
*isrcp = &sc->bls_isrcs[data->fdt.cells[0]].bli_isrc;
|
||||
*isrcp = &sc->bls_isrcs[daf->cells[0]].bli_isrc;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -225,13 +225,15 @@ gpio_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
{
|
||||
int error;
|
||||
u_int irq;
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct imx51_gpio_softc *sc;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
error = gpio_pic_map_fdt(dev, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
NULL, NULL);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
error = gpio_pic_map_fdt(dev, daf->ncells, daf->cells, &irq, NULL,
|
||||
NULL);
|
||||
if (error == 0) {
|
||||
sc = device_get_softc(dev);
|
||||
*isrcp = &sc->gpio_pic_irqsrc[irq].gi_isrc;
|
||||
@ -265,6 +267,7 @@ static int
|
||||
gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
struct resource *res, struct intr_map_data *data)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct imx51_gpio_softc *sc;
|
||||
struct gpio_irqsrc *gi;
|
||||
int error, icfg;
|
||||
@ -278,8 +281,9 @@ gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
/* Get config for interrupt. */
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
error = gpio_pic_map_fdt(dev, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
&pol, &trig);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
error = gpio_pic_map_fdt(dev, daf->ncells, daf->cells, &irq, &pol,
|
||||
&trig);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
if (gi->gi_irq != irq)
|
||||
|
@ -339,15 +339,19 @@ static int
|
||||
mpic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mv_mpic_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT || data->fdt.ncells !=1 ||
|
||||
data->fdt.cells[0] >= sc->nirqs)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells !=1 || daf->cells[0] >= sc->nirqs)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = &sc->mpic_isrcs[data->fdt.cells[0]].mmi_isrc;
|
||||
*isrcp = &sc->mpic_isrcs[daf->cells[0]].mmi_isrc;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -579,14 +579,19 @@ tegra_gpio_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
if (data->type == INTR_MAP_DATA_FDT)
|
||||
rv = tegra_gpio_pic_map_fdt(sc, data->fdt.ncells,
|
||||
data->fdt.cells, &irq, NULL);
|
||||
else if (data->type == INTR_MAP_DATA_GPIO)
|
||||
rv = tegra_gpio_pic_map_gpio(sc, data->gpio.gpio_pin_num,
|
||||
data->gpio.gpio_pin_flags, data->gpio.gpio_intr_mode,
|
||||
&irq, NULL);
|
||||
else
|
||||
if (data->type == INTR_MAP_DATA_FDT) {
|
||||
struct intr_map_data_fdt *daf;
|
||||
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
rv = tegra_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq,
|
||||
NULL);
|
||||
} else if (data->type == INTR_MAP_DATA_GPIO) {
|
||||
struct intr_map_data_gpio *dag;
|
||||
|
||||
dag = (struct intr_map_data_gpio *)data;
|
||||
rv = tegra_gpio_pic_map_gpio(sc, dag->gpio_pin_num,
|
||||
dag->gpio_pin_flags, dag->gpio_intr_mode, &irq, NULL);
|
||||
} else
|
||||
return (ENOTSUP);
|
||||
|
||||
if (rv == 0)
|
||||
@ -648,14 +653,19 @@ tegra_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
return (ENOTSUP);
|
||||
|
||||
/* Get and check config for an interrupt. */
|
||||
if (data->type == INTR_MAP_DATA_FDT)
|
||||
rv = tegra_gpio_pic_map_fdt(sc, data->fdt.ncells,
|
||||
data->fdt.cells, &irq, &cfgreg);
|
||||
else if (data->type == INTR_MAP_DATA_GPIO)
|
||||
rv = tegra_gpio_pic_map_gpio(sc, data->gpio.gpio_pin_num,
|
||||
data->gpio.gpio_pin_flags, data->gpio.gpio_intr_mode,
|
||||
&irq, &cfgreg);
|
||||
else
|
||||
if (data->type == INTR_MAP_DATA_FDT) {
|
||||
struct intr_map_data_fdt *daf;
|
||||
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
rv = tegra_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq,
|
||||
&cfgreg);
|
||||
} else if (data->type == INTR_MAP_DATA_GPIO) {
|
||||
struct intr_map_data_gpio *dag;
|
||||
|
||||
dag = (struct intr_map_data_gpio *)data;
|
||||
rv = tegra_gpio_pic_map_gpio(sc, dag->gpio_pin_num,
|
||||
dag->gpio_pin_flags, dag->gpio_intr_mode, &irq, &cfgreg);
|
||||
} else
|
||||
return (ENOTSUP);
|
||||
if (rv != 0)
|
||||
return (EINVAL);
|
||||
|
@ -178,14 +178,18 @@ static int
|
||||
ti_aintc_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct ti_aintc_softc *sc;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT || data->fdt.ncells != 1 ||
|
||||
data->fdt.cells[0] >= INTC_NIRQS)
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
if (daf->ncells != 1 || daf->cells[0] >= INTC_NIRQS)
|
||||
return (EINVAL);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
*isrcp = &sc->aintc_isrcs[data->fdt.cells[0]].tai_isrc;
|
||||
*isrcp = &sc->aintc_isrcs[daf->cells[0]].tai_isrc;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -979,13 +979,15 @@ ti_gpio_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
int error;
|
||||
u_int irq;
|
||||
struct ti_gpio_softc *sc;
|
||||
struct intr_map_data_fdt *daf;
|
||||
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
error = ti_gpio_pic_map_fdt(sc, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
NULL);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
error = ti_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq, NULL);
|
||||
if (error == 0)
|
||||
*isrcp = &sc->sc_isrcs[irq].tgi_isrc;
|
||||
return (error);
|
||||
@ -1027,15 +1029,17 @@ ti_gpio_pic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
|
||||
uint32_t cfgreg;
|
||||
struct ti_gpio_softc *sc;
|
||||
struct ti_gpio_irqsrc *tgi;
|
||||
struct intr_map_data_fdt *daf;
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
tgi = (struct ti_gpio_irqsrc *)isrc;
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
/* Get and check config for an interrupt. */
|
||||
if (ti_gpio_pic_map_fdt(sc, data->fdt.ncells, data->fdt.cells, &irq,
|
||||
if (ti_gpio_pic_map_fdt(sc, daf->ncells, daf->cells, &irq,
|
||||
&cfgreg) != 0 || tgi->tgi_irq != irq)
|
||||
return (EINVAL);
|
||||
|
||||
|
@ -128,7 +128,7 @@ struct intr_dev_data {
|
||||
device_t idd_dev;
|
||||
intptr_t idd_xref;
|
||||
u_int idd_irq;
|
||||
struct intr_map_data idd_data;
|
||||
struct intr_map_data * idd_data;
|
||||
struct intr_irqsrc * idd_isrc;
|
||||
};
|
||||
|
||||
@ -495,8 +495,10 @@ static struct intr_dev_data *
|
||||
intr_ddata_alloc(u_int extsize)
|
||||
{
|
||||
struct intr_dev_data *ddata;
|
||||
size_t size;
|
||||
|
||||
ddata = malloc(sizeof(*ddata) + extsize, M_INTRNG, M_WAITOK | M_ZERO);
|
||||
size = sizeof(*ddata);
|
||||
ddata = malloc(size + extsize, M_INTRNG, M_WAITOK | M_ZERO);
|
||||
|
||||
mtx_lock(&isrc_table_lock);
|
||||
if (intr_ddata_first_unused >= nitems(intr_ddata_tab)) {
|
||||
@ -507,6 +509,9 @@ intr_ddata_alloc(u_int extsize)
|
||||
intr_ddata_tab[intr_ddata_first_unused] = ddata;
|
||||
ddata->idd_irq = IRQ_DDATA_BASE + intr_ddata_first_unused++;
|
||||
mtx_unlock(&isrc_table_lock);
|
||||
|
||||
ddata->idd_data = (struct intr_map_data *)((uintptr_t)ddata + size);
|
||||
ddata->idd_data->size = size;
|
||||
return (ddata);
|
||||
}
|
||||
|
||||
@ -534,13 +539,13 @@ intr_ddata_lookup(u_int irq, struct intr_map_data **datap)
|
||||
ddata = intr_ddata_tab[irq];
|
||||
if (ddata->idd_isrc == NULL) {
|
||||
error = intr_map_irq(ddata->idd_dev, ddata->idd_xref,
|
||||
&ddata->idd_data, &irq);
|
||||
ddata->idd_data, &irq);
|
||||
if (error != 0)
|
||||
return (NULL);
|
||||
ddata->idd_isrc = isrc_lookup(irq);
|
||||
}
|
||||
if (datap != NULL)
|
||||
*datap = &ddata->idd_data;
|
||||
*datap = ddata->idd_data;
|
||||
return (ddata->idd_isrc);
|
||||
}
|
||||
|
||||
@ -554,17 +559,21 @@ u_int
|
||||
intr_acpi_map_irq(device_t dev, u_int irq, enum intr_polarity pol,
|
||||
enum intr_trigger trig)
|
||||
{
|
||||
struct intr_map_data_acpi *daa;
|
||||
struct intr_dev_data *ddata;
|
||||
|
||||
ddata = intr_ddata_alloc(0);
|
||||
ddata = intr_ddata_alloc(sizeof(struct intr_map_data_acpi));
|
||||
if (ddata == NULL)
|
||||
return (INTR_IRQ_INVALID); /* no space left */
|
||||
|
||||
ddata->idd_dev = dev;
|
||||
ddata->idd_data.type = INTR_MAP_DATA_ACPI;
|
||||
ddata->idd_data.acpi.irq = irq;
|
||||
ddata->idd_data.acpi.pol = pol;
|
||||
ddata->idd_data.acpi.trig = trig;
|
||||
ddata->idd_data->type = INTR_MAP_DATA_ACPI;
|
||||
|
||||
daa = (struct intr_map_data_acpi *)ddata->idd_data;
|
||||
daa->irq = irq;
|
||||
daa->pol = pol;
|
||||
daa->trig = trig;
|
||||
|
||||
return (ddata->idd_irq);
|
||||
}
|
||||
#endif
|
||||
@ -577,19 +586,21 @@ intr_acpi_map_irq(device_t dev, u_int irq, enum intr_polarity pol,
|
||||
u_int
|
||||
intr_fdt_map_irq(phandle_t node, pcell_t *cells, u_int ncells)
|
||||
{
|
||||
size_t cellsize;
|
||||
struct intr_dev_data *ddata;
|
||||
u_int cellsize;
|
||||
struct intr_map_data_fdt *daf;
|
||||
|
||||
cellsize = ncells * sizeof(*cells);
|
||||
ddata = intr_ddata_alloc(cellsize);
|
||||
ddata = intr_ddata_alloc(sizeof(struct intr_map_data_fdt) + cellsize);
|
||||
if (ddata == NULL)
|
||||
return (INTR_IRQ_INVALID); /* no space left */
|
||||
|
||||
ddata->idd_xref = (intptr_t)node;
|
||||
ddata->idd_data.type = INTR_MAP_DATA_FDT;
|
||||
ddata->idd_data.fdt.ncells = ncells;
|
||||
ddata->idd_data.fdt.cells = (pcell_t *)(ddata + 1);
|
||||
memcpy(ddata->idd_data.fdt.cells, cells, cellsize);
|
||||
ddata->idd_data->type = INTR_MAP_DATA_FDT;
|
||||
|
||||
daf = (struct intr_map_data_fdt *)ddata->idd_data;
|
||||
daf->ncells = ncells;
|
||||
memcpy(daf->cells, cells, cellsize);
|
||||
return (ddata->idd_irq);
|
||||
}
|
||||
#endif
|
||||
@ -602,16 +613,19 @@ 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(0);
|
||||
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;
|
||||
ddata->idd_data.gpio.gpio_pin_num = pin_num;
|
||||
ddata->idd_data.gpio.gpio_pin_flags = pin_flags;
|
||||
ddata->idd_data.gpio.gpio_intr_mode = intr_mode;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -514,15 +514,19 @@ static int
|
||||
mtk_gpio_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mtk_gpio_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
|
||||
data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->num_pins)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells != 1 || daf->cells[0] >= sc->num_pins)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = PIC_INTR_ISRC(sc, data->fdt.cells[0]);
|
||||
*isrcp = PIC_INTR_ISRC(sc, daf->cells[0]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -511,15 +511,19 @@ static int
|
||||
mtk_gpio_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mtk_gpio_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
|
||||
data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->num_pins)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells != 1 || daf->cells[0] >= sc->num_pins)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = PIC_INTR_ISRC(sc, data->fdt.cells[0]);
|
||||
*isrcp = PIC_INTR_ISRC(sc, daf->cells[0]);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -265,18 +265,22 @@ mtk_gic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mtk_gic_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
|
||||
data->fdt.ncells != 3 || data->fdt.cells[1] >= sc->nirqs)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells != 3 || daf->cells[1] >= sc->nirqs)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = GIC_INTR_ISRC(sc, data->fdt.cells[1]);
|
||||
*isrcp = GIC_INTR_ISRC(sc, daf->cells[1]);
|
||||
return (0);
|
||||
#else
|
||||
return (EINVAL);
|
||||
return (ENOTSUP);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -275,18 +275,22 @@ mtk_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mtk_pic_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
|
||||
data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->nirqs)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells != 1 || daf->cells[0] >= sc->nirqs)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = PIC_INTR_ISRC(sc, data->fdt.cells[0]);
|
||||
*isrcp = PIC_INTR_ISRC(sc, daf->cells[0]);
|
||||
return (0);
|
||||
#else
|
||||
return (EINVAL);
|
||||
return (ENOTSUP);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -270,18 +270,22 @@ mtk_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mtk_pic_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
|
||||
data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->nirqs)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells != 1 || daf->cells[0] >= sc->nirqs)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = PIC_INTR_ISRC(sc, data->fdt.cells[0]);
|
||||
*isrcp = PIC_INTR_ISRC(sc, daf->cells[0]);
|
||||
return (0);
|
||||
#else
|
||||
return (EINVAL);
|
||||
return (ENOTSUP);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -305,18 +305,22 @@ mips_pic_map_intr(device_t dev, struct intr_map_data *data,
|
||||
struct intr_irqsrc **isrcp)
|
||||
{
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt *daf;
|
||||
struct mips_pic_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
if (data->type != INTR_MAP_DATA_FDT)
|
||||
return (ENOTSUP);
|
||||
|
||||
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
|
||||
data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->nirqs)
|
||||
sc = device_get_softc(dev);
|
||||
daf = (struct intr_map_data_fdt *)data;
|
||||
|
||||
if (daf->ncells != 1 || daf->cells[0] >= sc->nirqs)
|
||||
return (EINVAL);
|
||||
|
||||
*isrcp = PIC_INTR_ISRC(sc, data->fdt.cells[0]);
|
||||
*isrcp = PIC_INTR_ISRC(sc, daf->cells[0]);
|
||||
return (0);
|
||||
#else
|
||||
return (EINVAL);
|
||||
return (ENOTSUP);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,14 @@ enum intr_map_data_type {
|
||||
INTR_MAP_DATA_GPIO,
|
||||
};
|
||||
|
||||
struct intr_map_data {
|
||||
enum intr_map_data_type type;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
struct intr_map_data_acpi {
|
||||
struct intr_map_data hdr;
|
||||
u_int irq;
|
||||
enum intr_polarity pol;
|
||||
enum intr_trigger trig;
|
||||
@ -49,30 +55,19 @@ struct intr_map_data_acpi {
|
||||
#endif
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt {
|
||||
u_int ncells;
|
||||
pcell_t *cells;
|
||||
struct intr_map_data hdr;
|
||||
u_int ncells;
|
||||
pcell_t cells[0];
|
||||
};
|
||||
#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;
|
||||
};
|
||||
|
||||
struct intr_map_data {
|
||||
enum intr_map_data_type type;
|
||||
union {
|
||||
#ifdef DEV_ACPI
|
||||
struct intr_map_data_acpi acpi;
|
||||
#endif
|
||||
#ifdef FDT
|
||||
struct intr_map_data_fdt fdt;
|
||||
#endif
|
||||
struct intr_map_data_gpio gpio;
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef notyet
|
||||
#define INTR_SOLO INTR_MD1
|
||||
typedef int intr_irq_filter_t(void *arg, struct trapframe *tf);
|
||||
|
Loading…
Reference in New Issue
Block a user