summaryrefslogtreecommitdiff
path: root/drivers/soc/imx
diff options
context:
space:
mode:
authorRichard Zhu <hongxing.zhu@nxp.com>2018-09-14 16:29:58 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:34:04 +0800
commit859ec31b3a7cfefab190ab0047dee6084ddf4ef2 (patch)
treee95191157309726be98e5c8e7d41b3732ad0418c /drivers/soc/imx
parent6038fc9d37645c45046ed6787a197fa7f5b2f6d6 (diff)
MLK-19588-1 imx: rpmsg: use timeout for MU_SendMessage function
- Add the timeout mu msg send api. - Use the timeout mu send message function to do the notification when multi-vdev is enabled on one channel. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
Diffstat (limited to 'drivers/soc/imx')
-rw-r--r--drivers/soc/imx/mu/mx8_mu.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/soc/imx/mu/mx8_mu.c b/drivers/soc/imx/mu/mx8_mu.c
index 30c7fd888cb4..2cd6dc880bbe 100644
--- a/drivers/soc/imx/mu/mx8_mu.c
+++ b/drivers/soc/imx/mu/mx8_mu.c
@@ -5,6 +5,7 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/mx8_mu.h>
@@ -103,6 +104,36 @@ void MU_SendMessage(void __iomem *base, uint32_t regIndex, uint32_t msg)
}
}
+/*
+ * Wait and send message to the other core with timeout mechanism.
+ */
+void MU_SendMessageTimeout(void __iomem *base, uint32_t regIndex, uint32_t msg,
+ uint32_t t)
+{
+ uint32_t mask = MU_SR_TE0_MASK1 >> regIndex;
+ uint32_t timeout = t;
+
+ if (unlikely(version == MU_VER_ID_V10)) {
+ /* Wait TX register to be empty. */
+ while (!(readl_relaxed(base + MU_V10_ASR_OFFSET1) & mask)) {
+ udelay(10);
+ if (timeout-- == 0)
+ return;
+ };
+
+ writel_relaxed(msg, base + MU_V10_ATR0_OFFSET1
+ + (regIndex * 4));
+ } else {
+ /* Wait TX register to be empty. */
+ while (!(readl_relaxed(base + MU_ASR_OFFSET1) & mask)) {
+ udelay(10);
+ if (timeout-- == 0)
+ return;
+ };
+
+ writel_relaxed(msg, base + MU_ATR0_OFFSET1 + (regIndex * 4));
+ }
+}
/*
* Wait to receive message from the other core.