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()
52 * a previous timed-out reply which arrived late could be wrongly in rx_callback()
55 if (cl->knows_txdone && !shmem_channel_free(smbox->shmem)) { in rx_callback()
56 dev_warn(smbox->cinfo->dev, "Ignoring spurious A2P IRQ !\n"); in rx_callback()
60 scmi_rx_callback(smbox->cinfo, shmem_read_header(smbox->shmem)); in rx_callback()
65 return !of_parse_phandle_with_args(dev->of_node, "mboxes", in mailbox_chan_available()
66 "#mbox-cells", idx, NULL); in mailbox_chan_available()
72 struct device_node *np = cdev->of_node; in mailbox_chan_validate()
74 num_mb = of_count_phandle_with_args(np, "mboxes", "#mbox-cells"); in mailbox_chan_validate()
75 num_sh = of_count_phandle_with_args(np, "shmem", NULL); in mailbox_chan_validate()
76 /* Bail out if mboxes and shmem descriptors are inconsistent */ in mailbox_chan_validate()
80 return -EINVAL; in mailbox_chan_validate()
86 np_tx = of_parse_phandle(np, "shmem", 0); in mailbox_chan_validate()
87 np_rx = of_parse_phandle(np, "shmem", 1); in mailbox_chan_validate()
88 /* SCMI Tx and Rx shared mem areas have to be distinct */ in mailbox_chan_validate()
90 dev_warn(cdev, "Invalid shmem descriptor for '%s'\n", in mailbox_chan_validate()
92 ret = -EINVAL; in mailbox_chan_validate()
106 struct device *cdev = cinfo->dev; in mailbox_chan_setup()
108 struct device_node *shmem; in mailbox_chan_setup() local
120 return -ENOMEM; in mailbox_chan_setup()
122 shmem = of_parse_phandle(cdev->of_node, "shmem", idx); in mailbox_chan_setup()
123 ret = of_address_to_resource(shmem, 0, &res); in mailbox_chan_setup()
124 of_node_put(shmem); in mailbox_chan_setup()
126 dev_err(cdev, "failed to get SCMI %s shared memory\n", desc); in mailbox_chan_setup()
131 smbox->shmem = devm_ioremap(dev, res.start, size); in mailbox_chan_setup()
132 if (!smbox->shmem) { in mailbox_chan_setup()
133 dev_err(dev, "failed to ioremap SCMI %s shared memory\n", desc); in mailbox_chan_setup()
134 return -EADDRNOTAVAIL; in mailbox_chan_setup()
137 cl = &smbox->cl; in mailbox_chan_setup()
138 cl->dev = cdev; in mailbox_chan_setup()
139 cl->tx_prepare = tx ? tx_prepare : NULL; in mailbox_chan_setup()
140 cl->rx_callback = rx_callback; in mailbox_chan_setup()
141 cl->tx_block = false; in mailbox_chan_setup()
142 cl->knows_txdone = tx; in mailbox_chan_setup()
144 smbox->chan = mbox_request_channel(cl, tx ? 0 : 1); in mailbox_chan_setup()
145 if (IS_ERR(smbox->chan)) { in mailbox_chan_setup()
146 ret = PTR_ERR(smbox->chan); in mailbox_chan_setup()
147 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
148 dev_err(cdev, "failed to request SCMI %s mailbox\n", in mailbox_chan_setup()
153 cinfo->transport_info = smbox; in mailbox_chan_setup()
154 smbox->cinfo = cinfo; in mailbox_chan_setup()
162 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_chan_free()
164 if (smbox && !IS_ERR(smbox->chan)) { in mailbox_chan_free()
165 mbox_free_channel(smbox->chan); in mailbox_chan_free()
166 cinfo->transport_info = NULL; in mailbox_chan_free()
167 smbox->chan = NULL; in mailbox_chan_free()
168 smbox->cinfo = NULL; in mailbox_chan_free()
179 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_send_message()
182 ret = mbox_send_message(smbox->chan, xfer); in mailbox_send_message()
184 /* mbox_send_message returns non-negative value on success, so reset */ in mailbox_send_message()
193 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_mark_txdone()
201 mbox_client_txdone(smbox->chan, ret); in mailbox_mark_txdone()
207 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_response()
209 shmem_fetch_response(smbox->shmem, xfer); in mailbox_fetch_response()
215 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_notification()
217 shmem_fetch_notification(smbox->shmem, max_len, xfer); in mailbox_fetch_notification()
222 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_clear_channel()
224 shmem_clear_channel(smbox->shmem); in mailbox_clear_channel()
230 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_poll_done()
232 return shmem_poll_done(smbox->shmem, xfer); in mailbox_poll_done()