Lines Matching +full:scmi +full:- +full:shmem

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
23 * @cinfo: SCMI channel info
24 * @shmem: Transmit/Receive shared memory area
30 struct scmi_shared_mem __iomem *shmem; member
39 shmem_tx_prepare(smbox->shmem, m); in tx_prepare()
46 scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem), NULL); in rx_callback()
51 return !of_parse_phandle_with_args(dev->of_node, "mboxes", in mailbox_chan_available()
52 "#mbox-cells", idx, NULL); in mailbox_chan_available()
59 struct device *cdev = cinfo->dev; in mailbox_chan_setup()
61 struct device_node *shmem; in mailbox_chan_setup() local
69 return -ENOMEM; in mailbox_chan_setup()
71 shmem = of_parse_phandle(cdev->of_node, "shmem", idx); in mailbox_chan_setup()
72 if (!of_device_is_compatible(shmem, "arm,scmi-shmem")) in mailbox_chan_setup()
73 return -ENXIO; in mailbox_chan_setup()
75 ret = of_address_to_resource(shmem, 0, &res); in mailbox_chan_setup()
76 of_node_put(shmem); in mailbox_chan_setup()
78 dev_err(cdev, "failed to get SCMI %s shared memory\n", desc); in mailbox_chan_setup()
83 smbox->shmem = devm_ioremap(dev, res.start, size); in mailbox_chan_setup()
84 if (!smbox->shmem) { in mailbox_chan_setup()
85 dev_err(dev, "failed to ioremap SCMI %s shared memory\n", desc); in mailbox_chan_setup()
86 return -EADDRNOTAVAIL; in mailbox_chan_setup()
89 cl = &smbox->cl; in mailbox_chan_setup()
90 cl->dev = cdev; in mailbox_chan_setup()
91 cl->tx_prepare = tx ? tx_prepare : NULL; in mailbox_chan_setup()
92 cl->rx_callback = rx_callback; in mailbox_chan_setup()
93 cl->tx_block = false; in mailbox_chan_setup()
94 cl->knows_txdone = tx; in mailbox_chan_setup()
96 smbox->chan = mbox_request_channel(cl, tx ? 0 : 1); in mailbox_chan_setup()
97 if (IS_ERR(smbox->chan)) { in mailbox_chan_setup()
98 ret = PTR_ERR(smbox->chan); in mailbox_chan_setup()
99 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
100 dev_err(cdev, "failed to request SCMI %s mailbox\n", in mailbox_chan_setup()
105 cinfo->transport_info = smbox; in mailbox_chan_setup()
106 smbox->cinfo = cinfo; in mailbox_chan_setup()
114 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_chan_free()
116 if (smbox && !IS_ERR(smbox->chan)) { in mailbox_chan_free()
117 mbox_free_channel(smbox->chan); in mailbox_chan_free()
118 cinfo->transport_info = NULL; in mailbox_chan_free()
119 smbox->chan = NULL; in mailbox_chan_free()
120 smbox->cinfo = NULL; in mailbox_chan_free()
131 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_send_message()
134 ret = mbox_send_message(smbox->chan, xfer); in mailbox_send_message()
136 /* mbox_send_message returns non-negative value on success, so reset */ in mailbox_send_message()
145 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_mark_txdone()
153 mbox_client_txdone(smbox->chan, ret); in mailbox_mark_txdone()
159 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_response()
161 shmem_fetch_response(smbox->shmem, xfer); in mailbox_fetch_response()
167 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_notification()
169 shmem_fetch_notification(smbox->shmem, max_len, xfer); in mailbox_fetch_notification()
174 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_clear_channel()
176 shmem_clear_channel(smbox->shmem); in mailbox_clear_channel()
182 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_poll_done()
184 return shmem_poll_done(smbox->shmem, xfer); in mailbox_poll_done()