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