From 16f2ec56243d2929a9aba9623457955491732cb9 Mon Sep 17 00:00:00 2001 From: tobhe Date: Mon, 22 Aug 2022 12:34:55 +0000 Subject: [PATCH] Get number of interrupt cells from device tree instead of guessing based on version. Fixes M2 Macbook Air 2022 which reports version 2 but only uses 3 cells. ok kettenis@ --- sys/arch/arm64/dev/aplintc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/arch/arm64/dev/aplintc.c b/sys/arch/arm64/dev/aplintc.c index 02cca4c52f2..c663ed04cfc 100644 --- a/sys/arch/arm64/dev/aplintc.c +++ b/sys/arch/arm64/dev/aplintc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aplintc.c,v 1.12 2022/07/13 09:28:18 kettenis Exp $ */ +/* $OpenBSD: aplintc.c,v 1.13 2022/08/22 12:34:55 tobhe Exp $ */ /* * Copyright (c) 2021 Mark Kettenis * @@ -118,6 +118,7 @@ struct aplintc_softc { struct intrhand **sc_irq_handler[AIC_MAXDIES]; int sc_nirq; int sc_ndie; + int sc_ncells; TAILQ_HEAD(, intrhand) sc_irq_list[NIPL]; uint32_t sc_cpuremap[AIC_MAXCPUS]; @@ -188,6 +189,12 @@ aplintc_attach(struct device *parent, struct device *self, void *aux) else sc->sc_version = 1; + sc->sc_ncells = OF_getpropint(faa->fa_node, "#interrupt-cells", 3); + if (sc->sc_ncells < 3 || sc->sc_ncells > 4) { + printf(": invalid number of cells\n"); + return; + } + /* * AIC2 has the event register specified separately. However * a preliminary device tree binding for AIC2 had it included @@ -507,7 +514,7 @@ aplintc_intr_establish(void *cookie, int *cell, int level, uint32_t type = cell[0]; uint32_t die, irq; - if (sc->sc_version == 1) { + if (sc->sc_ncells == 3) { die = 0; irq = cell[1]; } else { -- 2.20.1