diff options
author | Ranjani Vaidyanathan <Ranjani.Vaidyanathan@nxp.com> | 2018-11-02 15:51:01 -0500 |
---|---|---|
committer | Jason Liu <jason.hui.liu@nxp.com> | 2019-02-12 10:35:00 +0800 |
commit | 01d5af1e411193058a7341999855bf515ed8241c (patch) | |
tree | 83e3e4ac786ebad1ca6edf7bbf22288dbadf4362 /drivers/soc | |
parent | a73d9054a42b159e68b56b93f8834b121e82cde5 (diff) |
MLK-20222-1 soc: Update SCFW API
Update SCFW API to the following commit:
"
("430d1e3646fbe75e339e18abf2330565eac906e0")
Author: Chuck Cannon <chuck.cannon@nxp.com>
Date: Fri Nov 2 15:25:45 2018 -0500
SCF-105: RN updates.
"
Signed-off-by: Ranjani Vaidyanathan <Ranjani.Vaidyanathan@nxp.com>
Diffstat (limited to 'drivers/soc')
-rw-r--r-- | drivers/soc/imx/sc/main/ipc.c | 4 | ||||
-rw-r--r-- | drivers/soc/imx/sc/main/rpc.h | 119 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/irq/rpc.h | 32 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/irq/rpc_clnt.c | 34 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/misc/rpc.h | 80 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/misc/rpc_clnt.c | 531 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/pad/rpc.h | 60 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/pad/rpc_clnt.c | 290 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/pm/rpc.h | 70 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/pm/rpc_clnt.c | 341 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/rm/rpc.h | 91 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/rm/rpc_clnt.c | 477 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/timer/rpc.h | 59 | ||||
-rw-r--r-- | drivers/soc/imx/sc/svc/timer/rpc_clnt.c | 264 | ||||
-rw-r--r-- | drivers/soc/imx/soc-imx8.c | 1 |
15 files changed, 1463 insertions, 990 deletions
diff --git a/drivers/soc/imx/sc/main/ipc.c b/drivers/soc/imx/sc/main/ipc.c index f795b2465e8a..c070089dbfcd 100644 --- a/drivers/soc/imx/sc/main/ipc.c +++ b/drivers/soc/imx/sc/main/ipc.c @@ -54,7 +54,7 @@ EXPORT_SYMBOL(sc_pm_set_clock_rate); /*--------------------------------------------------------------------------*/ /* RPC command/response */ /*--------------------------------------------------------------------------*/ -void sc_call_rpc(sc_ipc_t handle, sc_rpc_msg_t *msg, bool no_resp) +void sc_call_rpc(sc_ipc_t handle, sc_rpc_msg_t *msg, sc_bool_t no_resp) { struct arm_smccc_res res; @@ -214,7 +214,7 @@ void sc_ipc_read(sc_ipc_t handle, void *data) * * This function will block if the outgoing buffer is full. */ -void sc_ipc_write(sc_ipc_t handle, void *data) +void sc_ipc_write(sc_ipc_t handle, const void *data) { uint32_t *base; uint8_t count = 0; diff --git a/drivers/soc/imx/sc/main/rpc.h b/drivers/soc/imx/sc/main/rpc.h index 85cff2315f65..d6bc39e3cb19 100644 --- a/drivers/soc/imx/sc/main/rpc.h +++ b/drivers/soc/imx/sc/main/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -9,8 +9,8 @@ * Header file for the RPC implementation. */ -#ifndef _SC_RPC_H -#define _SC_RPC_H +#ifndef SC_RPC_H +#define SC_RPC_H /* Includes */ @@ -19,35 +19,69 @@ /* Defines */ -#define SC_RPC_VERSION 1 - -#define SC_RPC_MAX_MSG 8 - -#define RPC_VER(MSG) ((MSG)->version) -#define RPC_SIZE(MSG) ((MSG)->size) -#define RPC_SVC(MSG) ((MSG)->svc) -#define RPC_FUNC(MSG) ((MSG)->func) -#define RPC_R8(MSG) ((MSG)->func) -#define RPC_I32(MSG, IDX) ((MSG)->DATA.i32[(IDX) / 4]) -#define RPC_I16(MSG, IDX) ((MSG)->DATA.i16[(IDX) / 2]) -#define RPC_I8(MSG, IDX) ((MSG)->DATA.i8[(IDX)]) -#define RPC_U32(MSG, IDX) ((MSG)->DATA.u32[(IDX) / 4]) -#define RPC_U16(MSG, IDX) ((MSG)->DATA.u16[(IDX) / 2]) -#define RPC_U8(MSG, IDX) ((MSG)->DATA.u8[(IDX)]) +#define SC_RPC_VERSION 1U + +#define SC_RPC_MAX_MSG 8U + +#define RPC_VER(MESG) ((MESG)->version) +#define RPC_SIZE(MESG) ((MESG)->size) +#define RPC_SVC(MESG) ((MESG)->svc) +#define RPC_FUNC(MESG) ((MESG)->func) +#define RPC_R8(MESG) ((MESG)->func) +#define RPC_I32(MESG, IDX) ((MESG)->DATA.i32[(IDX) / 4U]) +#define RPC_I16(MESG, IDX) ((MESG)->DATA.i16[(IDX) / 2U]) +#define RPC_I8(MESG, IDX) ((MESG)->DATA.i8[(IDX)]) +#define RPC_U32(MESG, IDX) ((MESG)->DATA.u32[(IDX) / 4U]) +#define RPC_U16(MESG, IDX) ((MESG)->DATA.u16[(IDX) / 2U]) +#define RPC_U8(MESG, IDX) ((MESG)->DATA.u8[(IDX)]) + +#define SC_RPC_SVC_UNKNOWN 0U +#define SC_RPC_SVC_RETURN 1U +#define SC_RPC_SVC_PM 2U +#define SC_RPC_SVC_RM 3U +#define SC_RPC_SVC_TIMER 5U +#define SC_RPC_SVC_PAD 6U +#define SC_RPC_SVC_MISC 7U +#define SC_RPC_SVC_IRQ 8U +#define SC_RPC_SVC_ABORT 9U + +#define SC_RPC_ASYNC_STATE_RD_START 0U +#define SC_RPC_ASYNC_STATE_RD_ACTIVE 1U +#define SC_RPC_ASYNC_STATE_RD_DONE 2U +#define SC_RPC_ASYNC_STATE_WR_START 3U +#define SC_RPC_ASYNC_STATE_WR_ACTIVE 4U +#define SC_RPC_ASYNC_STATE_WR_DONE 5U + +#define SC_RPC_MU_GIR_SVC 0x1U +#define SC_RPC_MU_GIR_DBG 0x8U + +#define I8(X) ((int8_t) (X)) +#define I16(X) ((int16_t) (X)) +#define I32(X) ((int32_t) (X)) +#define I64(X) ((int64_t) (X)) +#define U8(X) ((uint8_t) (X)) +#define U16(X) ((uint16_t) (X)) +#define U32(X) ((uint32_t) (X)) +#define U64(X) ((uint64_t) (X)) + +#define PTR_I8(X) ((int8_t *) (X)) +#define PTR_I16(X) ((int16_t *) (X)) +#define PTR_I32(X) ((int32_t *) (X)) +#define PTR_I64(X) ((int64_t *) (X)) +#define PTR_U8(X) ((uint8_t *) (X)) +#define PTR_U16(X) ((uint16_t *) (X)) +#define PTR_U32(X) ((uint32_t *) (X)) +#define PTR_U64(X) ((uint64_t *) (X)) + +#define U2B(X) (((X) != 0U) ? SC_TRUE : SC_FALSE) +#define U2B32(X) (((X) != 0UL) ? SC_TRUE : SC_FALSE) +#define B2U8(X) (((X) != SC_FALSE) ? U8(0x01U) : U8(0x00U)) +#define B2U16(X) (((X) != SC_FALSE) ? U16(0x01U) : U16(0x00U)) +#define B2U32(X) (((X) != SC_FALSE) ? U32(0x01U) : U32(0x00U)) /* Types */ -typedef enum sc_rpc_svc_e { - SC_RPC_SVC_UNKNOWN = 0, - SC_RPC_SVC_RETURN = 1, - SC_RPC_SVC_PM = 2, - SC_RPC_SVC_RM = 3, - SC_RPC_SVC_TIMER = 5, - SC_RPC_SVC_PAD = 6, - SC_RPC_SVC_MISC = 7, - SC_RPC_SVC_IRQ = 8, - SC_RPC_SVC_ABORT = 9 -} sc_rpc_svc_t; +typedef uint8_t sc_rpc_svc_t; typedef struct sc_rpc_msg_s { uint8_t version; @@ -55,23 +89,16 @@ typedef struct sc_rpc_msg_s { uint8_t svc; uint8_t func; union { - int32_t i32[(SC_RPC_MAX_MSG - 1)]; - int16_t i16[(SC_RPC_MAX_MSG - 1) * 2]; - int8_t i8[(SC_RPC_MAX_MSG - 1) * 4]; - uint32_t u32[(SC_RPC_MAX_MSG - 1)]; - uint16_t u16[(SC_RPC_MAX_MSG - 1) * 2]; - uint8_t u8[(SC_RPC_MAX_MSG - 1) * 4]; + int32_t i32[(SC_RPC_MAX_MSG - 1U)]; + int16_t i16[(SC_RPC_MAX_MSG - 1U) * 2U]; + int8_t i8[(SC_RPC_MAX_MSG - 1U) * 4U]; + uint32_t u32[(SC_RPC_MAX_MSG - 1U)]; + uint16_t u16[(SC_RPC_MAX_MSG - 1U) * 2U]; + uint8_t u8[(SC_RPC_MAX_MSG - 1U) * 4U]; } DATA; } sc_rpc_msg_t; -typedef enum sc_rpc_async_state_e { - SC_RPC_ASYNC_STATE_RD_START = 0, - SC_RPC_ASYNC_STATE_RD_ACTIVE = 1, - SC_RPC_ASYNC_STATE_RD_DONE = 2, - SC_RPC_ASYNC_STATE_WR_START = 3, - SC_RPC_ASYNC_STATE_WR_ACTIVE = 4, - SC_RPC_ASYNC_STATE_WR_DONE = 5, -} sc_rpc_async_state_t; +typedef uint8_t sc_rpc_async_state_t; typedef struct sc_rpc_async_msg_s { sc_rpc_async_state_t state; @@ -90,10 +117,10 @@ typedef struct sc_rpc_async_msg_s { * @param[in,out] msg handle to a message * @param[in] no_resp response flag * - * If \a no_resp is false then this function waits for a response + * If \a no_resp is SC_FALSE then this function waits for a response * and returns the result in \a msg. */ -void sc_call_rpc(sc_ipc_t ipc, sc_rpc_msg_t *msg, bool no_resp); +void sc_call_rpc(sc_ipc_t ipc, sc_rpc_msg_t *msg, sc_bool_t no_resp); /*! * This is an internal function to dispath an RPC call that has @@ -121,4 +148,4 @@ void sc_rpc_dispatch(sc_rsrc_t mu, sc_rpc_msg_t *msg); */ void sc_rpc_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); -#endif /* _SC_RPC_H */ +#endif /* SC_RPC_H */ diff --git a/drivers/soc/imx/sc/svc/irq/rpc.h b/drivers/soc/imx/sc/svc/irq/rpc.h index 93ce7c3b87a3..216659d0bcba 100644 --- a/drivers/soc/imx/sc/svc/irq/rpc.h +++ b/drivers/soc/imx/sc/svc/irq/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -12,23 +12,23 @@ * @{ */ -#ifndef _SC_IRQ_RPC_H -#define _SC_IRQ_RPC_H +#ifndef SC_IRQ_RPC_H +#define SC_IRQ_RPC_H /* Includes */ /* Defines */ -/* Types */ - /*! - * This type is used to indicate RPC IRQ function calls. + * @name Defines for RPC IRQ function calls */ -typedef enum irq_func_e { - IRQ_FUNC_UNKNOWN = 0, /* Unknown function */ - IRQ_FUNC_ENABLE = 1, /* Index for irq_enable() RPC call */ - IRQ_FUNC_STATUS = 2, /* Index for irq_status() RPC call */ -} irq_func_t; +/*@{*/ +#define IRQ_FUNC_UNKNOWN 0 /* Unknown function */ +#define IRQ_FUNC_ENABLE 1U /* Index for irq_enable() RPC call */ +#define IRQ_FUNC_STATUS 2U /* Index for irq_status() RPC call */ +/*@}*/ + +/* Types */ /* Functions */ @@ -40,14 +40,6 @@ typedef enum irq_func_e { */ void irq_dispatch(sc_rm_pt_t caller_pt, sc_rpc_msg_t *msg); -/*! - * This function translates and dispatches an IRQ RPC request. - * - * @param[in] ipc IPC handle - * @param[in] msg pointer to RPC message - */ -void irq_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); - -#endif /* _SC_IRQ_RPC_H */ +#endif /* SC_IRQ_RPC_H */ /**@}*/ diff --git a/drivers/soc/imx/sc/svc/irq/rpc_clnt.c b/drivers/soc/imx/sc/svc/irq/rpc_clnt.c index 779be383aea3..881e19a8c19f 100644 --- a/drivers/soc/imx/sc/svc/irq/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/irq/rpc_clnt.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -28,21 +28,21 @@ /* Local Functions */ sc_err_t sc_irq_enable(sc_ipc_t ipc, sc_rsrc_t resource, - sc_irq_group_t group, uint32_t mask, bool enable) + sc_irq_group_t group, uint32_t mask, sc_bool_t enable) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_IRQ; - RPC_FUNC(&msg) = (uint8_t)IRQ_FUNC_ENABLE; - RPC_U32(&msg, 0) = mask; - RPC_U16(&msg, 4) = resource; - RPC_U8(&msg, 6) = group; - RPC_U8(&msg, 7) = (uint8_t)enable; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_IRQ); + RPC_FUNC(&msg) = U8(IRQ_FUNC_ENABLE); + RPC_U32(&msg, 0U) = U32(mask); + RPC_U16(&msg, 4U) = U16(resource); + RPC_U8(&msg, 6U) = U8(group); + RPC_U8(&msg, 7U) = B2U8(enable); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -55,16 +55,16 @@ sc_err_t sc_irq_status(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_IRQ; - RPC_FUNC(&msg) = (uint8_t)IRQ_FUNC_STATUS; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = group; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_IRQ); + RPC_FUNC(&msg) = U8(IRQ_FUNC_STATUS); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(group); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (status != NULL) { - *status = RPC_U32(&msg, 0); + *status = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); diff --git a/drivers/soc/imx/sc/svc/misc/rpc.h b/drivers/soc/imx/sc/svc/misc/rpc.h index 087b6b9f6dea..df0604fe4ae5 100644 --- a/drivers/soc/imx/sc/svc/misc/rpc.h +++ b/drivers/soc/imx/sc/svc/misc/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -12,40 +12,54 @@ * @{ */ -#ifndef _SC_MISC_RPC_H -#define _SC_MISC_RPC_H +#ifndef SC_MISC_RPC_H +#define SC_MISC_RPC_H /* Includes */ /* Defines */ -/* Types */ - /*! - * This type is used to indicate RPC MISC function calls. + * @name Defines for RPC MISC function calls */ -typedef enum misc_func_e { - MISC_FUNC_UNKNOWN = 0, /* Unknown function */ - MISC_FUNC_SET_CONTROL = 1, /* Index for misc_set_control() RPC call */ - MISC_FUNC_GET_CONTROL = 2, /* Index for misc_get_control() RPC call */ - MISC_FUNC_SET_MAX_DMA_GROUP = 4, /* Index for misc_set_max_dma_group() RPC call */ - MISC_FUNC_SET_DMA_GROUP = 5, /* Index for misc_set_dma_group() RPC call */ - MISC_FUNC_SECO_IMAGE_LOAD = 8, /* Index for misc_seco_image_load() RPC call */ - MISC_FUNC_SECO_AUTHENTICATE = 9, /* Index for misc_seco_authenticate() RPC call */ - MISC_FUNC_DEBUG_OUT = 10, /* Index for misc_debug_out() RPC call */ - MISC_FUNC_WAVEFORM_CAPTURE = 6, /* Index for misc_waveform_capture() RPC call */ - MISC_FUNC_BUILD_INFO = 15, /* Index for misc_build_info() RPC call */ - MISC_FUNC_UNIQUE_ID = 19, /* Index for misc_unique_id() RPC call */ - MISC_FUNC_SET_ARI = 3, /* Index for misc_set_ari() RPC call */ - MISC_FUNC_BOOT_STATUS = 7, /* Index for misc_boot_status() RPC call */ - MISC_FUNC_BOOT_DONE = 14, /* Index for misc_boot_done() RPC call */ - MISC_FUNC_OTP_FUSE_READ = 11, /* Index for misc_otp_fuse_read() RPC call */ - MISC_FUNC_OTP_FUSE_WRITE = 17, /* Index for misc_otp_fuse_write() 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_BOOT_DEV = 16, /* Index for misc_get_boot_dev() RPC call */ - MISC_FUNC_GET_BUTTON_STATUS = 18, /* Index for misc_get_button_status() RPC call */ -} misc_func_t; +/*@{*/ +#define MISC_FUNC_UNKNOWN 0 /* Unknown function */ +#define MISC_FUNC_SET_CONTROL 1U /* Index for misc_set_control() RPC call */ +#define MISC_FUNC_GET_CONTROL 2U /* Index for misc_get_control() RPC call */ +#define MISC_FUNC_SET_MAX_DMA_GROUP 4U /* Index for misc_set_max_dma_group() RPC call */ +#define MISC_FUNC_SET_DMA_GROUP 5U /* Index for misc_set_dma_group() RPC call */ +#define MISC_FUNC_SECO_IMAGE_LOAD 8U /* Index for misc_seco_image_load() RPC call */ +#define MISC_FUNC_SECO_AUTHENTICATE 9U /* Index for misc_seco_authenticate() RPC call */ +#define MISC_FUNC_SECO_FUSE_WRITE 20U /* Index for misc_seco_fuse_write() RPC call */ +#define MISC_FUNC_SECO_ENABLE_DEBUG 21U /* Index for misc_seco_enable_debug() RPC call */ +#define MISC_FUNC_SECO_FORWARD_LIFECYCLE 22U /* Index for misc_seco_forward_lifecycle() RPC call */ +#define MISC_FUNC_SECO_RETURN_LIFECYCLE 23U /* Index for misc_seco_return_lifecycle() RPC call */ +#define MISC_FUNC_SECO_BUILD_INFO 24U /* Index for misc_seco_build_info() RPC call */ +#define MISC_FUNC_SECO_CHIP_INFO 25U /* Index for misc_seco_chip_info() RPC call */ +#define MISC_FUNC_SECO_ATTEST_MODE 27U /* Index for misc_seco_attest_mode() RPC call */ +#define MISC_FUNC_SECO_ATTEST 28U /* Index for misc_seco_attest() RPC call */ +#define MISC_FUNC_SECO_GET_ATTEST_PKEY 31U /* Index for misc_seco_get_attest_pkey() RPC call */ +#define MISC_FUNC_SECO_GET_ATTEST_SIGN 29U /* Index for misc_seco_get_attest_sign() RPC call */ +#define MISC_FUNC_SECO_ATTEST_VERIFY 30U /* Index for misc_seco_attest_verify() RPC call */ +#define MISC_FUNC_SECO_COMMIT 32U /* Index for misc_seco_commit() RPC call */ +#define MISC_FUNC_DEBUG_OUT 10U /* Index for misc_debug_out() RPC call */ +#define MISC_FUNC_WAVEFORM_CAPTURE 6U /* Index for misc_waveform_capture() RPC call */ +#define MISC_FUNC_BUILD_INFO 15U /* Index for misc_build_info() RPC call */ +#define MISC_FUNC_UNIQUE_ID 19U /* Index for misc_unique_id() RPC call */ +#define MISC_FUNC_SET_ARI 3U /* Index for misc_set_ari() RPC call */ +#define MISC_FUNC_BOOT_STATUS 7U /* Index for misc_boot_status() RPC call */ +#define MISC_FUNC_BOOT_DONE 14U /* Index for misc_boot_done() RPC call */ +#define MISC_FUNC_OTP_FUSE_READ 11U /* Index for misc_otp_fuse_read() RPC call */ +#define MISC_FUNC_OTP_FUSE_WRITE 17U /* Index for misc_otp_fuse_write() RPC call */ +#define MISC_FUNC_SET_TEMP 12U /* Index for misc_set_temp() RPC call */ +#define MISC_FUNC_GET_TEMP 13U /* Index for misc_get_temp() RPC call */ +#define MISC_FUNC_GET_BOOT_DEV 16U /* Index for misc_get_boot_dev() RPC call */ +#define MISC_FUNC_GET_BOOT_TYPE 33U /* Index for misc_get_boot_type() RPC call */ +#define MISC_FUNC_GET_BUTTON_STATUS 18U /* Index for misc_get_button_status() RPC call */ +#define MISC_FUNC_ROMPATCH_CHECKSUM 26U /* Index for misc_rompatch_checksum() RPC call */ +/*@}*/ + +/* Types */ /* Functions */ @@ -57,14 +71,6 @@ typedef enum misc_func_e { */ void misc_dispatch(sc_rm_pt_t caller_pt, sc_rpc_msg_t *msg); -/*! - * This function translates and dispatches an MISC RPC request. - * - * @param[in] ipc IPC handle - * @param[in] msg pointer to RPC message - */ -void misc_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); - -#endif /* _SC_MISC_RPC_H */ +#endif /* SC_MISC_RPC_H */ /**@}*/ diff --git a/drivers/soc/imx/sc/svc/misc/rpc_clnt.c b/drivers/soc/imx/sc/svc/misc/rpc_clnt.c index e1f588c52b5c..ab36e879bd8b 100644 --- a/drivers/soc/imx/sc/svc/misc/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/misc/rpc_clnt.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -34,14 +34,14 @@ sc_err_t sc_misc_set_control(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SET_CONTROL; - RPC_U32(&msg, 0) = ctrl; - RPC_U32(&msg, 4) = val; - RPC_U16(&msg, 8) = resource; - RPC_SIZE(&msg) = 4; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SET_CONTROL); + RPC_U32(&msg, 0U) = U32(ctrl); + RPC_U32(&msg, 4U) = U32(val); + RPC_U16(&msg, 8U) = U16(resource); + RPC_SIZE(&msg) = 4U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -54,16 +54,16 @@ sc_err_t sc_misc_get_control(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_GET_CONTROL; - RPC_U32(&msg, 0) = ctrl; - RPC_U16(&msg, 4) = resource; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_GET_CONTROL); + RPC_U32(&msg, 0U) = U32(ctrl); + RPC_U16(&msg, 4U) = U16(resource); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (val != NULL) { - *val = RPC_U32(&msg, 0); + *val = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); @@ -77,13 +77,13 @@ sc_err_t sc_misc_set_max_dma_group(sc_ipc_t ipc, sc_rm_pt_t pt, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SET_MAX_DMA_GROUP; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = max; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SET_MAX_DMA_GROUP); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(max); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -96,86 +96,323 @@ sc_err_t sc_misc_set_dma_group(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SET_DMA_GROUP; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = group; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SET_DMA_GROUP); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(group); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } -sc_err_t sc_misc_seco_image_load(sc_ipc_t ipc, uint32_t addr_src, - uint32_t addr_dst, uint32_t len, bool fw) +sc_err_t sc_misc_seco_image_load(sc_ipc_t ipc, sc_faddr_t addr_src, + sc_faddr_t addr_dst, uint32_t len, + sc_bool_t fw) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SECO_IMAGE_LOAD; - RPC_U32(&msg, 0) = addr_src; - RPC_U32(&msg, 4) = addr_dst; - RPC_U32(&msg, 8) = len; - RPC_U8(&msg, 12) = (uint8_t)fw; - RPC_SIZE(&msg) = 5; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_IMAGE_LOAD); + RPC_U32(&msg, 0U) = U32(addr_src >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr_src); + RPC_U32(&msg, 8U) = U32(addr_dst >> 32ULL); + RPC_U32(&msg, 12U) = U32(addr_dst); + RPC_U32(&msg, 16U) = U32(len); + RPC_U8(&msg, 20U) = B2U8(fw); + RPC_SIZE(&msg) = 7U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_misc_seco_authenticate(sc_ipc_t ipc, - sc_misc_seco_auth_cmd_t cmd, - uint32_t addr_meta) + sc_misc_seco_auth_cmd_t cmd, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_AUTHENTICATE); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_U8(&msg, 8U) = U8(cmd); + RPC_SIZE(&msg) = 4U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_fuse_write(sc_ipc_t ipc, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_FUSE_WRITE); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_enable_debug(sc_ipc_t ipc, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_ENABLE_DEBUG); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_forward_lifecycle(sc_ipc_t ipc, uint32_t change) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_FORWARD_LIFECYCLE); + RPC_U32(&msg, 0U) = U32(change); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_return_lifecycle(sc_ipc_t ipc, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_RETURN_LIFECYCLE); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +void sc_misc_seco_build_info(sc_ipc_t ipc, uint32_t *version, uint32_t *commit) +{ + sc_rpc_msg_t msg; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_BUILD_INFO); + RPC_SIZE(&msg) = 1U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + if (version != NULL) { + *version = RPC_U32(&msg, 0U); + } + + if (commit != NULL) { + *commit = RPC_U32(&msg, 4U); + } + + return; +} + +sc_err_t sc_misc_seco_chip_info(sc_ipc_t ipc, uint16_t *lc, + uint16_t *monotonic, uint32_t *uid_l, + uint32_t *uid_h) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_CHIP_INFO); + RPC_SIZE(&msg) = 1U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + if (uid_l != NULL) { + *uid_l = RPC_U32(&msg, 0U); + } + + if (uid_h != NULL) { + *uid_h = RPC_U32(&msg, 4U); + } + + if (lc != NULL) { + *lc = RPC_U16(&msg, 8U); + } + + if (monotonic != NULL) { + *monotonic = RPC_U16(&msg, 10U); + } + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_attest_mode(sc_ipc_t ipc, uint32_t mode) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_ATTEST_MODE); + RPC_U32(&msg, 0U) = U32(mode); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_attest(sc_ipc_t ipc, uint64_t nonce) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SECO_AUTHENTICATE; - RPC_U32(&msg, 0) = addr_meta; - RPC_U8(&msg, 4) = cmd; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_ATTEST); + RPC_U32(&msg, 0U) = U32(nonce >> 32ULL); + RPC_U32(&msg, 4U) = U32(nonce); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } +sc_err_t sc_misc_seco_get_attest_pkey(sc_ipc_t ipc, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_GET_ATTEST_PKEY); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_get_attest_sign(sc_ipc_t ipc, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_GET_ATTEST_SIGN); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_attest_verify(sc_ipc_t ipc, sc_faddr_t addr) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_ATTEST_VERIFY); + RPC_U32(&msg, 0U) = U32(addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_misc_seco_commit(sc_ipc_t ipc, uint32_t *info) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SECO_COMMIT); + RPC_U32(&msg, 0U) = *PTR_U32(info); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + *info = RPC_U32(&msg, 0U); + result = RPC_R8(&msg); + return (sc_err_t)result; +} + void sc_misc_debug_out(sc_ipc_t ipc, uint8_t ch) { sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_DEBUG_OUT; - RPC_U8(&msg, 0) = ch; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_DEBUG_OUT); + RPC_U8(&msg, 0U) = U8(ch); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); return; } -sc_err_t sc_misc_waveform_capture(sc_ipc_t ipc, bool enable) +sc_err_t sc_misc_waveform_capture(sc_ipc_t ipc, sc_bool_t enable) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_WAVEFORM_CAPTURE; - RPC_U8(&msg, 0) = (uint8_t)enable; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_WAVEFORM_CAPTURE); + RPC_U8(&msg, 0U) = B2U8(enable); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -186,18 +423,18 @@ void sc_misc_build_info(sc_ipc_t ipc, uint32_t *build, uint32_t *commit) sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_BUILD_INFO; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_BUILD_INFO); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (build != NULL) { - *build = RPC_U32(&msg, 0); + *build = RPC_U32(&msg, 0U); } if (commit != NULL) { - *commit = RPC_U32(&msg, 4); + *commit = RPC_U32(&msg, 4U); } return; @@ -208,39 +445,39 @@ void sc_misc_unique_id(sc_ipc_t ipc, uint32_t *id_l, uint32_t *id_h) sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_UNIQUE_ID; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_UNIQUE_ID); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (id_l != NULL) { - *id_l = RPC_U32(&msg, 0); + *id_l = RPC_U32(&msg, 0U); } if (id_h != NULL) { - *id_h = RPC_U32(&msg, 4); + *id_h = RPC_U32(&msg, 4U); } return; } sc_err_t sc_misc_set_ari(sc_ipc_t ipc, sc_rsrc_t resource, - sc_rsrc_t resource_mst, uint16_t ari, bool enable) + sc_rsrc_t resource_mst, uint16_t ari, sc_bool_t enable) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SET_ARI; - RPC_U16(&msg, 0) = resource; - RPC_U16(&msg, 2) = resource_mst; - RPC_U16(&msg, 4) = ari; - RPC_U8(&msg, 6) = (uint8_t)enable; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SET_ARI); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U16(&msg, 2U) = U16(resource_mst); + RPC_U16(&msg, 4U) = U16(ari); + RPC_U8(&msg, 6U) = B2U8(enable); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -251,12 +488,12 @@ void sc_misc_boot_status(sc_ipc_t ipc, sc_misc_boot_status_t status) sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_BOOT_STATUS; - RPC_U8(&msg, 0) = status; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_BOOT_STATUS); + RPC_U8(&msg, 0U) = U8(status); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, true); + sc_call_rpc(ipc, &msg, SC_TRUE); return; } @@ -267,12 +504,12 @@ sc_err_t sc_misc_boot_done(sc_ipc_t ipc, sc_rsrc_t cpu) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_BOOT_DONE; - RPC_U16(&msg, 0) = cpu; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_BOOT_DONE); + RPC_U16(&msg, 0U) = U16(cpu); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -284,15 +521,15 @@ sc_err_t sc_misc_otp_fuse_read(sc_ipc_t ipc, uint32_t word, uint32_t *val) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_OTP_FUSE_READ; - RPC_U32(&msg, 0) = word; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_OTP_FUSE_READ); + RPC_U32(&msg, 0U) = U32(word); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (val != NULL) { - *val = RPC_U32(&msg, 0); + *val = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); @@ -305,13 +542,13 @@ sc_err_t sc_misc_otp_fuse_write(sc_ipc_t ipc, uint32_t word, uint32_t val) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_OTP_FUSE_WRITE; - RPC_U32(&msg, 0) = word; - RPC_U32(&msg, 4) = val; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_OTP_FUSE_WRITE); + RPC_U32(&msg, 0U) = U32(word); + RPC_U32(&msg, 4U) = U32(val); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -324,15 +561,15 @@ sc_err_t sc_misc_set_temp(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_SET_TEMP; - RPC_U16(&msg, 0) = resource; - RPC_I16(&msg, 2) = celsius; - RPC_U8(&msg, 4) = temp; - RPC_I8(&msg, 5) = tenths; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_SET_TEMP); + RPC_U16(&msg, 0U) = U16(resource); + RPC_I16(&msg, 2U) = I16(celsius); + RPC_U8(&msg, 4U) = U8(temp); + RPC_I8(&msg, 5U) = I8(tenths); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -346,21 +583,21 @@ sc_err_t sc_misc_get_temp(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_GET_TEMP; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = temp; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_GET_TEMP); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(temp); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (celsius != NULL) { - *celsius = RPC_I16(&msg, 0); + *celsius = RPC_I16(&msg, 0U); } result = RPC_R8(&msg); if (tenths != NULL) { - *tenths = RPC_I8(&msg, 2); + *tenths = RPC_I8(&msg, 2U); } return (sc_err_t)result; @@ -371,35 +608,75 @@ void sc_misc_get_boot_dev(sc_ipc_t ipc, sc_rsrc_t *dev) sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_GET_BOOT_DEV; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_GET_BOOT_DEV); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (dev != NULL) { - *dev = RPC_U16(&msg, 0); + *dev = RPC_U16(&msg, 0U); } return; } -void sc_misc_get_button_status(sc_ipc_t ipc, bool *status) +sc_err_t sc_misc_get_boot_type(sc_ipc_t ipc, sc_misc_bt_t *type) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_GET_BOOT_TYPE); + RPC_SIZE(&msg) = 1U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + if (type != NULL) { + *type = RPC_U8(&msg, 0U); + } + + return (sc_err_t)result; +} + +void sc_misc_get_button_status(sc_ipc_t ipc, sc_bool_t *status) { sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_MISC; - RPC_FUNC(&msg) = (uint8_t)MISC_FUNC_GET_BUTTON_STATUS; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_GET_BUTTON_STATUS); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (status != NULL) { - *status = RPC_U8(&msg, 0); + *status = U2B(RPC_U8(&msg, 0U)); } return; } +sc_err_t sc_misc_rompatch_checksum(sc_ipc_t ipc, uint32_t *checksum) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_MISC); + RPC_FUNC(&msg) = U8(MISC_FUNC_ROMPATCH_CHECKSUM); + RPC_SIZE(&msg) = 1U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + if (checksum != NULL) { + *checksum = RPC_U32(&msg, 0U); + } + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + /**@}*/ diff --git a/drivers/soc/imx/sc/svc/pad/rpc.h b/drivers/soc/imx/sc/svc/pad/rpc.h index ee8fe3b42af2..b00b9c13255d 100644 --- a/drivers/soc/imx/sc/svc/pad/rpc.h +++ b/drivers/soc/imx/sc/svc/pad/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -12,37 +12,37 @@ * @{ */ -#ifndef _SC_PAD_RPC_H -#define _SC_PAD_RPC_H +#ifndef SC_PAD_RPC_H +#define SC_PAD_RPC_H /* Includes */ /* Defines */ -/* Types */ - /*! - * This type is used to indicate RPC PAD function calls. + * @name Defines for RPC PAD function calls */ -typedef enum pad_func_e { - PAD_FUNC_UNKNOWN = 0, /* Unknown function */ - PAD_FUNC_SET_MUX = 1, /* Index for pad_set_mux() RPC call */ - PAD_FUNC_GET_MUX = 6, /* Index for pad_get_mux() RPC call */ - PAD_FUNC_SET_GP = 2, /* Index for pad_set_gp() RPC call */ - PAD_FUNC_GET_GP = 7, /* Index for pad_get_gp() RPC call */ - PAD_FUNC_SET_WAKEUP = 4, /* Index for pad_set_wakeup() RPC call */ - PAD_FUNC_GET_WAKEUP = 9, /* Index for pad_get_wakeup() RPC call */ - PAD_FUNC_SET_ALL = 5, /* Index for pad_set_all() RPC call */ - PAD_FUNC_GET_ALL = 10, /* Index for pad_get_all() RPC call */ - PAD_FUNC_SET = 15, /* Index for pad_set() RPC call */ - PAD_FUNC_GET = 16, /* Index for pad_get() RPC call */ - PAD_FUNC_SET_GP_28FDSOI = 11, /* Index for pad_set_gp_28fdsoi() RPC call */ - PAD_FUNC_GET_GP_28FDSOI = 12, /* Index for pad_get_gp_28fdsoi() RPC call */ - PAD_FUNC_SET_GP_28FDSOI_HSIC = 3, /* Index for pad_set_gp_28fdsoi_hsic() RPC call */ - PAD_FUNC_GET_GP_28FDSOI_HSIC = 8, /* Index for pad_get_gp_28fdsoi_hsic() RPC call */ - PAD_FUNC_SET_GP_28FDSOI_COMP = 13, /* Index for pad_set_gp_28fdsoi_comp() RPC call */ - PAD_FUNC_GET_GP_28FDSOI_COMP = 14, /* Index for pad_get_gp_28fdsoi_comp() RPC call */ -} pad_func_t; +/*@{*/ +#define PAD_FUNC_UNKNOWN 0 /* Unknown function */ +#define PAD_FUNC_SET_MUX 1U /* Index for pad_set_mux() RPC call */ +#define PAD_FUNC_GET_MUX 6U /* Index for pad_get_mux() RPC call */ +#define PAD_FUNC_SET_GP 2U /* Index for pad_set_gp() RPC call */ +#define PAD_FUNC_GET_GP 7U /* Index for pad_get_gp() RPC call */ +#define PAD_FUNC_SET_WAKEUP 4U /* Index for pad_set_wakeup() RPC call */ +#define PAD_FUNC_GET_WAKEUP 9U /* Index for pad_get_wakeup() RPC call */ +#define PAD_FUNC_SET_ALL 5U /* Index for pad_set_all() RPC call */ +#define PAD_FUNC_GET_ALL 10U /* Index for pad_get_all() RPC call */ +#define PAD_FUNC_SET 15U /* Index for pad_set() RPC call */ +#define PAD_FUNC_GET 16U /* Index for pad_get() RPC call */ +#define PAD_FUNC_SET_GP_28FDSOI 11U /* Index for pad_set_gp_28fdsoi() RPC call */ +#define PAD_FUNC_GET_GP_28FDSOI 12U /* Index for pad_get_gp_28fdsoi() RPC call */ +#define PAD_FUNC_SET_GP_28FDSOI_HSIC 3U /* Index for pad_set_gp_28fdsoi_hsic() RPC call */ +#define PAD_FUNC_GET_GP_28FDSOI_HSIC 8U /* Index for pad_get_gp_28fdsoi_hsic() RPC call */ +#define PAD_FUNC_SET_GP_28FDSOI_COMP 13U /* Index for pad_set_gp_28fdsoi_comp() RPC call */ +#define PAD_FUNC_GET_GP_28FDSOI_COMP 14U /* Index for pad_get_gp_28fdsoi_comp() RPC call */ +/*@}*/ + +/* Types */ /* Functions */ @@ -54,14 +54,6 @@ typedef enum pad_func_e { */ void pad_dispatch(sc_rm_pt_t caller_pt, sc_rpc_msg_t *msg); -/*! - * This function translates and dispatches an PAD RPC request. - * - * @param[in] ipc IPC handle - * @param[in] msg pointer to RPC message - */ -void pad_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); - -#endif /* _SC_PAD_RPC_H */ +#endif /* SC_PAD_RPC_H */ /**@}*/ diff --git a/drivers/soc/imx/sc/svc/pad/rpc_clnt.c b/drivers/soc/imx/sc/svc/pad/rpc_clnt.c index 90fb3904ca7b..02677450fcf1 100644 --- a/drivers/soc/imx/sc/svc/pad/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/pad/rpc_clnt.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -34,15 +34,15 @@ sc_err_t sc_pad_set_mux(sc_ipc_t ipc, sc_pad_t pad, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_MUX; - RPC_U16(&msg, 0) = pad; - RPC_U8(&msg, 2) = mux; - RPC_U8(&msg, 3) = config; - RPC_U8(&msg, 4) = iso; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_MUX); + RPC_U16(&msg, 0U) = U16(pad); + RPC_U8(&msg, 2U) = U8(mux); + RPC_U8(&msg, 3U) = U8(config); + RPC_U8(&msg, 4U) = U8(iso); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -56,24 +56,24 @@ sc_err_t sc_pad_get_mux(sc_ipc_t ipc, sc_pad_t pad, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_MUX; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_MUX); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (mux != NULL) { - *mux = RPC_U8(&msg, 0); + *mux = RPC_U8(&msg, 0U); } if (config != NULL) { - *config = RPC_U8(&msg, 1); + *config = RPC_U8(&msg, 1U); } if (iso != NULL) { - *iso = RPC_U8(&msg, 2); + *iso = RPC_U8(&msg, 2U); } return (sc_err_t)result; @@ -85,13 +85,13 @@ sc_err_t sc_pad_set_gp(sc_ipc_t ipc, sc_pad_t pad, uint32_t ctrl) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP; - RPC_U32(&msg, 0) = ctrl; - RPC_U16(&msg, 4) = pad; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_GP); + RPC_U32(&msg, 0U) = U32(ctrl); + RPC_U16(&msg, 4U) = U16(pad); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -103,15 +103,15 @@ sc_err_t sc_pad_get_gp(sc_ipc_t ipc, sc_pad_t pad, uint32_t *ctrl) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_GP); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (ctrl != NULL) { - *ctrl = RPC_U32(&msg, 0); + *ctrl = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); @@ -124,13 +124,13 @@ sc_err_t sc_pad_set_wakeup(sc_ipc_t ipc, sc_pad_t pad, sc_pad_wakeup_t wakeup) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_WAKEUP; - RPC_U16(&msg, 0) = pad; - RPC_U8(&msg, 2) = wakeup; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_WAKEUP); + RPC_U16(&msg, 0U) = U16(pad); + RPC_U8(&msg, 2U) = U8(wakeup); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -142,16 +142,16 @@ sc_err_t sc_pad_get_wakeup(sc_ipc_t ipc, sc_pad_t pad, sc_pad_wakeup_t *wakeup) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_WAKEUP; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_WAKEUP); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (wakeup != NULL) { - *wakeup = RPC_U8(&msg, 0); + *wakeup = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -165,17 +165,17 @@ sc_err_t sc_pad_set_all(sc_ipc_t ipc, sc_pad_t pad, uint8_t mux, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_ALL; - RPC_U32(&msg, 0) = ctrl; - RPC_U16(&msg, 4) = pad; - RPC_U8(&msg, 6) = mux; - RPC_U8(&msg, 7) = config; - RPC_U8(&msg, 8) = iso; - RPC_U8(&msg, 9) = wakeup; - RPC_SIZE(&msg) = 4; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_ALL); + RPC_U32(&msg, 0U) = U32(ctrl); + RPC_U16(&msg, 4U) = U16(pad); + RPC_U8(&msg, 6U) = U8(mux); + RPC_U8(&msg, 7U) = U8(config); + RPC_U8(&msg, 8U) = U8(iso); + RPC_U8(&msg, 9U) = U8(wakeup); + RPC_SIZE(&msg) = 4U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -189,32 +189,32 @@ sc_err_t sc_pad_get_all(sc_ipc_t ipc, sc_pad_t pad, uint8_t *mux, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_ALL; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_ALL); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (ctrl != NULL) { - *ctrl = RPC_U32(&msg, 0); + *ctrl = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); if (mux != NULL) { - *mux = RPC_U8(&msg, 4); + *mux = RPC_U8(&msg, 4U); } if (config != NULL) { - *config = RPC_U8(&msg, 5); + *config = RPC_U8(&msg, 5U); } if (iso != NULL) { - *iso = RPC_U8(&msg, 6); + *iso = RPC_U8(&msg, 6U); } if (wakeup != NULL) { - *wakeup = RPC_U8(&msg, 7); + *wakeup = RPC_U8(&msg, 7U); } return (sc_err_t)result; @@ -226,13 +226,13 @@ sc_err_t sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, uint32_t val) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET; - RPC_U32(&msg, 0) = val; - RPC_U16(&msg, 4) = pad; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET); + RPC_U32(&msg, 0U) = U32(val); + RPC_U16(&msg, 4U) = U16(pad); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -244,15 +244,15 @@ sc_err_t sc_pad_get(sc_ipc_t ipc, sc_pad_t pad, uint32_t *val) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (val != NULL) { - *val = RPC_U32(&msg, 0); + *val = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); @@ -266,14 +266,14 @@ sc_err_t sc_pad_set_gp_28fdsoi(sc_ipc_t ipc, sc_pad_t pad, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP_28FDSOI; - RPC_U16(&msg, 0) = pad; - RPC_U8(&msg, 2) = dse; - RPC_U8(&msg, 3) = ps; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_GP_28FDSOI); + RPC_U16(&msg, 0U) = U16(pad); + RPC_U8(&msg, 2U) = U8(dse); + RPC_U8(&msg, 3U) = U8(ps); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -287,164 +287,164 @@ sc_err_t sc_pad_get_gp_28fdsoi(sc_ipc_t ipc, sc_pad_t pad, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP_28FDSOI; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_GP_28FDSOI); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (dse != NULL) { - *dse = RPC_U8(&msg, 0); + *dse = RPC_U8(&msg, 0U); } if (ps != NULL) { - *ps = RPC_U8(&msg, 1); + *ps = RPC_U8(&msg, 1U); } return (sc_err_t)result; } sc_err_t sc_pad_set_gp_28fdsoi_hsic(sc_ipc_t ipc, sc_pad_t pad, - sc_pad_28fdsoi_dse_t dse, bool hys, - sc_pad_28fdsoi_pus_t pus, bool pke, - bool pue) + sc_pad_28fdsoi_dse_t dse, sc_bool_t hys, + sc_pad_28fdsoi_pus_t pus, sc_bool_t pke, + sc_bool_t pue) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP_28FDSOI_HSIC; - RPC_U16(&msg, 0) = pad; - RPC_U8(&msg, 2) = dse; - RPC_U8(&msg, 3) = pus; - RPC_U8(&msg, 4) = (uint8_t)hys; - RPC_U8(&msg, 5) = (uint8_t)pke; - RPC_U8(&msg, 6) = (uint8_t)pue; - RPC_SIZE(&msg) = 3; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_GP_28FDSOI_HSIC); + RPC_U16(&msg, 0U) = U16(pad); + RPC_U8(&msg, 2U) = U8(dse); + RPC_U8(&msg, 3U) = U8(pus); + RPC_U8(&msg, 4U) = B2U8(hys); + RPC_U8(&msg, 5U) = B2U8(pke); + RPC_U8(&msg, 6U) = B2U8(pue); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_pad_get_gp_28fdsoi_hsic(sc_ipc_t ipc, sc_pad_t pad, - sc_pad_28fdsoi_dse_t *dse, bool *hys, - sc_pad_28fdsoi_pus_t *pus, bool *pke, - bool *pue) + sc_pad_28fdsoi_dse_t *dse, sc_bool_t *hys, + sc_pad_28fdsoi_pus_t *pus, sc_bool_t *pke, + sc_bool_t *pue) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP_28FDSOI_HSIC; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_GP_28FDSOI_HSIC); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (dse != NULL) { - *dse = RPC_U8(&msg, 0); + *dse = RPC_U8(&msg, 0U); } if (pus != NULL) { - *pus = RPC_U8(&msg, 1); + *pus = RPC_U8(&msg, 1U); } if (hys != NULL) { - *hys = RPC_U8(&msg, 2); + *hys = U2B(RPC_U8(&msg, 2U)); } if (pke != NULL) { - *pke = RPC_U8(&msg, 3); + *pke = U2B(RPC_U8(&msg, 3U)); } if (pue != NULL) { - *pue = RPC_U8(&msg, 4); + *pue = U2B(RPC_U8(&msg, 4U)); } return (sc_err_t)result; } sc_err_t sc_pad_set_gp_28fdsoi_comp(sc_ipc_t ipc, sc_pad_t pad, - uint8_t compen, bool fastfrz, + uint8_t compen, sc_bool_t fastfrz, uint8_t rasrcp, uint8_t rasrcn, - bool nasrc_sel, bool psw_ovr) + sc_bool_t nasrc_sel, sc_bool_t psw_ovr) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_SET_GP_28FDSOI_COMP; - RPC_U16(&msg, 0) = pad; - RPC_U8(&msg, 2) = compen; - RPC_U8(&msg, 3) = rasrcp; - RPC_U8(&msg, 4) = rasrcn; - RPC_U8(&msg, 5) = (uint8_t)fastfrz; - RPC_U8(&msg, 6) = (uint8_t)nasrc_sel; - RPC_U8(&msg, 7) = (uint8_t)psw_ovr; - RPC_SIZE(&msg) = 3; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_SET_GP_28FDSOI_COMP); + RPC_U16(&msg, 0U) = U16(pad); + RPC_U8(&msg, 2U) = U8(compen); + RPC_U8(&msg, 3U) = U8(rasrcp); + RPC_U8(&msg, 4U) = U8(rasrcn); + RPC_U8(&msg, 5U) = B2U8(fastfrz); + RPC_U8(&msg, 6U) = B2U8(nasrc_sel); + RPC_U8(&msg, 7U) = B2U8(psw_ovr); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_pad_get_gp_28fdsoi_comp(sc_ipc_t ipc, sc_pad_t pad, - uint8_t *compen, bool *fastfrz, + uint8_t *compen, sc_bool_t *fastfrz, uint8_t *rasrcp, uint8_t *rasrcn, - bool *nasrc_sel, bool *compok, - uint8_t *nasrc, bool *psw_ovr) + sc_bool_t *nasrc_sel, sc_bool_t *compok, + uint8_t *nasrc, sc_bool_t *psw_ovr) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PAD; - RPC_FUNC(&msg) = (uint8_t)PAD_FUNC_GET_GP_28FDSOI_COMP; - RPC_U16(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PAD); + RPC_FUNC(&msg) = U8(PAD_FUNC_GET_GP_28FDSOI_COMP); + RPC_U16(&msg, 0U) = U16(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (compen != NULL) { - *compen = RPC_U8(&msg, 0); + *compen = RPC_U8(&msg, 0U); } if (rasrcp != NULL) { - *rasrcp = RPC_U8(&msg, 1); + *rasrcp = RPC_U8(&msg, 1U); } if (rasrcn != NULL) { - *rasrcn = RPC_U8(&msg, 2); + *rasrcn = RPC_U8(&msg, 2U); } if (nasrc != NULL) { - *nasrc = RPC_U8(&msg, 3); + *nasrc = RPC_U8(&msg, 3U); } if (fastfrz != NULL) { - *fastfrz = RPC_U8(&msg, 4); + *fastfrz = U2B(RPC_U8(&msg, 4U)); } if (nasrc_sel != NULL) { - *nasrc_sel = RPC_U8(&msg, 5); + *nasrc_sel = U2B(RPC_U8(&msg, 5U)); } if (compok != NULL) { - *compok = RPC_U8(&msg, 6); + *compok = U2B(RPC_U8(&msg, 6U)); } if (psw_ovr != NULL) { - *psw_ovr = RPC_U8(&msg, 7); + *psw_ovr = U2B(RPC_U8(&msg, 7U)); } return (sc_err_t)result; diff --git a/drivers/soc/imx/sc/svc/pm/rpc.h b/drivers/soc/imx/sc/svc/pm/rpc.h index e83db74d20bd..037923ae6e95 100644 --- a/drivers/soc/imx/sc/svc/pm/rpc.h +++ b/drivers/soc/imx/sc/svc/pm/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -12,40 +12,44 @@ * @{ */ -#ifndef _SC_PM_RPC_H -#define _SC_PM_RPC_H +#ifndef SC_PM_RPC_H +#define SC_PM_RPC_H /* Includes */ /* Defines */ -/* Types */ - /*! - * This type is used to indicate RPC PM function calls. + * @name Defines for RPC PM function calls */ -typedef enum pm_func_e { - PM_FUNC_UNKNOWN = 0, /* Unknown function */ - PM_FUNC_SET_SYS_POWER_MODE = 19, /* Index for pm_set_sys_power_mode() RPC call */ - PM_FUNC_SET_PARTITION_POWER_MODE = 1, /* Index for pm_set_partition_power_mode() RPC call */ - PM_FUNC_GET_SYS_POWER_MODE = 2, /* Index for pm_get_sys_power_mode() RPC call */ - PM_FUNC_SET_RESOURCE_POWER_MODE = 3, /* Index for pm_set_resource_power_mode() RPC call */ - PM_FUNC_GET_RESOURCE_POWER_MODE = 4, /* Index for pm_get_resource_power_mode() RPC call */ - PM_FUNC_REQ_LOW_POWER_MODE = 16, /* Index for pm_req_low_power_mode() RPC call */ - PM_FUNC_SET_CPU_RESUME_ADDR = 17, /* Index for pm_set_cpu_resume_addr() RPC call */ - PM_FUNC_REQ_SYS_IF_POWER_MODE = 18, /* Index for pm_req_sys_if_power_mode() RPC call */ - PM_FUNC_SET_CLOCK_RATE = 5, /* Index for pm_set_clock_rate() RPC call */ - PM_FUNC_GET_CLOCK_RATE = 6, /* Index for pm_get_clock_rate() RPC call */ - PM_FUNC_CLOCK_ENABLE = 7, /* Index for pm_clock_enable() RPC call */ - PM_FUNC_SET_CLOCK_PARENT = 14, /* Index for pm_set_clock_parent() RPC call */ - PM_FUNC_GET_CLOCK_PARENT = 15, /* Index for pm_get_clock_parent() RPC call */ - PM_FUNC_RESET = 13, /* Index for pm_reset() RPC call */ - PM_FUNC_RESET_REASON = 10, /* Index for pm_reset_reason() RPC call */ - PM_FUNC_BOOT = 8, /* Index for pm_boot() RPC call */ - PM_FUNC_REBOOT = 9, /* Index for pm_reboot() RPC call */ - PM_FUNC_REBOOT_PARTITION = 12, /* Index for pm_reboot_partition() RPC call */ - PM_FUNC_CPU_START = 11, /* Index for pm_cpu_start() RPC call */ -} pm_func_t; +/*@{*/ +#define PM_FUNC_UNKNOWN 0 /* Unknown function */ +#define PM_FUNC_SET_SYS_POWER_MODE 19U /* Index for pm_set_sys_power_mode() RPC call */ +#define PM_FUNC_SET_PARTITION_POWER_MODE 1U /* Index for pm_set_partition_power_mode() RPC call */ +#define PM_FUNC_GET_SYS_POWER_MODE 2U /* Index for pm_get_sys_power_mode() RPC call */ +#define PM_FUNC_SET_RESOURCE_POWER_MODE 3U /* Index for pm_set_resource_power_mode() RPC call */ +#define PM_FUNC_SET_RESOURCE_POWER_MODE_ALL 22U /* Index for pm_set_resource_power_mode_all() RPC call */ +#define PM_FUNC_GET_RESOURCE_POWER_MODE 4U /* Index for pm_get_resource_power_mode() RPC call */ +#define PM_FUNC_REQ_LOW_POWER_MODE 16U /* Index for pm_req_low_power_mode() RPC call */ +#define PM_FUNC_REQ_CPU_LOW_POWER_MODE 20U /* Index for pm_req_cpu_low_power_mode() RPC call */ +#define PM_FUNC_SET_CPU_RESUME_ADDR 17U /* Index for pm_set_cpu_resume_addr() RPC call */ +#define PM_FUNC_SET_CPU_RESUME 21U /* Index for pm_set_cpu_resume() RPC call */ +#define PM_FUNC_REQ_SYS_IF_POWER_MODE 18U /* Index for pm_req_sys_if_power_mode() RPC call */ +#define PM_FUNC_SET_CLOCK_RATE 5U /* Index for pm_set_clock_rate() RPC call */ +#define PM_FUNC_GET_CLOCK_RATE 6U /* Index for pm_get_clock_rate() RPC call */ +#define PM_FUNC_CLOCK_ENABLE 7U /* Index for pm_clock_enable() RPC call */ +#define PM_FUNC_SET_CLOCK_PARENT 14U /* Index for pm_set_clock_parent() RPC call */ +#define PM_FUNC_GET_CLOCK_PARENT 15U /* Index for pm_get_clock_parent() RPC call */ +#define PM_FUNC_RESET 13U /* Index for pm_reset() RPC call */ +#define PM_FUNC_RESET_REASON 10U /* Index for pm_reset_reason() RPC call */ +#define PM_FUNC_BOOT 8U /* Index for pm_boot() RPC call */ +#define PM_FUNC_REBOOT 9U /* Index for pm_reboot() RPC call */ +#define PM_FUNC_REBOOT_PARTITION 12U /* Index for pm_reboot_partition() RPC call */ +#define PM_FUNC_CPU_START 11U /* Index for pm_cpu_start() RPC call */ +#define PM_FUNC_CPU_RESET 23U /* Index for pm_cpu_reset() RPC call */ +/*@}*/ + +/* Types */ /* Functions */ @@ -57,14 +61,6 @@ typedef enum pm_func_e { */ void pm_dispatch(sc_rm_pt_t caller_pt, sc_rpc_msg_t *msg); -/*! - * This function translates and dispatches an PM RPC request. - * - * @param[in] ipc IPC handle - * @param[in] msg pointer to RPC message - */ -void pm_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); - -#endif /* _SC_PM_RPC_H */ +#endif /* SC_PM_RPC_H */ /**@}*/ diff --git a/drivers/soc/imx/sc/svc/pm/rpc_clnt.c b/drivers/soc/imx/sc/svc/pm/rpc_clnt.c index b4b651e91ad5..acbf99c01fcf 100644 --- a/drivers/soc/imx/sc/svc/pm/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/pm/rpc_clnt.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -33,12 +33,12 @@ sc_err_t sc_pm_set_sys_power_mode(sc_ipc_t ipc, sc_pm_power_mode_t mode) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_SET_SYS_POWER_MODE; - RPC_U8(&msg, 0) = mode; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_SYS_POWER_MODE); + RPC_U8(&msg, 0U) = U8(mode); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -51,13 +51,13 @@ sc_err_t sc_pm_set_partition_power_mode(sc_ipc_t ipc, sc_rm_pt_t pt, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_SET_PARTITION_POWER_MODE; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = mode; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_PARTITION_POWER_MODE); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(mode); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -70,16 +70,16 @@ sc_err_t sc_pm_get_sys_power_mode(sc_ipc_t ipc, sc_rm_pt_t pt, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_GET_SYS_POWER_MODE; - RPC_U8(&msg, 0) = pt; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_GET_SYS_POWER_MODE); + RPC_U8(&msg, 0U) = U8(pt); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (mode != NULL) { - *mode = RPC_U8(&msg, 0); + *mode = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -92,13 +92,35 @@ sc_err_t sc_pm_set_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_SET_RESOURCE_POWER_MODE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = mode; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_RESOURCE_POWER_MODE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(mode); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_pm_set_resource_power_mode_all(sc_ipc_t ipc, + sc_rm_pt_t pt, + sc_pm_power_mode_t mode, + sc_rsrc_t exclude) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_RESOURCE_POWER_MODE_ALL); + RPC_U16(&msg, 0U) = U16(exclude); + RPC_U8(&msg, 2U) = U8(pt); + RPC_U8(&msg, 3U) = U8(mode); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -111,16 +133,16 @@ sc_err_t sc_pm_get_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_GET_RESOURCE_POWER_MODE; - RPC_U16(&msg, 0) = resource; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_GET_RESOURCE_POWER_MODE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (mode != NULL) { - *mode = RPC_U8(&msg, 0); + *mode = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -133,13 +155,34 @@ sc_err_t sc_pm_req_low_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_REQ_LOW_POWER_MODE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = mode; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_REQ_LOW_POWER_MODE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(mode); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_pm_req_cpu_low_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, + sc_pm_power_mode_t mode, + sc_pm_wake_src_t wake_src) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_REQ_CPU_LOW_POWER_MODE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(mode); + RPC_U8(&msg, 3U) = U8(wake_src); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -152,14 +195,35 @@ sc_err_t sc_pm_set_cpu_resume_addr(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_SET_CPU_RESUME_ADDR; - RPC_U32(&msg, 0) = (uint32_t)(address >> 32u); - RPC_U32(&msg, 4) = (uint32_t)address; - RPC_U16(&msg, 8) = resource; - RPC_SIZE(&msg) = 4; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_CPU_RESUME_ADDR); + RPC_U32(&msg, 0U) = U32(address >> 32ULL); + RPC_U32(&msg, 4U) = U32(address); + RPC_U16(&msg, 8U) = U16(resource); + RPC_SIZE(&msg) = 4U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_pm_set_cpu_resume(sc_ipc_t ipc, sc_rsrc_t resource, + sc_bool_t isPrimary, sc_faddr_t address) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_CPU_RESUME); + RPC_U32(&msg, 0U) = U32(address >> 32ULL); + RPC_U32(&msg, 4U) = U32(address); + RPC_U16(&msg, 8U) = U16(resource); + RPC_U8(&msg, 10U) = B2U8(isPrimary); + RPC_SIZE(&msg) = 4U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -174,15 +238,15 @@ sc_err_t sc_pm_req_sys_if_power_mode(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_REQ_SYS_IF_POWER_MODE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = sys_if; - RPC_U8(&msg, 3) = hpm; - RPC_U8(&msg, 4) = lpm; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_REQ_SYS_IF_POWER_MODE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(sys_if); + RPC_U8(&msg, 3U) = U8(hpm); + RPC_U8(&msg, 4U) = U8(lpm); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -195,16 +259,16 @@ sc_err_t sc_pm_set_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_SET_CLOCK_RATE; - RPC_U32(&msg, 0) = *rate; - RPC_U16(&msg, 4) = resource; - RPC_U8(&msg, 6) = clk; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_CLOCK_RATE); + RPC_U32(&msg, 0U) = *PTR_U32(rate); + RPC_U16(&msg, 4U) = U16(resource); + RPC_U8(&msg, 6U) = U8(clk); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); - *rate = RPC_U32(&msg, 0); + *rate = RPC_U32(&msg, 0U); result = RPC_R8(&msg); return (sc_err_t)result; } @@ -216,16 +280,16 @@ sc_err_t sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_GET_CLOCK_RATE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = clk; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_GET_CLOCK_RATE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(clk); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (rate != NULL) { - *rate = RPC_U32(&msg, 0); + *rate = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); @@ -233,21 +297,21 @@ sc_err_t sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, } sc_err_t sc_pm_clock_enable(sc_ipc_t ipc, sc_rsrc_t resource, - sc_pm_clk_t clk, bool enable, bool autog) + sc_pm_clk_t clk, sc_bool_t enable, sc_bool_t autog) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_CLOCK_ENABLE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = clk; - RPC_U8(&msg, 3) = (uint8_t)enable; - RPC_U8(&msg, 4) = (uint8_t)autog; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_CLOCK_ENABLE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(clk); + RPC_U8(&msg, 3U) = B2U8(enable); + RPC_U8(&msg, 4U) = B2U8(autog); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -260,14 +324,14 @@ sc_err_t sc_pm_set_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_SET_CLOCK_PARENT; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = clk; - RPC_U8(&msg, 3) = parent; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_SET_CLOCK_PARENT); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(clk); + RPC_U8(&msg, 3U) = U8(parent); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -280,17 +344,17 @@ sc_err_t sc_pm_get_clock_parent(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_GET_CLOCK_PARENT; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = clk; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_GET_CLOCK_PARENT); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(clk); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (parent != NULL) { - *parent = RPC_U8(&msg, 0); + *parent = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -302,12 +366,12 @@ sc_err_t sc_pm_reset(sc_ipc_t ipc, sc_pm_reset_type_t type) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_RESET; - RPC_U8(&msg, 0) = type; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_RESET); + RPC_U8(&msg, 0U) = U8(type); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -319,15 +383,15 @@ sc_err_t sc_pm_reset_reason(sc_ipc_t ipc, sc_pm_reset_reason_t *reason) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_RESET_REASON; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_RESET_REASON); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (reason != NULL) { - *reason = RPC_U8(&msg, 0); + *reason = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -341,17 +405,17 @@ sc_err_t sc_pm_boot(sc_ipc_t ipc, sc_rm_pt_t pt, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_BOOT; - RPC_U32(&msg, 0) = (uint32_t)(boot_addr >> 32u); - RPC_U32(&msg, 4) = (uint32_t)boot_addr; - RPC_U16(&msg, 8) = resource_cpu; - RPC_U16(&msg, 10) = resource_mu; - RPC_U16(&msg, 12) = resource_dev; - RPC_U8(&msg, 14) = pt; - RPC_SIZE(&msg) = 5; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_BOOT); + RPC_U32(&msg, 0U) = U32(boot_addr >> 32ULL); + RPC_U32(&msg, 4U) = U32(boot_addr); + RPC_U16(&msg, 8U) = U16(resource_cpu); + RPC_U16(&msg, 10U) = U16(resource_mu); + RPC_U16(&msg, 12U) = U16(resource_dev); + RPC_U8(&msg, 14U) = U8(pt); + RPC_SIZE(&msg) = 5U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -362,12 +426,12 @@ void sc_pm_reboot(sc_ipc_t ipc, sc_pm_reset_type_t type) sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_REBOOT; - RPC_U8(&msg, 0) = type; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_REBOOT); + RPC_U8(&msg, 0U) = U8(type); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, true); + sc_call_rpc(ipc, &msg, SC_TRUE); return; } @@ -379,37 +443,54 @@ sc_err_t sc_pm_reboot_partition(sc_ipc_t ipc, sc_rm_pt_t pt, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_REBOOT_PARTITION; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = type; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_REBOOT_PARTITION); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(type); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } -sc_err_t sc_pm_cpu_start(sc_ipc_t ipc, sc_rsrc_t resource, bool enable, +sc_err_t sc_pm_cpu_start(sc_ipc_t ipc, sc_rsrc_t resource, sc_bool_t enable, sc_faddr_t address) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_PM; - RPC_FUNC(&msg) = (uint8_t)PM_FUNC_CPU_START; - RPC_U32(&msg, 0) = (uint32_t)(address >> 32u); - RPC_U32(&msg, 4) = (uint32_t)address; - RPC_U16(&msg, 8) = resource; - RPC_U8(&msg, 10) = (uint8_t)enable; - RPC_SIZE(&msg) = 4; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_CPU_START); + RPC_U32(&msg, 0U) = U32(address >> 32ULL); + RPC_U32(&msg, 4U) = U32(address); + RPC_U16(&msg, 8U) = U16(resource); + RPC_U8(&msg, 10U) = B2U8(enable); + RPC_SIZE(&msg) = 4U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } +void sc_pm_cpu_reset(sc_ipc_t ipc, sc_rsrc_t resource, sc_faddr_t address) +{ + sc_rpc_msg_t msg; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_PM); + RPC_FUNC(&msg) = U8(PM_FUNC_CPU_RESET); + RPC_U32(&msg, 0U) = U32(address >> 32ULL); + RPC_U32(&msg, 4U) = U32(address); + RPC_U16(&msg, 8U) = U16(resource); + RPC_SIZE(&msg) = 4U; + + sc_call_rpc(ipc, &msg, SC_TRUE); + + return; +} + /**@}*/ diff --git a/drivers/soc/imx/sc/svc/rm/rpc.h b/drivers/soc/imx/sc/svc/rm/rpc.h index 457b01860ae5..9b2fa1176429 100644 --- a/drivers/soc/imx/sc/svc/rm/rpc.h +++ b/drivers/soc/imx/sc/svc/rm/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -12,52 +12,53 @@ * @{ */ -#ifndef _SC_RM_RPC_H -#define _SC_RM_RPC_H +#ifndef SC_RM_RPC_H +#define SC_RM_RPC_H /* Includes */ /* Defines */ -/* Types */ - /*! - * This type is used to indicate RPC RM function calls. + * @name Defines for RPC RM function calls */ -typedef enum rm_func_e { - RM_FUNC_UNKNOWN = 0, /* Unknown function */ - RM_FUNC_PARTITION_ALLOC = 1, /* Index for rm_partition_alloc() RPC call */ - RM_FUNC_SET_CONFIDENTIAL = 31, /* Index for rm_set_confidential() RPC call */ - RM_FUNC_PARTITION_FREE = 2, /* Index for rm_partition_free() RPC call */ - RM_FUNC_GET_DID = 26, /* Index for rm_get_did() RPC call */ - RM_FUNC_PARTITION_STATIC = 3, /* Index for rm_partition_static() RPC call */ - RM_FUNC_PARTITION_LOCK = 4, /* Index for rm_partition_lock() RPC call */ - RM_FUNC_GET_PARTITION = 5, /* Index for rm_get_partition() RPC call */ - RM_FUNC_SET_PARENT = 6, /* Index for rm_set_parent() RPC call */ - RM_FUNC_MOVE_ALL = 7, /* Index for rm_move_all() RPC call */ - RM_FUNC_ASSIGN_RESOURCE = 8, /* Index for rm_assign_resource() RPC call */ - RM_FUNC_SET_RESOURCE_MOVABLE = 9, /* Index for rm_set_resource_movable() RPC call */ - RM_FUNC_SET_SUBSYS_RSRC_MOVABLE = 28, /* Index for rm_set_subsys_rsrc_movable() RPC call */ - RM_FUNC_SET_MASTER_ATTRIBUTES = 10, /* Index for rm_set_master_attributes() RPC call */ - RM_FUNC_SET_MASTER_SID = 11, /* Index for rm_set_master_sid() RPC call */ - RM_FUNC_SET_PERIPHERAL_PERMISSIONS = 12, /* Index for rm_set_peripheral_permissions() RPC call */ - RM_FUNC_IS_RESOURCE_OWNED = 13, /* Index for rm_is_resource_owned() RPC call */ - RM_FUNC_IS_RESOURCE_MASTER = 14, /* Index for rm_is_resource_master() RPC call */ - RM_FUNC_IS_RESOURCE_PERIPHERAL = 15, /* Index for rm_is_resource_peripheral() RPC call */ - RM_FUNC_GET_RESOURCE_INFO = 16, /* Index for rm_get_resource_info() RPC call */ - RM_FUNC_MEMREG_ALLOC = 17, /* Index for rm_memreg_alloc() RPC call */ - RM_FUNC_MEMREG_SPLIT = 29, /* Index for rm_memreg_split() RPC call */ - RM_FUNC_MEMREG_FREE = 18, /* Index for rm_memreg_free() RPC call */ - RM_FUNC_FIND_MEMREG = 30, /* Index for rm_find_memreg() RPC call */ - RM_FUNC_ASSIGN_MEMREG = 19, /* Index for rm_assign_memreg() RPC call */ - RM_FUNC_SET_MEMREG_PERMISSIONS = 20, /* Index for rm_set_memreg_permissions() RPC call */ - RM_FUNC_IS_MEMREG_OWNED = 21, /* Index for rm_is_memreg_owned() RPC call */ - RM_FUNC_GET_MEMREG_INFO = 22, /* Index for rm_get_memreg_info() RPC call */ - RM_FUNC_ASSIGN_PAD = 23, /* Index for rm_assign_pad() RPC call */ - RM_FUNC_SET_PAD_MOVABLE = 24, /* Index for rm_set_pad_movable() RPC call */ - RM_FUNC_IS_PAD_OWNED = 25, /* Index for rm_is_pad_owned() RPC call */ - RM_FUNC_DUMP = 27, /* Index for rm_dump() RPC call */ -} rm_func_t; +/*@{*/ +#define RM_FUNC_UNKNOWN 0 /* Unknown function */ +#define RM_FUNC_PARTITION_ALLOC 1U /* Index for rm_partition_alloc() RPC call */ +#define RM_FUNC_SET_CONFIDENTIAL 31U /* Index for rm_set_confidential() RPC call */ +#define RM_FUNC_PARTITION_FREE 2U /* Index for rm_partition_free() RPC call */ +#define RM_FUNC_GET_DID 26U /* Index for rm_get_did() RPC call */ +#define RM_FUNC_PARTITION_STATIC 3U /* Index for rm_partition_static() RPC call */ +#define RM_FUNC_PARTITION_LOCK 4U /* Index for rm_partition_lock() RPC call */ +#define RM_FUNC_GET_PARTITION 5U /* Index for rm_get_partition() RPC call */ +#define RM_FUNC_SET_PARENT 6U /* Index for rm_set_parent() RPC call */ +#define RM_FUNC_MOVE_ALL 7U /* Index for rm_move_all() RPC call */ +#define RM_FUNC_ASSIGN_RESOURCE 8U /* Index for rm_assign_resource() RPC call */ +#define RM_FUNC_SET_RESOURCE_MOVABLE 9U /* Index for rm_set_resource_movable() RPC call */ +#define RM_FUNC_SET_SUBSYS_RSRC_MOVABLE 28U /* Index for rm_set_subsys_rsrc_movable() RPC call */ +#define RM_FUNC_SET_MASTER_ATTRIBUTES 10U /* Index for rm_set_master_attributes() RPC call */ +#define RM_FUNC_SET_MASTER_SID 11U /* Index for rm_set_master_sid() RPC call */ +#define RM_FUNC_SET_PERIPHERAL_PERMISSIONS 12U /* Index for rm_set_peripheral_permissions() RPC call */ +#define RM_FUNC_IS_RESOURCE_OWNED 13U /* Index for rm_is_resource_owned() RPC call */ +#define RM_FUNC_IS_RESOURCE_MASTER 14U /* Index for rm_is_resource_master() RPC call */ +#define RM_FUNC_IS_RESOURCE_PERIPHERAL 15U /* Index for rm_is_resource_peripheral() RPC call */ +#define RM_FUNC_GET_RESOURCE_INFO 16U /* Index for rm_get_resource_info() RPC call */ +#define RM_FUNC_MEMREG_ALLOC 17U /* Index for rm_memreg_alloc() RPC call */ +#define RM_FUNC_MEMREG_SPLIT 29U /* Index for rm_memreg_split() RPC call */ +#define RM_FUNC_MEMREG_FRAG 32U /* Index for rm_memreg_frag() RPC call */ +#define RM_FUNC_MEMREG_FREE 18U /* Index for rm_memreg_free() RPC call */ +#define RM_FUNC_FIND_MEMREG 30U /* Index for rm_find_memreg() RPC call */ +#define RM_FUNC_ASSIGN_MEMREG 19U /* Index for rm_assign_memreg() RPC call */ +#define RM_FUNC_SET_MEMREG_PERMISSIONS 20U /* Index for rm_set_memreg_permissions() RPC call */ +#define RM_FUNC_IS_MEMREG_OWNED 21U /* Index for rm_is_memreg_owned() RPC call */ +#define RM_FUNC_GET_MEMREG_INFO 22U /* Index for rm_get_memreg_info() RPC call */ +#define RM_FUNC_ASSIGN_PAD 23U /* Index for rm_assign_pad() RPC call */ +#define RM_FUNC_SET_PAD_MOVABLE 24U /* Index for rm_set_pad_movable() RPC call */ +#define RM_FUNC_IS_PAD_OWNED 25U /* Index for rm_is_pad_owned() RPC call */ +#define RM_FUNC_DUMP 27U /* Index for rm_dump() RPC call */ +/*@}*/ + +/* Types */ /* Functions */ @@ -69,14 +70,6 @@ typedef enum rm_func_e { */ void rm_dispatch(sc_rm_pt_t caller_pt, sc_rpc_msg_t *msg); -/*! - * This function translates and dispatches an RM RPC request. - * - * @param[in] ipc IPC handle - * @param[in] msg pointer to RPC message - */ -void rm_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); - -#endif /* _SC_RM_RPC_H */ +#endif /* SC_RM_RPC_H */ /**@}*/ diff --git a/drivers/soc/imx/sc/svc/rm/rpc_clnt.c b/drivers/soc/imx/sc/svc/rm/rpc_clnt.c index a9bb6ba42c15..a24502386ea1 100644 --- a/drivers/soc/imx/sc/svc/rm/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/rm/rpc_clnt.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -26,46 +26,46 @@ /* Local Functions */ -sc_err_t sc_rm_partition_alloc(sc_ipc_t ipc, sc_rm_pt_t *pt, bool secure, - bool isolated, bool restricted, bool grant, - bool coherent) +sc_err_t sc_rm_partition_alloc(sc_ipc_t ipc, sc_rm_pt_t *pt, sc_bool_t secure, + sc_bool_t isolated, sc_bool_t restricted, + sc_bool_t grant, sc_bool_t coherent) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_ALLOC; - RPC_U8(&msg, 0) = (uint8_t)secure; - RPC_U8(&msg, 1) = (uint8_t)isolated; - RPC_U8(&msg, 2) = (uint8_t)restricted; - RPC_U8(&msg, 3) = (uint8_t)grant; - RPC_U8(&msg, 4) = (uint8_t)coherent; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_PARTITION_ALLOC); + RPC_U8(&msg, 0U) = B2U8(secure); + RPC_U8(&msg, 1U) = B2U8(isolated); + RPC_U8(&msg, 2U) = B2U8(restricted); + RPC_U8(&msg, 3U) = B2U8(grant); + RPC_U8(&msg, 4U) = B2U8(coherent); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (pt != NULL) { - *pt = RPC_U8(&msg, 0); + *pt = RPC_U8(&msg, 0U); } return (sc_err_t)result; } -sc_err_t sc_rm_set_confidential(sc_ipc_t ipc, sc_rm_pt_t pt, bool retro) +sc_err_t sc_rm_set_confidential(sc_ipc_t ipc, sc_rm_pt_t pt, sc_bool_t retro) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_CONFIDENTIAL; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = (uint8_t)retro; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_CONFIDENTIAL); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = B2U8(retro); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -77,12 +77,12 @@ sc_err_t sc_rm_partition_free(sc_ipc_t ipc, sc_rm_pt_t pt) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_FREE; - RPC_U8(&msg, 0) = pt; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_PARTITION_FREE); + RPC_U8(&msg, 0U) = U8(pt); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -94,11 +94,11 @@ sc_rm_did_t sc_rm_get_did(sc_ipc_t ipc) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_DID; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_GET_DID); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_rm_did_t) result; @@ -110,13 +110,13 @@ sc_err_t sc_rm_partition_static(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_did_t did) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_STATIC; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = did; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_PARTITION_STATIC); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(did); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -128,12 +128,12 @@ sc_err_t sc_rm_partition_lock(sc_ipc_t ipc, sc_rm_pt_t pt) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_PARTITION_LOCK; - RPC_U8(&msg, 0) = pt; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_PARTITION_LOCK); + RPC_U8(&msg, 0U) = U8(pt); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -145,15 +145,15 @@ sc_err_t sc_rm_get_partition(sc_ipc_t ipc, sc_rm_pt_t *pt) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_PARTITION; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_GET_PARTITION); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (pt != NULL) { - *pt = RPC_U8(&msg, 0); + *pt = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -165,34 +165,34 @@ sc_err_t sc_rm_set_parent(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_pt_t pt_parent) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_PARENT; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = pt_parent; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_PARENT); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(pt_parent); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_rm_move_all(sc_ipc_t ipc, sc_rm_pt_t pt_src, sc_rm_pt_t pt_dst, - bool move_rsrc, bool move_pads) + sc_bool_t move_rsrc, sc_bool_t move_pads) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MOVE_ALL; - RPC_U8(&msg, 0) = pt_src; - RPC_U8(&msg, 1) = pt_dst; - RPC_U8(&msg, 2) = (uint8_t)move_rsrc; - RPC_U8(&msg, 3) = (uint8_t)move_pads; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_MOVE_ALL); + RPC_U8(&msg, 0U) = U8(pt_src); + RPC_U8(&msg, 1U) = U8(pt_dst); + RPC_U8(&msg, 2U) = B2U8(move_rsrc); + RPC_U8(&msg, 3U) = B2U8(move_pads); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -204,52 +204,52 @@ sc_err_t sc_rm_assign_resource(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rsrc_t resource) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_ASSIGN_RESOURCE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = pt; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_ASSIGN_RESOURCE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(pt); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_rm_set_resource_movable(sc_ipc_t ipc, sc_rsrc_t resource_fst, - sc_rsrc_t resource_lst, bool movable) + sc_rsrc_t resource_lst, sc_bool_t movable) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_RESOURCE_MOVABLE; - RPC_U16(&msg, 0) = resource_fst; - RPC_U16(&msg, 2) = resource_lst; - RPC_U8(&msg, 4) = (uint8_t)movable; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_RESOURCE_MOVABLE); + RPC_U16(&msg, 0U) = U16(resource_fst); + RPC_U16(&msg, 2U) = U16(resource_lst); + RPC_U8(&msg, 4U) = B2U8(movable); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_rm_set_subsys_rsrc_movable(sc_ipc_t ipc, sc_rsrc_t resource, - bool movable) + sc_bool_t movable) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_SUBSYS_RSRC_MOVABLE; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = (uint8_t)movable; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_SUBSYS_RSRC_MOVABLE); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = B2U8(movable); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -257,21 +257,21 @@ sc_err_t sc_rm_set_subsys_rsrc_movable(sc_ipc_t ipc, sc_rsrc_t resource, sc_err_t sc_rm_set_master_attributes(sc_ipc_t ipc, sc_rsrc_t resource, sc_rm_spa_t sa, sc_rm_spa_t pa, - bool smmu_bypass) + sc_bool_t smmu_bypass) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_MASTER_ATTRIBUTES; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = sa; - RPC_U8(&msg, 3) = pa; - RPC_U8(&msg, 4) = (uint8_t)smmu_bypass; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_MASTER_ATTRIBUTES); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(sa); + RPC_U8(&msg, 3U) = U8(pa); + RPC_U8(&msg, 4U) = B2U8(smmu_bypass); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -283,13 +283,13 @@ sc_err_t sc_rm_set_master_sid(sc_ipc_t ipc, sc_rsrc_t resource, sc_rm_sid_t sid) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_MASTER_SID; - RPC_U16(&msg, 0) = resource; - RPC_U16(&msg, 2) = sid; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_MASTER_SID); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U16(&msg, 2U) = U16(sid); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -302,68 +302,68 @@ sc_err_t sc_rm_set_peripheral_permissions(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_PERIPHERAL_PERMISSIONS; - RPC_U16(&msg, 0) = resource; - RPC_U8(&msg, 2) = pt; - RPC_U8(&msg, 3) = perm; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_PERIPHERAL_PERMISSIONS); + RPC_U16(&msg, 0U) = U16(resource); + RPC_U8(&msg, 2U) = U8(pt); + RPC_U8(&msg, 3U) = U8(perm); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } -bool sc_rm_is_resource_owned(sc_ipc_t ipc, sc_rsrc_t resource) +sc_bool_t sc_rm_is_resource_owned(sc_ipc_t ipc, sc_rsrc_t resource) { sc_rpc_msg_t msg; - uint8_t result; + sc_bool_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_RESOURCE_OWNED; - RPC_U16(&msg, 0) = resource; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_IS_RESOURCE_OWNED); + RPC_U16(&msg, 0U) = U16(resource); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); - result = RPC_R8(&msg); - return (bool)result; + result = U2B(RPC_R8(&msg)); + return result; } -bool sc_rm_is_resource_master(sc_ipc_t ipc, sc_rsrc_t resource) +sc_bool_t sc_rm_is_resource_master(sc_ipc_t ipc, sc_rsrc_t resource) { sc_rpc_msg_t msg; - uint8_t result; + sc_bool_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_RESOURCE_MASTER; - RPC_U16(&msg, 0) = resource; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_IS_RESOURCE_MASTER); + RPC_U16(&msg, 0U) = U16(resource); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); - result = RPC_R8(&msg); - return (bool)result; + result = U2B(RPC_R8(&msg)); + return result; } -bool sc_rm_is_resource_peripheral(sc_ipc_t ipc, sc_rsrc_t resource) +sc_bool_t sc_rm_is_resource_peripheral(sc_ipc_t ipc, sc_rsrc_t resource) { sc_rpc_msg_t msg; - uint8_t result; + sc_bool_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_RESOURCE_PERIPHERAL; - RPC_U16(&msg, 0) = resource; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_IS_RESOURCE_PERIPHERAL); + RPC_U16(&msg, 0U) = U16(resource); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); - result = RPC_R8(&msg); - return (bool)result; + result = U2B(RPC_R8(&msg)); + return result; } sc_err_t sc_rm_get_resource_info(sc_ipc_t ipc, sc_rsrc_t resource, @@ -373,15 +373,15 @@ sc_err_t sc_rm_get_resource_info(sc_ipc_t ipc, sc_rsrc_t resource, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_RESOURCE_INFO; - RPC_U16(&msg, 0) = resource; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_GET_RESOURCE_INFO); + RPC_U16(&msg, 0U) = U16(resource); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (sid != NULL) { - *sid = RPC_U16(&msg, 0); + *sid = RPC_U16(&msg, 0U); } result = RPC_R8(&msg); @@ -395,19 +395,19 @@ sc_err_t sc_rm_memreg_alloc(sc_ipc_t ipc, sc_rm_mr_t *mr, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MEMREG_ALLOC; - RPC_U32(&msg, 0) = (uint32_t)(addr_start >> 32u); - RPC_U32(&msg, 4) = (uint32_t)addr_start; - RPC_U32(&msg, 8) = (uint32_t)(addr_end >> 32u); - RPC_U32(&msg, 12) = (uint32_t)addr_end; - RPC_SIZE(&msg) = 5; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_MEMREG_ALLOC); + RPC_U32(&msg, 0U) = U32(addr_start >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr_start); + RPC_U32(&msg, 8U) = U32(addr_end >> 32ULL); + RPC_U32(&msg, 12U) = U32(addr_end); + RPC_SIZE(&msg) = 5U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (mr != NULL) { - *mr = RPC_U8(&msg, 0); + *mr = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -421,20 +421,45 @@ sc_err_t sc_rm_memreg_split(sc_ipc_t ipc, sc_rm_mr_t mr, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MEMREG_SPLIT; - RPC_U32(&msg, 0) = (uint32_t)(addr_start >> 32u); - RPC_U32(&msg, 4) = (uint32_t)addr_start; - RPC_U32(&msg, 8) = (uint32_t)(addr_end >> 32u); - RPC_U32(&msg, 12) = (uint32_t)addr_end; - RPC_U8(&msg, 16) = mr; - RPC_SIZE(&msg) = 6; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_MEMREG_SPLIT); + RPC_U32(&msg, 0U) = U32(addr_start >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr_start); + RPC_U32(&msg, 8U) = U32(addr_end >> 32ULL); + RPC_U32(&msg, 12U) = U32(addr_end); + RPC_U8(&msg, 16U) = U8(mr); + RPC_SIZE(&msg) = 6U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (mr_ret != NULL) { - *mr_ret = RPC_U8(&msg, 0); + *mr_ret = RPC_U8(&msg, 0U); + } + + return (sc_err_t)result; +} + +sc_err_t sc_rm_memreg_frag(sc_ipc_t ipc, sc_rm_mr_t *mr_ret, + sc_faddr_t addr_start, sc_faddr_t addr_end) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_MEMREG_FRAG); + RPC_U32(&msg, 0U) = U32(addr_start >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr_start); + RPC_U32(&msg, 8U) = U32(addr_end >> 32ULL); + RPC_U32(&msg, 12U) = U32(addr_end); + RPC_SIZE(&msg) = 5U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + if (mr_ret != NULL) { + *mr_ret = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -446,12 +471,12 @@ sc_err_t sc_rm_memreg_free(sc_ipc_t ipc, sc_rm_mr_t mr) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_MEMREG_FREE; - RPC_U8(&msg, 0) = mr; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_MEMREG_FREE); + RPC_U8(&msg, 0U) = U8(mr); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -464,19 +489,19 @@ sc_err_t sc_rm_find_memreg(sc_ipc_t ipc, sc_rm_mr_t *mr, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_FIND_MEMREG; - RPC_U32(&msg, 0) = (uint32_t)(addr_start >> 32u); - RPC_U32(&msg, 4) = (uint32_t)addr_start; - RPC_U32(&msg, 8) = (uint32_t)(addr_end >> 32u); - RPC_U32(&msg, 12) = (uint32_t)addr_end; - RPC_SIZE(&msg) = 5; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_FIND_MEMREG); + RPC_U32(&msg, 0U) = U32(addr_start >> 32ULL); + RPC_U32(&msg, 4U) = U32(addr_start); + RPC_U32(&msg, 8U) = U32(addr_end >> 32ULL); + RPC_U32(&msg, 12U) = U32(addr_end); + RPC_SIZE(&msg) = 5U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); if (mr != NULL) { - *mr = RPC_U8(&msg, 0); + *mr = RPC_U8(&msg, 0U); } return (sc_err_t)result; @@ -488,13 +513,13 @@ sc_err_t sc_rm_assign_memreg(sc_ipc_t ipc, sc_rm_pt_t pt, sc_rm_mr_t mr) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_ASSIGN_MEMREG; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = mr; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_ASSIGN_MEMREG); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(mr); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -507,34 +532,34 @@ sc_err_t sc_rm_set_memreg_permissions(sc_ipc_t ipc, sc_rm_mr_t mr, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_MEMREG_PERMISSIONS; - RPC_U8(&msg, 0) = mr; - RPC_U8(&msg, 1) = pt; - RPC_U8(&msg, 2) = perm; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_MEMREG_PERMISSIONS); + RPC_U8(&msg, 0U) = U8(mr); + RPC_U8(&msg, 1U) = U8(pt); + RPC_U8(&msg, 2U) = U8(perm); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } -bool sc_rm_is_memreg_owned(sc_ipc_t ipc, sc_rm_mr_t mr) +sc_bool_t sc_rm_is_memreg_owned(sc_ipc_t ipc, sc_rm_mr_t mr) { sc_rpc_msg_t msg; - uint8_t result; + sc_bool_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_MEMREG_OWNED; - RPC_U8(&msg, 0) = mr; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_IS_MEMREG_OWNED); + RPC_U8(&msg, 0U) = U8(mr); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); - result = RPC_R8(&msg); - return (bool)result; + result = U2B(RPC_R8(&msg)); + return result; } sc_err_t sc_rm_get_memreg_info(sc_ipc_t ipc, sc_rm_mr_t mr, @@ -544,21 +569,21 @@ sc_err_t sc_rm_get_memreg_info(sc_ipc_t ipc, sc_rm_mr_t mr, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_GET_MEMREG_INFO; - RPC_U8(&msg, 0) = mr; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_GET_MEMREG_INFO); + RPC_U8(&msg, 0U) = U8(mr); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (addr_start != NULL) { *addr_start = - ((uint64_t) RPC_U32(&msg, 0) << 32u) | RPC_U32(&msg, 4); + ((uint64_t) RPC_U32(&msg, 0U) << 32U) | RPC_U32(&msg, 4U); } if (addr_end != NULL) { *addr_end = - ((uint64_t) RPC_U32(&msg, 8) << 32u) | RPC_U32(&msg, 12); + ((uint64_t) RPC_U32(&msg, 8U) << 32U) | RPC_U32(&msg, 12U); } result = RPC_R8(&msg); @@ -571,53 +596,53 @@ sc_err_t sc_rm_assign_pad(sc_ipc_t ipc, sc_rm_pt_t pt, sc_pad_t pad) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_ASSIGN_PAD; - RPC_U16(&msg, 0) = pad; - RPC_U8(&msg, 2) = pt; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_ASSIGN_PAD); + RPC_U16(&msg, 0U) = U16(pad); + RPC_U8(&msg, 2U) = U8(pt); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } sc_err_t sc_rm_set_pad_movable(sc_ipc_t ipc, sc_pad_t pad_fst, - sc_pad_t pad_lst, bool movable) + sc_pad_t pad_lst, sc_bool_t movable) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_SET_PAD_MOVABLE; - RPC_U16(&msg, 0) = pad_fst; - RPC_U16(&msg, 2) = pad_lst; - RPC_U8(&msg, 4) = (uint8_t)movable; - RPC_SIZE(&msg) = 3; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_SET_PAD_MOVABLE); + RPC_U16(&msg, 0U) = U16(pad_fst); + RPC_U16(&msg, 2U) = U16(pad_lst); + RPC_U8(&msg, 4U) = B2U8(movable); + RPC_SIZE(&msg) = 3U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } -bool sc_rm_is_pad_owned(sc_ipc_t ipc, sc_pad_t pad) +sc_bool_t sc_rm_is_pad_owned(sc_ipc_t ipc, sc_pad_t pad) { sc_rpc_msg_t msg; - uint8_t result; + sc_bool_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_IS_PAD_OWNED; - RPC_U8(&msg, 0) = pad; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_IS_PAD_OWNED); + RPC_U8(&msg, 0U) = U8(pad); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); - result = RPC_R8(&msg); - return (bool)result; + result = U2B(RPC_R8(&msg)); + return result; } void sc_rm_dump(sc_ipc_t ipc) @@ -625,11 +650,11 @@ void sc_rm_dump(sc_ipc_t ipc) sc_rpc_msg_t msg; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_RM; - RPC_FUNC(&msg) = (uint8_t)RM_FUNC_DUMP; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_RM); + RPC_FUNC(&msg) = U8(RM_FUNC_DUMP); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); return; } diff --git a/drivers/soc/imx/sc/svc/timer/rpc.h b/drivers/soc/imx/sc/svc/timer/rpc.h index 42413a049ea4..3d15d877471e 100644 --- a/drivers/soc/imx/sc/svc/timer/rpc.h +++ b/drivers/soc/imx/sc/svc/timer/rpc.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -12,34 +12,39 @@ * @{ */ -#ifndef _SC_TIMER_RPC_H -#define _SC_TIMER_RPC_H +#ifndef SC_TIMER_RPC_H +#define SC_TIMER_RPC_H /* Includes */ /* Defines */ -/* Types */ - /*! - * This type is used to indicate RPC TIMER function calls. + * @name Defines for RPC TIMER function calls */ -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 */ - TIMER_FUNC_GET_WDOG_STATUS = 5, /* Index for timer_get_wdog_status() RPC call */ - TIMER_FUNC_PT_GET_WDOG_STATUS = 13, /* Index for timer_pt_get_wdog_status() RPC call */ - TIMER_FUNC_SET_WDOG_ACTION = 10, /* Index for timer_set_wdog_action() RPC call */ - TIMER_FUNC_SET_RTC_TIME = 6, /* Index for timer_set_rtc_time() RPC call */ - TIMER_FUNC_GET_RTC_TIME = 7, /* Index for timer_get_rtc_time() RPC call */ - TIMER_FUNC_GET_RTC_SEC1970 = 9, /* Index for timer_get_rtc_sec1970() RPC call */ - TIMER_FUNC_SET_RTC_ALARM = 8, /* Index for timer_set_rtc_alarm() RPC call */ - TIMER_FUNC_SET_RTC_CALB = 11, /* Index for timer_set_rtc_calb() RPC call */ -} timer_func_t; +/*@{*/ +#define TIMER_FUNC_UNKNOWN 0 /* Unknown function */ +#define TIMER_FUNC_SET_WDOG_TIMEOUT 1U /* Index for timer_set_wdog_timeout() RPC call */ +#define TIMER_FUNC_SET_WDOG_PRE_TIMEOUT 12U /* Index for timer_set_wdog_pre_timeout() RPC call */ +#define TIMER_FUNC_START_WDOG 2U /* Index for timer_start_wdog() RPC call */ +#define TIMER_FUNC_STOP_WDOG 3U /* Index for timer_stop_wdog() RPC call */ +#define TIMER_FUNC_PING_WDOG 4U /* Index for timer_ping_wdog() RPC call */ +#define TIMER_FUNC_GET_WDOG_STATUS 5U /* Index for timer_get_wdog_status() RPC call */ +#define TIMER_FUNC_PT_GET_WDOG_STATUS 13U /* Index for timer_pt_get_wdog_status() RPC call */ +#define TIMER_FUNC_SET_WDOG_ACTION 10U /* Index for timer_set_wdog_action() RPC call */ +#define TIMER_FUNC_SET_RTC_TIME 6U /* Index for timer_set_rtc_time() RPC call */ +#define TIMER_FUNC_GET_RTC_TIME 7U /* Index for timer_get_rtc_time() RPC call */ +#define TIMER_FUNC_GET_RTC_SEC1970 9U /* Index for timer_get_rtc_sec1970() RPC call */ +#define TIMER_FUNC_SET_RTC_ALARM 8U /* Index for timer_set_rtc_alarm() RPC call */ +#define TIMER_FUNC_SET_RTC_PERIODIC_ALARM 14U /* Index for timer_set_rtc_periodic_alarm() RPC call */ +#define TIMER_FUNC_CANCEL_RTC_ALARM 15U /* Index for timer_cancel_rtc_alarm() RPC call */ +#define TIMER_FUNC_SET_RTC_CALB 11U /* Index for timer_set_rtc_calb() RPC call */ +#define TIMER_FUNC_SET_SYSCTR_ALARM 16U /* Index for timer_set_sysctr_alarm() RPC call */ +#define TIMER_FUNC_SET_SYSCTR_PERIODIC_ALARM 17U /* Index for timer_set_sysctr_periodic_alarm() RPC call */ +#define TIMER_FUNC_CANCEL_SYSCTR_ALARM 18U /* Index for timer_cancel_sysctr_alarm() RPC call */ +/*@}*/ + +/* Types */ /* Functions */ @@ -51,14 +56,6 @@ typedef enum timer_func_e { */ void timer_dispatch(sc_rm_pt_t caller_pt, sc_rpc_msg_t *msg); -/*! - * This function translates and dispatches an TIMER RPC request. - * - * @param[in] ipc IPC handle - * @param[in] msg pointer to RPC message - */ -void timer_xlate(sc_ipc_t ipc, sc_rpc_msg_t *msg); - -#endif /* _SC_TIMER_RPC_H */ +#endif /* SC_TIMER_RPC_H */ /**@}*/ diff --git a/drivers/soc/imx/sc/svc/timer/rpc_clnt.c b/drivers/soc/imx/sc/svc/timer/rpc_clnt.c index badb79e44c41..fe9fdab6f644 100644 --- a/drivers/soc/imx/sc/svc/timer/rpc_clnt.c +++ b/drivers/soc/imx/sc/svc/timer/rpc_clnt.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017 NXP + * Copyright 2017-2018 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -33,12 +33,12 @@ sc_err_t sc_timer_set_wdog_timeout(sc_ipc_t ipc, sc_timer_wdog_time_t timeout) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_SET_WDOG_TIMEOUT; - RPC_U32(&msg, 0) = timeout; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_WDOG_TIMEOUT); + RPC_U32(&msg, 0U) = U32(timeout); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -51,29 +51,29 @@ sc_err_t sc_timer_set_wdog_pre_timeout(sc_ipc_t ipc, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_SET_WDOG_PRE_TIMEOUT; - RPC_U32(&msg, 0) = pre_timeout; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_WDOG_PRE_TIMEOUT); + RPC_U32(&msg, 0U) = U32(pre_timeout); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; } -sc_err_t sc_timer_start_wdog(sc_ipc_t ipc, bool lock) +sc_err_t sc_timer_start_wdog(sc_ipc_t ipc, sc_bool_t lock) { sc_rpc_msg_t msg; uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_START_WDOG; - RPC_U8(&msg, 0) = (uint8_t)lock; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_START_WDOG); + RPC_U8(&msg, 0U) = B2U8(lock); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -85,11 +85,11 @@ sc_err_t sc_timer_stop_wdog(sc_ipc_t ipc) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_STOP_WDOG; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_STOP_WDOG); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -101,11 +101,11 @@ sc_err_t sc_timer_ping_wdog(sc_ipc_t ipc) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_PING_WDOG; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_PING_WDOG); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -120,29 +120,30 @@ sc_err_t sc_timer_get_wdog_status(sc_ipc_t ipc, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_GET_WDOG_STATUS; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_GET_WDOG_STATUS); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (timeout != NULL) { - *timeout = RPC_U32(&msg, 0); + *timeout = RPC_U32(&msg, 0U); } if (max_timeout != NULL) { - *max_timeout = RPC_U32(&msg, 4); + *max_timeout = RPC_U32(&msg, 4U); } if (remaining_time != NULL) { - *remaining_time = RPC_U32(&msg, 8); + *remaining_time = RPC_U32(&msg, 8U); } result = RPC_R8(&msg); return (sc_err_t)result; } -sc_err_t sc_timer_pt_get_wdog_status(sc_ipc_t ipc, sc_rm_pt_t pt, bool *enb, +sc_err_t sc_timer_pt_get_wdog_status(sc_ipc_t ipc, sc_rm_pt_t pt, + sc_bool_t *enb, sc_timer_wdog_time_t *timeout, sc_timer_wdog_time_t *remaining_time) { @@ -150,24 +151,24 @@ sc_err_t sc_timer_pt_get_wdog_status(sc_ipc_t ipc, sc_rm_pt_t pt, bool *enb, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_PT_GET_WDOG_STATUS; - RPC_U8(&msg, 0) = pt; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_PT_GET_WDOG_STATUS); + RPC_U8(&msg, 0U) = U8(pt); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (timeout != NULL) { - *timeout = RPC_U32(&msg, 0); + *timeout = RPC_U32(&msg, 0U); } if (remaining_time != NULL) { - *remaining_time = RPC_U32(&msg, 4); + *remaining_time = RPC_U32(&msg, 4U); } result = RPC_R8(&msg); if (enb != NULL) { - *enb = RPC_U8(&msg, 8); + *enb = U2B(RPC_U8(&msg, 8U)); } return (sc_err_t)result; @@ -180,13 +181,13 @@ sc_err_t sc_timer_set_wdog_action(sc_ipc_t ipc, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_SET_WDOG_ACTION; - RPC_U8(&msg, 0) = pt; - RPC_U8(&msg, 1) = action; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_WDOG_ACTION); + RPC_U8(&msg, 0U) = U8(pt); + RPC_U8(&msg, 1U) = U8(action); + RPC_SIZE(&msg) = 2U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -200,17 +201,17 @@ sc_err_t sc_timer_set_rtc_time(sc_ipc_t ipc, uint16_t year, uint8_t mon, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_SET_RTC_TIME; - RPC_U16(&msg, 0) = year; - RPC_U8(&msg, 2) = mon; - RPC_U8(&msg, 3) = day; - RPC_U8(&msg, 4) = hour; - RPC_U8(&msg, 5) = min; - RPC_U8(&msg, 6) = sec; - RPC_SIZE(&msg) = 3; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_RTC_TIME); + RPC_U16(&msg, 0U) = U16(year); + RPC_U8(&msg, 2U) = U8(mon); + RPC_U8(&msg, 3U) = U8(day); + RPC_U8(&msg, 4U) = U8(hour); + RPC_U8(&msg, 5U) = U8(min); + RPC_U8(&msg, 6U) = U8(sec); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -224,35 +225,35 @@ sc_err_t sc_timer_get_rtc_time(sc_ipc_t ipc, uint16_t *year, uint8_t *mon, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_GET_RTC_TIME; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_GET_RTC_TIME); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (year != NULL) { - *year = RPC_U16(&msg, 0); + *year = RPC_U16(&msg, 0U); } result = RPC_R8(&msg); if (mon != NULL) { - *mon = RPC_U8(&msg, 2); + *mon = RPC_U8(&msg, 2U); } if (day != NULL) { - *day = RPC_U8(&msg, 3); + *day = RPC_U8(&msg, 3U); } if (hour != NULL) { - *hour = RPC_U8(&msg, 4); + *hour = RPC_U8(&msg, 4U); } if (min != NULL) { - *min = RPC_U8(&msg, 5); + *min = RPC_U8(&msg, 5U); } if (sec != NULL) { - *sec = RPC_U8(&msg, 6); + *sec = RPC_U8(&msg, 6U); } return (sc_err_t)result; @@ -264,14 +265,14 @@ sc_err_t sc_timer_get_rtc_sec1970(sc_ipc_t ipc, uint32_t *sec) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_GET_RTC_SEC1970; - RPC_SIZE(&msg) = 1; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_GET_RTC_SEC1970); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); if (sec != NULL) { - *sec = RPC_U32(&msg, 0); + *sec = RPC_U32(&msg, 0U); } result = RPC_R8(&msg); @@ -286,17 +287,50 @@ sc_err_t sc_timer_set_rtc_alarm(sc_ipc_t ipc, uint16_t year, uint8_t mon, uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_SET_RTC_ALARM; - RPC_U16(&msg, 0) = year; - RPC_U8(&msg, 2) = mon; - RPC_U8(&msg, 3) = day; - RPC_U8(&msg, 4) = hour; - RPC_U8(&msg, 5) = min; - RPC_U8(&msg, 6) = sec; - RPC_SIZE(&msg) = 3; - - sc_call_rpc(ipc, &msg, false); + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_RTC_ALARM); + RPC_U16(&msg, 0U) = U16(year); + RPC_U8(&msg, 2U) = U8(mon); + RPC_U8(&msg, 3U) = U8(day); + RPC_U8(&msg, 4U) = U8(hour); + RPC_U8(&msg, 5U) = U8(min); + RPC_U8(&msg, 6U) = U8(sec); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_timer_set_rtc_periodic_alarm(sc_ipc_t ipc, uint32_t sec) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_RTC_PERIODIC_ALARM); + RPC_U32(&msg, 0U) = U32(sec); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_timer_cancel_rtc_alarm(sc_ipc_t ipc) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_CANCEL_RTC_ALARM); + RPC_SIZE(&msg) = 1U; + + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; @@ -308,12 +342,64 @@ sc_err_t sc_timer_set_rtc_calb(sc_ipc_t ipc, int8_t count) uint8_t result; RPC_VER(&msg) = SC_RPC_VERSION; - RPC_SVC(&msg) = (uint8_t)SC_RPC_SVC_TIMER; - RPC_FUNC(&msg) = (uint8_t)TIMER_FUNC_SET_RTC_CALB; - RPC_I8(&msg, 0) = count; - RPC_SIZE(&msg) = 2; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_RTC_CALB); + RPC_I8(&msg, 0U) = I8(count); + RPC_SIZE(&msg) = 2U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_timer_set_sysctr_alarm(sc_ipc_t ipc, uint64_t ticks) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_SYSCTR_ALARM); + RPC_U32(&msg, 0U) = U32(ticks >> 32ULL); + RPC_U32(&msg, 4U) = U32(ticks); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_timer_set_sysctr_periodic_alarm(sc_ipc_t ipc, uint64_t ticks) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_SET_SYSCTR_PERIODIC_ALARM); + RPC_U32(&msg, 0U) = U32(ticks >> 32ULL); + RPC_U32(&msg, 4U) = U32(ticks); + RPC_SIZE(&msg) = 3U; + + sc_call_rpc(ipc, &msg, SC_FALSE); + + result = RPC_R8(&msg); + return (sc_err_t)result; +} + +sc_err_t sc_timer_cancel_sysctr_alarm(sc_ipc_t ipc) +{ + sc_rpc_msg_t msg; + uint8_t result; + + RPC_VER(&msg) = SC_RPC_VERSION; + RPC_SVC(&msg) = U8(SC_RPC_SVC_TIMER); + RPC_FUNC(&msg) = U8(TIMER_FUNC_CANCEL_SYSCTR_ALARM); + RPC_SIZE(&msg) = 1U; - sc_call_rpc(ipc, &msg, false); + sc_call_rpc(ipc, &msg, SC_FALSE); result = RPC_R8(&msg); return (sc_err_t)result; diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c index 0fc298e9c700..331f93454a8b 100644 --- a/drivers/soc/imx/soc-imx8.c +++ b/drivers/soc/imx/soc-imx8.c @@ -24,6 +24,7 @@ #include <linux/platform_device.h> #include <linux/of.h> +#include <soc/imx8/sc/types.h> #include <soc/imx8/sc/sci.h> #include <soc/imx8/soc.h> #include <soc/imx/revision.h> |