drivers: mbox: Add nxp mbox multi-channel support
Current implementation of NXP mbox driver mbox_nxp_imx_mu is using only one channel 0. This commit adds support for multiple mbox channels as is indented by mbox drivers. Change done in .send api signaling mode leveraging provided channel id to select correct General Purpose Interrupt. Another change done in IRQHandler to check and handle all channels. Signed-off-by: Tomas Galbicka <tomas.galbicka@nxp.com>
This commit is contained in:
parent
690460a06a
commit
89bd024a1c
|
@ -38,7 +38,7 @@ static int nxp_imx_mu_send(const struct device *dev, uint32_t channel,
|
|||
/* Signalling mode. */
|
||||
if (msg == NULL) {
|
||||
return MU_TriggerInterrupts(
|
||||
cfg->base, kMU_GenInt0InterruptTrigger);
|
||||
cfg->base, kMU_GenInt0InterruptTrigger >> channel);
|
||||
}
|
||||
|
||||
/* Data transfer mode. */
|
||||
|
@ -149,27 +149,31 @@ static const struct mbox_driver_api nxp_imx_mu_driver_api = {
|
|||
const struct device *dev = DEVICE_DT_INST_GET(idx); \
|
||||
const struct nxp_imx_mu_data *data = dev->data; \
|
||||
const struct nxp_imx_mu_config *config = dev->config; \
|
||||
int channel = 0; \
|
||||
struct mbox_msg msg; \
|
||||
struct mbox_msg *callback_msg_ptr = NULL; \
|
||||
uint32_t flag = MU_GetStatusFlags(config->base); \
|
||||
\
|
||||
if ((flag & kMU_Rx0FullFlag) == kMU_Rx0FullFlag) { \
|
||||
mu_##idx##_received_data = \
|
||||
MU_ReceiveMsgNonBlocking(config->base, 0); \
|
||||
msg.data = (const void *)&mu_##idx##_received_data; \
|
||||
msg.size = MU_MBOX_SIZE; \
|
||||
callback_msg_ptr = &msg; \
|
||||
} else if ((flag & kMU_GenInt0Flag) == kMU_GenInt0Flag) { \
|
||||
MU_ClearStatusFlags(config->base, kMU_GenInt0Flag); \
|
||||
callback_msg_ptr = NULL; \
|
||||
} \
|
||||
\
|
||||
if (data->cb[channel]) { \
|
||||
data->cb[channel](dev, channel, \
|
||||
data->user_data[channel], \
|
||||
callback_msg_ptr); \
|
||||
} \
|
||||
for (int i_channel = 0; i_channel < MU_MAX_CHANNELS; i_channel++) { \
|
||||
if ((flag & (kMU_Rx0FullFlag >> i_channel)) == \
|
||||
(kMU_Rx0FullFlag >> i_channel)) { \
|
||||
mu_##idx##_received_data = \
|
||||
MU_ReceiveMsgNonBlocking(config->base, 0); \
|
||||
msg.data = (const void *)&mu_##idx##_received_data; \
|
||||
msg.size = MU_MBOX_SIZE; \
|
||||
callback_msg_ptr = &msg; \
|
||||
} else if ((flag & (kMU_GenInt0Flag >> i_channel)) == \
|
||||
(kMU_GenInt0Flag >> i_channel)) { \
|
||||
MU_ClearStatusFlags(config->base, \
|
||||
(kMU_GenInt0Flag >> i_channel)); \
|
||||
callback_msg_ptr = NULL; \
|
||||
} \
|
||||
\
|
||||
if (data->cb[i_channel]) { \
|
||||
data->cb[i_channel](dev, i_channel, \
|
||||
data->user_data[i_channel], \
|
||||
callback_msg_ptr); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define MU_INST(idx) \
|
||||
|
|
Loading…
Reference in a new issue