Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions drivers/firmware/scmi/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@

LOG_MODULE_REGISTER(scmi_mbox);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/callbak/callback/ in the commit subject.


static void scmi_mbox_cb(const struct device *mbox,
mbox_channel_id_t channel_id,
void *user_data,
struct mbox_msg *data)
static void scmi_mbox_tx_reply_cb(const struct device *mbox,
mbox_channel_id_t channel_id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this into 2 patches:

  1. Preparation for introducing the RX channel. Here you rename scmi_mbox_cb -> scmi_mbox_tx_reply_cb and implement scmi_mbox_cb with the logic for supporting tx/rx direction but only TX implemented so far.
  2. Add the RX channel.

Much easier to review the transition like this.

void *user_data,
struct mbox_msg *data)
{
struct scmi_channel *scmi_chan = user_data;

if (scmi_chan->cb) {
scmi_chan->cb(scmi_chan);
}
}

static void scmi_mbox_notify_cb(const struct device *mbox,
mbox_channel_id_t channel_id,
void *user_data,
struct mbox_msg *data)
{
struct scmi_channel *scmi_chan = user_data;

Expand Down Expand Up @@ -71,25 +83,34 @@ static int scmi_mbox_setup_chan(const struct device *transport,
{
int ret;
struct scmi_mbox_channel *mbox_chan;
struct mbox_dt_spec *tx_reply;
struct mbox_dt_spec *mbox_spec;

mbox_chan = chan->data;

if (mbox_chan->tx_reply.dev) {
tx_reply = &mbox_chan->tx_reply;
if (tx) {
mbox_spec = mbox_chan->tx_reply.dev ? &mbox_chan->tx_reply : &mbox_chan->tx;
ret = mbox_register_callback_dt(mbox_spec, scmi_mbox_tx_reply_cb, chan);
if (ret < 0) {
LOG_ERR("failed to register reply cb on %s",
mbox_chan->tx_reply.dev ? "tx_reply" : "tx");
return ret;
}
} else {
tx_reply = &mbox_chan->tx;
}

ret = mbox_register_callback_dt(tx_reply, scmi_mbox_cb, chan);
if (ret < 0) {
LOG_ERR("failed to register tx reply cb");
return ret;
if (!mbox_chan->rx.dev) {
LOG_ERR("RX channel not defined");
return -ENOTSUP;
}
mbox_spec = &mbox_chan->rx;
ret = mbox_register_callback_dt(&mbox_chan->rx, scmi_mbox_notify_cb, chan);
if (ret < 0) {
LOG_ERR("failed to register notify cb on rx");
return ret;
}
}

ret = mbox_set_enabled_dt(tx_reply, true);
ret = mbox_set_enabled_dt(mbox_spec, true);
if (ret < 0) {
LOG_ERR("failed to enable tx reply dbell");
LOG_ERR("failed to enable %s dbell", tx ? "tx" : "rx");
}

/* enable interrupt-based communication */
Expand Down