xref: /openbmc/u-boot/include/remoteproc.h (revision 81ae6e6d0098c9ad7d6746b4f2952a046130999c)
183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2ddf56bc7SNishanth Menon /*
3ddf56bc7SNishanth Menon  * (C) Copyright 2015
4ddf56bc7SNishanth Menon  * Texas Instruments Incorporated - http://www.ti.com/
5ddf56bc7SNishanth Menon  */
6ddf56bc7SNishanth Menon 
7ddf56bc7SNishanth Menon #ifndef _RPROC_H_
8ddf56bc7SNishanth Menon #define _RPROC_H_
9ddf56bc7SNishanth Menon 
10ddf56bc7SNishanth Menon /*
11ddf56bc7SNishanth Menon  * Note: The platform data support is not meant for use with newer
12ddf56bc7SNishanth Menon  * platforms. This is meant only for legacy devices. This mode of
13ddf56bc7SNishanth Menon  * initialization *will* be eventually removed once all necessary
14ddf56bc7SNishanth Menon  * platforms have moved to dm/fdt.
15ddf56bc7SNishanth Menon  */
16ddf56bc7SNishanth Menon #include <dm/platdata.h>	/* For platform data support - non dt world */
17ddf56bc7SNishanth Menon 
18ddf56bc7SNishanth Menon /**
19ddf56bc7SNishanth Menon  * enum rproc_mem_type - What type of memory model does the rproc use
20ddf56bc7SNishanth Menon  * @RPROC_INTERNAL_MEMORY_MAPPED: Remote processor uses own memory and is memory
21ddf56bc7SNishanth Menon  *	mapped to the host processor over an address range.
22ddf56bc7SNishanth Menon  *
23ddf56bc7SNishanth Menon  * Please note that this is an enumeration of memory model of different types
24ddf56bc7SNishanth Menon  * of remote processors. Few of the remote processors do have own internal
25ddf56bc7SNishanth Menon  * memories, while others use external memory for instruction and data.
26ddf56bc7SNishanth Menon  */
27ddf56bc7SNishanth Menon enum rproc_mem_type {
28ddf56bc7SNishanth Menon 	RPROC_INTERNAL_MEMORY_MAPPED	= 0,
29ddf56bc7SNishanth Menon };
30ddf56bc7SNishanth Menon 
31ddf56bc7SNishanth Menon /**
32ddf56bc7SNishanth Menon  * struct dm_rproc_uclass_pdata - platform data for a CPU
33ddf56bc7SNishanth Menon  * @name: Platform-specific way of naming the Remote proc
34ddf56bc7SNishanth Menon  * @mem_type: one of 'enum rproc_mem_type'
35ddf56bc7SNishanth Menon  * @driver_plat_data: driver specific platform data that may be needed.
36ddf56bc7SNishanth Menon  *
37ddf56bc7SNishanth Menon  * This can be accessed with dev_get_uclass_platdata() for any UCLASS_REMOTEPROC
38ddf56bc7SNishanth Menon  * device.
39ddf56bc7SNishanth Menon  *
40ddf56bc7SNishanth Menon  */
41ddf56bc7SNishanth Menon struct dm_rproc_uclass_pdata {
42ddf56bc7SNishanth Menon 	const char *name;
43ddf56bc7SNishanth Menon 	enum rproc_mem_type mem_type;
44ddf56bc7SNishanth Menon 	void *driver_plat_data;
45ddf56bc7SNishanth Menon };
46ddf56bc7SNishanth Menon 
47ddf56bc7SNishanth Menon /**
48ddf56bc7SNishanth Menon  * struct dm_rproc_ops - Operations that are provided by remote proc driver
49ddf56bc7SNishanth Menon  * @init:	Initialize the remoteproc device invoked after probe (optional)
50ddf56bc7SNishanth Menon  *		Return 0 on success, -ve error on fail
51ddf56bc7SNishanth Menon  * @load:	Load the remoteproc device using data provided(mandatory)
52ddf56bc7SNishanth Menon  *		This takes the following additional arguments.
53ddf56bc7SNishanth Menon  *			addr- Address of the binary image to be loaded
54ddf56bc7SNishanth Menon  *			size- Size of the binary image to be loaded
55ddf56bc7SNishanth Menon  *		Return 0 on success, -ve error on fail
56ddf56bc7SNishanth Menon  * @start:	Start the remoteproc device (mandatory)
57ddf56bc7SNishanth Menon  *		Return 0 on success, -ve error on fail
58ddf56bc7SNishanth Menon  * @stop:	Stop the remoteproc device (optional)
59ddf56bc7SNishanth Menon  *		Return 0 on success, -ve error on fail
60ddf56bc7SNishanth Menon  * @reset:	Reset the remote proc device (optional)
61ddf56bc7SNishanth Menon  *		Return 0 on success, -ve error on fail
62ddf56bc7SNishanth Menon  * @is_running:	Check if the remote processor is running(optional)
63ddf56bc7SNishanth Menon  *		Return 0 on success, 1 if not running, -ve on others errors
64ddf56bc7SNishanth Menon  * @ping:	Ping the remote device for basic communication check(optional)
65ddf56bc7SNishanth Menon  *		Return 0 on success, 1 if not responding, -ve on other errors
66ddf56bc7SNishanth Menon  */
67ddf56bc7SNishanth Menon struct dm_rproc_ops {
68ddf56bc7SNishanth Menon 	int (*init)(struct udevice *dev);
69ddf56bc7SNishanth Menon 	int (*load)(struct udevice *dev, ulong addr, ulong size);
70ddf56bc7SNishanth Menon 	int (*start)(struct udevice *dev);
71ddf56bc7SNishanth Menon 	int (*stop)(struct udevice *dev);
72ddf56bc7SNishanth Menon 	int (*reset)(struct udevice *dev);
73ddf56bc7SNishanth Menon 	int (*is_running)(struct udevice *dev);
74ddf56bc7SNishanth Menon 	int (*ping)(struct udevice *dev);
75ddf56bc7SNishanth Menon };
76ddf56bc7SNishanth Menon 
77ddf56bc7SNishanth Menon /* Accessor */
78ddf56bc7SNishanth Menon #define rproc_get_ops(dev) ((struct dm_rproc_ops *)(dev)->driver->ops)
79ddf56bc7SNishanth Menon 
80ddf56bc7SNishanth Menon #ifdef CONFIG_REMOTEPROC
81ddf56bc7SNishanth Menon /**
82ddf56bc7SNishanth Menon  * rproc_init() - Initialize all bound remote proc devices
83ddf56bc7SNishanth Menon  *
84ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
85ddf56bc7SNishanth Menon  */
86ddf56bc7SNishanth Menon int rproc_init(void);
87ddf56bc7SNishanth Menon 
88ddf56bc7SNishanth Menon /**
89*81ae6e6dSLokesh Vutla  * rproc_dev_init() - Initialize a remote proc device based on id
90*81ae6e6dSLokesh Vutla  * @id:		id of the remote processor
91*81ae6e6dSLokesh Vutla  *
92*81ae6e6dSLokesh Vutla  * Return: 0 if all ok, else appropriate error value.
93*81ae6e6dSLokesh Vutla  */
94*81ae6e6dSLokesh Vutla int rproc_dev_init(int id);
95*81ae6e6dSLokesh Vutla 
96*81ae6e6dSLokesh Vutla /**
97ddf56bc7SNishanth Menon  * rproc_is_initialized() - check to see if remoteproc devices are initialized
98ddf56bc7SNishanth Menon  *
99ddf56bc7SNishanth Menon  * Return: 0 if all devices are initialized, else appropriate error value.
100ddf56bc7SNishanth Menon  */
101ddf56bc7SNishanth Menon bool rproc_is_initialized(void);
102ddf56bc7SNishanth Menon 
103ddf56bc7SNishanth Menon /**
104ddf56bc7SNishanth Menon  * rproc_load() - load binary to a remote processor
105ddf56bc7SNishanth Menon  * @id:		id of the remote processor
106ddf56bc7SNishanth Menon  * @addr:	address in memory where the binary image is located
107ddf56bc7SNishanth Menon  * @size:	size of the binary image
108ddf56bc7SNishanth Menon  *
109ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
110ddf56bc7SNishanth Menon  */
111ddf56bc7SNishanth Menon int rproc_load(int id, ulong addr, ulong size);
112ddf56bc7SNishanth Menon 
113ddf56bc7SNishanth Menon /**
114ddf56bc7SNishanth Menon  * rproc_start() - Start a remote processor
115ddf56bc7SNishanth Menon  * @id:		id of the remote processor
116ddf56bc7SNishanth Menon  *
117ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
118ddf56bc7SNishanth Menon  */
119ddf56bc7SNishanth Menon int rproc_start(int id);
120ddf56bc7SNishanth Menon 
121ddf56bc7SNishanth Menon /**
122ddf56bc7SNishanth Menon  * rproc_stop() - Stop a remote processor
123ddf56bc7SNishanth Menon  * @id:		id of the remote processor
124ddf56bc7SNishanth Menon  *
125ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
126ddf56bc7SNishanth Menon  */
127ddf56bc7SNishanth Menon int rproc_stop(int id);
128ddf56bc7SNishanth Menon 
129ddf56bc7SNishanth Menon /**
130ddf56bc7SNishanth Menon  * rproc_reset() - reset a remote processor
131ddf56bc7SNishanth Menon  * @id:		id of the remote processor
132ddf56bc7SNishanth Menon  *
133ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
134ddf56bc7SNishanth Menon  */
135ddf56bc7SNishanth Menon int rproc_reset(int id);
136ddf56bc7SNishanth Menon 
137ddf56bc7SNishanth Menon /**
138ddf56bc7SNishanth Menon  * rproc_ping() - ping a remote processor to check if it can communicate
139ddf56bc7SNishanth Menon  * @id:		id of the remote processor
140ddf56bc7SNishanth Menon  *
141ddf56bc7SNishanth Menon  * NOTE: this might need communication path available, which is not implemented
142ddf56bc7SNishanth Menon  * as part of remoteproc framework - hook on to appropriate bus architecture to
143ddf56bc7SNishanth Menon  * do the same
144ddf56bc7SNishanth Menon  *
145ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
146ddf56bc7SNishanth Menon  */
147ddf56bc7SNishanth Menon int rproc_ping(int id);
148ddf56bc7SNishanth Menon 
149ddf56bc7SNishanth Menon /**
150ddf56bc7SNishanth Menon  * rproc_is_running() - check to see if remote processor is running
151ddf56bc7SNishanth Menon  * @id:		id of the remote processor
152ddf56bc7SNishanth Menon  *
153ddf56bc7SNishanth Menon  * NOTE: this may not involve actual communication capability of the remote
154ddf56bc7SNishanth Menon  * processor, but just ensures that it is out of reset and executing code.
155ddf56bc7SNishanth Menon  *
156ddf56bc7SNishanth Menon  * Return: 0 if all ok, else appropriate error value.
157ddf56bc7SNishanth Menon  */
158ddf56bc7SNishanth Menon int rproc_is_running(int id);
159ddf56bc7SNishanth Menon #else
rproc_init(void)160ddf56bc7SNishanth Menon static inline int rproc_init(void) { return -ENOSYS; }
rproc_dev_init(int id)161*81ae6e6dSLokesh Vutla static inline int rproc_dev_init(int id) { return -ENOSYS; }
rproc_is_initialized(void)162ddf56bc7SNishanth Menon static inline bool rproc_is_initialized(void) { return false; }
rproc_load(int id,ulong addr,ulong size)163ddf56bc7SNishanth Menon static inline int rproc_load(int id, ulong addr, ulong size) { return -ENOSYS; }
rproc_start(int id)164ddf56bc7SNishanth Menon static inline int rproc_start(int id) { return -ENOSYS; }
rproc_stop(int id)165ddf56bc7SNishanth Menon static inline int rproc_stop(int id) { return -ENOSYS; }
rproc_reset(int id)166ddf56bc7SNishanth Menon static inline int rproc_reset(int id) { return -ENOSYS; }
rproc_ping(int id)167ddf56bc7SNishanth Menon static inline int rproc_ping(int id) { return -ENOSYS; }
rproc_is_running(int id)168ddf56bc7SNishanth Menon static inline int rproc_is_running(int id) { return -ENOSYS; }
169ddf56bc7SNishanth Menon #endif
170ddf56bc7SNishanth Menon 
171ddf56bc7SNishanth Menon #endif	/* _RPROC_H_ */
172