Skip to content

Commit ff1c1a7

Browse files
jamikePatrice Chotard
authored andcommitted
firmware: scmi: smt: add a polling completion method
Since u-boot does not support interrupt, implement a polling completion method on smt status with a timeout. Change-Id: I0e4ef68cb7da51975530bf1c5de7edd9bf5a6d32 Signed-off-by: Michel JAOUEN <michel.jaouen@st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/446888 Reviewed-by: Patrice CHOTARD <patrice.chotard@foss.st.com> ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com> ACI: CIBUILD <MDG-smet-aci-builds@list.st.com> Domain-Review: Patrick DELAUNAY <patrick.delaunay@foss.st.com>
1 parent ed9ef63 commit ff1c1a7

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

drivers/firmware/scmi/smt.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <dm/ofnode.h>
1818
#include <linux/compat.h>
1919
#include <linux/io.h>
20+
#include <linux/iopoll.h>
2021
#include <linux/ioport.h>
2122

2223
#include "smt.h"
@@ -129,6 +130,26 @@ int scmi_read_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,
129130
return 0;
130131
}
131132

133+
/**
134+
* Wait SCMI message from a SMT shared buffer @smt and copy it into @msg.
135+
* Return 0 on success and with a negative errno in case of error.
136+
*/
137+
int scmi_wait_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,
138+
struct scmi_msg *msg, ulong timeout_us)
139+
{
140+
struct scmi_smt_header *hdr = (void *)smt->buf;
141+
__le32 status;
142+
int ret;
143+
144+
ret = readl_poll_timeout(&hdr->channel_status, status, status &
145+
SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE,
146+
timeout_us);
147+
if (ret)
148+
return ret;
149+
150+
return scmi_read_resp_from_smt(dev, smt, msg);
151+
}
152+
132153
/**
133154
* Clear SMT flags in shared buffer to allow further message exchange
134155
*/

drivers/firmware/scmi/smt.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ int scmi_read_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,
106106

107107
void scmi_clear_smt_channel(struct scmi_smt *smt);
108108

109+
/*
110+
* Wait SCMI message from a SMT shared memory
111+
* @dev: SCMI device
112+
* @smt: Reference to shared memory using SMT header
113+
* @msg: Output SCMI message received
114+
* @timeout_us: The maximum time to wait for a message to be available, in
115+
* micro-seconds. A value of 0 does not wait at all.
116+
*/
117+
int scmi_wait_resp_from_smt(struct udevice *dev, struct scmi_smt *smt,
118+
struct scmi_msg *msg, ulong timeout_us);
119+
109120
/*
110121
* Write SCMI message to SMT_MSG shared memory
111122
* @dev: SCMI device

0 commit comments

Comments
 (0)