Skip to content

Commit ee5f38f

Browse files
committed
drivers: firmware: scmi: Add RX channel callback support in mailbox
Implement dedicated RX channel support with separate notification callback. TX and RX channels now use different callbacks for proper message handling. Signed-off-by: Yongxu Wang <[email protected]>
1 parent abd65dc commit ee5f38f

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

drivers/firmware/scmi/mailbox.c

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@
1010
LOG_MODULE_REGISTER(scmi_mbox);
1111

1212
static void scmi_mbox_tx_reply_cb(const struct device *mbox,
13-
mbox_channel_id_t channel_id,
14-
void *user_data,
15-
struct mbox_msg *data)
13+
mbox_channel_id_t channel_id,
14+
void *user_data,
15+
struct mbox_msg *data)
16+
{
17+
struct scmi_channel *scmi_chan = user_data;
18+
19+
if (scmi_chan->cb) {
20+
scmi_chan->cb(scmi_chan);
21+
}
22+
}
23+
24+
static void scmi_mbox_rx_notify_cb(const struct device *mbox,
25+
mbox_channel_id_t channel_id,
26+
void *user_data,
27+
struct mbox_msg *data)
1628
{
1729
struct scmi_channel *scmi_chan = user_data;
1830

@@ -71,25 +83,34 @@ static int scmi_mbox_setup_chan(const struct device *transport,
7183
{
7284
int ret;
7385
struct scmi_mbox_channel *mbox_chan;
74-
struct mbox_dt_spec *tx_reply;
86+
struct mbox_dt_spec *mbox_spec;
7587

7688
mbox_chan = chan->data;
7789

78-
if (mbox_chan->tx_reply.dev) {
79-
tx_reply = &mbox_chan->tx_reply;
90+
if (tx) {
91+
mbox_spec = mbox_chan->tx_reply.dev ? &mbox_chan->tx_reply : &mbox_chan->tx;
92+
ret = mbox_register_callback_dt(mbox_spec, scmi_mbox_tx_reply_cb, chan);
93+
if (ret < 0) {
94+
LOG_ERR("failed to register reply cb on %s",
95+
mbox_chan->tx_reply.dev ? "tx_reply" : "tx");
96+
return ret;
97+
}
8098
} else {
81-
tx_reply = &mbox_chan->tx;
82-
}
83-
84-
ret = mbox_register_callback_dt(tx_reply, scmi_mbox_tx_reply_cb, chan);
85-
if (ret < 0) {
86-
LOG_ERR("failed to register tx reply cb");
87-
return ret;
99+
if (!mbox_chan->rx.dev) {
100+
LOG_ERR("RX channel not defined");
101+
return -ENOTSUP;
102+
}
103+
mbox_spec = &mbox_chan->rx;
104+
ret = mbox_register_callback_dt(&mbox_chan->rx, scmi_mbox_rx_notify_cb, chan);
105+
if (ret < 0) {
106+
LOG_ERR("failed to register notify cb on rx");
107+
return ret;
108+
}
88109
}
89110

90-
ret = mbox_set_enabled_dt(tx_reply, true);
111+
ret = mbox_set_enabled_dt(mbox_spec, true);
91112
if (ret < 0) {
92-
LOG_ERR("failed to enable tx reply dbell");
113+
LOG_ERR("failed to enable %s dbell", tx ? "tx" : "rx");
93114
}
94115

95116
/* enable interrupt-based communication */

0 commit comments

Comments
 (0)