From b2c9fd94bcf8e92f2d288102bfedfde5855ff07c Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Mon, 2 Dec 2024 21:18:41 -0800 Subject: [PATCH] soc/mediatek/adsp: Union mbox ISRs The SOF source code is confusing. On some hardware these devices have distinct IRQs assigned, and on others they seem to share an ISR for all. Leave the existing assignments in place for SOF-compatibility, but union all the devices into a single ISR path that will poll each (there are only two). This will work in all configurations, and we can figure out the proper architecture at leisure. Signed-off-by: Andy Ross --- soc/mediatek/mt8xxx/mbox.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/soc/mediatek/mt8xxx/mbox.c b/soc/mediatek/mt8xxx/mbox.c index 4e0cbb905a6..448cb3b96a5 100644 --- a/soc/mediatek/mt8xxx/mbox.c +++ b/soc/mediatek/mt8xxx/mbox.c @@ -57,7 +57,6 @@ struct mtk_mbox { struct mbox_cfg { volatile struct mtk_mbox *mbox; - uint32_t irq; }; struct mbox_data { @@ -85,7 +84,12 @@ void mtk_adsp_mbox_signal(const struct device *mbox, uint32_t chan) } } -static void mbox_isr(const void *arg) +#define DEF_DEVPTR(N) DEVICE_DT_INST_GET(N), +const struct device * const mbox_devs[] = { + DT_INST_FOREACH_STATUS_OKAY(DEF_DEVPTR) +}; + +static void mbox_handle(const void *arg) { const struct mbox_cfg *cfg = ((struct device *)arg)->config; struct mbox_data *data = ((struct device *)arg)->data; @@ -101,11 +105,17 @@ static void mbox_isr(const void *arg) cfg->mbox->in_cmd_clr = cfg->mbox->in_cmd; /* ACK */ } +static void mbox_isr(const void *arg) +{ + for (int i = 0; i < ARRAY_SIZE(mbox_devs); i++) { + mbox_handle(mbox_devs[i]); + } +} + #define DEF_IRQ(N) \ { IRQ_CONNECT(DT_INST_IRQN(N), 0, mbox_isr, DEVICE_DT_INST_GET(N), 0); \ irq_enable(DT_INST_IRQN(N)); } - static int mbox_init(void) { DT_INST_FOREACH_STATUS_OKAY(DEF_IRQ); @@ -117,7 +127,7 @@ SYS_INIT(mbox_init, POST_KERNEL, 0); #define DEF_DEV(N) \ static struct mbox_data dev_data##N; \ static const struct mbox_cfg dev_cfg##N = \ - { .irq = DT_INST_IRQN(N), .mbox = (void *)DT_INST_REG_ADDR(N), }; \ + { .mbox = (void *)DT_INST_REG_ADDR(N), }; \ DEVICE_DT_INST_DEFINE(N, NULL, NULL, &dev_data##N, &dev_cfg##N, \ POST_KERNEL, 0, NULL);