1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Texas Instruments TI-SCI Processor Controller Helper Functions
5 * Copyright (C) 2018-2019 Texas Instruments Incorporated - http://www.ti.com/
6 * Lokesh Vutla <lokeshvutla@ti.com>
7 * Suman Anna <s-anna@ti.com>
10 #ifndef REMOTEPROC_TI_SCI_PROC_H
11 #define REMOTEPROC_TI_SCI_PROC_H
13 #define TISCI_INVALID_HOST 0xff
16 * struct ti_sci_proc - structure representing a processor control client
17 * @sci: cached TI-SCI protocol handle
18 * @ops: cached TI-SCI proc ops
19 * @proc_id: processor id for the consumer remoteproc device
20 * @host_id: host id to pass the control over for this consumer remoteproc
24 const struct ti_sci_handle *sci;
25 const struct ti_sci_proc_ops *ops;
30 static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
34 debug("%s: proc_id = %d\n", __func__, tsp->proc_id);
36 ret = tsp->ops->proc_request(tsp->sci, tsp->proc_id);
38 pr_err("ti-sci processor request failed: %d\n", ret);
42 static inline int ti_sci_proc_release(struct ti_sci_proc *tsp)
46 debug("%s: proc_id = %d\n", __func__, tsp->proc_id);
48 if (tsp->host_id != TISCI_INVALID_HOST)
49 ret = tsp->ops->proc_handover(tsp->sci, tsp->proc_id,
52 ret = tsp->ops->proc_release(tsp->sci, tsp->proc_id);
55 pr_err("ti-sci processor release failed: %d\n", ret);
59 static inline int ti_sci_proc_handover(struct ti_sci_proc *tsp)
63 debug("%s: proc_id = %d\n", __func__, tsp->proc_id);
65 ret = tsp->ops->proc_handover(tsp->sci, tsp->proc_id, tsp->host_id);
67 pr_err("ti-sci processor handover of %d to %d failed: %d\n",
68 tsp->proc_id, tsp->host_id, ret);
72 static inline int ti_sci_proc_get_status(struct ti_sci_proc *tsp,
73 u64 *boot_vector, u32 *cfg_flags,
74 u32 *ctrl_flags, u32 *status_flags)
78 ret = tsp->ops->get_proc_boot_status(tsp->sci, tsp->proc_id,
79 boot_vector, cfg_flags, ctrl_flags,
82 pr_err("ti-sci processor get_status failed: %d\n", ret);
84 debug("%s: proc_id = %d, boot_vector = 0x%llx, cfg_flags = 0x%x, ctrl_flags = 0x%x, sts = 0x%x\n",
85 __func__, tsp->proc_id, *boot_vector, *cfg_flags, *ctrl_flags,
90 static inline int ti_sci_proc_set_config(struct ti_sci_proc *tsp,
92 u32 cfg_set, u32 cfg_clr)
96 debug("%s: proc_id = %d, boot_vector = 0x%llx, cfg_set = 0x%x, cfg_clr = 0x%x\n",
97 __func__, tsp->proc_id, boot_vector, cfg_set, cfg_clr);
99 ret = tsp->ops->set_proc_boot_cfg(tsp->sci, tsp->proc_id, boot_vector,
102 pr_err("ti-sci processor set_config failed: %d\n", ret);
106 static inline int ti_sci_proc_set_control(struct ti_sci_proc *tsp,
107 u32 ctrl_set, u32 ctrl_clr)
111 debug("%s: proc_id = %d, ctrl_set = 0x%x, ctrl_clr = 0x%x\n", __func__,
112 tsp->proc_id, ctrl_set, ctrl_clr);
114 ret = tsp->ops->set_proc_boot_ctrl(tsp->sci, tsp->proc_id, ctrl_set,
117 pr_err("ti-sci processor set_control failed: %d\n", ret);
121 #endif /* REMOTEPROC_TI_SCI_PROC_H */