drivers: mbox: Introduce MBOX driver class

One limitation of the current IPM API is that it is assuming that the
hardware is only exporting one single channel through which the data can
be sent or signalling can happen.

If the hardware supports multiple channels, the IPM device must be
instantiated (possibly in the DT) several times, one for each channel to
be able to send data through multiple channels using the same hw
peripheral. Also in the current IPM API only one callback can be
registered, that means that only one driver is controlling all the
signalling happening on all the channels.

This patch is introducing a new MBOX API that is supporting
multi-channel signalling and data exachange leveraging and extending the
previous (and outdated) IPM API.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2021-10-15 11:55:56 +02:00 committed by Carles Cufí
commit 1976f33e87
13 changed files with 623 additions and 1 deletions

View file

@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_USERSPACE mbox_handlers.c)

8
drivers/mbox/Kconfig Normal file
View file

@ -0,0 +1,8 @@
# Copyright (c) 2021 Carlo Caione <ccaione@baylibre.com>
# SPDX-License-Identifier: Apache-2.0
menuconfig MBOX
bool "MBOX drivers"
help
Include multi-channel interrupt-based inter-processor mailboxes
drivers in system configuration

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) 2021 Carlo Caione <ccaione@baylibre.com>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <syscall_handler.h>
#include <drivers/mbox.h>
static inline int z_vrfy_mbox_send(const struct mbox_channel *channel,
const struct mbox_msg *msg)
{
Z_OOPS(Z_SYSCALL_MEMORY_READ(channel, sizeof(struct mbox_channel)));
Z_OOPS(Z_SYSCALL_DRIVER_MBOX(channel->dev, send));
Z_OOPS(Z_SYSCALL_MEMORY_READ(msg, sizeof(struct mbox_msg)));
Z_OOPS(Z_SYSCALL_MEMORY_READ(msg->data, msg->size));
return z_impl_mbox_send(channel, msg);
}
#include <syscalls/mbox_send_mrsh.c>
static inline int z_vrfy_mbox_mtu_get(const struct device *dev)
{
Z_OOPS(Z_SYSCALL_DRIVER_MBOX(dev, max_data_size_get));
return z_impl_mbox_mtu_get(dev);
}
#include <syscalls/mbox_mtu_get_mrsh.c>
static inline uint32_t z_vrfy_mbox_max_channels_get(const struct device *dev)
{
Z_OOPS(Z_SYSCALL_DRIVER_MBOX(dev, max_channels_get));
return z_impl_mbox_max_channels_get(dev);
}
#include <syscalls/mbox_max_channels_get_mrsh.c>
static inline int z_vrfy_mbox_set_enabled(const struct mbox_channel *channel, bool enable)
{
Z_OOPS(Z_SYSCALL_MEMORY_READ(channel, sizeof(struct mbox_channel)));
Z_OOPS(Z_SYSCALL_DRIVER_MBOX(channel->dev, set_enabled));
return z_impl_mbox_set_enabled(channel, enable);
}
#include <syscalls/mbox_set_enabled_mrsh.c>