drivers: mbox: update MBOX consumers to the new API
Update all usages of the MBOX API to the latest API changes (to be squashed for bisectability). Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
This commit is contained in:
parent
8be65b6608
commit
80cc7d1ee5
|
@ -81,13 +81,13 @@ int nxp_s32_eth_initialize_common(const struct device *dev)
|
|||
|
||||
for (int i = 0; i < NETC_MSIX_EVENTS_COUNT; i++) {
|
||||
msix = &cfg->msix[i];
|
||||
if (msix->mbox_channel.dev != NULL) {
|
||||
err = mbox_register_callback(&msix->mbox_channel,
|
||||
nxp_s32_eth_msix_wrapper,
|
||||
(void *)msix);
|
||||
if (mbox_is_ready_dt(&msix->mbox_spec)) {
|
||||
err = mbox_register_callback_dt(&msix->mbox_spec,
|
||||
nxp_s32_eth_msix_wrapper,
|
||||
(void *)msix);
|
||||
if (err != 0) {
|
||||
LOG_ERR("Failed to register MRU callback on channel %u",
|
||||
msix->mbox_channel.id);
|
||||
msix->mbox_spec.channel_id);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#define NETC_MSIX(node, name, cb) \
|
||||
{ \
|
||||
.handler = cb, \
|
||||
.mbox_channel = MBOX_DT_CHANNEL_GET(node, name), \
|
||||
.mbox_spec = MBOX_DT_SPEC_GET(node, name), \
|
||||
}
|
||||
|
||||
/* Tx/Rx ENETC ring definitions */
|
||||
|
@ -100,7 +100,7 @@
|
|||
|
||||
struct nxp_s32_eth_msix {
|
||||
void (*handler)(uint8_t chan, const uint32_t *buf, uint8_t buf_size);
|
||||
struct mbox_channel mbox_channel;
|
||||
struct mbox_dt_spec mbox_spec;
|
||||
};
|
||||
|
||||
struct nxp_s32_eth_config {
|
||||
|
|
|
@ -197,9 +197,10 @@ static void nxp_s32_eth_iface_init(struct net_if *iface)
|
|||
|
||||
for (int i = 0; i < NETC_MSIX_EVENTS_COUNT; i++) {
|
||||
msix = &cfg->msix[i];
|
||||
if (msix->mbox_channel.dev != NULL) {
|
||||
if (mbox_set_enabled(&msix->mbox_channel, true)) {
|
||||
LOG_ERR("Failed to enable MRU channel %u", msix->mbox_channel.id);
|
||||
if (mbox_is_ready_dt(&msix->mbox_spec)) {
|
||||
if (mbox_set_enabled_dt(&msix->mbox_spec, true)) {
|
||||
LOG_ERR("Failed to enable MRU channel %u",
|
||||
msix->mbox_spec.channel_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,10 @@ static void nxp_s32_eth_iface_init(struct net_if *iface)
|
|||
|
||||
for (int i = 0; i < NETC_MSIX_EVENTS_COUNT; i++) {
|
||||
msix = &cfg->msix[i];
|
||||
if (msix->mbox_channel.dev != NULL) {
|
||||
if (mbox_set_enabled(&msix->mbox_channel, true)) {
|
||||
LOG_ERR("Failed to enable MRU channel %u", msix->mbox_channel.id);
|
||||
if (mbox_is_ready_dt(&msix->mbox_spec)) {
|
||||
if (mbox_set_enabled_dt(&msix->mbox_spec, true)) {
|
||||
LOG_ERR("Failed to enable MRU channel %u",
|
||||
msix->mbox_spec.channel_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ enum icmsg_state {
|
|||
};
|
||||
|
||||
struct icmsg_config_t {
|
||||
struct mbox_channel mbox_tx;
|
||||
struct mbox_channel mbox_rx;
|
||||
struct mbox_dt_spec mbox_tx;
|
||||
struct mbox_dt_spec mbox_rx;
|
||||
};
|
||||
|
||||
struct icmsg_data_t {
|
||||
|
|
|
@ -42,7 +42,6 @@ static void mbox_callback(const struct device *dev, uint32_t channel,
|
|||
static int mbox_init(void)
|
||||
{
|
||||
const struct device *dev;
|
||||
struct mbox_channel channel;
|
||||
int err;
|
||||
|
||||
dev = COND_CODE_1(CONFIG_MBOX, (DEVICE_DT_GET(DT_NODELABEL(mbox))), (NULL));
|
||||
|
@ -50,14 +49,12 @@ static int mbox_init(void)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
mbox_init_channel(&channel, dev, 2);
|
||||
|
||||
err = mbox_register_callback(&channel, mbox_callback, NULL);
|
||||
err = mbox_register_callback(dev, 2, mbox_callback, NULL);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return mbox_set_enabled(&channel, true);
|
||||
return mbox_set_enabled(dev, 2, true);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
|
|
@ -13,47 +13,42 @@
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_RX_ENABLED
|
||||
static void callback(const struct device *dev, uint32_t channel,
|
||||
static void callback(const struct device *dev, mbox_channel_id_t channel_id,
|
||||
void *user_data, struct mbox_msg *data)
|
||||
{
|
||||
printk("Pong (on channel %d)\n", channel);
|
||||
printk("Pong (on channel %d)\n", channel_id);
|
||||
}
|
||||
#endif /* CONFIG_RX_ENABLED */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
const struct device *const dev = DEVICE_DT_GET(DT_NODELABEL(mbox));
|
||||
|
||||
printk("Hello from REMOTE\n");
|
||||
|
||||
#ifdef CONFIG_RX_ENABLED
|
||||
const struct mbox_channel rx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx);
|
||||
const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx);
|
||||
|
||||
mbox_init_channel(&rx_channel, dev, CONFIG_RX_CHANNEL_ID);
|
||||
|
||||
ret = mbox_register_callback(&rx_channel, callback, NULL);
|
||||
ret = mbox_register_callback_dt(&rx_channel, callback, NULL);
|
||||
if (ret < 0) {
|
||||
printk("Could not register callback (%d)\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = mbox_set_enabled(&rx_channel, true);
|
||||
ret = mbox_set_enabled_dt(&rx_channel, true);
|
||||
if (ret < 0) {
|
||||
printk("Could not enable RX channel %d (%d)\n", rx_channel.id, ret);
|
||||
printk("Could not enable RX channel %d (%d)\n", rx_channel.channel_id, ret);
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_RX_ENABLED */
|
||||
|
||||
#ifdef CONFIG_TX_ENABLED
|
||||
const struct mbox_channel tx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx);
|
||||
|
||||
mbox_init_channel(&tx_channel, dev, CONFIG_TX_CHANNEL_ID);
|
||||
const struct mbox_dt_spec tx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx);
|
||||
|
||||
while (1) {
|
||||
printk("Ping (on channel %d)\n", tx_channel.id);
|
||||
printk("Ping (on channel %d)\n", tx_channel.channel_id);
|
||||
|
||||
ret = mbox_send(&tx_channel, NULL);
|
||||
ret = mbox_send_dt(&tx_channel, NULL);
|
||||
if (ret < 0) {
|
||||
printk("Could not send (%d)\n", ret);
|
||||
return 0;
|
||||
|
|
|
@ -9,49 +9,44 @@
|
|||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#ifdef CONFIG_RX_ENABLED
|
||||
static void callback(const struct device *dev, uint32_t channel,
|
||||
static void callback(const struct device *dev, mbox_channel_id_t channel_id,
|
||||
void *user_data, struct mbox_msg *data)
|
||||
{
|
||||
printk("Pong (on channel %d)\n", channel);
|
||||
printk("Pong (on channel %d)\n", channel_id);
|
||||
}
|
||||
#endif /* CONFIG_RX_ENABLED */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int ret;
|
||||
const struct device *const dev = DEVICE_DT_GET(DT_NODELABEL(mbox));
|
||||
|
||||
printk("Hello from APP\n");
|
||||
|
||||
#ifdef CONFIG_RX_ENABLED
|
||||
const struct mbox_channel rx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx);
|
||||
const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx);
|
||||
|
||||
mbox_init_channel(&rx_channel, dev, CONFIG_RX_CHANNEL_ID);
|
||||
|
||||
ret = mbox_register_callback(&rx_channel, callback, NULL);
|
||||
ret = mbox_register_callback_dt(&rx_channel, callback, NULL);
|
||||
if (ret < 0) {
|
||||
printk("Could not register callback (%d)\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = mbox_set_enabled(&rx_channel, true);
|
||||
ret = mbox_set_enabled_dt(&rx_channel, true);
|
||||
if (ret < 0) {
|
||||
printk("Could not enable RX channel %d (%d)\n", rx_channel.id, ret);
|
||||
printk("Could not enable RX channel %d (%d)\n", rx_channel.channel_id, ret);
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_RX_ENABLED */
|
||||
|
||||
#ifdef CONFIG_TX_ENABLED
|
||||
const struct mbox_channel tx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx);
|
||||
|
||||
mbox_init_channel(&tx_channel, dev, CONFIG_TX_CHANNEL_ID);
|
||||
const struct mbox_dt_spec tx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx);
|
||||
|
||||
while (1) {
|
||||
k_sleep(K_MSEC(2000));
|
||||
|
||||
printk("Ping (on channel %d)\n", tx_channel.id);
|
||||
printk("Ping (on channel %d)\n", tx_channel.channel_id);
|
||||
|
||||
ret = mbox_send(&tx_channel, NULL);
|
||||
ret = mbox_send_dt(&tx_channel, NULL);
|
||||
if (ret < 0) {
|
||||
printk("Could not send (%d)\n", ret);
|
||||
return 0;
|
||||
|
|
|
@ -12,40 +12,40 @@
|
|||
|
||||
static K_SEM_DEFINE(g_mbox_data_rx_sem, 0, 1);
|
||||
|
||||
static uint32_t g_mbox_received_data;
|
||||
static uint32_t g_mbox_received_channel;
|
||||
static mbox_channel_id_t g_mbox_received_data;
|
||||
static mbox_channel_id_t g_mbox_received_channel;
|
||||
|
||||
static void callback(const struct device *dev, uint32_t channel, void *user_data,
|
||||
static void callback(const struct device *dev, mbox_channel_id_t channel_id, void *user_data,
|
||||
struct mbox_msg *data)
|
||||
{
|
||||
memcpy(&g_mbox_received_data, data->data, data->size);
|
||||
g_mbox_received_channel = channel;
|
||||
g_mbox_received_channel = channel_id;
|
||||
|
||||
k_sem_give(&g_mbox_data_rx_sem);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct mbox_channel tx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx);
|
||||
const struct mbox_channel rx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx);
|
||||
const struct mbox_dt_spec tx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx);
|
||||
const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx);
|
||||
struct mbox_msg msg = {0};
|
||||
uint32_t message = 0;
|
||||
|
||||
printk("mbox_data Server demo started\n");
|
||||
|
||||
const int max_transfer_size_bytes = mbox_mtu_get(tx_channel.dev);
|
||||
const int max_transfer_size_bytes = mbox_mtu_get_dt(&tx_channel);
|
||||
/* Sample currently supports only transfer size up to 4 bytes */
|
||||
if ((max_transfer_size_bytes <= 0) || (max_transfer_size_bytes > 4)) {
|
||||
printk("mbox_mtu_get() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbox_register_callback(&rx_channel, callback, NULL)) {
|
||||
if (mbox_register_callback_dt(&rx_channel, callback, NULL)) {
|
||||
printk("mbox_register_callback() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbox_set_enabled(&rx_channel, 1)) {
|
||||
if (mbox_set_enabled_dt(&rx_channel, 1)) {
|
||||
printk("mbox_set_enable() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ int main(void)
|
|||
msg.data = &message;
|
||||
msg.size = max_transfer_size_bytes;
|
||||
|
||||
printk("Server send (on channel %d) value: %d\n", tx_channel.id, message);
|
||||
if (mbox_send(&tx_channel, &msg) < 0) {
|
||||
printk("Server send (on channel %d) value: %d\n", tx_channel.channel_id, message);
|
||||
if (mbox_send_dt(&tx_channel, &msg) < 0) {
|
||||
printk("mbox_send() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,40 +12,40 @@
|
|||
|
||||
static K_SEM_DEFINE(g_mbox_data_rx_sem, 0, 1);
|
||||
|
||||
static uint32_t g_mbox_received_data;
|
||||
static uint32_t g_mbox_received_channel;
|
||||
static mbox_channel_id_t g_mbox_received_data;
|
||||
static mbox_channel_id_t g_mbox_received_channel;
|
||||
|
||||
static void callback(const struct device *dev, uint32_t channel, void *user_data,
|
||||
static void callback(const struct device *dev, mbox_channel_id_t channel_id, void *user_data,
|
||||
struct mbox_msg *data)
|
||||
{
|
||||
memcpy(&g_mbox_received_data, data->data, data->size);
|
||||
g_mbox_received_channel = channel;
|
||||
g_mbox_received_channel = channel_id;
|
||||
|
||||
k_sem_give(&g_mbox_data_rx_sem);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct mbox_channel tx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx);
|
||||
const struct mbox_channel rx_channel = MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx);
|
||||
const struct mbox_dt_spec tx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx);
|
||||
const struct mbox_dt_spec rx_channel = MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx);
|
||||
struct mbox_msg msg = {0};
|
||||
uint32_t message = 0;
|
||||
|
||||
printk("mbox_data Client demo started\n");
|
||||
|
||||
const int max_transfer_size_bytes = mbox_mtu_get(tx_channel.dev);
|
||||
const int max_transfer_size_bytes = mbox_mtu_get_dt(&tx_channel);
|
||||
/* Sample currently supports only transfer size up to 4 bytes */
|
||||
if ((max_transfer_size_bytes < 0) || (max_transfer_size_bytes > 4)) {
|
||||
printk("mbox_mtu_get() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbox_register_callback(&rx_channel, callback, NULL)) {
|
||||
if (mbox_register_callback_dt(&rx_channel, callback, NULL)) {
|
||||
printk("mbox_register_callback() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbox_set_enabled(&rx_channel, 1)) {
|
||||
if (mbox_set_enabled_dt(&rx_channel, 1)) {
|
||||
printk("mbox_set_enable() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ int main(void)
|
|||
msg.data = &message;
|
||||
msg.size = max_transfer_size_bytes;
|
||||
|
||||
printk("Client send (on channel %d) value: %d\n", tx_channel.id, message);
|
||||
if (mbox_send(&tx_channel, &msg) < 0) {
|
||||
printk("Client send (on channel %d) value: %d\n", tx_channel.channel_id, message);
|
||||
if (mbox_send_dt(&tx_channel, &msg) < 0) {
|
||||
printk("mbox_send() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -190,14 +190,12 @@ static void remote_callback(void *user_data)
|
|||
}
|
||||
}
|
||||
|
||||
static void mbox_callback(const struct device *dev, uint32_t channel,
|
||||
static void mbox_callback(const struct device *dev, mbox_channel_id_t channel_id,
|
||||
void *user_data, struct mbox_msg *data)
|
||||
{
|
||||
struct mbox_channel ch;
|
||||
int err;
|
||||
|
||||
mbox_init_channel(&ch, dev, channel);
|
||||
err = mbox_set_enabled(&ch, false);
|
||||
err = mbox_set_enabled(dev, channel_id, false);
|
||||
|
||||
(void)err;
|
||||
__ASSERT_NO_MSG(err == 0);
|
||||
|
@ -208,7 +206,6 @@ static void mbox_callback(const struct device *dev, uint32_t channel,
|
|||
static int mbox_rx_init(void *user_data)
|
||||
{
|
||||
const struct device *dev;
|
||||
struct mbox_channel channel;
|
||||
int err;
|
||||
|
||||
dev = COND_CODE_1(CONFIG_MBOX, (DEVICE_DT_GET(DT_NODELABEL(mbox))), (NULL));
|
||||
|
@ -216,14 +213,12 @@ static int mbox_rx_init(void *user_data)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
mbox_init_channel(&channel, dev, CONFIG_NRF53_SYNC_RTC_IPM_IN);
|
||||
|
||||
err = mbox_register_callback(&channel, mbox_callback, user_data);
|
||||
err = mbox_register_callback(dev, CONFIG_NRF53_SYNC_RTC_IPM_IN, mbox_callback, user_data);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return mbox_set_enabled(&channel, true);
|
||||
return mbox_set_enabled(dev, CONFIG_NRF53_SYNC_RTC_IPM_IN, true);
|
||||
}
|
||||
|
||||
/* Setup RTC synchronization. */
|
||||
|
|
|
@ -1263,8 +1263,8 @@ const static struct ipc_service_backend backend_ops = {
|
|||
static const struct icbmsg_config backend_config_##i = \
|
||||
{ \
|
||||
.control_config = { \
|
||||
.mbox_tx = MBOX_DT_INST_CHANNEL_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_INST_CHANNEL_GET(i, rx), \
|
||||
.mbox_tx = MBOX_DT_SPEC_INST_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_SPEC_INST_GET(i, rx), \
|
||||
}, \
|
||||
.tx = { \
|
||||
.blocks_ptr = (uint8_t *)GET_BLOCKS_ADDR_INST(i, tx, rx), \
|
||||
|
|
|
@ -56,8 +56,8 @@ static int backend_init(const struct device *instance)
|
|||
|
||||
#define DEFINE_BACKEND_DEVICE(i) \
|
||||
static const struct icmsg_config_t backend_config_##i = { \
|
||||
.mbox_tx = MBOX_DT_INST_CHANNEL_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_INST_CHANNEL_GET(i, rx), \
|
||||
.mbox_tx = MBOX_DT_SPEC_INST_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_SPEC_INST_GET(i, rx), \
|
||||
}; \
|
||||
\
|
||||
PBUF_DEFINE(tx_pb_##i, \
|
||||
|
|
|
@ -278,8 +278,8 @@ static int backend_init(const struct device *instance)
|
|||
|
||||
#define DEFINE_BACKEND_DEVICE(i) \
|
||||
static const struct icmsg_config_t backend_config_##i = { \
|
||||
.mbox_tx = MBOX_DT_INST_CHANNEL_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_INST_CHANNEL_GET(i, rx), \
|
||||
.mbox_tx = MBOX_DT_SPEC_INST_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_SPEC_INST_GET(i, rx), \
|
||||
}; \
|
||||
\
|
||||
PBUF_DEFINE(tx_pb_##i, \
|
||||
|
|
|
@ -184,8 +184,8 @@ static int backend_init(const struct device *instance)
|
|||
|
||||
#define DEFINE_BACKEND_DEVICE(i) \
|
||||
static const struct icmsg_config_t backend_config_##i = { \
|
||||
.mbox_tx = MBOX_DT_INST_CHANNEL_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_INST_CHANNEL_GET(i, rx), \
|
||||
.mbox_tx = MBOX_DT_SPEC_INST_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_SPEC_INST_GET(i, rx), \
|
||||
}; \
|
||||
\
|
||||
PBUF_DEFINE(tx_pb_##i, \
|
||||
|
|
|
@ -55,8 +55,8 @@ struct backend_config_t {
|
|||
unsigned int role;
|
||||
uintptr_t shm_addr;
|
||||
size_t shm_size;
|
||||
struct mbox_channel mbox_tx;
|
||||
struct mbox_channel mbox_rx;
|
||||
struct mbox_dt_spec mbox_tx;
|
||||
struct mbox_dt_spec mbox_rx;
|
||||
unsigned int wq_prio_type;
|
||||
unsigned int wq_prio;
|
||||
unsigned int id;
|
||||
|
@ -292,7 +292,7 @@ static void virtio_notify_cb(struct virtqueue *vq, void *priv)
|
|||
struct backend_config_t *conf = priv;
|
||||
|
||||
if (conf->mbox_tx.dev) {
|
||||
mbox_send(&conf->mbox_tx, NULL);
|
||||
mbox_send_dt(&conf->mbox_tx, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,12 +329,12 @@ static int mbox_init(const struct device *instance)
|
|||
|
||||
k_work_init(&data->mbox_work, mbox_callback_process);
|
||||
|
||||
err = mbox_register_callback(&conf->mbox_rx, mbox_callback, data);
|
||||
err = mbox_register_callback_dt(&conf->mbox_rx, mbox_callback, data);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return mbox_set_enabled(&conf->mbox_rx, 1);
|
||||
return mbox_set_enabled_dt(&conf->mbox_rx, 1);
|
||||
}
|
||||
|
||||
static int mbox_deinit(const struct device *instance)
|
||||
|
@ -344,7 +344,7 @@ static int mbox_deinit(const struct device *instance)
|
|||
k_tid_t wq_thread;
|
||||
int err;
|
||||
|
||||
err = mbox_set_enabled(&conf->mbox_rx, 0);
|
||||
err = mbox_set_enabled_dt(&conf->mbox_rx, 0);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
@ -798,8 +798,8 @@ static int backend_init(const struct device *instance)
|
|||
.role = DT_ENUM_IDX_OR(DT_DRV_INST(i), role, ROLE_HOST), \
|
||||
.shm_size = DT_REG_SIZE(DT_INST_PHANDLE(i, memory_region)), \
|
||||
.shm_addr = BACKEND_SHM_ADDR(i), \
|
||||
.mbox_tx = MBOX_DT_INST_CHANNEL_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_INST_CHANNEL_GET(i, rx), \
|
||||
.mbox_tx = MBOX_DT_SPEC_INST_GET(i, tx), \
|
||||
.mbox_rx = MBOX_DT_SPEC_INST_GET(i, rx), \
|
||||
.wq_prio = COND_CODE_1(DT_INST_NODE_HAS_PROP(i, zephyr_priority), \
|
||||
(DT_INST_PROP_BY_IDX(i, zephyr_priority, 0)), \
|
||||
(0)), \
|
||||
|
|
|
@ -32,12 +32,12 @@ static int mbox_deinit(const struct icmsg_config_t *conf,
|
|||
{
|
||||
int err;
|
||||
|
||||
err = mbox_set_enabled(&conf->mbox_rx, 0);
|
||||
err = mbox_set_enabled_dt(&conf->mbox_rx, 0);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = mbox_register_callback(&conf->mbox_rx, NULL, NULL);
|
||||
err = mbox_register_callback_dt(&conf->mbox_rx, NULL, NULL);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ static void notify_process(struct k_work *item)
|
|||
struct icmsg_data_t *dev_data =
|
||||
CONTAINER_OF(dwork, struct icmsg_data_t, notify_work);
|
||||
|
||||
(void)mbox_send(&dev_data->cfg->mbox_tx, NULL);
|
||||
(void)mbox_send_dt(&dev_data->cfg->mbox_tx, NULL);
|
||||
|
||||
atomic_t state = atomic_get(&dev_data->state);
|
||||
|
||||
|
@ -181,12 +181,12 @@ static int mbox_init(const struct icmsg_config_t *conf,
|
|||
k_work_init(&dev_data->mbox_work, mbox_callback_process);
|
||||
k_work_init_delayable(&dev_data->notify_work, notify_process);
|
||||
|
||||
err = mbox_register_callback(&conf->mbox_rx, mbox_callback, dev_data);
|
||||
err = mbox_register_callback_dt(&conf->mbox_rx, mbox_callback, dev_data);
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return mbox_set_enabled(&conf->mbox_rx, 1);
|
||||
return mbox_set_enabled_dt(&conf->mbox_rx, 1);
|
||||
}
|
||||
|
||||
int icmsg_open(const struct icmsg_config_t *conf,
|
||||
|
@ -293,7 +293,7 @@ int icmsg_send(const struct icmsg_config_t *conf,
|
|||
|
||||
__ASSERT_NO_MSG(conf->mbox_tx.dev != NULL);
|
||||
|
||||
ret = mbox_send(&conf->mbox_tx, NULL);
|
||||
ret = mbox_send_dt(&conf->mbox_tx, NULL);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -19,22 +19,22 @@ static uint32_t g_mbox_received_channel;
|
|||
#define TX_CHANNEL_INDEX 0
|
||||
#define RX_CHANNEL_INDEX 1
|
||||
|
||||
static const struct mbox_channel channels[CHANNELS_TO_TEST][2] = {
|
||||
static const struct mbox_dt_spec channels[CHANNELS_TO_TEST][2] = {
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx0),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx0),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx0),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx0),
|
||||
},
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx1),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx1),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx1),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx1),
|
||||
},
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx2),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx2),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx2),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx2),
|
||||
},
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx3),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx3),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx3),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx3),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -55,22 +55,22 @@ int main(void)
|
|||
uint32_t message = 0;
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(channels); i++) {
|
||||
const struct mbox_channel *tx_channel = &channels[i][TX_CHANNEL_INDEX];
|
||||
const struct mbox_channel *rx_channel = &channels[i][RX_CHANNEL_INDEX];
|
||||
const struct mbox_dt_spec *tx_channel = &channels[i][TX_CHANNEL_INDEX];
|
||||
const struct mbox_dt_spec *rx_channel = &channels[i][RX_CHANNEL_INDEX];
|
||||
|
||||
const int max_transfer_size_bytes = mbox_mtu_get(tx_channel->dev);
|
||||
const int max_transfer_size_bytes = mbox_mtu_get_dt(tx_channel);
|
||||
/* Sample currently supports only transfer size up to 4 bytes */
|
||||
if ((max_transfer_size_bytes <= 0) || (max_transfer_size_bytes > 4)) {
|
||||
printk("mbox_mtu_get() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbox_register_callback(rx_channel, callback, NULL)) {
|
||||
if (mbox_register_callback_dt(rx_channel, callback, NULL)) {
|
||||
printk("mbox_register_callback() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mbox_set_enabled(rx_channel, 1)) {
|
||||
if (mbox_set_enabled_dt(rx_channel, 1)) {
|
||||
printk("mbox_set_enable() error\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -88,13 +88,13 @@ int main(void)
|
|||
msg.data = &message;
|
||||
msg.size = max_transfer_size_bytes;
|
||||
|
||||
if (mbox_send(tx_channel, &msg) < 0) {
|
||||
if (mbox_send_dt(tx_channel, &msg) < 0) {
|
||||
printk("mbox_send() error\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable current rx channel after channel loop */
|
||||
mbox_set_enabled(rx_channel, 0);
|
||||
mbox_set_enabled_dt(rx_channel, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,22 +27,22 @@ static int g_max_transfer_size_bytes;
|
|||
#define TX_CHANNEL_INDEX 0
|
||||
#define RX_CHANNEL_INDEX 1
|
||||
|
||||
static const struct mbox_channel channels[CHANNELS_TO_TEST][2] = {
|
||||
static const struct mbox_dt_spec channels[CHANNELS_TO_TEST][2] = {
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx0),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx0),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx0),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx0),
|
||||
},
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx1),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx1),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx1),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx1),
|
||||
},
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx2),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx2),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx2),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx2),
|
||||
},
|
||||
{
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), tx3),
|
||||
MBOX_DT_CHANNEL_GET(DT_PATH(mbox_consumer), rx3),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), tx3),
|
||||
MBOX_DT_SPEC_GET(DT_PATH(mbox_consumer), rx3),
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -68,11 +68,11 @@ static void mbox_data_tests_before(void *f)
|
|||
{
|
||||
zassert_false(current_channel_index >= CHANNELS_TO_TEST, "Channel to test is out of range");
|
||||
|
||||
const struct mbox_channel *tx_channel = &channels[current_channel_index][TX_CHANNEL_INDEX];
|
||||
const struct mbox_channel *rx_channel = &channels[current_channel_index][RX_CHANNEL_INDEX];
|
||||
const struct mbox_dt_spec *tx_channel = &channels[current_channel_index][TX_CHANNEL_INDEX];
|
||||
const struct mbox_dt_spec *rx_channel = &channels[current_channel_index][RX_CHANNEL_INDEX];
|
||||
int ret_val = 0;
|
||||
|
||||
g_max_transfer_size_bytes = mbox_mtu_get(tx_channel->dev);
|
||||
g_max_transfer_size_bytes = mbox_mtu_get_dt(tx_channel);
|
||||
/* Test currently supports only transfer size up to 4 bytes */
|
||||
if ((g_max_transfer_size_bytes < 0) || (g_max_transfer_size_bytes > 4)) {
|
||||
printk("mbox_mtu_get() error\n");
|
||||
|
@ -80,10 +80,10 @@ static void mbox_data_tests_before(void *f)
|
|||
g_max_transfer_size_bytes);
|
||||
}
|
||||
|
||||
ret_val = mbox_register_callback(rx_channel, callback, NULL);
|
||||
ret_val = mbox_register_callback_dt(rx_channel, callback, NULL);
|
||||
zassert_false(ret_val != 0, "mbox failed to register callback. ret_val", ret_val);
|
||||
|
||||
ret_val = mbox_set_enabled(rx_channel, 1);
|
||||
ret_val = mbox_set_enabled_dt(rx_channel, 1);
|
||||
zassert_false(ret_val != 0, "mbox failed to enable mbox. ret_val: %d", ret_val);
|
||||
}
|
||||
|
||||
|
@ -91,10 +91,10 @@ static void mbox_data_tests_after(void *f)
|
|||
{
|
||||
zassert_false(current_channel_index >= CHANNELS_TO_TEST, "Channel to test is out of range");
|
||||
|
||||
const struct mbox_channel *rx_channel = &channels[current_channel_index][RX_CHANNEL_INDEX];
|
||||
const struct mbox_dt_spec *rx_channel = &channels[current_channel_index][RX_CHANNEL_INDEX];
|
||||
|
||||
/* Disable channel after test end */
|
||||
int ret_val = mbox_set_enabled(rx_channel, 0);
|
||||
int ret_val = mbox_set_enabled_dt(rx_channel, 0);
|
||||
|
||||
zassert_false(ret_val != 0, "mbox failed to disable mbox. ret_val: %d", ret_val);
|
||||
|
||||
|
@ -110,14 +110,15 @@ static void mbox_test(const uint32_t data)
|
|||
int ret_val = 0;
|
||||
|
||||
while (test_count < 100) {
|
||||
const struct mbox_channel *tx_channel = &channels[current_channel_index][TX_CHANNEL_INDEX];
|
||||
const struct mbox_dt_spec *tx_channel =
|
||||
&channels[current_channel_index][TX_CHANNEL_INDEX];
|
||||
|
||||
/* Main core prepare test data */
|
||||
msg.data = &test_data;
|
||||
msg.size = g_max_transfer_size_bytes;
|
||||
|
||||
/* Main core send test data */
|
||||
ret_val = mbox_send(tx_channel, &msg);
|
||||
ret_val = mbox_send_dt(tx_channel, &msg);
|
||||
zassert_false(ret_val < 0, "mbox failed to send. ret_val: %d", ret_val);
|
||||
|
||||
/* Expect next received data will be incremented by one.
|
||||
|
@ -142,7 +143,8 @@ static void mbox_test(const uint32_t data)
|
|||
g_mbox_expected_data, test_data);
|
||||
|
||||
/* Expect reception of data on current RX channel */
|
||||
g_mbox_expected_channel = channels[current_channel_index][RX_CHANNEL_INDEX].id;
|
||||
g_mbox_expected_channel =
|
||||
channels[current_channel_index][RX_CHANNEL_INDEX].channel_id;
|
||||
zassert_equal(g_mbox_expected_channel, g_mbox_received_channel,
|
||||
"Received channel does not match!: Expected: %d, Got: %d",
|
||||
g_mbox_expected_channel, g_mbox_received_channel);
|
||||
|
|
|
@ -2660,11 +2660,11 @@ ZTEST(devicetree_api, test_mbox)
|
|||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT vnd_adc_temp_sensor
|
||||
|
||||
const struct mbox_channel channel_tx = MBOX_DT_CHANNEL_GET(TEST_TEMP, tx);
|
||||
const struct mbox_channel channel_rx = MBOX_DT_CHANNEL_GET(TEST_TEMP, rx);
|
||||
const struct mbox_dt_spec channel_tx = MBOX_DT_SPEC_GET(TEST_TEMP, tx);
|
||||
const struct mbox_dt_spec channel_rx = MBOX_DT_SPEC_GET(TEST_TEMP, rx);
|
||||
|
||||
zassert_equal(channel_tx.id, 1, "");
|
||||
zassert_equal(channel_rx.id, 2, "");
|
||||
zassert_equal(channel_tx.channel_id, 1, "");
|
||||
zassert_equal(channel_rx.channel_id, 2, "");
|
||||
|
||||
zassert_equal(DT_MBOX_CHANNEL_BY_NAME(TEST_TEMP, tx), 1, "");
|
||||
zassert_equal(DT_MBOX_CHANNEL_BY_NAME(TEST_TEMP, rx), 2, "");
|
||||
|
@ -2677,9 +2677,9 @@ ZTEST(devicetree_api, test_mbox)
|
|||
zassert_equal(DT_MBOX_CHANNEL_BY_NAME(TEST_TEMP, tx), 1, "");
|
||||
zassert_equal(DT_MBOX_CHANNEL_BY_NAME(TEST_TEMP, rx), 2, "");
|
||||
|
||||
const struct mbox_channel channel_zero = MBOX_DT_CHANNEL_GET(TEST_TEMP, zero);
|
||||
const struct mbox_dt_spec channel_zero = MBOX_DT_SPEC_GET(TEST_TEMP, zero);
|
||||
|
||||
zassert_equal(channel_zero.id, 0, "");
|
||||
zassert_equal(channel_zero.channel_id, 0, "");
|
||||
|
||||
zassert_equal(DT_MBOX_CHANNEL_BY_NAME(TEST_TEMP, zero), 0, "");
|
||||
|
||||
|
|
Loading…
Reference in New Issue