Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/arm/gic_fdt.c
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | gic_fdt_probe(device_t dev) | ||||
device_set_desc(dev, "ARM Generic Interrupt Controller"); | device_set_desc(dev, "ARM Generic Interrupt Controller"); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
static int | static int | ||||
gic_fdt_attach(device_t dev) | gic_fdt_attach(device_t dev) | ||||
{ | { | ||||
struct arm_gic_fdt_softc *sc = device_get_softc(dev); | struct arm_gic_fdt_softc *sc = device_get_softc(dev); | ||||
phandle_t pxref; | phandle_t pxref = ofw_bus_find_iparent(ofw_bus_get_node(dev)); | ||||
intptr_t xref; | intptr_t xref = OF_xref_from_node(ofw_bus_get_node(dev)); | ||||
int err; | int err; | ||||
sc->base.is_root = false; | |||||
/* | |||||
* Controller is root if: | |||||
* - doesn't have interrupt parent | |||||
* - his interrupt parent is this controller | |||||
*/ | |||||
if (pxref == 0 || xref == pxref) | |||||
sc->base.is_root = true; | |||||
sc->base.gic_bus = GIC_BUS_FDT; | sc->base.gic_bus = GIC_BUS_FDT; | ||||
err = arm_gic_attach(dev); | err = arm_gic_attach(dev); | ||||
if (err != 0) | if (err != 0) | ||||
return (err); | return (err); | ||||
xref = OF_xref_from_node(ofw_bus_get_node(dev)); | |||||
/* | /* | ||||
* Now, when everything is initialized, it's right time to | * Now, when everything is initialized, it's right time to | ||||
* register interrupt controller to interrupt framefork. | * register interrupt controller to interrupt framefork. | ||||
*/ | */ | ||||
if (intr_pic_register(dev, xref) == NULL) { | if (intr_pic_register(dev, xref) == NULL) { | ||||
device_printf(dev, "could not register PIC\n"); | device_printf(dev, "could not register PIC\n"); | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
/* | if (sc->base.is_root) { | ||||
* Controller is root if: | |||||
* - doesn't have interrupt parent | |||||
* - his interrupt parent is this controller | |||||
*/ | |||||
pxref = ofw_bus_find_iparent(ofw_bus_get_node(dev)); | |||||
if (pxref == 0 || xref == pxref) { | |||||
if (intr_pic_claim_root(dev, xref, arm_gic_intr, sc, | if (intr_pic_claim_root(dev, xref, arm_gic_intr, sc, | ||||
GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) { | GIC_LAST_SGI - GIC_FIRST_SGI + 1) != 0) { | ||||
device_printf(dev, "could not set PIC as a root\n"); | device_printf(dev, "could not set PIC as a root\n"); | ||||
intr_pic_deregister(dev, xref); | intr_pic_deregister(dev, xref); | ||||
goto cleanup; | goto cleanup; | ||||
} | } | ||||
} else { | } else { | ||||
if (sc->base.gic_res[2] == NULL) { | if (sc->base.gic_res[2] == NULL) { | ||||
▲ Show 20 Lines • Show All 196 Lines • Show Last 20 Lines |