Lines Matching +full:enable +full:- +full:channel
4 * SPDX-License-Identifier: Apache-2.0
36 const struct mbox_nrf_conf *conf = dev->config; in is_rx_channel_valid()
38 return ((ch < IPC_CONF_NUM) && (conf->rx_mask & BIT(ch))); in is_rx_channel_valid()
43 const struct mbox_nrf_conf *conf = dev->config; in is_tx_channel_valid()
45 return ((ch < IPC_CONF_NUM) && (conf->tx_mask & BIT(ch))); in is_tx_channel_valid()
51 const struct device *dev = data->dev; in mbox_dispatcher()
53 uint32_t channel = event_idx; in mbox_dispatcher() local
55 if (!is_rx_channel_valid(dev, channel)) { in mbox_dispatcher()
56 LOG_WRN("RX event on illegal channel"); in mbox_dispatcher()
59 if (!(data->enabled_mask & BIT(channel))) { in mbox_dispatcher()
60 LOG_WRN("RX event on disabled channel"); in mbox_dispatcher()
63 if (data->cb[channel] != NULL) { in mbox_dispatcher()
64 data->cb[channel](dev, channel, data->user_data[channel], NULL); in mbox_dispatcher()
68 static int mbox_nrf_send(const struct device *dev, uint32_t channel, in mbox_nrf_send() argument
75 if (!is_tx_channel_valid(dev, channel)) { in mbox_nrf_send()
76 return -EINVAL; in mbox_nrf_send()
79 nrfx_ipc_signal(channel); in mbox_nrf_send()
84 static int mbox_nrf_register_callback(const struct device *dev, uint32_t channel, in mbox_nrf_register_callback() argument
87 struct mbox_nrf_data *data = dev->data; in mbox_nrf_register_callback()
89 if (channel >= IPC_CONF_NUM) { in mbox_nrf_register_callback()
90 return -EINVAL; in mbox_nrf_register_callback()
93 data->cb[channel] = cb; in mbox_nrf_register_callback()
94 data->user_data[channel] = user_data; in mbox_nrf_register_callback()
110 static int mbox_nrf_set_enabled(const struct device *dev, uint32_t channel, bool enable) in mbox_nrf_set_enabled() argument
112 struct mbox_nrf_data *data = dev->data; in mbox_nrf_set_enabled()
114 if (!is_rx_channel_valid(dev, channel)) { in mbox_nrf_set_enabled()
115 return -EINVAL; in mbox_nrf_set_enabled()
118 if ((enable == 0 && (!(data->enabled_mask & BIT(channel)))) || in mbox_nrf_set_enabled()
119 (enable != 0 && (data->enabled_mask & BIT(channel)))) { in mbox_nrf_set_enabled()
120 return -EALREADY; in mbox_nrf_set_enabled()
123 if (enable && (data->cb[channel] == NULL)) { in mbox_nrf_set_enabled()
124 LOG_WRN("Enabling channel without a registered callback\n"); in mbox_nrf_set_enabled()
127 if (enable && data->enabled_mask == 0) { in mbox_nrf_set_enabled()
131 if (enable) { in mbox_nrf_set_enabled()
132 data->enabled_mask |= BIT(channel); in mbox_nrf_set_enabled()
134 nrfx_ipc_receive_event_enable(channel); in mbox_nrf_set_enabled()
136 nrfx_ipc_receive_event_disable(channel); in mbox_nrf_set_enabled()
138 data->enabled_mask &= ~BIT(channel); in mbox_nrf_set_enabled()
141 if (data->enabled_mask == 0) { in mbox_nrf_set_enabled()
150 const struct mbox_nrf_conf *conf = dev->config; in enable_dt_channels()
153 if (conf->tx_mask >= BIT(IPC_CONF_NUM)) { in enable_dt_channels()
157 if (conf->rx_mask >= BIT(IPC_CONF_NUM)) { in enable_dt_channels()
161 /* Enable the interrupts on .set_enabled() only */ in enable_dt_channels()
165 if (conf->tx_mask & BIT(ch)) { in enable_dt_channels()
169 if (conf->rx_mask & BIT(ch)) { in enable_dt_channels()
179 struct mbox_nrf_data *data = dev->data; in mbox_nrf_init()
181 data->dev = dev; in mbox_nrf_init()