Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149251565
D803.id1700.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D803.id1700.diff
View Options
Index: sys/conf/files
===================================================================
--- sys/conf/files
+++ sys/conf/files
@@ -1380,7 +1380,7 @@
dev/fb/splash.c optional sc splash
dev/fdt/fdt_clock.c optional fdt fdt_clock
dev/fdt/fdt_clock_if.m optional fdt fdt_clock
-dev/fdt/fdt_common.c optional fdt
+dev/fdt/fdt_common.c optional fdt | aim
dev/fdt/fdt_pinctrl.c optional fdt fdt_pinctrl
dev/fdt/fdt_pinctrl_if.m optional fdt fdt_pinctrl
dev/fdt/fdt_slicer.c optional fdt cfi | fdt nand
Index: sys/dev/fdt/fdt_common.h
===================================================================
--- sys/dev/fdt/fdt_common.h
+++ sys/dev/fdt/fdt_common.h
@@ -88,7 +88,7 @@
int fdt_get_range(phandle_t, int, u_long *, u_long *);
int fdt_immr_addr(vm_offset_t);
int fdt_regsize(phandle_t, u_long *, u_long *);
-int fdt_intr_to_rl(device_t, phandle_t, struct resource_list *, struct fdt_sense_level *);
+int fdt_intr_to_rl(device_t, phandle_t, struct resource_list *);
int fdt_is_compatible(phandle_t, const char *);
int fdt_is_compatible_strict(phandle_t, const char *);
int fdt_is_enabled(phandle_t);
Index: sys/dev/fdt/fdt_common.c
===================================================================
--- sys/dev/fdt/fdt_common.c
+++ sys/dev/fdt/fdt_common.c
@@ -494,12 +494,12 @@
}
int
-fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl,
- struct fdt_sense_level *intr_sl)
+fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl)
{
phandle_t iparent;
- uint32_t *intr, icells;
- int nintr, i, k;
+ uint32_t icells, *intr;
+ int err, i, irqnum, nintr, rid;
+ boolean_t extended;
nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
(void **)&intr);
@@ -512,8 +512,8 @@
}
if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
- device_printf(dev, "Missing #interrupt-cells property, "
- "assuming <1>\n");
+ device_printf(dev, "Missing #interrupt-cells "
+ "property, assuming <1>\n");
icells = 1;
}
if (icells < 1 || icells > nintr) {
@@ -521,16 +521,38 @@
"value <%d>, assuming <1>\n", icells);
icells = 1;
}
- for (i = 0, k = 0; i < nintr; i += icells, k++) {
- intr[i] = ofw_bus_map_intr(dev, iparent, icells,
- &intr[i]);
- resource_list_add(rl, SYS_RES_IRQ, k, intr[i], intr[i],
- 1);
+ extended = false;
+ } else {
+ nintr = OF_getencprop_alloc(node, "interrupts-extended",
+ sizeof(*intr), (void **)&intr);
+ if (nintr <= 0)
+ return (0);
+ extended = true;
+ }
+ err = 0;
+ rid = 0;
+ for (i = 0; i < nintr; i += icells) {
+ if (extended) {
+ iparent = intr[i++];
+ if (OF_searchencprop(OF_node_from_xref(iparent),
+ "#interrupt-cells", &icells, sizeof(icells)) == -1) {
+ device_printf(dev, "Missing #interrupt-cells "
+ "property\n");
+ err = ENOENT;
+ break;
+ }
+ if (icells < 1 || (i + icells) > nintr) {
+ device_printf(dev, "Invalid #interrupt-cells "
+ "property value <%d>\n", icells);
+ err = ERANGE;
+ break;
+ }
}
- free(intr, M_OFWPROP);
+ irqnum = ofw_bus_map_intr(dev, iparent, icells, &intr[i]);
+ resource_list_add(rl, SYS_RES_IRQ, rid++, irqnum, irqnum, 1);
}
-
- return (0);
+ free(intr, M_OFWPROP);
+ return (err);
}
int
Index: sys/dev/fdt/simplebus.c
===================================================================
--- sys/dev/fdt/simplebus.c
+++ sys/dev/fdt/simplebus.c
@@ -34,6 +34,7 @@
#include <sys/kernel.h>
#include <sys/rman.h>
+#include <dev/fdt/fdt_common.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -247,11 +248,9 @@
{
struct simplebus_softc *sc;
struct simplebus_devinfo *ndi;
- uint32_t *reg, *intr, icells;
+ uint32_t *reg;
uint64_t phys, size;
- phandle_t iparent;
int i, j, k;
- int nintr;
int nreg;
sc = device_get_softc(dev);
@@ -289,34 +288,7 @@
}
free(reg, M_OFWPROP);
- nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
- (void **)&intr);
- if (nintr > 0) {
- if (OF_searchencprop(node, "interrupt-parent", &iparent,
- sizeof(iparent)) == -1) {
- device_printf(dev, "No interrupt-parent found, "
- "assuming direct parent\n");
- iparent = OF_parent(node);
- }
- if (OF_searchencprop(OF_node_from_xref(iparent),
- "#interrupt-cells", &icells, sizeof(icells)) == -1) {
- device_printf(dev, "Missing #interrupt-cells property, "
- "assuming <1>\n");
- icells = 1;
- }
- if (icells < 1 || icells > nintr) {
- device_printf(dev, "Invalid #interrupt-cells property "
- "value <%d>, assuming <1>\n", icells);
- icells = 1;
- }
- for (i = 0, k = 0; i < nintr; i += icells, k++) {
- intr[i] = ofw_bus_map_intr(dev, iparent, icells,
- &intr[i]);
- resource_list_add(&ndi->rl, SYS_RES_IRQ, k, intr[i],
- intr[i], 1);
- }
- free(intr, M_OFWPROP);
- }
+ fdt_intr_to_rl(dev, node, &ndi->rl);
return (ndi);
}
Index: sys/dev/ofw/ofwbus.c
===================================================================
--- sys/dev/ofw/ofwbus.c
+++ sys/dev/ofw/ofwbus.c
@@ -47,6 +47,7 @@
#include <vm/vm.h>
#include <vm/pmap.h>
+#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/openfirm.h>
@@ -436,11 +437,9 @@
struct ofwbus_softc *sc;
struct ofwbus_devinfo *ndi;
const char *nodename;
- uint32_t *reg, *intr, icells;
+ uint32_t *reg;
uint64_t phys, size;
- phandle_t iparent;
int i, j, rid;
- int nintr;
int nreg;
sc = device_get_softc(dev);
@@ -485,35 +484,7 @@
}
free(reg, M_OFWPROP);
- nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
- (void **)&intr);
- if (nintr > 0) {
- if (OF_searchencprop(node, "interrupt-parent", &iparent,
- sizeof(iparent)) == -1) {
- device_printf(dev, "No interrupt-parent found, "
- "assuming nexus on <%s>\n", nodename);
- iparent = 0xffffffff;
- }
- if (OF_searchencprop(OF_node_from_xref(iparent),
- "#interrupt-cells", &icells, sizeof(icells)) == -1) {
- device_printf(dev, "Missing #interrupt-cells property, "
- "assuming <1> on <%s>\n", nodename);
- icells = 1;
- }
- if (icells < 1 || icells > nintr) {
- device_printf(dev, "Invalid #interrupt-cells property "
- "value <%d>, assuming <1> on <%s>\n", icells,
- nodename);
- icells = 1;
- }
- for (i = 0, rid = 0; i < nintr; i += icells, rid++) {
- intr[i] = ofw_bus_map_intr(dev, iparent, icells,
- &intr[i]);
- resource_list_add(&ndi->ndi_rl, SYS_RES_IRQ, rid, intr[i],
- intr[i], 1);
- }
- free(intr, M_OFWPROP);
- }
+ fdt_intr_to_rl(dev, node, &ndi->ndi_rl);
return (ndi);
}
Index: sys/mips/beri/beri_simplebus.c
===================================================================
--- sys/mips/beri/beri_simplebus.c
+++ sys/mips/beri/beri_simplebus.c
@@ -198,7 +198,7 @@
continue;
}
- if (fdt_intr_to_rl(dev, dt_child, &di->di_res, di->di_intr_sl)) {
+ if (fdt_intr_to_rl(dev, dt_child, &di->di_res)) {
device_printf(dev, "%s: could not process "
"'interrupts' property\n", di->di_ofw.obd_name);
resource_list_free(&di->di_res);
Index: sys/powerpc/ofw/ofw_pcibus.c
===================================================================
--- sys/powerpc/ofw/ofw_pcibus.c
+++ sys/powerpc/ofw/ofw_pcibus.c
@@ -37,6 +37,7 @@
#include <sys/module.h>
#include <sys/pciio.h>
+#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/ofw_pci.h>
@@ -200,29 +201,8 @@
* interrupts property, so add that value to the device's
* resource list.
*/
- if (dinfo->opd_dinfo.cfg.intpin == 0) {
- ofw_pci_intr_t intr[2];
- phandle_t iparent;
- int icells;
-
- if (OF_getprop(child, "interrupts", &intr,
- sizeof(intr)) > 0) {
- iparent = 0;
- icells = 1;
- OF_getprop(child, "interrupt-parent", &iparent,
- sizeof(iparent));
- if (iparent != 0) {
- OF_getprop(OF_node_from_xref(iparent),
- "#interrupt-cells", &icells,
- sizeof(icells));
- intr[0] = ofw_bus_map_intr(dev, iparent,
- icells, intr);
- }
-
- resource_list_add(&dinfo->opd_dinfo.resources,
- SYS_RES_IRQ, 0, intr[0], intr[0], 1);
- }
- }
+ if (dinfo->opd_dinfo.cfg.intpin == 0)
+ fdt_intr_to_rl(dev, node, &dinfo->opd_dinfo.resources);
}
}
Index: sys/powerpc/pseries/vdevice.c
===================================================================
--- sys/powerpc/pseries/vdevice.c
+++ sys/powerpc/pseries/vdevice.c
@@ -37,6 +37,7 @@
#include <machine/bus.h>
#include <machine/intr_machdep.h>
+#include <dev/fdt/fdt_common.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -128,8 +129,6 @@
{
phandle_t root, child;
device_t cdev;
- int icells, i, nintr, *intr;
- phandle_t iparent;
struct vdevice_devinfo *dinfo;
root = ofw_bus_get_node(dev);
@@ -144,25 +143,7 @@
}
resource_list_init(&dinfo->mdi_resources);
- if (OF_searchprop(child, "#interrupt-cells", &icells,
- sizeof(icells)) <= 0)
- icells = 2;
- if (OF_getprop(child, "interrupt-parent", &iparent,
- sizeof(iparent)) <= 0)
- iparent = -1;
- nintr = OF_getprop_alloc(child, "interrupts", sizeof(*intr),
- (void **)&intr);
- if (nintr > 0) {
- for (i = 0; i < nintr; i += icells) {
- u_int irq = intr[i];
- if (iparent != -1)
- irq = ofw_bus_map_intr(dev, iparent,
- icells, &intr[i]);
-
- resource_list_add(&dinfo->mdi_resources,
- SYS_RES_IRQ, i, irq, irq, i);
- }
- }
+ fdt_intr_to_rl(dev, child, &dinfo->mdi_resources);
cdev = device_add_child(dev, NULL, -1);
if (cdev == NULL) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 24, 7:22 AM (9 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30236047
Default Alt Text
D803.id1700.diff (9 KB)
Attached To
Mode
D803: Use common fdt_intr_to_rl() function, enhance that to handle interrupt-extended properties, remove duplicated code.
Attached
Detach File
Event Timeline
Log In to Comment