Lines Matching +full:tx +full:- +full:channel
4 * SPDX-License-Identifier: Apache-2.0
23 return -EOPNOTSUPP; in scmi_status_to_errno()
25 return -EINVAL; in scmi_status_to_errno()
27 return -EACCES; in scmi_status_to_errno()
29 return -ENOENT; in scmi_status_to_errno()
31 return -ERANGE; in scmi_status_to_errno()
34 return -EBUSY; in scmi_status_to_errno()
36 return -EPROTO; in scmi_status_to_errno()
41 return -EIO; in scmi_status_to_errno()
48 k_sem_give(&chan->sem); in scmi_core_reply_cb()
53 struct scmi_channel *chan, bool tx) in scmi_core_setup_chan() argument
58 return -EINVAL; in scmi_core_setup_chan()
61 if (chan->ready) { in scmi_core_setup_chan()
66 if (!tx) { in scmi_core_setup_chan()
67 return -ENOTSUP; in scmi_core_setup_chan()
70 k_mutex_init(&chan->lock); in scmi_core_setup_chan()
71 k_sem_init(&chan->sem, 0, 1); in scmi_core_setup_chan()
73 chan->cb = scmi_core_reply_cb; in scmi_core_setup_chan()
75 /* setup transport-related channel data */ in scmi_core_setup_chan()
76 ret = scmi_transport_setup_chan(transport, chan, tx); in scmi_core_setup_chan()
78 LOG_ERR("failed to setup channel"); in scmi_core_setup_chan()
82 /* protocols might share a channel. In such cases, this in scmi_core_setup_chan()
85 chan->ready = true; in scmi_core_setup_chan()
96 ret = scmi_transport_send_message(proto->transport, proto->tx, msg); in scmi_send_message_pre_kernel()
103 * Cortex-M quirk: no interrupts at this point => no timer => in scmi_send_message_pre_kernel()
108 while (!scmi_transport_channel_is_free(proto->transport, proto->tx)) { in scmi_send_message_pre_kernel()
111 ret = scmi_transport_read_message(proto->transport, proto->tx, reply); in scmi_send_message_pre_kernel()
125 if (!proto->tx) { in scmi_send_message_post_kernel()
126 return -ENODEV; in scmi_send_message_post_kernel()
129 /* wait for channel to be free */ in scmi_send_message_post_kernel()
130 ret = k_mutex_lock(&proto->tx->lock, K_USEC(SCMI_CHAN_LOCK_TIMEOUT_USEC)); in scmi_send_message_post_kernel()
136 ret = scmi_transport_send_message(proto->transport, proto->tx, msg); in scmi_send_message_post_kernel()
143 ret = k_sem_take(&proto->tx->sem, K_USEC(SCMI_CHAN_SEM_TIMEOUT_USEC)); in scmi_send_message_post_kernel()
149 ret = scmi_transport_read_message(proto->transport, proto->tx, reply); in scmi_send_message_post_kernel()
156 k_mutex_unlock(&proto->tx->lock); in scmi_send_message_post_kernel()
164 if (!proto->tx) { in scmi_send_message()
165 return -ENODEV; in scmi_send_message()
168 if (!proto->tx->ready) { in scmi_send_message()
169 return -EINVAL; in scmi_send_message()
184 it->transport = transport; in scmi_core_protocol_setup()
187 /* no static channel allocation, attempt dynamic binding */ in scmi_core_protocol_setup()
188 it->tx = scmi_transport_request_channel(transport, it->id, true); in scmi_core_protocol_setup()
191 if (!it->tx) { in scmi_core_protocol_setup()
192 return -ENODEV; in scmi_core_protocol_setup()
195 ret = scmi_core_setup_chan(transport, it->tx, true); in scmi_core_protocol_setup()