From 8091e9383852fff6634827c51aefea82ea748ee3 Mon Sep 17 00:00:00 2001 From: Jakub Zymelka Date: Wed, 22 May 2024 13:26:25 +0200 Subject: [PATCH] drivers: mbox: nrf: Change VEVIFs and BELLBOARD nomenclature Renaming 'LOCAL' to 'RX' and 'REMOTE' to 'TX'. This seems more descriptive and intuitive to use. Signed-off-by: Jakub Zymelka --- drivers/mbox/CMakeLists.txt | 8 +- drivers/mbox/Kconfig | 2 +- drivers/mbox/Kconfig.nrf_bellboard | 16 +-- drivers/mbox/Kconfig.nrf_vevif | 16 --- drivers/mbox/Kconfig.nrf_vevif_task | 16 +++ ...lboard_local.c => mbox_nrf_bellboard_rx.c} | 28 ++-- ...board_remote.c => mbox_nrf_bellboard_tx.c} | 24 ++-- drivers/mbox/mbox_nrf_vevif_local.c | 122 ---------------- drivers/mbox/mbox_nrf_vevif_task_rx.c | 133 ++++++++++++++++++ ...evif_remote.c => mbox_nrf_vevif_task_tx.c} | 44 +++--- ...ocal.yaml => nordic,nrf-bellboard-rx.yaml} | 6 +- ...mote.yaml => nordic,nrf-bellboard-tx.yaml} | 6 +- .../mbox/nordic,nrf-vevif-common.yaml | 18 --- dts/bindings/mbox/nordic,nrf-vevif-local.yaml | 32 ----- .../mbox/nordic,nrf-vevif-remote.yaml | 29 ---- .../mbox/nordic,nrf-vevif-task-rx.yaml | 49 +++++++ .../mbox/nordic,nrf-vevif-task-tx.yaml | 46 ++++++ 17 files changed, 314 insertions(+), 281 deletions(-) delete mode 100644 drivers/mbox/Kconfig.nrf_vevif create mode 100644 drivers/mbox/Kconfig.nrf_vevif_task rename drivers/mbox/{mbox_nrf_bellboard_local.c => mbox_nrf_bellboard_rx.c} (82%) rename drivers/mbox/{mbox_nrf_bellboard_remote.c => mbox_nrf_bellboard_tx.c} (60%) delete mode 100644 drivers/mbox/mbox_nrf_vevif_local.c create mode 100644 drivers/mbox/mbox_nrf_vevif_task_rx.c rename drivers/mbox/{mbox_nrf_vevif_remote.c => mbox_nrf_vevif_task_tx.c} (52%) rename dts/bindings/mbox/{nordic,nrf-bellboard-local.yaml => nordic,nrf-bellboard-rx.yaml} (88%) rename dts/bindings/mbox/{nordic,nrf-bellboard-remote.yaml => nordic,nrf-bellboard-tx.yaml} (76%) delete mode 100644 dts/bindings/mbox/nordic,nrf-vevif-common.yaml delete mode 100644 dts/bindings/mbox/nordic,nrf-vevif-local.yaml delete mode 100644 dts/bindings/mbox/nordic,nrf-vevif-remote.yaml create mode 100644 dts/bindings/mbox/nordic,nrf-vevif-task-rx.yaml create mode 100644 dts/bindings/mbox/nordic,nrf-vevif-task-tx.yaml diff --git a/drivers/mbox/CMakeLists.txt b/drivers/mbox/CMakeLists.txt index 6c57c7f8695..1d4bcda272d 100644 --- a/drivers/mbox/CMakeLists.txt +++ b/drivers/mbox/CMakeLists.txt @@ -10,10 +10,10 @@ zephyr_library_sources_ifdef(CONFIG_MBOX_NXP_S32_MRU mbox_nxp_s32_mru.c) zephyr_library_sources_ifdef(CONFIG_MBOX_NXP_IMX_MU mbox_nxp_imx_mu.c) zephyr_library_sources_ifdef(CONFIG_MBOX_NXP_MAILBOX mbox_nxp_mailbox.c) zephyr_library_sources_ifdef(CONFIG_MBOX_ANDES_PLIC_SW mbox_andes_plic_sw.c) -zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_VEVIF_LOCAL mbox_nrf_vevif_local.c) -zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_VEVIF_REMOTE mbox_nrf_vevif_remote.c) +zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_VEVIF_TASK_RX mbox_nrf_vevif_task_rx.c) +zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_VEVIF_TASK_TX mbox_nrf_vevif_task_tx.c) zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_VEVIF_EVENT_RX mbox_nrf_vevif_event_rx.c) zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_VEVIF_EVENT_TX mbox_nrf_vevif_event_tx.c) -zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_BELLBOARD_LOCAL mbox_nrf_bellboard_local.c) -zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_BELLBOARD_REMOTE mbox_nrf_bellboard_remote.c) +zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_BELLBOARD_RX mbox_nrf_bellboard_rx.c) +zephyr_library_sources_ifdef(CONFIG_MBOX_NRF_BELLBOARD_TX mbox_nrf_bellboard_tx.c) zephyr_library_sources_ifdef(CONFIG_MBOX_STM32_HSEM mbox_stm32_hsem.c) diff --git a/drivers/mbox/Kconfig b/drivers/mbox/Kconfig index 4c5ec50fbac..f4001f9429a 100644 --- a/drivers/mbox/Kconfig +++ b/drivers/mbox/Kconfig @@ -17,7 +17,7 @@ source "drivers/mbox/Kconfig.nxp_s32" source "drivers/mbox/Kconfig.nxp_imx" source "drivers/mbox/Kconfig.nxp_mailbox" source "drivers/mbox/Kconfig.andes" -source "drivers/mbox/Kconfig.nrf_vevif" +source "drivers/mbox/Kconfig.nrf_vevif_task" source "drivers/mbox/Kconfig.nrf_vevif_event" source "drivers/mbox/Kconfig.nrf_bellboard" source "drivers/mbox/Kconfig.stm32_hsem" diff --git a/drivers/mbox/Kconfig.nrf_bellboard b/drivers/mbox/Kconfig.nrf_bellboard index 45233122bd5..7f9f8568ad5 100644 --- a/drivers/mbox/Kconfig.nrf_bellboard +++ b/drivers/mbox/Kconfig.nrf_bellboard @@ -1,16 +1,16 @@ # Copyright (c) 2024 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 -config MBOX_NRF_BELLBOARD_LOCAL - bool "nRF BELLBOARD local driver" - depends on DT_HAS_NORDIC_NRF_BELLBOARD_LOCAL_ENABLED +config MBOX_NRF_BELLBOARD_RX + bool "nRF BELLBOARD RX driver" + depends on DT_HAS_NORDIC_NRF_BELLBOARD_RX_ENABLED default y help - Mailbox driver for local Nordic nRF BELLBOARD + Mailbox driver for RX Nordic nRF BELLBOARD -config MBOX_NRF_BELLBOARD_REMOTE - bool "nRF BELLBOARD remote driver" - depends on DT_HAS_NORDIC_NRF_BELLBOARD_REMOTE_ENABLED +config MBOX_NRF_BELLBOARD_TX + bool "nRF BELLBOARD TX driver" + depends on DT_HAS_NORDIC_NRF_BELLBOARD_TX_ENABLED default y help - Mailbox driver for remote Nordic nRF BELLBOARD + Mailbox driver for TX Nordic nRF BELLBOARD diff --git a/drivers/mbox/Kconfig.nrf_vevif b/drivers/mbox/Kconfig.nrf_vevif deleted file mode 100644 index 4abb0ef8241..00000000000 --- a/drivers/mbox/Kconfig.nrf_vevif +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2024 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -config MBOX_NRF_VEVIF_LOCAL - bool "nRF VEVIF local driver" - depends on DT_HAS_NORDIC_NRF_VEVIF_LOCAL_ENABLED - default y - help - Mailbox driver for local Nordic nRF VEVIF (VPR Event Interface) - -config MBOX_NRF_VEVIF_REMOTE - bool "nRF VEVIF remote driver" - depends on DT_HAS_NORDIC_NRF_VEVIF_REMOTE_ENABLED - default y - help - Mailbox driver for remote Nordic nRF VEVIF (VPR Event Interface) diff --git a/drivers/mbox/Kconfig.nrf_vevif_task b/drivers/mbox/Kconfig.nrf_vevif_task new file mode 100644 index 00000000000..e421877c6d2 --- /dev/null +++ b/drivers/mbox/Kconfig.nrf_vevif_task @@ -0,0 +1,16 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +config MBOX_NRF_VEVIF_TASK_RX + bool "nRF VEVIF task RX driver" + depends on DT_HAS_NORDIC_NRF_VEVIF_TASK_RX_ENABLED + default y + help + Mailbox driver for receiving VEVIF tasks on VPR as CLIC interrupts + +config MBOX_NRF_VEVIF_TASK_TX + bool "nRF VEVIF task TX driver" + depends on DT_HAS_NORDIC_NRF_VEVIF_TASK_TX_ENABLED + default y + help + Mailbox driver for transmitting VEVIF tasks to VPR as CLIC interrupts diff --git a/drivers/mbox/mbox_nrf_bellboard_local.c b/drivers/mbox/mbox_nrf_bellboard_rx.c similarity index 82% rename from drivers/mbox/mbox_nrf_bellboard_local.c rename to drivers/mbox/mbox_nrf_bellboard_rx.c index 99d05351aaa..8b98d361d0c 100644 --- a/drivers/mbox/mbox_nrf_bellboard_local.c +++ b/drivers/mbox/mbox_nrf_bellboard_rx.c @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_nrf_bellboard_local +#define DT_DRV_COMPAT nordic_nrf_bellboard_rx #include #include @@ -37,7 +37,7 @@ static mbox_callback_t cbs[NRF_BELLBOARD_EVENTS_TRIGGERED_COUNT]; static void *cbs_ctx[NRF_BELLBOARD_EVENTS_TRIGGERED_COUNT]; static uint32_t evt_enabled_masks[BELLBOARD_NUM_IRQS]; -static void bellboard_local_isr(const void *parameter) +static void bellboard_rx_isr(const void *parameter) { uint8_t irq_idx = (uint8_t)(uintptr_t)parameter; uint32_t int_pend; @@ -59,15 +59,15 @@ static void bellboard_local_isr(const void *parameter) } } -static uint32_t bellboard_local_max_channels_get(const struct device *dev) +static uint32_t bellboard_rx_max_channels_get(const struct device *dev) { ARG_UNUSED(dev); return NRF_BELLBOARD_EVENTS_TRIGGERED_COUNT; } -static int bellboard_local_register_callback(const struct device *dev, uint32_t id, - mbox_callback_t cb, void *user_data) +static int bellboard_rx_register_callback(const struct device *dev, uint32_t id, mbox_callback_t cb, + void *user_data) { ARG_UNUSED(dev); @@ -81,7 +81,7 @@ static int bellboard_local_register_callback(const struct device *dev, uint32_t return 0; } -static int bellboard_local_set_enabled(const struct device *dev, uint32_t id, bool enable) +static int bellboard_rx_set_enabled(const struct device *dev, uint32_t id, bool enable) { bool valid_found = false; @@ -125,21 +125,21 @@ static int bellboard_local_set_enabled(const struct device *dev, uint32_t id, bo return 0; } -static const struct mbox_driver_api bellboard_local_driver_api = { - .max_channels_get = bellboard_local_max_channels_get, - .register_callback = bellboard_local_register_callback, - .set_enabled = bellboard_local_set_enabled, +static const struct mbox_driver_api bellboard_rx_driver_api = { + .max_channels_get = bellboard_rx_max_channels_get, + .register_callback = bellboard_rx_register_callback, + .set_enabled = bellboard_rx_set_enabled, }; #define BELLBOARD_IRQ_CONFIGURE(name, idx) \ COND_CODE_1(DT_INST_IRQ_HAS_NAME(0, name), \ (IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, name, irq), \ - DT_INST_IRQ_BY_NAME(0, name, priority), bellboard_local_isr, \ + DT_INST_IRQ_BY_NAME(0, name, priority), bellboard_rx_isr, \ (const void *)idx, 0); \ irq_enable(DT_INST_IRQ_BY_NAME(0, name, irq));), \ ()) -static int bellboard_local_init(const struct device *dev) +static int bellboard_rx_init(const struct device *dev) { uint32_t evt_all_mappings = evt_mappings[0] | evt_mappings[1] | evt_mappings[2] | evt_mappings[3]; @@ -165,5 +165,5 @@ static int bellboard_local_init(const struct device *dev) return 0; } -DEVICE_DT_INST_DEFINE(0, bellboard_local_init, NULL, NULL, NULL, POST_KERNEL, - CONFIG_MBOX_INIT_PRIORITY, &bellboard_local_driver_api); +DEVICE_DT_INST_DEFINE(0, bellboard_rx_init, NULL, NULL, NULL, POST_KERNEL, + CONFIG_MBOX_INIT_PRIORITY, &bellboard_rx_driver_api); diff --git a/drivers/mbox/mbox_nrf_bellboard_remote.c b/drivers/mbox/mbox_nrf_bellboard_tx.c similarity index 60% rename from drivers/mbox/mbox_nrf_bellboard_remote.c rename to drivers/mbox/mbox_nrf_bellboard_tx.c index c362522c0bf..e3f297623a6 100644 --- a/drivers/mbox/mbox_nrf_bellboard_remote.c +++ b/drivers/mbox/mbox_nrf_bellboard_tx.c @@ -3,20 +3,20 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_nrf_bellboard_remote +#define DT_DRV_COMPAT nordic_nrf_bellboard_tx #include #include #include -struct mbox_bellboard_remote_conf { +struct mbox_bellboard_tx_conf { NRF_BELLBOARD_Type *bellboard; }; -static int bellboard_remote_send(const struct device *dev, uint32_t id, const struct mbox_msg *msg) +static int bellboard_tx_send(const struct device *dev, uint32_t id, const struct mbox_msg *msg) { - const struct mbox_bellboard_remote_conf *config = dev->config; + const struct mbox_bellboard_tx_conf *config = dev->config; if (id >= BELLBOARD_TASKS_TRIGGER_MaxCount) { return -EINVAL; @@ -31,32 +31,32 @@ static int bellboard_remote_send(const struct device *dev, uint32_t id, const st return 0; } -static int bellboard_remote_mtu_get(const struct device *dev) +static int bellboard_tx_mtu_get(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static uint32_t bellboard_remote_max_channels_get(const struct device *dev) +static uint32_t bellboard_tx_max_channels_get(const struct device *dev) { ARG_UNUSED(dev); return BELLBOARD_TASKS_TRIGGER_MaxCount; } -static const struct mbox_driver_api bellboard_remote_driver_api = { - .send = bellboard_remote_send, - .mtu_get = bellboard_remote_mtu_get, - .max_channels_get = bellboard_remote_max_channels_get, +static const struct mbox_driver_api bellboard_tx_driver_api = { + .send = bellboard_tx_send, + .mtu_get = bellboard_tx_mtu_get, + .max_channels_get = bellboard_tx_max_channels_get, }; #define BELLBOARD_REMOTE_DEFINE(inst) \ - static const struct mbox_bellboard_remote_conf conf##inst = { \ + static const struct mbox_bellboard_tx_conf conf##inst = { \ .bellboard = (NRF_BELLBOARD_Type *)DT_INST_REG_ADDR(inst), \ }; \ \ DEVICE_DT_INST_DEFINE(inst, NULL, NULL, NULL, &conf##inst, POST_KERNEL, \ - CONFIG_MBOX_INIT_PRIORITY, &bellboard_remote_driver_api); + CONFIG_MBOX_INIT_PRIORITY, &bellboard_tx_driver_api); DT_INST_FOREACH_STATUS_OKAY(BELLBOARD_REMOTE_DEFINE) diff --git a/drivers/mbox/mbox_nrf_vevif_local.c b/drivers/mbox/mbox_nrf_vevif_local.c deleted file mode 100644 index 56cb5cc49d9..00000000000 --- a/drivers/mbox/mbox_nrf_vevif_local.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2024 Nordic Semiconductor ASA - * SPDX-License-Identifier: Apache-2.0 - */ - -#define DT_DRV_COMPAT nordic_nrf_vevif_local - -#include -#include - -#include -#include -#include - -#define VEVIF_TASKS_NUM DT_INST_PROP(0, nordic_tasks) -#define VEVIF_TASKS_MASK DT_INST_PROP(0, nordic_tasks_mask) - -BUILD_ASSERT(VEVIF_TASKS_NUM <= VPR_TASKS_TRIGGER_MaxCount, "Number of tasks exceeds maximum"); -BUILD_ASSERT(VEVIF_TASKS_NUM == DT_NUM_IRQS(DT_DRV_INST(0)), "# IRQs != # tasks"); - -/* callbacks */ -struct mbox_vevif_local_cbs { - mbox_callback_t cb[VEVIF_TASKS_NUM]; - void *user_data[VEVIF_TASKS_NUM]; - uint32_t enabled_mask; -}; - -static struct mbox_vevif_local_cbs cbs; - -/* IRQ list */ -#define VEVIF_IRQN(idx, _) DT_INST_IRQ_BY_IDX(0, idx, irq) - -static const uint8_t vevif_irqs[VEVIF_TASKS_NUM] = { - LISTIFY(DT_NUM_IRQS(DT_DRV_INST(0)), VEVIF_IRQN, (,)) -}; - -static void vevif_local_isr(const void *parameter) -{ - uint8_t id = *(uint8_t *)parameter; - - nrf_vpr_csr_vevif_tasks_clear(BIT(id)); - - if (cbs.cb[id] != NULL) { - cbs.cb[id](DEVICE_DT_INST_GET(0), id, cbs.user_data[id], NULL); - } -} - -static inline bool vevif_local_is_task_valid(uint32_t id) -{ - return (id < VEVIF_TASKS_NUM) && ((VEVIF_TASKS_MASK & BIT(id)) != 0U); -} - -static uint32_t vevif_local_max_channels_get(const struct device *dev) -{ - ARG_UNUSED(dev); - - return VEVIF_TASKS_NUM; -} - -static int vevif_local_register_callback(const struct device *dev, uint32_t id, mbox_callback_t cb, - void *user_data) -{ - ARG_UNUSED(dev); - - if (!vevif_local_is_task_valid(id)) { - return -EINVAL; - } - - cbs.cb[id] = cb; - cbs.user_data[id] = user_data; - - return 0; -} - -static int vevif_local_set_enabled(const struct device *dev, uint32_t id, bool enable) -{ - ARG_UNUSED(dev); - - if (!vevif_local_is_task_valid(id)) { - return -EINVAL; - } - - if (enable) { - if ((cbs.enabled_mask & BIT(id)) != 0U) { - return -EALREADY; - } - - cbs.enabled_mask |= BIT(id); - irq_enable(vevif_irqs[id]); - } else { - if ((cbs.enabled_mask & BIT(id)) == 0U) { - return -EALREADY; - } - - cbs.enabled_mask &= ~BIT(id); - irq_disable(vevif_irqs[id]); - } - - return 0; -} - -static const struct mbox_driver_api vevif_local_driver_api = { - .max_channels_get = vevif_local_max_channels_get, - .register_callback = vevif_local_register_callback, - .set_enabled = vevif_local_set_enabled, -}; - -#define VEVIF_IRQ_CONNECT(idx, _) \ - IRQ_CONNECT(DT_INST_IRQ_BY_IDX(0, idx, irq), DT_INST_IRQ_BY_IDX(0, idx, priority), \ - vevif_local_isr, &vevif_irqs[idx], 0) - -static int vevif_local_init(const struct device *dev) -{ - nrf_vpr_csr_vevif_tasks_clear(NRF_VPR_TASK_TRIGGER_ALL_MASK); - - LISTIFY(DT_NUM_IRQS(DT_DRV_INST(0)), VEVIF_IRQ_CONNECT, (;)); - - return 0; -} - -DEVICE_DT_INST_DEFINE(0, vevif_local_init, NULL, NULL, NULL, POST_KERNEL, CONFIG_MBOX_INIT_PRIORITY, - &vevif_local_driver_api); diff --git a/drivers/mbox/mbox_nrf_vevif_task_rx.c b/drivers/mbox/mbox_nrf_vevif_task_rx.c new file mode 100644 index 00000000000..8a4d81e0e6e --- /dev/null +++ b/drivers/mbox/mbox_nrf_vevif_task_rx.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#define DT_DRV_COMPAT nordic_nrf_vevif_task_rx + +#include +#include + +#include +#include +#include + +#if defined(CONFIG_SOC_NRF54L15_ENGA_CPUFLPR) +#define TASKS_IDX_MIN 11U +#define TASKS_IDX_MAX 17U +#else +#define TASKS_IDX_MIN NRF_VPR_TASKS_TRIGGER_MIN +#define TASKS_IDX_MAX NRF_VPR_TASKS_TRIGGER_MAX +#endif + +#define VEVIF_TASKS_NUM DT_INST_PROP(0, nordic_tasks) +#define VEVIF_TASKS_MASK DT_INST_PROP(0, nordic_tasks_mask) + +BUILD_ASSERT(VEVIF_TASKS_NUM <= VPR_TASKS_TRIGGER_MaxCount, "Number of tasks exceeds maximum"); +BUILD_ASSERT(VEVIF_TASKS_NUM == DT_NUM_IRQS(DT_DRV_INST(0)), "# IRQs != # tasks"); + +/* callbacks */ +struct mbox_vevif_task_rx_cbs { + mbox_callback_t cb[TASKS_IDX_MAX - TASKS_IDX_MIN + 1U]; + void *user_data[TASKS_IDX_MAX - TASKS_IDX_MIN + 1U]; + uint32_t enabled_mask; +}; + +static struct mbox_vevif_task_rx_cbs cbs; + +/* IRQ list */ +#define VEVIF_IRQN(idx, _) DT_INST_IRQ_BY_IDX(0, idx, irq) + +static const uint8_t vevif_irqs[VEVIF_TASKS_NUM] = { + LISTIFY(DT_NUM_IRQS(DT_DRV_INST(0)), VEVIF_IRQN, (,)) +}; + +static void vevif_task_rx_isr(const void *parameter) +{ + uint8_t channel = *(uint8_t *)parameter; + uint8_t idx = channel - TASKS_IDX_MIN; + + nrf_vpr_csr_vevif_tasks_clear(BIT(channel)); + + if (cbs.cb[idx] != NULL) { + cbs.cb[idx](DEVICE_DT_INST_GET(0), channel, cbs.user_data[idx], NULL); + } +} + +static inline bool vevif_task_rx_is_task_valid(uint32_t id) +{ + return ((id <= TASKS_IDX_MAX) && ((VEVIF_TASKS_MASK & BIT(id)) != 0U)); +} + +static uint32_t vevif_task_rx_max_channels_get(const struct device *dev) +{ + ARG_UNUSED(dev); + + return VEVIF_TASKS_NUM; +} + +static int vevif_task_rx_register_callback(const struct device *dev, uint32_t id, + mbox_callback_t cb, void *user_data) +{ + ARG_UNUSED(dev); + uint8_t idx = id - TASKS_IDX_MIN; + + if (!vevif_task_rx_is_task_valid(id)) { + return -EINVAL; + } + + cbs.cb[idx] = cb; + cbs.user_data[idx] = user_data; + + return 0; +} + +static int vevif_task_rx_set_enabled(const struct device *dev, uint32_t id, bool enable) +{ + ARG_UNUSED(dev); + uint8_t idx = id - TASKS_IDX_MIN; + + if (!vevif_task_rx_is_task_valid(id)) { + return -EINVAL; + } + + if (enable) { + if ((cbs.enabled_mask & BIT(id)) != 0U) { + return -EALREADY; + } + + cbs.enabled_mask |= BIT(id); + irq_enable(vevif_irqs[idx]); + } else { + if ((cbs.enabled_mask & BIT(id)) == 0U) { + return -EALREADY; + } + + cbs.enabled_mask &= ~BIT(id); + irq_disable(vevif_irqs[idx]); + } + + return 0; +} + +static const struct mbox_driver_api vevif_task_rx_driver_api = { + .max_channels_get = vevif_task_rx_max_channels_get, + .register_callback = vevif_task_rx_register_callback, + .set_enabled = vevif_task_rx_set_enabled, +}; + +#define VEVIF_IRQ_CONNECT(idx, _) \ + IRQ_CONNECT(DT_INST_IRQ_BY_IDX(0, idx, irq), DT_INST_IRQ_BY_IDX(0, idx, priority), \ + vevif_task_rx_isr, &vevif_irqs[idx], 0) + +static int vevif_task_rx_init(const struct device *dev) +{ + nrf_vpr_csr_vevif_tasks_clear(NRF_VPR_TASK_TRIGGER_ALL_MASK); + + LISTIFY(DT_NUM_IRQS(DT_DRV_INST(0)), VEVIF_IRQ_CONNECT, (;)); + + return 0; +} + +DEVICE_DT_INST_DEFINE(0, vevif_task_rx_init, NULL, NULL, NULL, POST_KERNEL, + CONFIG_MBOX_INIT_PRIORITY, &vevif_task_rx_driver_api); diff --git a/drivers/mbox/mbox_nrf_vevif_remote.c b/drivers/mbox/mbox_nrf_vevif_task_tx.c similarity index 52% rename from drivers/mbox/mbox_nrf_vevif_remote.c rename to drivers/mbox/mbox_nrf_vevif_task_tx.c index cb5d7c507c5..6aac7522617 100644 --- a/drivers/mbox/mbox_nrf_vevif_remote.c +++ b/drivers/mbox/mbox_nrf_vevif_task_tx.c @@ -3,31 +3,37 @@ * SPDX-License-Identifier: Apache-2.0 */ -#define DT_DRV_COMPAT nordic_nrf_vevif_remote +#define DT_DRV_COMPAT nordic_nrf_vevif_task_tx #include #include #include -struct mbox_vevif_remote_conf { +#if defined(CONFIG_SOC_NRF54L15_ENGA_CPUAPP) +#define TASKS_IDX_MAX 17U +#else +#define TASKS_IDX_MAX NRF_VPR_TASKS_TRIGGER_MAX +#endif + +struct mbox_vevif_task_tx_conf { NRF_VPR_Type *vpr; uint32_t tasks_mask; uint8_t tasks; }; -static inline bool vevif_remote_is_task_valid(const struct device *dev, uint32_t id) +static inline bool vevif_task_tx_is_valid(const struct device *dev, uint32_t id) { - const struct mbox_vevif_remote_conf *config = dev->config; + const struct mbox_vevif_task_tx_conf *config = dev->config; - return (id < config->tasks) && ((config->tasks_mask & BIT(id)) != 0U); + return ((id <= TASKS_IDX_MAX) && ((config->tasks_mask & BIT(id)) != 0U)); } -static int vevif_remote_send(const struct device *dev, uint32_t id, const struct mbox_msg *msg) +static int vevif_task_tx_send(const struct device *dev, uint32_t id, const struct mbox_msg *msg) { - const struct mbox_vevif_remote_conf *config = dev->config; + const struct mbox_vevif_task_tx_conf *config = dev->config; - if (!vevif_remote_is_task_valid(dev, id)) { + if (!vevif_task_tx_is_valid(dev, id)) { return -EINVAL; } @@ -40,37 +46,37 @@ static int vevif_remote_send(const struct device *dev, uint32_t id, const struct return 0; } -static int vevif_remote_mtu_get(const struct device *dev) +static int vevif_task_tx_mtu_get(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static uint32_t vevif_remote_max_channels_get(const struct device *dev) +static uint32_t vevif_task_tx_max_channels_get(const struct device *dev) { - const struct mbox_vevif_remote_conf *config = dev->config; + const struct mbox_vevif_task_tx_conf *config = dev->config; return config->tasks; } -static const struct mbox_driver_api vevif_remote_driver_api = { - .send = vevif_remote_send, - .mtu_get = vevif_remote_mtu_get, - .max_channels_get = vevif_remote_max_channels_get, +static const struct mbox_driver_api vevif_task_tx_driver_api = { + .send = vevif_task_tx_send, + .mtu_get = vevif_task_tx_mtu_get, + .max_channels_get = vevif_task_tx_max_channels_get, }; -#define VEVIF_REMOTE_DEFINE(inst) \ +#define VEVIF_TASK_TX_DEFINE(inst) \ BUILD_ASSERT(DT_INST_PROP(inst, nordic_tasks) <= VPR_TASKS_TRIGGER_MaxCount, \ "Number of tasks exceeds maximum"); \ \ - static const struct mbox_vevif_remote_conf conf##inst = { \ + static const struct mbox_vevif_task_tx_conf conf##inst = { \ .vpr = (NRF_VPR_Type *)DT_INST_REG_ADDR(inst), \ .tasks = DT_INST_PROP(inst, nordic_tasks), \ .tasks_mask = DT_INST_PROP(inst, nordic_tasks_mask), \ }; \ \ DEVICE_DT_INST_DEFINE(inst, NULL, NULL, NULL, &conf##inst, POST_KERNEL, \ - CONFIG_MBOX_INIT_PRIORITY, &vevif_remote_driver_api); + CONFIG_MBOX_INIT_PRIORITY, &vevif_task_tx_driver_api); -DT_INST_FOREACH_STATUS_OKAY(VEVIF_REMOTE_DEFINE) +DT_INST_FOREACH_STATUS_OKAY(VEVIF_TASK_TX_DEFINE) diff --git a/dts/bindings/mbox/nordic,nrf-bellboard-local.yaml b/dts/bindings/mbox/nordic,nrf-bellboard-rx.yaml similarity index 88% rename from dts/bindings/mbox/nordic,nrf-bellboard-local.yaml rename to dts/bindings/mbox/nordic,nrf-bellboard-rx.yaml index 5c1709987cc..77bba202f52 100644 --- a/dts/bindings/mbox/nordic,nrf-bellboard-local.yaml +++ b/dts/bindings/mbox/nordic,nrf-bellboard-rx.yaml @@ -6,13 +6,13 @@ description: | BELLBOARD provides support for inter-domain software signaling. It implements a set of tasks and events intended for signaling within an interprocessor - communication (IPC) framework. When used in local mode, the BELLBOARD + communication (IPC) framework. When used in the rx mode, the BELLBOARD instance is used to receive events triggered by other remote cores. Example definition: bellboard: mailbox@deadbeef { - compatible = "nordic,nrf-bellboard-local"; + compatible = "nordic,nrf-bellboard-rx"; reg = <0xdeadbeef 0x1000>; interrupts = <98 NRF_DEFAULT_IRQ_PRIORITY>, <99 NRF_DEFAULT_IRQ_PRIORITY>; @@ -21,7 +21,7 @@ description: | #mbox-cells = <1>; }; -compatible: "nordic,nrf-bellboard-local" +compatible: "nordic,nrf-bellboard-rx" include: "nordic,nrf-bellboard-common.yaml" diff --git a/dts/bindings/mbox/nordic,nrf-bellboard-remote.yaml b/dts/bindings/mbox/nordic,nrf-bellboard-tx.yaml similarity index 76% rename from dts/bindings/mbox/nordic,nrf-bellboard-remote.yaml rename to dts/bindings/mbox/nordic,nrf-bellboard-tx.yaml index ae17fc916a1..95efcdededf 100644 --- a/dts/bindings/mbox/nordic,nrf-bellboard-remote.yaml +++ b/dts/bindings/mbox/nordic,nrf-bellboard-tx.yaml @@ -6,17 +6,17 @@ description: | BELLBOARD provides support for inter-domain software signaling. It implements a set of tasks and events intended for signaling within an interprocessor - communication (IPC) framework. When used in remote mode, the BELLBOARD + communication (IPC) framework. When used in the tx mode, the BELLBOARD instance is used to trigger events to another core. Example definition: bellboard: mailbox@deadbeef { - compatible = "nordic,nrf-bellboard-remote"; + compatible = "nordic,nrf-bellboard-tx"; reg = <0xdeadbeef 0x1000>; #mbox-cells = <1>; }; -compatible: "nordic,nrf-bellboard-remote" +compatible: "nordic,nrf-bellboard-tx" include: "nordic,nrf-bellboard-common.yaml" diff --git a/dts/bindings/mbox/nordic,nrf-vevif-common.yaml b/dts/bindings/mbox/nordic,nrf-vevif-common.yaml deleted file mode 100644 index b7cb15457f6..00000000000 --- a/dts/bindings/mbox/nordic,nrf-vevif-common.yaml +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2024 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -include: mailbox-controller.yaml - -properties: - nordic,tasks: - type: int - required: true - description: Number of tasks supported by the VEVIF instance. - - nordic,tasks-mask: - type: int - required: true - description: Mask of tasks supported by the VEVIF instance. - -mbox-cells: - - channel diff --git a/dts/bindings/mbox/nordic,nrf-vevif-local.yaml b/dts/bindings/mbox/nordic,nrf-vevif-local.yaml deleted file mode 100644 index 5d23cfdcf1e..00000000000 --- a/dts/bindings/mbox/nordic,nrf-vevif-local.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (c) 2024 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -description: | - Nordic VEVIF (VPR Event Interface) - Local - - VEVIF is an event interface for VPR, allowing connection to the domain's DPPI - system. VEVIF can also generate IRQs to other CPUs. - - Example definition: - - cpuppr: cpu@d { - ... - cpuppr_vevif_local: mailbox { - compatible = "nordic,nrf-vevif-local"; - interrupts = <0 NRF_DEFAULT_IRQ_PRIORITY>, - <1 NRF_DEFAULT_IRQ_PRIORITY>, - ... - ; - #mbox-cells = <1>; - nordic,tasks = <16>; - nordic,tasks-mask: <0xfffffff0>; - }; - }; - -compatible: "nordic,nrf-vevif-local" - -include: [base.yaml, "nordic,nrf-vevif-common.yaml"] - -properties: - interrupts: - required: true diff --git a/dts/bindings/mbox/nordic,nrf-vevif-remote.yaml b/dts/bindings/mbox/nordic,nrf-vevif-remote.yaml deleted file mode 100644 index 07522fed99d..00000000000 --- a/dts/bindings/mbox/nordic,nrf-vevif-remote.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2024 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 - -description: | - Nordic VEVIF (VPR Event Interface) - Remote - - VEVIF is an event interface for VPR, allowing connection to the domain's DPPI - system. VEVIF can also generate IRQs to other CPUs. - - Example definition: - - cpuppr_vpr: vpr@deadbeef{ - ... - cpuppr_vevif_remote: mailbox@0 { - compatible = "nordic,nrf-vevif-remote"; - reg = <0x0 0x1000>; - #mbox-cells = <1>; - nordic,tasks = <16>; - nordic,tasks-mask: <0xfffffff0>; - }; - }; - -compatible: "nordic,nrf-vevif-remote" - -include: [base.yaml, "nordic,nrf-vevif-common.yaml"] - -properties: - reg: - required: true diff --git a/dts/bindings/mbox/nordic,nrf-vevif-task-rx.yaml b/dts/bindings/mbox/nordic,nrf-vevif-task-rx.yaml new file mode 100644 index 00000000000..98304c83474 --- /dev/null +++ b/dts/bindings/mbox/nordic,nrf-vevif-task-rx.yaml @@ -0,0 +1,49 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Nordic VEVIF (VPR Event Interface) - TASK RX MODE + + VEVIF is an event interface for VPR, allowing connection to the domain's DPPI + system. VEVIF can also generate IRQs to other CPUs. + + VEVIF provides support for inter-domain software signaling. It implements a set of tasks + intended for signaling within an interprocessor communication (IPC) framework. + When used in task rx mode, the VEVIF tasks are used to receive events triggered by other core. + + Example definition: + + cpuppr: cpu@d { + ... + cpuppr_vevif_task_rx: mailbox { + compatible = "nordic,nrf-vevif-task-rx"; + interrupts = <0 NRF_DEFAULT_IRQ_PRIORITY>, + <1 NRF_DEFAULT_IRQ_PRIORITY>, + ... + ; + #mbox-cells = <1>; + nordic,tasks = <16>; + nordic,tasks-mask = <0xfffffff0>; + }; + }; + +compatible: "nordic,nrf-vevif-task-rx" + +include: [base.yaml, mailbox-controller.yaml] + +properties: + nordic,tasks: + type: int + required: true + description: Number of tasks supported by the VEVIF instance. + + nordic,tasks-mask: + type: int + required: true + description: Mask of tasks supported by the VEVIF instance. + + interrupts: + required: true + +mbox-cells: + - channel diff --git a/dts/bindings/mbox/nordic,nrf-vevif-task-tx.yaml b/dts/bindings/mbox/nordic,nrf-vevif-task-tx.yaml new file mode 100644 index 00000000000..d8f603854cb --- /dev/null +++ b/dts/bindings/mbox/nordic,nrf-vevif-task-tx.yaml @@ -0,0 +1,46 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Nordic VEVIF (VPR Event Interface) - TASK TX MODE + + VEVIF is an event interface for VPR, allowing connection to the domain's DPPI + system. VEVIF can also generate IRQs to other CPUs. + + VEVIF provides support for inter-domain software signaling. It implements a set of tasks + intended for signaling within an interprocessor communication (IPC) framework. + When used in task tx mode, the VEVIF tasks are used to trigger IRQs on VPR core. + + Example definition: + + cpuppr_vpr: vpr@deadbeef{ + ... + cpuppr_vevif_task_tx: mailbox@0 { + compatible = "nordic,nrf-vevif-task-tx"; + reg = <0x0 0x1000>; + #mbox-cells = <1>; + nordic,tasks = <16>; + nordic,tasks-mask = <0xfffffff0>; + }; + }; + +compatible: "nordic,nrf-vevif-task-tx" + +include: [base.yaml, mailbox-controller.yaml] + +properties: + nordic,tasks: + type: int + required: true + description: Number of tasks supported by the VEVIF instance. + + nordic,tasks-mask: + type: int + required: true + description: Mask of tasks supported by the VEVIF instance. + + reg: + required: true + +mbox-cells: + - channel