Commit b2c9fd94 authored by Andy Ross's avatar Andy Ross Committed by Henrik Brix Andersen
Browse files

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: default avatarAndy Ross <andyross@google.com>
parent cba7faed
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -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);