Lines Matching +full:rx +full:- +full:shared
1 // SPDX-License-Identifier: GPL-2.0
3 * For transport using shared mem structure.
5 * Copyright (C) 2019-2024 ARM Ltd.
46 * until it releases the shared memory, otherwise we may endup in shmem_tx_prepare()
47 * overwriting its response with new message payload or vice-versa. in shmem_tx_prepare()
49 * not to bail-out on intermittent issues where the platform is in shmem_tx_prepare()
52 * Note that after a timeout is detected we bail-out and carry on but in shmem_tx_prepare()
57 stop = ktime_add_ms(ktime_get(), 2 * cinfo->rx_timeout_ms); in shmem_tx_prepare()
58 spin_until_cond((ioread32(&shmem->channel_status) & in shmem_tx_prepare()
61 if (!(ioread32(&shmem->channel_status) & in shmem_tx_prepare()
64 dev_err(cinfo->dev, in shmem_tx_prepare()
70 iowrite32(0x0, &shmem->channel_status); in shmem_tx_prepare()
71 iowrite32(xfer->hdr.poll_completion ? 0 : SCMI_SHMEM_FLAG_INTR_ENABLED, in shmem_tx_prepare()
72 &shmem->flags); in shmem_tx_prepare()
73 iowrite32(sizeof(shmem->msg_header) + xfer->tx.len, &shmem->length); in shmem_tx_prepare()
74 iowrite32(pack_scmi_header(&xfer->hdr), &shmem->msg_header); in shmem_tx_prepare()
75 if (xfer->tx.buf) in shmem_tx_prepare()
76 memcpy_toio(shmem->msg_payload, xfer->tx.buf, xfer->tx.len); in shmem_tx_prepare()
81 return ioread32(&shmem->msg_header); in shmem_read_header()
87 size_t len = ioread32(&shmem->length); in shmem_fetch_response()
89 xfer->hdr.status = ioread32(shmem->msg_payload); in shmem_fetch_response()
91 xfer->rx.len = min_t(size_t, xfer->rx.len, len > 8 ? len - 8 : 0); in shmem_fetch_response()
93 /* Take a copy to the rx buffer.. */ in shmem_fetch_response()
94 memcpy_fromio(xfer->rx.buf, shmem->msg_payload + 4, xfer->rx.len); in shmem_fetch_response()
100 size_t len = ioread32(&shmem->length); in shmem_fetch_notification()
103 xfer->rx.len = min_t(size_t, max_len, len > 4 ? len - 4 : 0); in shmem_fetch_notification()
105 /* Take a copy to the rx buffer.. */ in shmem_fetch_notification()
106 memcpy_fromio(xfer->rx.buf, shmem->msg_payload, xfer->rx.len); in shmem_fetch_notification()
111 iowrite32(SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE, &shmem->channel_status); in shmem_clear_channel()
119 xfer_id = MSG_XTRACT_TOKEN(ioread32(&shmem->msg_header)); in shmem_poll_done()
121 if (xfer->hdr.seq != xfer_id) in shmem_poll_done()
124 return ioread32(&shmem->channel_status) & in shmem_poll_done()
131 return (ioread32(&shmem->channel_status) & in shmem_channel_free()
137 return ioread32(&shmem->flags) & SCMI_SHMEM_FLAG_INTR_ENABLED; in shmem_channel_intr_enabled()
145 const char *desc = tx ? "Tx" : "Rx"; in shmem_setup_iomap()
147 struct device *cdev = cinfo->dev; in shmem_setup_iomap()
152 shmem = of_parse_phandle(cdev->of_node, "shmem", idx); in shmem_setup_iomap()
154 return IOMEM_ERR_PTR(-ENODEV); in shmem_setup_iomap()
156 if (!of_device_is_compatible(shmem, "arm,scmi-shmem")) in shmem_setup_iomap()
157 return IOMEM_ERR_PTR(-ENXIO); in shmem_setup_iomap()
159 /* Use a local on-stack as a working area when not provided */ in shmem_setup_iomap()
165 dev_err(cdev, "failed to get SCMI %s shared memory\n", desc); in shmem_setup_iomap()
170 addr = devm_ioremap(dev, res->start, size); in shmem_setup_iomap()
172 dev_err(dev, "failed to ioremap SCMI %s shared memory\n", desc); in shmem_setup_iomap()
173 return IOMEM_ERR_PTR(-EADDRNOTAVAIL); in shmem_setup_iomap()