diff options
author | Chee Hong Ang <chee.hong.ang@intel.com> | 2020-08-12 09:56:21 +0800 |
---|---|---|
committer | Ley Foon Tan <ley.foon.tan@intel.com> | 2020-10-09 17:53:13 +0800 |
commit | e3fca5072bf78f7fd7eeab027d6e83bb555def9e (patch) | |
tree | 6d4fe600818999794d082e136ebdc7eba47828f5 /arch | |
parent | e2afbee50c5042fdbca78e2a6f86d9442af68783 (diff) | |
download | u-boot-e3fca5072bf78f7fd7eeab027d6e83bb555def9e.zip u-boot-e3fca5072bf78f7fd7eeab027d6e83bb555def9e.tar.gz u-boot-e3fca5072bf78f7fd7eeab027d6e83bb555def9e.tar.bz2 |
arm: socfpga: mailbox: Refactor mailbox timeout event handling
Add miliseconds delay when waiting for mailbox event to happen
before timeout. This will ensure the timeout duration is predictive.
Signed-off-by: Chee Hong Ang <chee.hong.ang@intel.com>
Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-socfpga/mailbox_s10.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c index f30e7f8..729d9b0 100644 --- a/arch/arm/mach-socfpga/mailbox_s10.c +++ b/arch/arm/mach-socfpga/mailbox_s10.c @@ -29,13 +29,14 @@ DECLARE_GLOBAL_DATA_PTR; static __always_inline int mbox_polling_resp(u32 rout) { u32 rin; - unsigned long i = ~0; + unsigned long i = 2000; while (i) { rin = MBOX_READL(MBOX_RIN); if (rout != rin) return 0; + udelay(1000); i--; } @@ -176,11 +177,15 @@ static __always_inline int mbox_send_cmd_common(u8 id, u32 cmd, u8 is_indirect, MBOX_WRITEL(1, MBOX_DOORBELL_TO_SDM); while (1) { - ret = ~0; + ret = 1000; /* Wait for doorbell from SDM */ - while (!MBOX_READL(MBOX_DOORBELL_FROM_SDM) && ret--) - ; + do { + if (MBOX_READL(MBOX_DOORBELL_FROM_SDM)) + break; + udelay(1000); + } while (--ret); + if (!ret) return -ETIMEDOUT; |