• Home
  • Raw
  • Download

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)); 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()
58 struct device_node *np = cdev->of_node; in mailbox_chan_validate()
60 num_mb = of_count_phandle_with_args(np, "mboxes", "#mbox-cells"); in mailbox_chan_validate()
61 num_sh = of_count_phandle_with_args(np, "shmem", NULL); in mailbox_chan_validate()
62 /* Bail out if mboxes and shmem descriptors are inconsistent */ in mailbox_chan_validate()
66 return -EINVAL; in mailbox_chan_validate()
72 np_tx = of_parse_phandle(np, "shmem", 0); in mailbox_chan_validate()
73 np_rx = of_parse_phandle(np, "shmem", 1); in mailbox_chan_validate()
74 /* SCMI Tx and Rx shared mem areas have to be distinct */ in mailbox_chan_validate()
76 dev_warn(cdev, "Invalid shmem descriptor for '%s'\n", in mailbox_chan_validate()
78 ret = -EINVAL; in mailbox_chan_validate()
92 struct device *cdev = cinfo->dev; in mailbox_chan_setup()
94 struct device_node *shmem; in mailbox_chan_setup() local
106 return -ENOMEM; in mailbox_chan_setup()
108 shmem = of_parse_phandle(cdev->of_node, "shmem", idx); in mailbox_chan_setup()
109 ret = of_address_to_resource(shmem, 0, &res); in mailbox_chan_setup()
110 of_node_put(shmem); in mailbox_chan_setup()
112 dev_err(cdev, "failed to get SCMI %s shared memory\n", desc); in mailbox_chan_setup()
117 smbox->shmem = devm_ioremap(dev, res.start, size); in mailbox_chan_setup()
118 if (!smbox->shmem) { in mailbox_chan_setup()
119 dev_err(dev, "failed to ioremap SCMI %s shared memory\n", desc); in mailbox_chan_setup()
120 return -EADDRNOTAVAIL; in mailbox_chan_setup()
123 cl = &smbox->cl; in mailbox_chan_setup()
124 cl->dev = cdev; in mailbox_chan_setup()
125 cl->tx_prepare = tx ? tx_prepare : NULL; in mailbox_chan_setup()
126 cl->rx_callback = rx_callback; in mailbox_chan_setup()
127 cl->tx_block = false; in mailbox_chan_setup()
128 cl->knows_txdone = tx; in mailbox_chan_setup()
130 smbox->chan = mbox_request_channel(cl, tx ? 0 : 1); in mailbox_chan_setup()
131 if (IS_ERR(smbox->chan)) { in mailbox_chan_setup()
132 ret = PTR_ERR(smbox->chan); in mailbox_chan_setup()
133 if (ret != -EPROBE_DEFER) in mailbox_chan_setup()
134 dev_err(cdev, "failed to request SCMI %s mailbox\n", in mailbox_chan_setup()
139 cinfo->transport_info = smbox; in mailbox_chan_setup()
140 smbox->cinfo = cinfo; in mailbox_chan_setup()
148 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_chan_free()
150 if (smbox && !IS_ERR(smbox->chan)) { in mailbox_chan_free()
151 mbox_free_channel(smbox->chan); in mailbox_chan_free()
152 cinfo->transport_info = NULL; in mailbox_chan_free()
153 smbox->chan = NULL; in mailbox_chan_free()
154 smbox->cinfo = NULL; in mailbox_chan_free()
165 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_send_message()
168 ret = mbox_send_message(smbox->chan, xfer); in mailbox_send_message()
170 /* mbox_send_message returns non-negative value on success, so reset */ in mailbox_send_message()
179 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_mark_txdone()
187 mbox_client_txdone(smbox->chan, ret); in mailbox_mark_txdone()
193 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_response()
195 shmem_fetch_response(smbox->shmem, xfer); in mailbox_fetch_response()
201 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_fetch_notification()
203 shmem_fetch_notification(smbox->shmem, max_len, xfer); in mailbox_fetch_notification()
208 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_clear_channel()
210 shmem_clear_channel(smbox->shmem); in mailbox_clear_channel()
216 struct scmi_mailbox *smbox = cinfo->transport_info; in mailbox_poll_done()
218 return shmem_poll_done(smbox->shmem, xfer); in mailbox_poll_done()