Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Texas Instruments TI-SCI Processor Controller Helper Functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	Suman Anna <s-anna@ti.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef REMOTEPROC_TI_SCI_PROC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define REMOTEPROC_TI_SCI_PROC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/soc/ti/ti_sci_protocol.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * struct ti_sci_proc - structure representing a processor control client
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * @sci: cached TI-SCI protocol handle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * @ops: cached TI-SCI proc ops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * @dev: cached client device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * @proc_id: processor id for the consumer remoteproc device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * @host_id: host id to pass the control over for this consumer remoteproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *	     device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct ti_sci_proc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	const struct ti_sci_handle *sci;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	const struct ti_sci_proc_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	u8 proc_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u8 host_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static inline int ti_sci_proc_request(struct ti_sci_proc *tsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	ret = tsp->ops->request(tsp->sci, tsp->proc_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		dev_err(tsp->dev, "ti-sci processor request failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static inline int ti_sci_proc_release(struct ti_sci_proc *tsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	ret = tsp->ops->release(tsp->sci, tsp->proc_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		dev_err(tsp->dev, "ti-sci processor release failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static inline int ti_sci_proc_handover(struct ti_sci_proc *tsp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	ret = tsp->ops->handover(tsp->sci, tsp->proc_id, tsp->host_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		dev_err(tsp->dev, "ti-sci processor handover of %d to %d failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			tsp->proc_id, tsp->host_id, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static inline int ti_sci_proc_set_config(struct ti_sci_proc *tsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 					 u64 boot_vector,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 					 u32 cfg_set, u32 cfg_clr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	ret = tsp->ops->set_config(tsp->sci, tsp->proc_id, boot_vector,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 				   cfg_set, cfg_clr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		dev_err(tsp->dev, "ti-sci processor set_config failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static inline int ti_sci_proc_set_control(struct ti_sci_proc *tsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 					  u32 ctrl_set, u32 ctrl_clr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	ret = tsp->ops->set_control(tsp->sci, tsp->proc_id, ctrl_set, ctrl_clr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		dev_err(tsp->dev, "ti-sci processor set_control failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) static inline int ti_sci_proc_get_status(struct ti_sci_proc *tsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 					 u64 *boot_vector, u32 *cfg_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 					 u32 *ctrl_flags, u32 *status_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	ret = tsp->ops->get_status(tsp->sci, tsp->proc_id, boot_vector,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 				   cfg_flags, ctrl_flags, status_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		dev_err(tsp->dev, "ti-sci processor get_status failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #endif /* REMOTEPROC_TI_SCI_PROC_H */