summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/octeon/dev/octeon_intr.c33
-rw-r--r--sys/arch/octeon/include/intr.h4
2 files changed, 35 insertions, 2 deletions
diff --git a/sys/arch/octeon/dev/octeon_intr.c b/sys/arch/octeon/dev/octeon_intr.c
index 9ee25635f17..b731c520805 100644
--- a/sys/arch/octeon/dev/octeon_intr.c
+++ b/sys/arch/octeon/dev/octeon_intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: octeon_intr.c,v 1.18 2016/12/04 11:52:51 visa Exp $ */
+/* $OpenBSD: octeon_intr.c,v 1.19 2016/12/08 16:27:46 visa Exp $ */
/*
* Copyright (c) 2000-2004 Opsycon AB (www.opsycon.se)
@@ -39,6 +39,8 @@
#include <sys/proc.h>
#include <sys/atomic.h>
+#include <dev/ofw/openfirm.h>
+
#include <mips64/mips_cpu.h>
#include <machine/autoconf.h>
@@ -149,6 +151,35 @@ octeon_intr_establish(int irq, int level,
return (ih);
}
+void *
+octeon_intr_establish_fdt_idx(int node, int idx, int level,
+ int (*ih_fun)(void *), void *ih_arg, const char *ih_what)
+{
+ uint32_t *cells;
+ int irq, len;
+
+ /*
+ * Assume the interrupt controller is compatible with
+ * cavium,octeon-3860-ciu.
+ */
+
+ len = OF_getproplen(node, "interrupts");
+ if (len / (sizeof(uint32_t) * 2) <= idx ||
+ len % (sizeof(uint32_t) * 2) != 0)
+ return NULL;
+
+ cells = malloc(len, M_TEMP, M_NOWAIT);
+ if (cells == NULL)
+ return NULL;
+
+ OF_getpropintarray(node, "interrupts", cells, len);
+ irq = cells[idx * 2] * BANK_SIZE + cells[idx * 2 + 1];
+
+ free(cells, M_TEMP, len);
+
+ return octeon_intr_establish(irq, level, ih_fun, ih_arg, ih_what);
+}
+
void
octeon_intr_disestablish(void *_ih)
{
diff --git a/sys/arch/octeon/include/intr.h b/sys/arch/octeon/include/intr.h
index 88417321056..2b1eb6a5e42 100644
--- a/sys/arch/octeon/include/intr.h
+++ b/sys/arch/octeon/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.7 2016/03/06 19:42:27 mpi Exp $ */
+/* $OpenBSD: intr.h,v 1.8 2016/12/08 16:27:46 visa Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -202,6 +202,8 @@ void octeon_intr_init(void);
void octeon_setintrmask(int);
void *octeon_intr_establish(int, int, int (*)(void *),
void *, const char *);
+void *octeon_intr_establish_fdt_idx(int, int, int, int (*)(void *),
+ void *, const char *);
void octeon_intr_disestablish(void *);
void octeon_intr_init(void);