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
22 * @dev_id: Device ID as identified by system controller.
25 const struct ti_sci_handle *sci;
26 const struct ti_sci_proc_ops *ops;
32 static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
36 debug("%s: proc_id = %d\n", __func__, tsp->proc_id);
38 ret = tsp->ops->proc_request(tsp->sci, tsp->proc_id);
40 pr_err("ti-sci processor request failed: %d\n", ret);
44 static inline int ti_sci_proc_release(struct ti_sci_proc *tsp)
48 debug("%s: proc_id = %d\n", __func__, tsp->proc_id);
50 if (tsp->host_id != TISCI_INVALID_HOST)
51 ret = tsp->ops->proc_handover(tsp->sci, tsp->proc_id,
54 ret = tsp->ops->proc_release(tsp->sci, tsp->proc_id);
57 pr_err("ti-sci processor release failed: %d\n", ret);
61 static inline int ti_sci_proc_handover(struct ti_sci_proc *tsp)
65 debug("%s: proc_id = %d\n", __func__, tsp->proc_id);
67 ret = tsp->ops->proc_handover(tsp->sci, tsp->proc_id, tsp->host_id);
69 pr_err("ti-sci processor handover of %d to %d failed: %d\n",
70 tsp->proc_id, tsp->host_id, ret);
74 static inline int ti_sci_proc_get_status(struct ti_sci_proc *tsp,
75 u64 *boot_vector, u32 *cfg_flags,
76 u32 *ctrl_flags, u32 *status_flags)
80 ret = tsp->ops->get_proc_boot_status(tsp->sci, tsp->proc_id,
81 boot_vector, cfg_flags, ctrl_flags,
84 pr_err("ti-sci processor get_status failed: %d\n", ret);
86 debug("%s: proc_id = %d, boot_vector = 0x%llx, cfg_flags = 0x%x, ctrl_flags = 0x%x, sts = 0x%x\n",
87 __func__, tsp->proc_id, *boot_vector, *cfg_flags, *ctrl_flags,
92 static inline int ti_sci_proc_set_config(struct ti_sci_proc *tsp,
94 u32 cfg_set, u32 cfg_clr)
98 debug("%s: proc_id = %d, boot_vector = 0x%llx, cfg_set = 0x%x, cfg_clr = 0x%x\n",
99 __func__, tsp->proc_id, boot_vector, cfg_set, cfg_clr);
101 ret = tsp->ops->set_proc_boot_cfg(tsp->sci, tsp->proc_id, boot_vector,
104 pr_err("ti-sci processor set_config failed: %d\n", ret);
108 static inline int ti_sci_proc_set_control(struct ti_sci_proc *tsp,
109 u32 ctrl_set, u32 ctrl_clr)
113 debug("%s: proc_id = %d, ctrl_set = 0x%x, ctrl_clr = 0x%x\n", __func__,
114 tsp->proc_id, ctrl_set, ctrl_clr);
116 ret = tsp->ops->set_proc_boot_ctrl(tsp->sci, tsp->proc_id, ctrl_set,
119 pr_err("ti-sci processor set_control failed: %d\n", ret);
123 static inline int ti_sci_proc_power_domain_on(struct ti_sci_proc *tsp)
127 debug("%s: dev_id = %d\n", __func__, tsp->dev_id);
129 ret = tsp->sci->ops.dev_ops.get_device_exclusive(tsp->sci, tsp->dev_id);
131 pr_err("Power-domain on failed for dev = %d\n", tsp->dev_id);
136 static inline int ti_sci_proc_power_domain_off(struct ti_sci_proc *tsp)
140 debug("%s: dev_id = %d\n", __func__, tsp->dev_id);
142 ret = tsp->sci->ops.dev_ops.put_device(tsp->sci, tsp->dev_id);
144 pr_err("Power-domain off failed for dev = %d\n", tsp->dev_id);
148 #endif /* REMOTEPROC_TI_SCI_PROC_H */