forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/firmware/arm_scmi/shmem.c
....@@ -26,7 +26,7 @@
2626 #define SCMI_SHMEM_FLAG_INTR_ENABLED BIT(0)
2727 __le32 length;
2828 __le32 msg_header;
29
- u8 msg_payload[0];
29
+ u8 msg_payload[];
3030 };
3131
3232 void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem,
....@@ -67,6 +67,21 @@
6767 memcpy_fromio(xfer->rx.buf, shmem->msg_payload + 4, xfer->rx.len);
6868 }
6969
70
+void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
71
+ size_t max_len, struct scmi_xfer *xfer)
72
+{
73
+ /* Skip only the length of header in shmem area i.e 4 bytes */
74
+ xfer->rx.len = min_t(size_t, max_len, ioread32(&shmem->length) - 4);
75
+
76
+ /* Take a copy to the rx buffer.. */
77
+ memcpy_fromio(xfer->rx.buf, shmem->msg_payload, xfer->rx.len);
78
+}
79
+
80
+void shmem_clear_channel(struct scmi_shared_mem __iomem *shmem)
81
+{
82
+ iowrite32(SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE, &shmem->channel_status);
83
+}
84
+
7085 bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
7186 struct scmi_xfer *xfer)
7287 {