summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLey Foon Tan <ley.foon.tan@intel.com>2020-05-20 14:50:25 +0800
committerLey Foon Tan <ley.foon.tan@intel.com>2020-06-02 15:35:02 +0800
commit3ee17dbfbdf253ce50d5ddfaf5485c7b65683baa (patch)
tree1c8430cc5bba601d6d69308bf4b5245c5203b3ee
parente8c7888a116eaa37ca9ddbb75e8641c785134fcc (diff)
downloadu-boot-socfpga-rel_socfpga_v2017.09_20.06.02_rc1.tar.gz
[Backport from v2019.10 commit ID 9e299b430b10] Resend mailbox command for 3 times with 2ms interval in between if it receives MBOX_RESP_TIMEOUT and MBOX_RESP_DEVICE_BUSY response code. Add a wrapper function __mbox_send_cmd_retry() for retry, change all the callers to use this wrapper function. Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
-rw-r--r--arch/arm/mach-socfpga/mailbox_s10.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c
index 5be15bc9f7..c57cb39b85 100644
--- a/arch/arm/mach-socfpga/mailbox_s10.c
+++ b/arch/arm/mach-socfpga/mailbox_s10.c
@@ -309,6 +309,25 @@ static __always_inline int __mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect,
return -EIO;
}
+static __always_inline int __mbox_send_cmd_retry(u8 id, u32 cmd, u8 is_indirect,
+ u32 len, u32 *arg, u8 urgent,
+ u32 *resp_buf_len, u32 *resp_buf)
+{
+ int ret;
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ ret = __mbox_send_cmd(id, cmd, is_indirect, len, arg,
+ urgent, resp_buf_len, resp_buf);
+ if (ret == MBOX_RESP_TIMEOUT || ret == MBOX_RESP_DEVICE_BUSY)
+ __udelay(2000); /* wait for 2ms before resend */
+ else
+ break;
+ }
+
+ return ret;
+}
+
int mbox_init(void)
{
static const struct socfpga_mailbox *mbox_base =
@@ -415,7 +434,7 @@ static __always_inline int __mbox_get_fpga_config_status(u32 cmd)
int ret;
reconfig_status_resp_len = RECONFIG_STATUS_RESPONSE_LEN;
- ret = __mbox_send_cmd(MBOX_ID_UBOOT, cmd,
+ ret = __mbox_send_cmd_retry(MBOX_ID_UBOOT, cmd,
MBOX_CMD_DIRECT, 0, NULL, 0,
&reconfig_status_resp_len,
reconfig_status_resp);
@@ -448,7 +467,7 @@ static __always_inline int __mbox_get_fpga_config_status(u32 cmd)
int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
u8 urgent, u32 *resp_buf_len, u32 *resp_buf)
{
- return __mbox_send_cmd(id, cmd, is_indirect, len, arg, urgent,
+ return __mbox_send_cmd_retry(id, cmd, is_indirect, len, arg, urgent,
resp_buf_len, resp_buf);
}
@@ -456,7 +475,7 @@ int __secure mbox_send_cmd_psci(u8 id, u32 cmd, u8 is_indirect, u32 len,
u32 *arg, u8 urgent, u32 *resp_buf_len,
u32 *resp_buf)
{
- return __mbox_send_cmd(id, cmd, is_indirect, len, arg, urgent,
+ return __mbox_send_cmd_retry(id, cmd, is_indirect, len, arg, urgent,
resp_buf_len, resp_buf);
}