-/* $OpenBSD: intr.c,v 1.28 2024/05/26 13:37:31 kettenis Exp $ */
+/* $OpenBSD: intr.c,v 1.29 2024/08/04 12:01:18 kettenis Exp $ */
/*
* Copyright (c) 2011 Dale Rahn <drahn@openbsd.org>
*
#include <dev/ofw/openfirm.h>
-uint32_t arm_intr_get_parent(int);
+int arm_intr_get_parent(int);
uint32_t arm_intr_map_msi(int, uint64_t *);
void *arm_intr_prereg_establish_fdt(void *, int *, int, struct cpu_info *,
/*
* Find the interrupt parent by walking up the tree.
*/
-uint32_t
+int
arm_intr_get_parent(int node)
{
- uint32_t phandle = 0;
+ uint32_t phandle;
- while (node && !phandle) {
+ while (node) {
phandle = OF_getpropint(node, "interrupt-parent", 0);
+ if (phandle)
+ return OF_getnodebyphandle(phandle);
node = OF_parent(node);
+ if (OF_getpropbool(node, "interrupt-controller"))
+ return node;
}
- return phandle;
+ return 0;
}
uint32_t
ic->ic_cells = OF_getpropint(ic->ic_node, "#interrupt-cells", 0);
ic->ic_phandle = OF_getpropint(ic->ic_node, "phandle", 0);
- if (ic->ic_phandle == 0)
- return;
KASSERT(ic->ic_cells <= MAX_INTERRUPT_CELLS);
LIST_INSERT_HEAD(&interrupt_controllers, ic, ic_list);
int (*func)(void *), void *cookie, char *name)
{
struct interrupt_controller *ic;
- int i, len, ncells, extended = 1;
+ int i, len, ncells, parent;
+ int extended = 1;
uint32_t *cell, *cells, phandle;
struct machine_intr_handle *ih;
void *val = NULL;
/* Old style. */
if (!extended) {
- phandle = arm_intr_get_parent(node);
+ parent = arm_intr_get_parent(node);
LIST_FOREACH(ic, &interrupt_controllers, ic_list) {
- if (ic->ic_phandle == phandle)
+ if (ic->ic_node == parent)
break;
}
{
struct interrupt_controller *ic = cookie;
struct machine_intr_handle *ih;
- uint32_t phandle;
+ int parent;
void *val;
- phandle = arm_intr_get_parent(ic->ic_node);
+ parent = arm_intr_get_parent(ic->ic_node);
LIST_FOREACH(ic, &interrupt_controllers, ic_list) {
- if (ic->ic_phandle == phandle)
+ if (ic->ic_node == parent)
break;
}
if (ic == NULL)