1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Freescale Semiconductor, Inc.
4 * Copyright 2017~2018 NXP
5 * Author: Dong Aisheng <aisheng.dong@nxp.com>
7 * File containing client-side RPC functions for the MISC service. These
8 * function are ported to clients that communicate to the SC.
12 #include <linux/firmware/imx/svc/misc.h>
14 struct imx_sc_msg_req_misc_set_ctrl
{
15 struct imx_sc_rpc_msg hdr
;
21 struct imx_sc_msg_req_misc_get_ctrl
{
22 struct imx_sc_rpc_msg hdr
;
27 struct imx_sc_msg_resp_misc_get_ctrl
{
28 struct imx_sc_rpc_msg hdr
;
33 * This function sets a miscellaneous control value.
35 * @param[in] ipc IPC handle
36 * @param[in] resource resource the control is associated with
37 * @param[in] ctrl control to change
38 * @param[in] val value to apply to the control
40 * @return Returns 0 for success and < 0 for errors.
43 int imx_sc_misc_set_control(struct imx_sc_ipc
*ipc
, u32 resource
,
46 struct imx_sc_msg_req_misc_set_ctrl msg
;
47 struct imx_sc_rpc_msg
*hdr
= &msg
.hdr
;
49 hdr
->ver
= IMX_SC_RPC_VERSION
;
50 hdr
->svc
= (uint8_t)IMX_SC_RPC_SVC_MISC
;
51 hdr
->func
= (uint8_t)IMX_SC_MISC_FUNC_SET_CONTROL
;
56 msg
.resource
= resource
;
58 return imx_scu_call_rpc(ipc
, &msg
, true);
60 EXPORT_SYMBOL(imx_sc_misc_set_control
);
63 * This function gets a miscellaneous control value.
65 * @param[in] ipc IPC handle
66 * @param[in] resource resource the control is associated with
67 * @param[in] ctrl control to get
68 * @param[out] val pointer to return the control value
70 * @return Returns 0 for success and < 0 for errors.
73 int imx_sc_misc_get_control(struct imx_sc_ipc
*ipc
, u32 resource
,
76 struct imx_sc_msg_req_misc_get_ctrl msg
;
77 struct imx_sc_msg_resp_misc_get_ctrl
*resp
;
78 struct imx_sc_rpc_msg
*hdr
= &msg
.hdr
;
81 hdr
->ver
= IMX_SC_RPC_VERSION
;
82 hdr
->svc
= (uint8_t)IMX_SC_RPC_SVC_MISC
;
83 hdr
->func
= (uint8_t)IMX_SC_MISC_FUNC_GET_CONTROL
;
87 msg
.resource
= resource
;
89 ret
= imx_scu_call_rpc(ipc
, &msg
, true);
93 resp
= (struct imx_sc_msg_resp_misc_get_ctrl
*)&msg
;
99 EXPORT_SYMBOL(imx_sc_misc_get_control
);