Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Texas Instruments TI-SCI Processor Controller Helper Functions
0004  *
0005  * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/
0006  *  Suman Anna <s-anna@ti.com>
0007  */
0008 
0009 #ifndef REMOTEPROC_TI_SCI_PROC_H
0010 #define REMOTEPROC_TI_SCI_PROC_H
0011 
0012 #include <linux/soc/ti/ti_sci_protocol.h>
0013 
0014 /**
0015  * struct ti_sci_proc - structure representing a processor control client
0016  * @sci: cached TI-SCI protocol handle
0017  * @ops: cached TI-SCI proc ops
0018  * @dev: cached client device pointer
0019  * @proc_id: processor id for the consumer remoteproc device
0020  * @host_id: host id to pass the control over for this consumer remoteproc
0021  *       device
0022  */
0023 struct ti_sci_proc {
0024     const struct ti_sci_handle *sci;
0025     const struct ti_sci_proc_ops *ops;
0026     struct device *dev;
0027     u8 proc_id;
0028     u8 host_id;
0029 };
0030 
0031 static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
0032 {
0033     int ret;
0034 
0035     ret = tsp->ops->request(tsp->sci, tsp->proc_id);
0036     if (ret)
0037         dev_err(tsp->dev, "ti-sci processor request failed: %d\n",
0038             ret);
0039     return ret;
0040 }
0041 
0042 static inline int ti_sci_proc_release(struct ti_sci_proc *tsp)
0043 {
0044     int ret;
0045 
0046     ret = tsp->ops->release(tsp->sci, tsp->proc_id);
0047     if (ret)
0048         dev_err(tsp->dev, "ti-sci processor release failed: %d\n",
0049             ret);
0050     return ret;
0051 }
0052 
0053 static inline int ti_sci_proc_handover(struct ti_sci_proc *tsp)
0054 {
0055     int ret;
0056 
0057     ret = tsp->ops->handover(tsp->sci, tsp->proc_id, tsp->host_id);
0058     if (ret)
0059         dev_err(tsp->dev, "ti-sci processor handover of %d to %d failed: %d\n",
0060             tsp->proc_id, tsp->host_id, ret);
0061     return ret;
0062 }
0063 
0064 static inline int ti_sci_proc_set_config(struct ti_sci_proc *tsp,
0065                      u64 boot_vector,
0066                      u32 cfg_set, u32 cfg_clr)
0067 {
0068     int ret;
0069 
0070     ret = tsp->ops->set_config(tsp->sci, tsp->proc_id, boot_vector,
0071                    cfg_set, cfg_clr);
0072     if (ret)
0073         dev_err(tsp->dev, "ti-sci processor set_config failed: %d\n",
0074             ret);
0075     return ret;
0076 }
0077 
0078 static inline int ti_sci_proc_set_control(struct ti_sci_proc *tsp,
0079                       u32 ctrl_set, u32 ctrl_clr)
0080 {
0081     int ret;
0082 
0083     ret = tsp->ops->set_control(tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr);
0084     if (ret)
0085         dev_err(tsp->dev, "ti-sci processor set_control failed: %d\n",
0086             ret);
0087     return ret;
0088 }
0089 
0090 static inline int ti_sci_proc_get_status(struct ti_sci_proc *tsp,
0091                      u64 *boot_vector, u32 *cfg_flags,
0092                      u32 *ctrl_flags, u32 *status_flags)
0093 {
0094     int ret;
0095 
0096     ret = tsp->ops->get_status(tsp->sci, tsp->proc_id, boot_vector,
0097                    cfg_flags, ctrl_flags, status_flags);
0098     if (ret)
0099         dev_err(tsp->dev, "ti-sci processor get_status failed: %d\n",
0100             ret);
0101     return ret;
0102 }
0103 
0104 #endif /* REMOTEPROC_TI_SCI_PROC_H */