summaryrefslogtreecommitdiff
path: root/plat/imx/common
diff options
context:
space:
mode:
authorRobin Gong <yibin.gong@nxp.com>2017-10-27 10:13:46 +0800
committerAbel Vesa <abel.vesa@nxp.com>2018-06-11 10:08:40 +0300
commitf62d4ae081d935ac0c77534b28445b0db157d041 (patch)
treee76d1b07d95353561696d231c4c4e2af29ec31d1 /plat/imx/common
parent905204763cb18b899b261fe893dd6e889e0fcb8d (diff)
imx8qm/qxp: add watchdog sip interfaces
To support virtual watchdog driver in Linux, add those watchdog functions to call scfw interface in ATF. Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Diffstat (limited to 'plat/imx/common')
-rw-r--r--plat/imx/common/include/fsl_sip.h5
-rw-r--r--plat/imx/common/sci/svc/timer/timer_rpc_clnt.c87
-rw-r--r--plat/imx/common/srtc.c29
3 files changed, 120 insertions, 1 deletions
diff --git a/plat/imx/common/include/fsl_sip.h b/plat/imx/common/include/fsl_sip.h
index c4d3f955..e118928a 100644
--- a/plat/imx/common/include/fsl_sip.h
+++ b/plat/imx/common/include/fsl_sip.h
@@ -18,6 +18,11 @@
#define FSL_SIP_SRTC 0xC2000002
#define FSL_SIP_SRTC_SET_TIME 0x00
+#define FSL_SIP_SRTC_START_WDOG 0x01
+#define FSL_SIP_SRTC_STOP_WDOG 0x02
+#define FSL_SIP_SRTC_SET_WDOG_ACT 0x03
+#define FSL_SIP_SRTC_PING_WDOG 0x04
+#define FSL_SIP_SRTC_SET_TIMEOUT_WDOG 0x05
#define FSL_SIP_BUILDINFO 0xC2000003
#define FSL_SIP_BUILDINFO_GET_COMMITHASH 0x00
diff --git a/plat/imx/common/sci/svc/timer/timer_rpc_clnt.c b/plat/imx/common/sci/svc/timer/timer_rpc_clnt.c
index 7aeb0e47..9543eab3 100644
--- a/plat/imx/common/sci/svc/timer/timer_rpc_clnt.c
+++ b/plat/imx/common/sci/svc/timer/timer_rpc_clnt.c
@@ -48,7 +48,8 @@
/* Local Defines */
/* Local Types */
-
+typedef uint8_t sc_timer_wdog_action_t;
+typedef uint32_t sc_timer_wdog_time_t;
/* Local Functions */
sc_err_t sc_timer_set_rtc_time(sc_ipc_t ipc, uint16_t year, uint8_t mon,
@@ -147,4 +148,88 @@ sc_err_t sc_timer_set_rtc_alarm(sc_ipc_t ipc, uint16_t year, uint8_t mon,
return (sc_err_t)result;
}
+sc_err_t sc_timer_start_wdog(sc_ipc_t ipc, bool lock)
+{
+ sc_rpc_msg_t msg;
+ uint8_t result;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = SC_RPC_SVC_TIMER;
+ RPC_FUNC(&msg) = TIMER_FUNC_START_WDOG;
+ RPC_U8(&msg, 0) = lock;
+ RPC_SIZE(&msg) = 2;
+
+ sc_call_rpc(ipc, &msg, false);
+
+ result = RPC_R8(&msg);
+ return (sc_err_t)result;
+}
+
+sc_err_t sc_timer_stop_wdog(sc_ipc_t ipc)
+{
+ sc_rpc_msg_t msg;
+ uint8_t result;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = SC_RPC_SVC_TIMER;
+ RPC_FUNC(&msg) = TIMER_FUNC_STOP_WDOG;
+ RPC_SIZE(&msg) = 1;
+
+ sc_call_rpc(ipc, &msg, false);
+
+ result = RPC_R8(&msg);
+ return (sc_err_t)result;
+}
+
+sc_err_t sc_timer_set_wdog_action(sc_ipc_t ipc,
+ sc_rm_pt_t pt, sc_timer_wdog_action_t action)
+{
+ sc_rpc_msg_t msg;
+ uint8_t result;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = SC_RPC_SVC_TIMER;
+ RPC_FUNC(&msg) = TIMER_FUNC_SET_WDOG_ACTION;
+ RPC_U8(&msg, 0) = pt;
+ RPC_U8(&msg, 1) = action;
+ RPC_SIZE(&msg) = 2;
+
+ sc_call_rpc(ipc, &msg, false);
+
+ result = RPC_R8(&msg);
+ return (sc_err_t)result;
+}
+
+sc_err_t sc_timer_set_wdog_timeout(sc_ipc_t ipc, sc_timer_wdog_time_t timeout)
+{
+ sc_rpc_msg_t msg;
+ uint8_t result;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = SC_RPC_SVC_TIMER;
+ RPC_FUNC(&msg) = TIMER_FUNC_SET_WDOG_TIMEOUT;
+ RPC_U32(&msg, 0) = timeout;
+ RPC_SIZE(&msg) = 2;
+
+ sc_call_rpc(ipc, &msg, false);
+
+ result = RPC_R8(&msg);
+ return (sc_err_t)result;
+}
+
+sc_err_t sc_timer_ping_wdog(sc_ipc_t ipc)
+{
+ sc_rpc_msg_t msg;
+ uint8_t result;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = SC_RPC_SVC_TIMER;
+ RPC_FUNC(&msg) = TIMER_FUNC_PING_WDOG;
+ RPC_SIZE(&msg) = 1;
+
+ sc_call_rpc(ipc, &msg, false);
+
+ result = RPC_R8(&msg);
+ return (sc_err_t)result;
+}
/**@}*/
diff --git a/plat/imx/common/srtc.c b/plat/imx/common/srtc.c
index 0a32d65b..56b32a92 100644
--- a/plat/imx/common/srtc.c
+++ b/plat/imx/common/srtc.c
@@ -48,6 +48,20 @@ static int imx_srtc_set_time(uint32_t year_mon, unsigned long day_hour, unsigned
min_sec >> 16, min_sec & 0xffff);
}
+static int imx_srtc_set_wdog_action(uint32_t x2)
+{
+ sc_rm_pt_t secure_part;
+ sc_err_t err;
+
+ err = sc_rm_get_partition(ipc_handle, &secure_part);
+ if (err)
+ return err;
+
+ err = sc_timer_set_wdog_action(ipc_handle, secure_part, x2);
+
+ return err;
+}
+
int imx_srtc_handler(uint32_t smc_fid,
u_register_t x1,
u_register_t x2,
@@ -60,6 +74,21 @@ int imx_srtc_handler(uint32_t smc_fid,
case FSL_SIP_SRTC_SET_TIME:
ret = imx_srtc_set_time(x2, x3, x4);
break;
+ case FSL_SIP_SRTC_START_WDOG:
+ ret = sc_timer_start_wdog(ipc_handle, !!x2);
+ break;
+ case FSL_SIP_SRTC_STOP_WDOG:
+ ret = sc_timer_stop_wdog(ipc_handle);
+ break;
+ case FSL_SIP_SRTC_SET_WDOG_ACT:
+ ret = imx_srtc_set_wdog_action(x2);
+ break;
+ case FSL_SIP_SRTC_PING_WDOG:
+ ret = sc_timer_ping_wdog(ipc_handle);
+ break;
+ case FSL_SIP_SRTC_SET_TIMEOUT_WDOG:
+ ret = sc_timer_set_wdog_timeout(ipc_handle, x2);
+ break;
default:
return SMC_UNK;
}