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;
19 } __packed __aligned(4);
21 struct imx_sc_msg_req_cpu_start {
22 struct imx_sc_rpc_msg hdr;
27 } __packed __aligned(4);
29 struct imx_sc_msg_req_misc_get_ctrl {
30 struct imx_sc_rpc_msg hdr;
33 } __packed __aligned(4);
35 struct imx_sc_msg_resp_misc_get_ctrl {
36 struct imx_sc_rpc_msg hdr;
38 } __packed __aligned(4);
41 * This function sets a miscellaneous control value.
43 * @param[in] ipc IPC handle
44 * @param[in] resource resource the control is associated with
45 * @param[in] ctrl control to change
46 * @param[in] val value to apply to the control
48 * @return Returns 0 for success and < 0 for errors.
51 int imx_sc_misc_set_control(struct imx_sc_ipc *ipc, u32 resource,
54 struct imx_sc_msg_req_misc_set_ctrl msg;
55 struct imx_sc_rpc_msg *hdr = &msg.hdr;
57 hdr->ver = IMX_SC_RPC_VERSION;
58 hdr->svc = (uint8_t)IMX_SC_RPC_SVC_MISC;
59 hdr->func = (uint8_t)IMX_SC_MISC_FUNC_SET_CONTROL;
64 msg.resource = resource;
66 return imx_scu_call_rpc(ipc, &msg, true);
68 EXPORT_SYMBOL(imx_sc_misc_set_control);
71 * This function gets a miscellaneous control value.
73 * @param[in] ipc IPC handle
74 * @param[in] resource resource the control is associated with
75 * @param[in] ctrl control to get
76 * @param[out] val pointer to return the control value
78 * @return Returns 0 for success and < 0 for errors.
81 int imx_sc_misc_get_control(struct imx_sc_ipc *ipc, u32 resource,
84 struct imx_sc_msg_req_misc_get_ctrl msg;
85 struct imx_sc_msg_resp_misc_get_ctrl *resp;
86 struct imx_sc_rpc_msg *hdr = &msg.hdr;
89 hdr->ver = IMX_SC_RPC_VERSION;
90 hdr->svc = (uint8_t)IMX_SC_RPC_SVC_MISC;
91 hdr->func = (uint8_t)IMX_SC_MISC_FUNC_GET_CONTROL;
95 msg.resource = resource;
97 ret = imx_scu_call_rpc(ipc, &msg, true);
101 resp = (struct imx_sc_msg_resp_misc_get_ctrl *)&msg;
107 EXPORT_SYMBOL(imx_sc_misc_get_control);
110 * This function starts/stops a CPU identified by @resource
112 * @param[in] ipc IPC handle
113 * @param[in] resource resource the control is associated with
114 * @param[in] enable true for start, false for stop
115 * @param[in] phys_addr initial instruction address to be executed
117 * @return Returns 0 for success and < 0 for errors.
119 int imx_sc_pm_cpu_start(struct imx_sc_ipc *ipc, u32 resource,
120 bool enable, u64 phys_addr)
122 struct imx_sc_msg_req_cpu_start msg;
123 struct imx_sc_rpc_msg *hdr = &msg.hdr;
125 hdr->ver = IMX_SC_RPC_VERSION;
126 hdr->svc = IMX_SC_RPC_SVC_PM;
127 hdr->func = IMX_SC_PM_FUNC_CPU_START;
130 msg.address_hi = phys_addr >> 32;
131 msg.address_lo = phys_addr;
132 msg.resource = resource;
135 return imx_scu_call_rpc(ipc, &msg, true);
137 EXPORT_SYMBOL(imx_sc_pm_cpu_start);