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 <andyross@google.com>
This commit is contained in:
Andy Ross 2024-12-02 21:18:41 -08:00 committed by Henrik Brix Andersen
commit b2c9fd94bc

View file

@ -57,7 +57,6 @@ struct mtk_mbox {
struct mbox_cfg { struct mbox_cfg {
volatile struct mtk_mbox *mbox; volatile struct mtk_mbox *mbox;
uint32_t irq;
}; };
struct mbox_data { 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; const struct mbox_cfg *cfg = ((struct device *)arg)->config;
struct mbox_data *data = ((struct device *)arg)->data; 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 */ 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) \ #define DEF_IRQ(N) \
{ IRQ_CONNECT(DT_INST_IRQN(N), 0, mbox_isr, DEVICE_DT_INST_GET(N), 0); \ { IRQ_CONNECT(DT_INST_IRQN(N), 0, mbox_isr, DEVICE_DT_INST_GET(N), 0); \
irq_enable(DT_INST_IRQN(N)); } irq_enable(DT_INST_IRQN(N)); }
static int mbox_init(void) static int mbox_init(void)
{ {
DT_INST_FOREACH_STATUS_OKAY(DEF_IRQ); DT_INST_FOREACH_STATUS_OKAY(DEF_IRQ);
@ -117,7 +127,7 @@ SYS_INIT(mbox_init, POST_KERNEL, 0);
#define DEF_DEV(N) \ #define DEF_DEV(N) \
static struct mbox_data dev_data##N; \ static struct mbox_data dev_data##N; \
static const struct mbox_cfg dev_cfg##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, \ DEVICE_DT_INST_DEFINE(N, NULL, NULL, &dev_data##N, &dev_cfg##N, \
POST_KERNEL, 0, NULL); POST_KERNEL, 0, NULL);