Allocate resources selectively.
One of the SMMU interrupt lines (priq) is optional and may be ommited in FDT. Tested on ARM Morello Board, which has three SMMU units: first two have four interrupt lines, last one has three interrupt lines. Sponsored by: UKRI
This commit is contained in:
parent
0a8e88fa73
commit
f224006fe1
@ -152,7 +152,7 @@ __FBSDID("$FreeBSD$");
|
||||
static struct resource_spec smmu_spec[] = {
|
||||
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
|
||||
{ SYS_RES_IRQ, 0, RF_ACTIVE },
|
||||
{ SYS_RES_IRQ, 1, RF_ACTIVE },
|
||||
{ SYS_RES_IRQ, 1, RF_ACTIVE | RF_OPTIONAL },
|
||||
{ SYS_RES_IRQ, 2, RF_ACTIVE },
|
||||
{ SYS_RES_IRQ, 3, RF_ACTIVE },
|
||||
RESOURCE_SPEC_END
|
||||
@ -1547,12 +1547,6 @@ smmu_attach(device_t dev)
|
||||
|
||||
mtx_init(&sc->sc_mtx, device_get_nameunit(sc->dev), "smmu", MTX_DEF);
|
||||
|
||||
error = bus_alloc_resources(dev, smmu_spec, sc->res);
|
||||
if (error) {
|
||||
device_printf(dev, "Couldn't allocate resources.\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
error = smmu_setup_interrupts(sc);
|
||||
if (error) {
|
||||
bus_release_resources(dev, smmu_spec, sc->res);
|
||||
|
@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/bus.h>
|
||||
#include <sys/bitstring.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/tree.h>
|
||||
#include <sys/taskqueue.h>
|
||||
#include <sys/malloc.h>
|
||||
@ -192,6 +193,7 @@ smmu_acpi_attach(device_t dev)
|
||||
struct iommu_unit *iommu;
|
||||
uintptr_t priv;
|
||||
int err;
|
||||
int rid;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
@ -204,6 +206,43 @@ smmu_acpi_attach(device_t dev)
|
||||
device_printf(sc->dev, "%s: features %x\n",
|
||||
__func__, sc->features);
|
||||
|
||||
rid = 0;
|
||||
sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
|
||||
RF_ACTIVE);
|
||||
if (sc->res[0] == NULL) {
|
||||
device_printf(dev, "Can't allocate memory resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interrupt lines are "eventq", "priq", "cmdq-sync", "gerror".
|
||||
*/
|
||||
|
||||
rid = 0;
|
||||
sc->res[1] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
|
||||
if (sc->res[1] == NULL) {
|
||||
device_printf(dev, "Can't allocate eventq IRQ resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
rid = 2;
|
||||
sc->res[3] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
|
||||
if (sc->res[3] == NULL) {
|
||||
device_printf(dev, "Can't allocate cmdq-sync IRQ resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
rid = 3;
|
||||
sc->res[4] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
|
||||
if (sc->res[4] == NULL) {
|
||||
device_printf(dev, "Can't allocate gerror IRQ resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = smmu_attach(dev);
|
||||
if (err != 0)
|
||||
goto error;
|
||||
|
@ -82,11 +82,79 @@ smmu_fdt_attach(device_t dev)
|
||||
struct smmu_softc *sc;
|
||||
struct smmu_unit *unit;
|
||||
struct iommu_unit *iommu;
|
||||
phandle_t node;
|
||||
int err;
|
||||
int rid;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
|
||||
node = ofw_bus_get_node(dev);
|
||||
|
||||
rid = 0;
|
||||
sc->res[0] = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
|
||||
RF_ACTIVE);
|
||||
if (sc->res[0] == NULL) {
|
||||
device_printf(dev, "Can't allocate memory resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Interrupt lines are "eventq", "priq", "cmdq-sync", "gerror".
|
||||
*/
|
||||
|
||||
err = ofw_bus_find_string_index(node, "interrupt-names", "eventq",
|
||||
&rid);
|
||||
if (err != 0) {
|
||||
device_printf(dev, "Can't get eventq IRQ.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
sc->res[1] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
|
||||
if (sc->res[1] == NULL) {
|
||||
device_printf(dev, "Can't allocate eventq IRQ resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* sc->res[2] is reserved for priq IRQ. It is optional and not used
|
||||
* by the SMMU driver. This IRQ line may or may not be provided by
|
||||
* hardware.
|
||||
*/
|
||||
|
||||
err = ofw_bus_find_string_index(node, "interrupt-names", "cmdq-sync",
|
||||
&rid);
|
||||
if (err != 0) {
|
||||
device_printf(dev, "Can't get cmdq-sync IRQ.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
sc->res[3] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
|
||||
if (sc->res[3] == NULL) {
|
||||
device_printf(dev, "Can't allocate cmdq-sync IRQ resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = ofw_bus_find_string_index(node, "interrupt-names", "gerror",
|
||||
&rid);
|
||||
if (err != 0) {
|
||||
device_printf(dev, "Can't get gerror IRQ.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
sc->res[4] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE);
|
||||
if (sc->res[4] == NULL) {
|
||||
device_printf(dev, "Can't allocate gerror IRQ resource.\n");
|
||||
err = ENXIO;
|
||||
goto error;
|
||||
}
|
||||
|
||||
err = smmu_attach(dev);
|
||||
if (err != 0)
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user