From f51ede86dd51c014dd2fdc93143508a7c39cb513 Mon Sep 17 00:00:00 2001 From: orenbh Date: Wed, 19 Apr 2017 09:06:52 +0300 Subject: pm: a70x0: a80x0: Add message trigger timeout Add timeout validation check after PM message interrupt trigger Change-Id: I10ae8d36ac04024960085419877b55d67661927c Signed-off-by: orenbh Reviewed-on: http://vgitil04.il.marvell.com:8080/38714 Reviewed-by: Kostya Porotchkin Tested-by: Kostya Porotchkin --- plat/marvell/a8k/common/mss/mss_pm_ipc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plat/marvell/a8k/common/mss/mss_pm_ipc.c b/plat/marvell/a8k/common/mss/mss_pm_ipc.c index 9d8aedac..151e839b 100644 --- a/plat/marvell/a8k/common/mss/mss_pm_ipc.c +++ b/plat/marvell/a8k/common/mss/mss_pm_ipc.c @@ -53,6 +53,8 @@ #define MSS_SISTR (MVEBU_REGS_BASE + 0x5800D8) #define MSS_MSG_INT_MASK (0x80000000) +#define MSS_TIMER_BASE (MVEBU_REGS_BASE_MASK + 0x580110) +#define MSS_TRIGGER_TIMEOUT (1000) /******************************************************************************* * mss_pm_ipc_msg_send @@ -78,12 +80,27 @@ int mss_pm_ipc_msg_send(unsigned int channel_id, unsigned int msg_id, const psci *******************************************************************************/ int mss_pm_ipc_msg_trigger(void) { + unsigned int timeout; + unsigned int t_end; + unsigned int t_start = mmio_read_32(MSS_TIMER_BASE); + mmio_write_32(MSS_SISR, MSS_MSG_INT_MASK); do { /* wait while SCP process incoming interrupt */ + if (mmio_read_32(MSS_SISTR) != MSS_MSG_INT_MASK) + break; + + /* check timeout */ + t_end = mmio_read_32(MSS_TIMER_BASE); + + timeout = ((t_start > t_end) ? (t_start - t_end) : (t_end - t_start)); + if (timeout > MSS_TRIGGER_TIMEOUT) { + ERROR("PM MSG Trigger Timeout\n"); + break; + } - } while (mmio_read_32(MSS_SISTR) == MSS_MSG_INT_MASK); + } while (1); return 0; } -- cgit