Lines Matching +full:bad +full:- +full:key +full:- +full:1

2  * Copyright (c) 2020-2023 Intel Corporation
4 * SPDX-License-Identifier: Apache-2.0
23 struct ipm_sedi_context *ipm = dev->data; in set_ipm_dev_busy()
24 unsigned int key = irq_lock(); in set_ipm_dev_busy() local
26 atomic_set_bit(&ipm->status, is_write ? IPM_WRITE_BUSY_BIT : IPM_READ_BUSY_BIT); in set_ipm_dev_busy()
28 irq_unlock(key); in set_ipm_dev_busy()
33 struct ipm_sedi_context *ipm = dev->data; in clear_ipm_dev_busy()
34 unsigned int key = irq_lock(); in clear_ipm_dev_busy() local
36 atomic_clear_bit(&ipm->status, is_write ? IPM_WRITE_BUSY_BIT : IPM_READ_BUSY_BIT); in clear_ipm_dev_busy()
37 if ((!atomic_test_bit(&ipm->status, IPM_WRITE_BUSY_BIT)) in clear_ipm_dev_busy()
38 && (!atomic_test_bit(&ipm->status, IPM_READ_BUSY_BIT))) { in clear_ipm_dev_busy()
41 irq_unlock(key); in clear_ipm_dev_busy()
47 struct ipm_sedi_context *ipm = dev->data; in ipm_event_dispose()
53 if (ipm->rx_msg_notify_cb != NULL) { in ipm_event_dispose()
57 sedi_ipc_read_msg(device, ipm->incoming_data_buf, len); in ipm_event_dispose()
58 ipm->rx_msg_notify_cb(dev, in ipm_event_dispose()
59 ipm->rx_msg_notify_cb_data, in ipm_event_dispose()
60 drbl_in, ipm->incoming_data_buf); in ipm_event_dispose()
66 if (atomic_test_bit(&ipm->status, IPM_WRITE_IN_PROC_BIT)) { in ipm_event_dispose()
67 k_sem_give(&ipm->device_write_msg_sem); in ipm_event_dispose()
80 const struct ipm_sedi_config_t *info = dev->config; in ipm_init()
81 sedi_ipc_t device = info->ipc_device; in ipm_init()
82 struct ipm_sedi_context *ipm = dev->data; in ipm_init()
84 info->irq_config(); in ipm_init()
85 k_sem_init(&ipm->device_write_msg_sem, 0, 1); in ipm_init()
86 k_mutex_init(&ipm->device_write_lock); in ipm_init()
87 ipm->status = 0; in ipm_init()
90 atomic_set_bit(&ipm->status, IPM_PEER_READY_BIT); in ipm_init()
100 const struct ipm_sedi_config_t *info = dev->config; in ipm_send_isr()
101 sedi_ipc_t device = info->ipc_device; in ipm_send_isr()
120 __ASSERT((dev != NULL), "bad params\n"); in ipm_sedi_send()
121 const struct ipm_sedi_config_t *info = dev->config; in ipm_sedi_send()
122 struct ipm_sedi_context *ipm = dev->data; in ipm_sedi_send()
123 sedi_ipc_t device = info->ipc_device; in ipm_sedi_send()
129 LOG_ERR("bad params when sending ipm msg on device: %p", dev); in ipm_sedi_send()
130 return -EINVAL; in ipm_sedi_send()
135 return -ENOTSUP; in ipm_sedi_send()
142 k_mutex_lock(&ipm->device_write_lock, K_FOREVER); in ipm_sedi_send()
145 if (!atomic_test_bit(&ipm->status, IPM_PEER_READY_BIT)) { in ipm_sedi_send()
147 ret = -EBUSY; in ipm_sedi_send()
157 ret = -EBUSY; in ipm_sedi_send()
162 atomic_set_bit(&ipm->status, IPM_WRITE_IN_PROC_BIT); in ipm_sedi_send()
168 ret = -EBUSY; in ipm_sedi_send()
172 /* wait for busy-bit-consumed interrupt */ in ipm_sedi_send()
173 ret = k_sem_take(&ipm->device_write_msg_sem, K_MSEC(IPM_TIMEOUT_MS)); in ipm_sedi_send()
180 atomic_clear_bit(&ipm->status, IPM_WRITE_IN_PROC_BIT); in ipm_sedi_send()
184 k_mutex_unlock(&ipm->device_write_lock); in ipm_sedi_send()
195 __ASSERT((dev != NULL), "bad params\n"); in ipm_sedi_register_callback()
197 struct ipm_sedi_context *ipm = dev->data; in ipm_sedi_register_callback()
200 LOG_ERR("bad params when add ipm callback on device: %p", dev); in ipm_sedi_register_callback()
204 if (ipm->rx_msg_notify_cb == NULL) { in ipm_sedi_register_callback()
205 ipm->rx_msg_notify_cb = cb; in ipm_sedi_register_callback()
206 ipm->rx_msg_notify_cb_data = user_data; in ipm_sedi_register_callback()
216 __ASSERT((dev != NULL), "bad params\n"); in ipm_sedi_complete()
218 const struct ipm_sedi_config_t *info = dev->config; in ipm_sedi_complete()
219 sedi_ipc_t device = info->ipc_device; in ipm_sedi_complete()
243 __ASSERT((dev != NULL), "bad params\n"); in ipm_sedi_set_enable()
245 const struct ipm_sedi_config_t *info = dev->config; in ipm_sedi_set_enable()
248 irq_enable(info->irq_num); in ipm_sedi_set_enable()
250 irq_disable(info->irq_num); in ipm_sedi_set_enable()