1 /* SPDX-License-Identifier: GPL-2.0+ */
4 * Texas Instruments Incorporated - http://www.ti.com/
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.
16 #include <dm/platdata.h> /* For platform data support - non dt world */
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.
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.
28 RPROC_INTERNAL_MEMORY_MAPPED = 0,
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.
37 * This can be accessed with dev_get_uclass_plat() for any UCLASS_REMOTEPROC
41 struct dm_rproc_uclass_pdata {
43 enum rproc_mem_type mem_type;
44 void *driver_plat_data;
48 * struct dm_rproc_ops - Driver model remote proc operations.
50 * This defines the operations provided by remote proc driver.
54 * init() - Initialize the remoteproc device (optional)
56 * This is called after the probe is completed allowing the remote
57 * processor drivers to split up the initializations between probe and
60 * @dev: Remote proc device
61 * @return 0 if all ok, else appropriate error value.
63 int (*init)(struct udevice *dev);
66 * load() - Load the remoteproc device using data provided (mandatory)
68 * Load the remoteproc device with an image, do not start the device.
70 * @dev: Remote proc device
71 * @addr: Address of the image to be loaded
72 * @size: Size of the image to be loaded
73 * @return 0 if all ok, else appropriate error value.
75 int (*load)(struct udevice *dev, ulong addr, ulong size);
78 * start() - Start the remoteproc device (mandatory)
80 * @dev: Remote proc device
81 * @return 0 if all ok, else appropriate error value.
83 int (*start)(struct udevice *dev);
86 * stop() - Stop the remoteproc device (optional)
88 * @dev: Remote proc device
89 * @return 0 if all ok, else appropriate error value.
91 int (*stop)(struct udevice *dev);
94 * reset() - Reset the remoteproc device (optional)
96 * @dev: Remote proc device
97 * @return 0 if all ok, else appropriate error value.
99 int (*reset)(struct udevice *dev);
102 * is_running() - Check if the remote processor is running (optional)
104 * @dev: Remote proc device
105 * @return 0 if running, 1 if not running, -ve on error.
107 int (*is_running)(struct udevice *dev);
110 * ping() - Ping the remote device for basic communication (optional)
112 * @dev: Remote proc device
113 * @return 0 on success, 1 if not responding, -ve on other errors.
115 int (*ping)(struct udevice *dev);
118 * device_to_virt() - Return translated virtual address (optional)
120 * Translate a device address (remote processor view) to virtual
121 * address (main processor view).
123 * @dev: Remote proc device
124 * @da: Device address
125 * @size: Size of the memory region @da is pointing to
126 * @return virtual address.
128 void * (*device_to_virt)(struct udevice *dev, ulong da, ulong size);
132 #define rproc_get_ops(dev) ((struct dm_rproc_ops *)(dev)->driver->ops)
134 #if CONFIG_IS_ENABLED(REMOTEPROC)
136 * rproc_init() - Initialize all bound remote proc devices
137 * @return 0 if all ok, else appropriate error value.
139 int rproc_init(void);
142 * rproc_dev_init() - Initialize a remote proc device based on id
143 * @id: id of the remote processor
144 * @return 0 if all ok, else appropriate error value.
146 int rproc_dev_init(int id);
149 * rproc_is_initialized() - check to see if remoteproc devices are initialized
150 * @return true if all devices are initialized, false otherwise.
152 bool rproc_is_initialized(void);
155 * rproc_load() - load binary or elf to a remote processor
156 * @id: id of the remote processor
157 * @addr: address in memory where the image is located
158 * @size: size of the image
159 * @return 0 if all ok, else appropriate error value.
161 int rproc_load(int id, ulong addr, ulong size);
164 * rproc_start() - Start a remote processor
165 * @id: id of the remote processor
166 * @return 0 if all ok, else appropriate error value.
168 int rproc_start(int id);
171 * rproc_stop() - Stop a remote processor
172 * @id: id of the remote processor
173 * @return 0 if all ok, else appropriate error value.
175 int rproc_stop(int id);
178 * rproc_reset() - reset a remote processor
179 * @id: id of the remote processor
180 * @return 0 if all ok, else appropriate error value.
182 int rproc_reset(int id);
185 * rproc_ping() - ping a remote processor to check if it can communicate
186 * @id: id of the remote processor
187 * @return 0 if all ok, else appropriate error value.
189 * NOTE: this might need communication path available, which is not implemented
190 * as part of remoteproc framework - hook on to appropriate bus architecture to
193 int rproc_ping(int id);
196 * rproc_is_running() - check to see if remote processor is running
197 * @id: id of the remote processor
198 * @return 0 if running, 1 if not running, -ve on error.
200 * NOTE: this may not involve actual communication capability of the remote
201 * processor, but just ensures that it is out of reset and executing code.
203 int rproc_is_running(int id);
206 * rproc_elf32_sanity_check() - Verify if an image is a valid ELF32 one
208 * Check if a valid ELF32 image exists at the given memory location. Verify
209 * basic ELF32 format requirements like magic number and sections size.
211 * @addr: address of the image to verify
212 * @size: size of the image
213 * @return 0 if the image looks good, else appropriate error value.
215 int rproc_elf32_sanity_check(ulong addr, ulong size);
218 * rproc_elf64_sanity_check() - Verify if an image is a valid ELF32 one
220 * Check if a valid ELF64 image exists at the given memory location. Verify
221 * basic ELF64 format requirements like magic number and sections size.
223 * @addr: address of the image to verify
224 * @size: size of the image
225 * @return 0 if the image looks good, else appropriate error value.
227 int rproc_elf64_sanity_check(ulong addr, ulong size);
230 * rproc_elf32_load_image() - load an ELF32 image
231 * @dev: device loading the ELF32 image
232 * @addr: valid ELF32 image address
233 * @size: size of the image
234 * @return 0 if the image is successfully loaded, else appropriate error value.
236 int rproc_elf32_load_image(struct udevice *dev, unsigned long addr, ulong size);
239 * rproc_elf64_load_image() - load an ELF64 image
240 * @dev: device loading the ELF64 image
241 * @addr: valid ELF64 image address
242 * @size: size of the image
243 * @return 0 if the image is successfully loaded, else appropriate error value.
245 int rproc_elf64_load_image(struct udevice *dev, ulong addr, ulong size);
248 * rproc_elf_load_image() - load an ELF image
249 * @dev: device loading the ELF image
250 * @addr: valid ELF image address
251 * @size: size of the image
253 * Auto detects if the image is ELF32 or ELF64 image and load accordingly.
254 * @return 0 if the image is successfully loaded, else appropriate error value.
256 int rproc_elf_load_image(struct udevice *dev, unsigned long addr, ulong size);
259 * rproc_elf_get_boot_addr() - Get rproc's boot address.
260 * @dev: device loading the ELF image
261 * @addr: valid ELF image address
263 * This function returns the entry point address of the ELF
266 ulong rproc_elf_get_boot_addr(struct udevice *dev, ulong addr);
269 * rproc_elf32_load_rsc_table() - load the resource table from an ELF32 image
271 * Search for the resource table in an ELF32 image, and if found, copy it to
274 * @dev: device loading the resource table
275 * @fw_addr: ELF image address
276 * @fw_size: size of the ELF image
277 * @rsc_addr: pointer to the found resource table address. Updated on
279 * @rsc_size: pointer to the found resource table size. Updated on operation
282 * @return 0 if a valid resource table is successfully loaded, -ENODATA if there
283 * is no resource table (which is optional), or another appropriate error value.
285 int rproc_elf32_load_rsc_table(struct udevice *dev, ulong fw_addr,
286 ulong fw_size, ulong *rsc_addr, ulong *rsc_size);
288 * rproc_elf64_load_rsc_table() - load the resource table from an ELF64 image
290 * Search for the resource table in an ELF64 image, and if found, copy it to
293 * @dev: device loading the resource table
294 * @fw_addr: ELF image address
295 * @fw_size: size of the ELF image
296 * @rsc_addr: pointer to the found resource table address. Updated on
298 * @rsc_size: pointer to the found resource table size. Updated on operation
301 * @return 0 if a valid resource table is successfully loaded, -ENODATA if there
302 * is no resource table (which is optional), or another appropriate error value.
304 int rproc_elf64_load_rsc_table(struct udevice *dev, ulong fw_addr,
305 ulong fw_size, ulong *rsc_addr, ulong *rsc_size);
307 * rproc_elf_load_rsc_table() - load the resource table from an ELF image
309 * Auto detects if the image is ELF32 or ELF64 image and search accordingly for
310 * the resource table, and if found, copy it to device memory.
312 * @dev: device loading the resource table
313 * @fw_addr: ELF image address
314 * @fw_size: size of the ELF image
315 * @rsc_addr: pointer to the found resource table address. Updated on
317 * @rsc_size: pointer to the found resource table size. Updated on operation
320 * @return 0 if a valid resource table is successfully loaded, -ENODATA if there
321 * is no resource table (which is optional), or another appropriate error value.
323 int rproc_elf_load_rsc_table(struct udevice *dev, ulong fw_addr,
324 ulong fw_size, ulong *rsc_addr, ulong *rsc_size);
326 static inline int rproc_init(void) { return -ENOSYS; }
327 static inline int rproc_dev_init(int id) { return -ENOSYS; }
328 static inline bool rproc_is_initialized(void) { return false; }
329 static inline int rproc_load(int id, ulong addr, ulong size) { return -ENOSYS; }
330 static inline int rproc_start(int id) { return -ENOSYS; }
331 static inline int rproc_stop(int id) { return -ENOSYS; }
332 static inline int rproc_reset(int id) { return -ENOSYS; }
333 static inline int rproc_ping(int id) { return -ENOSYS; }
334 static inline int rproc_is_running(int id) { return -ENOSYS; }
335 static inline int rproc_elf32_sanity_check(ulong addr,
336 ulong size) { return -ENOSYS; }
337 static inline int rproc_elf64_sanity_check(ulong addr,
338 ulong size) { return -ENOSYS; }
339 static inline int rproc_elf_sanity_check(ulong addr,
340 ulong size) { return -ENOSYS; }
341 static inline int rproc_elf32_load_image(struct udevice *dev,
342 unsigned long addr, ulong size)
344 static inline int rproc_elf64_load_image(struct udevice *dev, ulong addr,
347 static inline int rproc_elf_load_image(struct udevice *dev, ulong addr,
350 static inline ulong rproc_elf_get_boot_addr(struct udevice *dev, ulong addr)
352 static inline int rproc_elf32_load_rsc_table(struct udevice *dev, ulong fw_addr,
353 ulong fw_size, ulong *rsc_addr,
356 static inline int rproc_elf64_load_rsc_table(struct udevice *dev, ulong fw_addr,
357 ulong fw_size, ulong *rsc_addr,
360 static inline int rproc_elf_load_rsc_table(struct udevice *dev, ulong fw_addr,
361 ulong fw_size, ulong *rsc_addr,
366 #endif /* _RPROC_H_ */