Page MenuHomeFreeBSD

D59813.1794759820.diff
No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None

D59813.1794759820.diff

Index: sys/riscv/riscv/intc.c
===================================================================
--- sys/riscv/riscv/intc.c
+++ sys/riscv/riscv/intc.c
@@ -58,6 +58,7 @@
#include <dev/ofw/ofw_bus_subr.h>
#include "pic_if.h"
+#include "ofw_bus_if.h"
#define INTC_NIRQS 16
@@ -69,6 +70,12 @@
struct intc_softc {
device_t dev;
struct intc_irqsrc isrcs[INTC_NIRQS];
+ device_t imsic;
+};
+
+struct intc_devinfo {
+ struct resource_list di_rl;
+ struct ofw_bus_devinfo di_dinfo;
};
static int intc_intr(void *arg);
@@ -139,6 +146,60 @@
device_printf(parent, "Can't add intc child\n");
}
+static int
+intc_add_imsic(device_t dev)
+{
+ struct intc_softc *sc;
+ struct intc_devinfo *di;
+ pcell_t addr_cells, size_cells;
+ phandle_t parent;
+ phandle_t child;
+
+ sc = device_get_softc(dev);
+
+ child = ofw_bus_find_compatible(OF_finddevice("/"), "riscv,imsics");
+ if (child == 0)
+ return (0);
+
+ parent = OF_parent(child);
+
+ if (OF_getencprop(parent, "#address-cells", &addr_cells,
+ sizeof(addr_cells)) == -1) {
+ panic("no ac");
+ device_printf(dev, "Unable to read #address-cells\n");
+ return (ENXIO);
+ }
+
+ if (OF_getencprop(parent, "#size-cells", &size_cells,
+ sizeof(size_cells)) == -1) {
+ panic("no sc");
+ device_printf(dev, "Unable to read #size-cells\n");
+ return (ENXIO);
+ }
+
+ di = malloc(sizeof(*di), M_DEVBUF, M_WAITOK | M_ZERO);
+ if (ofw_bus_gen_setup_devinfo(&di->di_dinfo, child)) {
+ if (bootverbose)
+ device_printf(dev, "Could not set up devinfo\n");
+ free(di, M_DEVBUF);
+ return (ENXIO);
+ }
+
+ sc->imsic = device_add_child(dev, "imsic", DEVICE_UNIT_ANY);
+ if (sc->imsic == NULL) {
+ free(di, M_DEVBUF);
+ return (ENXIO);
+ }
+
+ /* Initialize and populate resource list. */
+ resource_list_init(&di->di_rl);
+ ofw_bus_reg_to_rl(dev, child, addr_cells, size_cells, &di->di_rl);
+ ofw_bus_intr_to_rl(dev, child, &di->di_rl, NULL);
+ device_set_ivars(sc->imsic, di);
+
+ return (0);
+}
+
static int
intc_probe(device_t dev)
{
@@ -181,6 +242,8 @@
if (pic == NULL)
return (ENXIO);
+ intc_add_imsic(dev);
+
return (intr_pic_claim_root(sc->dev, xref, intc_intr, sc, INTR_ROOT_IRQ));
}
@@ -256,6 +319,9 @@
if (intr_isrc_init_on_cpu(isrc, cpu))
intc_enable_intr(dev, isrc);
}
+
+ if (sc->imsic != NULL)
+ PIC_INIT_SECONDARY(sc->imsic, rootnum);
}
#endif
@@ -288,12 +354,45 @@
return (FILTER_HANDLED);
}
+static const struct ofw_bus_devinfo *
+intc_get_devinfo(device_t bus __unused, device_t child)
+{
+ struct intc_devinfo *di;
+
+ di = device_get_ivars(child);
+ if (di == NULL)
+ return (NULL);
+ return (&di->di_dinfo);
+}
+
+static struct resource_list *
+intc_get_resource_list(device_t bus, device_t child)
+{
+ struct intc_devinfo *di;
+
+ di = device_get_ivars(child);
+ KASSERT(di != NULL, ("%s: No devinfo", __func__));
+
+ return (&di->di_rl);
+}
+
static device_method_t intc_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, intc_identify),
DEVMETHOD(device_probe, intc_probe),
DEVMETHOD(device_attach, intc_attach),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+
+ DEVMETHOD(bus_get_resource_list, intc_get_resource_list),
+ DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
+ DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, intc_disable_intr),
DEVMETHOD(pic_enable_intr, intc_enable_intr),
@@ -302,6 +401,12 @@
#ifdef SMP
DEVMETHOD(pic_init_secondary, intc_init_secondary),
#endif
+ DEVMETHOD(ofw_bus_get_devinfo, intc_get_devinfo),
+ DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
+ DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
+ DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
+ DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
+ DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
DEVMETHOD_END
};

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 15, 4:23 PM (8 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41745202
Default Alt Text
D59813.1794759820.diff (4 KB)

Event Timeline