Lines Matching +full:device +full:- +full:id
3 * SPDX-License-Identifier: Apache-2.0
24 mbox_callback_t cb[EVENTS_IDX_MAX - EVENTS_IDX_MIN + 1U];
25 void *user_data[EVENTS_IDX_MAX - EVENTS_IDX_MIN + 1U];
36 static void trigger_callback(const struct device *dev, struct mbox_vevif_event_rx_cbs *cbs, in trigger_callback()
37 uint8_t id) in trigger_callback() argument
39 uint8_t idx = id - EVENTS_IDX_MIN; in trigger_callback()
41 if ((cbs->enabled_mask & BIT(id)) && (cbs->cb[idx] != NULL)) { in trigger_callback()
42 cbs->cb[idx](dev, id, cbs->user_data[idx], NULL); in trigger_callback()
46 static void vevif_event_rx_isr(const void *device) in vevif_event_rx_isr() argument
48 const struct device *dev = (struct device *)device; in vevif_event_rx_isr()
49 struct mbox_vevif_event_rx_cbs *cbs = dev->data; in vevif_event_rx_isr()
52 const struct mbox_vevif_event_rx_conf *config = dev->config; in vevif_event_rx_isr()
54 for (uint8_t id = EVENTS_IDX_MIN; id < EVENTS_IDX_MAX + 1U; id++) { in vevif_event_rx_isr() local
55 nrf_vpr_event_t event = nrfy_vpr_triggered_event_get(id); in vevif_event_rx_isr()
56 if (nrfy_vpr_event_check(config->vpr, event)) { in vevif_event_rx_isr()
57 nrfy_vpr_event_clear(config->vpr, event); in vevif_event_rx_isr()
58 trigger_callback(dev, cbs, id); in vevif_event_rx_isr()
66 static inline bool vevif_event_rx_event_is_valid(uint32_t events_mask, uint32_t id) in vevif_event_rx_event_is_valid() argument
68 return ((id <= EVENTS_IDX_MAX) && ((events_mask & BIT(id)) != 0U)); in vevif_event_rx_event_is_valid()
71 static uint32_t vevif_event_rx_max_channels_get(const struct device *dev) in vevif_event_rx_max_channels_get()
73 const struct mbox_vevif_event_rx_conf *config = dev->config; in vevif_event_rx_max_channels_get()
75 return config->events; in vevif_event_rx_max_channels_get()
78 static int vevif_event_rx_register_callback(const struct device *dev, uint32_t id, in vevif_event_rx_register_callback() argument
81 const struct mbox_vevif_event_rx_conf *config = dev->config; in vevif_event_rx_register_callback()
82 struct mbox_vevif_event_rx_cbs *cbs = dev->data; in vevif_event_rx_register_callback()
83 uint8_t idx = id - EVENTS_IDX_MIN; in vevif_event_rx_register_callback()
85 if (!vevif_event_rx_event_is_valid(config->events_mask, id)) { in vevif_event_rx_register_callback()
86 return -EINVAL; in vevif_event_rx_register_callback()
89 cbs->cb[idx] = cb; in vevif_event_rx_register_callback()
90 cbs->user_data[idx] = user_data; in vevif_event_rx_register_callback()
95 static int vevif_event_rx_set_enabled(const struct device *dev, uint32_t id, bool enable) in vevif_event_rx_set_enabled() argument
97 const struct mbox_vevif_event_rx_conf *config = dev->config; in vevif_event_rx_set_enabled()
98 struct mbox_vevif_event_rx_cbs *cbs = dev->data; in vevif_event_rx_set_enabled()
100 if (!vevif_event_rx_event_is_valid(config->events_mask, id)) { in vevif_event_rx_set_enabled()
101 return -EINVAL; in vevif_event_rx_set_enabled()
105 if ((cbs->enabled_mask & BIT(id)) != 0U) { in vevif_event_rx_set_enabled()
106 return -EALREADY; in vevif_event_rx_set_enabled()
109 cbs->enabled_mask |= BIT(id); in vevif_event_rx_set_enabled()
110 nrfy_vpr_int_enable(config->vpr, BIT(id)); in vevif_event_rx_set_enabled()
112 if ((cbs->enabled_mask & BIT(id)) == 0U) { in vevif_event_rx_set_enabled()
113 return -EALREADY; in vevif_event_rx_set_enabled()
116 cbs->enabled_mask &= ~BIT(id); in vevif_event_rx_set_enabled()
117 nrfy_vpr_int_disable(config->vpr, BIT(id)); in vevif_event_rx_set_enabled()
129 static int vevif_event_rx_init(const struct device *dev) in vevif_event_rx_init()
131 const struct mbox_vevif_event_rx_conf *config = dev->config; in vevif_event_rx_init()
133 config->irq_connect(); in vevif_event_rx_init()