Lines Matching +full:p2a +full:- +full:control

1 // SPDX-License-Identifier: GPL-2.0
3 * System Control and Management Interface (SCMI) Message Mailbox Transport
19 * struct scmi_mailbox - Structure representing a SCMI mailbox transport
22 * @chan: Transmit/Receive mailbox uni/bi-directional channel
43 shmem_tx_prepare(smbox->shmem, m, smbox->cinfo); in tx_prepare()
56 * a previous timed-out reply which arrived late could be wrongly in rx_callback()
59 if (cl->knows_txdone && !shmem_channel_free(smbox->shmem)) { in rx_callback()
60 dev_warn(smbox->cinfo->dev, "Ignoring spurious A2P IRQ !\n"); in rx_callback()
61 scmi_bad_message_trace(smbox->cinfo, in rx_callback()
62 shmem_read_header(smbox->shmem), in rx_callback()
67 scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem), NULL); in rx_callback()
79 num_mb = of_count_phandle_with_args(of_node, "mboxes", "#mbox-cells"); in mailbox_chan_available()
84 "#mbox-cells", idx, NULL); in mailbox_chan_available()
88 * mailbox_chan_validate - Validate transport configuration and map channels
94 * @p2a_chan: A reference to the optional p2a channel.
107 struct device_node *np = cdev->of_node; in mailbox_chan_validate()
109 num_mb = of_count_phandle_with_args(np, "mboxes", "#mbox-cells"); in mailbox_chan_validate()
117 "Invalid channel descriptor for '%s' - mbs:%d shm:%d\n", in mailbox_chan_validate()
119 return -EINVAL; in mailbox_chan_validate()
131 ret = -EINVAL; in mailbox_chan_validate()
168 struct device *cdev = cinfo->dev; in mailbox_chan_setup()
181 return -ENODEV; in mailbox_chan_setup()
185 return -ENOMEM; in mailbox_chan_setup()
187 shmem = of_parse_phandle(cdev->of_node, "shmem", idx); in mailbox_chan_setup()
188 if (!of_device_is_compatible(shmem, "arm,scmi-shmem")) { in mailbox_chan_setup()
190 return -ENXIO; in mailbox_chan_setup()
201 smbox->shmem = devm_ioremap(dev, res.start, size); in mailbox_chan_setup()
202 if (!smbox->shmem) { in mailbox_chan_setup()
204 return -EADDRNOTAVAIL; in mailbox_chan_setup()
207 cl = &smbox->cl; in mailbox_chan_setup()
208 cl->dev = cdev; in mailbox_chan_setup()
209 cl->tx_prepare = tx ? tx_prepare : NULL; in mailbox_chan_setup()
210 cl->rx_callback = rx_callback; in mailbox_chan_setup()
211 cl->tx_block = false; in mailbox_chan_setup()
212 cl->knows_txdone = tx; in mailbox_chan_setup()
214 smbox->chan = mbox_request_channel(cl, tx ? 0 : p2a_chan); in mailbox_chan_setup()
215 if (IS_ERR(smbox->chan)) { in mailbox_chan_setup()
216 ret = PTR_ERR(smbox->chan); in mailbox_chan_setup()
217 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
225 smbox->chan_receiver = mbox_request_channel(cl, a2p_rx_chan); in mailbox_chan_setup()
226 if (IS_ERR(smbox->chan_receiver)) { in mailbox_chan_setup()
227 ret = PTR_ERR(smbox->chan_receiver); in mailbox_chan_setup()
228 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
234 cinfo->transport_info = smbox; in mailbox_chan_setup()
235 smbox->cinfo = cinfo; in mailbox_chan_setup()
236 mutex_init(&smbox->chan_lock); in mailbox_chan_setup()
244 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_chan_free()
246 if (smbox && !IS_ERR(smbox->chan)) { in mailbox_chan_free()
247 mbox_free_channel(smbox->chan); in mailbox_chan_free()
248 mbox_free_channel(smbox->chan_receiver); in mailbox_chan_free()
249 cinfo->transport_info = NULL; in mailbox_chan_free()
250 smbox->chan = NULL; in mailbox_chan_free()
251 smbox->chan_receiver = NULL; in mailbox_chan_free()
252 smbox->cinfo = NULL; in mailbox_chan_free()
261 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_send_message()
271 mutex_lock(&smbox->chan_lock); in mailbox_send_message()
273 ret = mbox_send_message(smbox->chan, xfer); in mailbox_send_message()
274 /* mbox_send_message returns non-negative value on success */ in mailbox_send_message()
276 mutex_unlock(&smbox->chan_lock); in mailbox_send_message()
286 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_mark_txdone()
288 mbox_client_txdone(smbox->chan, ret); in mailbox_mark_txdone()
291 mutex_unlock(&smbox->chan_lock); in mailbox_mark_txdone()
297 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_response()
299 shmem_fetch_response(smbox->shmem, xfer); in mailbox_fetch_response()
305 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_notification()
307 shmem_fetch_notification(smbox->shmem, max_len, xfer); in mailbox_fetch_notification()
312 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_clear_channel()
314 shmem_clear_channel(smbox->shmem); in mailbox_clear_channel()
320 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_poll_done()
322 return shmem_poll_done(smbox->shmem, xfer); in mailbox_poll_done()