From b6b631e6382c3eee7622f301774ea062ff35c125 Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Mon, 13 Nov 2017 18:04:31 +0800 Subject: [PATCH] MLK-16765-1: soc: i.MX8: Update to the latest SCFW API Update since new button/wdog interface added on scfw: commit e7d95e1e306a Signed-off-by: Robin Gong Reviewed-by: Peng Fan Reviewed-by: Anson Huang --- drivers/soc/imx/sc/svc/misc/rpc.h | 2 ++ drivers/soc/imx/sc/svc/misc/rpc_clnt.c | 15 +++++++++++++++ drivers/soc/imx/sc/svc/timer/rpc.h | 1 + drivers/soc/imx/sc/svc/timer/rpc_clnt.c | 18 ++++++++++++++++++ include/soc/imx8/sc/svc/misc/api.h | 8 ++++++++ include/soc/imx8/sc/svc/timer/api.h | 16 ++++++++++++++++ 6 files changed, 60 insertions(+) diff --git a/drivers/soc/imx/sc/svc/misc/rpc.h b/drivers/soc/imx/sc/svc/misc/rpc.h index 81aad091b14a..caf0d30310fd 100644 --- a/drivers/soc/imx/sc/svc/misc/rpc.h +++ b/drivers/soc/imx/sc/svc/misc/rpc.h @@ -40,6 +40,8 @@ typedef enum misc_func_e { MISC_FUNC_OTP_FUSE_READ = 11, /* Index for misc_otp_fuse_read() RPC call */ MISC_FUNC_SET_TEMP = 12, /* Index for misc_set_temp() RPC call */ MISC_FUNC_GET_TEMP = 13, /* Index for misc_get_temp() RPC call */ + MISC_FUNC_GET_BUTTON_STATUS = 18, /* Index for misc_get_button_status() RPC call */ + } misc_func_t; /* Functions */ diff --git a/drivers/soc/imx/sc/svc/misc/rpc_clnt.c b/drivers/soc/imx/sc/svc/misc/rpc_clnt.c index 90385a6438db..e042ec681cba 100644 --- a/drivers/soc/imx/sc/svc/misc/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/misc/rpc_clnt.c @@ -296,4 +296,19 @@ sc_err_t sc_misc_get_temp(sc_ipc_t ipc, sc_rsrc_t resource, return (sc_err_t)result; } +void sc_misc_get_button_status(sc_ipc_t ipc, bool *status) +{ + sc_rpc_msg_t msg; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = SC_RPC_SVC_MISC; + RPC_FUNC(&msg) = MISC_FUNC_GET_BUTTON_STATUS; + RPC_SIZE(&msg) = 1; + + sc_call_rpc(ipc, &msg, false); + + if (status != NULL) + *status = RPC_U8(&msg, 0); +} + /**@}*/ diff --git a/drivers/soc/imx/sc/svc/timer/rpc.h b/drivers/soc/imx/sc/svc/timer/rpc.h index 234823fb2148..54e9385fdb8c 100644 --- a/drivers/soc/imx/sc/svc/timer/rpc.h +++ b/drivers/soc/imx/sc/svc/timer/rpc.h @@ -27,6 +27,7 @@ typedef enum timer_func_e { TIMER_FUNC_UNKNOWN = 0, /* Unknown function */ TIMER_FUNC_SET_WDOG_TIMEOUT = 1, /* Index for timer_set_wdog_timeout() RPC call */ + TIMER_FUNC_SET_WDOG_PRE_TIMEOUT = 12, /* Index for timer_set_wdog_pre_timeout() RPC call */ TIMER_FUNC_START_WDOG = 2, /* Index for timer_start_wdog() RPC call */ TIMER_FUNC_STOP_WDOG = 3, /* Index for timer_stop_wdog() RPC call */ TIMER_FUNC_PING_WDOG = 4, /* Index for timer_ping_wdog() RPC call */ diff --git a/drivers/soc/imx/sc/svc/timer/rpc_clnt.c b/drivers/soc/imx/sc/svc/timer/rpc_clnt.c index 93a6e1fc3512..83d2cba4105a 100644 --- a/drivers/soc/imx/sc/svc/timer/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/timer/rpc_clnt.c @@ -44,6 +44,24 @@ sc_err_t sc_timer_set_wdog_timeout(sc_ipc_t ipc, sc_timer_wdog_time_t timeout) return (sc_err_t)result; } +sc_err_t sc_timer_set_wdog_pre_timeout(sc_ipc_t ipc, + sc_timer_wdog_time_t pre_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_PRE_TIMEOUT; + RPC_U32(&msg, 0) = pre_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_start_wdog(sc_ipc_t ipc, bool lock) { sc_rpc_msg_t msg; diff --git a/include/soc/imx8/sc/svc/misc/api.h b/include/soc/imx8/sc/svc/misc/api.h index 157c9ca4973d..46d4778e4185 100644 --- a/include/soc/imx8/sc/svc/misc/api.h +++ b/include/soc/imx8/sc/svc/misc/api.h @@ -360,6 +360,14 @@ sc_err_t sc_misc_get_temp(sc_ipc_t ipc, sc_rsrc_t resource, sc_misc_temp_t temp, int16_t * celsius, int8_t * tenths); +/*! + * This function returns the current status of the ON/OFF button. + * + * @param[in] ipc IPC handle + * @param[out] status pointer to return button status + */ +void sc_misc_get_button_status(sc_ipc_t ipc, bool *status); + /* @} */ #endif /* _SC_MISC_API_H */ diff --git a/include/soc/imx8/sc/svc/timer/api.h b/include/soc/imx8/sc/svc/timer/api.h index b270379e0eb4..40d6fff34a65 100644 --- a/include/soc/imx8/sc/svc/timer/api.h +++ b/include/soc/imx8/sc/svc/timer/api.h @@ -77,6 +77,22 @@ typedef uint32_t sc_timer_wdog_time_t; */ sc_err_t sc_timer_set_wdog_timeout(sc_ipc_t ipc, sc_timer_wdog_time_t timeout); +/*! + * This function sets the watchdog pre-timeout in milliseconds. If not + * set then the pre-timeout defaults to the max. Once locked this value + * cannot be changed. + * + * @param[in] ipc IPC handle + * @param[in] pre_timeout pre-timeout period for the watchdog + * + * When the pre-timout expires an IRQ will be generated. Note this timeout + * clears when the IRQ is triggered. + * + * @return Returns an error code (SC_ERR_NONE = success). + */ +sc_err_t sc_timer_set_wdog_pre_timeout(sc_ipc_t ipc, + sc_timer_wdog_time_t pre_timeout); + /*! * This function starts the watchdog. * -- 2.17.1