Lines Matching +full:bi +full:- +full:directional

1 // SPDX-License-Identifier: GPL-2.0
6 * Copyright (C) 2019-2024 ARM Ltd.
20 * struct scmi_mailbox - Structure representing a SCMI mailbox transport
23 * @chan: Transmit/Receive mailbox uni/bi-directional channel
50 core->shmem->tx_prepare(smbox->shmem, m, smbox->cinfo, in tx_prepare()
51 smbox->io_ops->toio); in tx_prepare()
64 * a previous timed-out reply which arrived late could be wrongly in rx_callback()
67 if (cl->knows_txdone && in rx_callback()
68 !core->shmem->channel_free(smbox->shmem)) { in rx_callback()
69 dev_warn(smbox->cinfo->dev, "Ignoring spurious A2P IRQ !\n"); in rx_callback()
70 core->bad_message_trace(smbox->cinfo, in rx_callback()
71 core->shmem->read_header(smbox->shmem), in rx_callback()
76 core->rx_callback(smbox->cinfo, in rx_callback()
77 core->shmem->read_header(smbox->shmem), NULL); in rx_callback()
89 num_mb = of_count_phandle_with_args(of_node, "mboxes", "#mbox-cells"); in mailbox_chan_available()
94 "#mbox-cells", idx, NULL); in mailbox_chan_available()
98 * mailbox_chan_validate - Validate transport configuration and map channels
119 struct device_node *np = cdev->of_node; in mailbox_chan_validate()
121 num_mb = of_count_phandle_with_args(np, "mboxes", "#mbox-cells"); in mailbox_chan_validate()
130 "Invalid channel descriptor for '%s' - mbs:%d shm:%d\n", in mailbox_chan_validate()
132 return -EINVAL; in mailbox_chan_validate()
145 ret = -EINVAL; in mailbox_chan_validate()
187 struct device *cdev = cinfo->dev; in mailbox_chan_setup()
197 return -ENODEV; in mailbox_chan_setup()
201 return -ENOMEM; in mailbox_chan_setup()
203 smbox->shmem = core->shmem->setup_iomap(cinfo, dev, tx, NULL, in mailbox_chan_setup()
204 &smbox->io_ops); in mailbox_chan_setup()
205 if (IS_ERR(smbox->shmem)) in mailbox_chan_setup()
206 return PTR_ERR(smbox->shmem); in mailbox_chan_setup()
208 cl = &smbox->cl; in mailbox_chan_setup()
209 cl->dev = cdev; in mailbox_chan_setup()
210 cl->tx_prepare = tx ? tx_prepare : NULL; in mailbox_chan_setup()
211 cl->rx_callback = rx_callback; in mailbox_chan_setup()
212 cl->tx_block = false; in mailbox_chan_setup()
213 cl->knows_txdone = tx; in mailbox_chan_setup()
215 smbox->chan = mbox_request_channel(cl, tx ? 0 : p2a_chan); in mailbox_chan_setup()
216 if (IS_ERR(smbox->chan)) { in mailbox_chan_setup()
217 ret = PTR_ERR(smbox->chan); in mailbox_chan_setup()
218 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
226 smbox->chan_receiver = mbox_request_channel(cl, a2p_rx_chan); in mailbox_chan_setup()
227 if (IS_ERR(smbox->chan_receiver)) { in mailbox_chan_setup()
228 ret = PTR_ERR(smbox->chan_receiver); in mailbox_chan_setup()
229 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
236 smbox->chan_platform_receiver = mbox_request_channel(cl, p2a_rx_chan); in mailbox_chan_setup()
237 if (IS_ERR(smbox->chan_platform_receiver)) { in mailbox_chan_setup()
238 ret = PTR_ERR(smbox->chan_platform_receiver); in mailbox_chan_setup()
239 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
245 cinfo->transport_info = smbox; in mailbox_chan_setup()
246 smbox->cinfo = cinfo; in mailbox_chan_setup()
247 mutex_init(&smbox->chan_lock); in mailbox_chan_setup()
255 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_chan_free()
257 if (smbox && !IS_ERR(smbox->chan)) { in mailbox_chan_free()
258 mbox_free_channel(smbox->chan); in mailbox_chan_free()
259 mbox_free_channel(smbox->chan_receiver); in mailbox_chan_free()
260 mbox_free_channel(smbox->chan_platform_receiver); in mailbox_chan_free()
261 cinfo->transport_info = NULL; in mailbox_chan_free()
262 smbox->chan = NULL; in mailbox_chan_free()
263 smbox->chan_receiver = NULL; in mailbox_chan_free()
264 smbox->chan_platform_receiver = NULL; in mailbox_chan_free()
265 smbox->cinfo = NULL; in mailbox_chan_free()
274 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_send_message()
284 mutex_lock(&smbox->chan_lock); in mailbox_send_message()
286 ret = mbox_send_message(smbox->chan, xfer); in mailbox_send_message()
287 /* mbox_send_message returns non-negative value on success */ in mailbox_send_message()
289 mutex_unlock(&smbox->chan_lock); in mailbox_send_message()
299 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_mark_txdone()
301 mbox_client_txdone(smbox->chan, ret); in mailbox_mark_txdone()
304 mutex_unlock(&smbox->chan_lock); in mailbox_mark_txdone()
310 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_response()
312 core->shmem->fetch_response(smbox->shmem, xfer, smbox->io_ops->fromio); in mailbox_fetch_response()
318 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_notification()
320 core->shmem->fetch_notification(smbox->shmem, max_len, xfer, in mailbox_fetch_notification()
321 smbox->io_ops->fromio); in mailbox_fetch_notification()
326 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_clear_channel()
330 core->shmem->clear_channel(smbox->shmem); in mailbox_clear_channel()
332 if (!core->shmem->channel_intr_enabled(smbox->shmem)) in mailbox_clear_channel()
335 if (smbox->chan_platform_receiver) in mailbox_clear_channel()
336 intr_chan = smbox->chan_platform_receiver; in mailbox_clear_channel()
337 else if (smbox->chan) in mailbox_clear_channel()
338 intr_chan = smbox->chan; in mailbox_clear_channel()
343 /* mbox_send_message returns non-negative value on success, so reset */ in mailbox_clear_channel()
353 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_poll_done()
355 return core->shmem->poll_done(smbox->shmem, xfer); in mailbox_poll_done()