1edbee095SDong Aisheng /* SPDX-License-Identifier: GPL-2.0+ */
2edbee095SDong Aisheng /*
3edbee095SDong Aisheng * Copyright 2018 NXP
4edbee095SDong Aisheng *
5edbee095SDong Aisheng * Header file for the IPC implementation.
6edbee095SDong Aisheng */
7edbee095SDong Aisheng
8edbee095SDong Aisheng #ifndef _SC_IPC_H
9edbee095SDong Aisheng #define _SC_IPC_H
10edbee095SDong Aisheng
11edbee095SDong Aisheng #include <linux/device.h>
12edbee095SDong Aisheng #include <linux/types.h>
13edbee095SDong Aisheng
14edbee095SDong Aisheng #define IMX_SC_RPC_VERSION 1
15edbee095SDong Aisheng #define IMX_SC_RPC_MAX_MSG 8
16edbee095SDong Aisheng
17edbee095SDong Aisheng struct imx_sc_ipc;
18edbee095SDong Aisheng
19edbee095SDong Aisheng enum imx_sc_rpc_svc {
20edbee095SDong Aisheng IMX_SC_RPC_SVC_UNKNOWN = 0,
21edbee095SDong Aisheng IMX_SC_RPC_SVC_RETURN = 1,
22edbee095SDong Aisheng IMX_SC_RPC_SVC_PM = 2,
23edbee095SDong Aisheng IMX_SC_RPC_SVC_RM = 3,
24edbee095SDong Aisheng IMX_SC_RPC_SVC_TIMER = 5,
25edbee095SDong Aisheng IMX_SC_RPC_SVC_PAD = 6,
26edbee095SDong Aisheng IMX_SC_RPC_SVC_MISC = 7,
27edbee095SDong Aisheng IMX_SC_RPC_SVC_IRQ = 8,
28edbee095SDong Aisheng };
29edbee095SDong Aisheng
30edbee095SDong Aisheng struct imx_sc_rpc_msg {
31edbee095SDong Aisheng uint8_t ver;
32edbee095SDong Aisheng uint8_t size;
33edbee095SDong Aisheng uint8_t svc;
34edbee095SDong Aisheng uint8_t func;
35edbee095SDong Aisheng };
36edbee095SDong Aisheng
37*95de5094SPeng Fan #ifdef CONFIG_IMX_SCU
38edbee095SDong Aisheng /*
39edbee095SDong Aisheng * This is an function to send an RPC message over an IPC channel.
40edbee095SDong Aisheng * It is called by client-side SCFW API function shims.
41edbee095SDong Aisheng *
42edbee095SDong Aisheng * @param[in] ipc IPC handle
43edbee095SDong Aisheng * @param[in,out] msg handle to a message
44edbee095SDong Aisheng * @param[in] have_resp response flag
45edbee095SDong Aisheng *
46edbee095SDong Aisheng * If have_resp is true then this function waits for a response
47edbee095SDong Aisheng * and returns the result in msg.
48edbee095SDong Aisheng */
49edbee095SDong Aisheng int imx_scu_call_rpc(struct imx_sc_ipc *ipc, void *msg, bool have_resp);
50edbee095SDong Aisheng
51edbee095SDong Aisheng /*
52edbee095SDong Aisheng * This function gets the default ipc handle used by SCU
53edbee095SDong Aisheng *
54edbee095SDong Aisheng * @param[out] ipc sc ipc handle
55edbee095SDong Aisheng *
56edbee095SDong Aisheng * @return Returns an error code (0 = success, failed if < 0)
57edbee095SDong Aisheng */
58edbee095SDong Aisheng int imx_scu_get_handle(struct imx_sc_ipc **ipc);
59*95de5094SPeng Fan #else
imx_scu_call_rpc(struct imx_sc_ipc * ipc,void * msg,bool have_resp)60*95de5094SPeng Fan static inline int imx_scu_call_rpc(struct imx_sc_ipc *ipc, void *msg,
61*95de5094SPeng Fan bool have_resp)
62*95de5094SPeng Fan {
63*95de5094SPeng Fan return -ENOTSUPP;
64*95de5094SPeng Fan }
65*95de5094SPeng Fan
imx_scu_get_handle(struct imx_sc_ipc ** ipc)66*95de5094SPeng Fan static inline int imx_scu_get_handle(struct imx_sc_ipc **ipc)
67*95de5094SPeng Fan {
68*95de5094SPeng Fan return -ENOTSUPP;
69*95de5094SPeng Fan }
70*95de5094SPeng Fan #endif
71edbee095SDong Aisheng #endif /* _SC_IPC_H */
72