Implement OFW_BUS_MAP_INTR() in terms of the FDT PIC table, which will

become an ARM-specific quirk.
This commit is contained in:
Nathan Whitehorn 2014-01-04 20:59:03 +00:00
parent 6907488efa
commit 818f49fc98

View file

@ -64,7 +64,9 @@ __FBSDID("$FreeBSD$");
#ifdef FDT
#include <dev/ofw/ofw_nexus.h>
#include <dev/fdt/fdt_common.h>
#include <machine/fdt.h>
#include "ofw_bus_if.h"
#else
static MALLOC_DEFINE(M_NEXUSDEV, "nexusdev", "Nexus device");
@ -94,6 +96,11 @@ static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
static int nexus_teardown_intr(device_t, device_t, struct resource *, void *);
#ifdef FDT
static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent,
int irq);
#endif
static device_method_t nexus_methods[] = {
#ifndef FDT
/* Device interface */
@ -109,6 +116,9 @@ static device_method_t nexus_methods[] = {
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_setup_intr, nexus_setup_intr),
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
#ifdef FDT
DEVMETHOD(ofw_bus_map_intr, nexus_ofw_map_intr),
#endif
{ 0, 0 }
};
@ -300,3 +310,33 @@ nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
return (rman_deactivate_resource(res));
}
#ifdef FDT
static int
nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int irq)
{
pcell_t intr[2];
fdt_pic_decode_t intr_decode;
phandle_t intr_offset;
int i, rv, interrupt, trig, pol;
intr_offset = OF_xref_phandle(iparent);
intr[0] = cpu_to_fdt32(irq);
for (i = 0; fdt_pic_table[i] != NULL; i++) {
intr_decode = fdt_pic_table[i];
rv = intr_decode(intr_offset, intr, &interrupt, &trig, &pol);
if (rv == 0) {
/* This was recognized as our PIC and decoded. */
interrupt = FDT_MAP_IRQ(intr_parent, interrupt);
return (interrupt);
}
}
/* Not in table, so guess */
interrupt = FDT_MAP_IRQ(intr_parent, fdt32_to_cpu(*intr));
return (interrupt);
}
#endif