Blame view
include/remoteproc.h
12.4 KB
83d290c56 SPDX: Convert all... |
1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
ddf56bc7e drivers: Introduc... |
2 3 4 |
/* * (C) Copyright 2015 * Texas Instruments Incorporated - http://www.ti.com/ |
ddf56bc7e drivers: Introduc... |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
*/ #ifndef _RPROC_H_ #define _RPROC_H_ /* * Note: The platform data support is not meant for use with newer * platforms. This is meant only for legacy devices. This mode of * initialization *will* be eventually removed once all necessary * platforms have moved to dm/fdt. */ #include <dm/platdata.h> /* For platform data support - non dt world */ /** * enum rproc_mem_type - What type of memory model does the rproc use * @RPROC_INTERNAL_MEMORY_MAPPED: Remote processor uses own memory and is memory * mapped to the host processor over an address range. * * Please note that this is an enumeration of memory model of different types * of remote processors. Few of the remote processors do have own internal * memories, while others use external memory for instruction and data. */ enum rproc_mem_type { RPROC_INTERNAL_MEMORY_MAPPED = 0, }; /** * struct dm_rproc_uclass_pdata - platform data for a CPU * @name: Platform-specific way of naming the Remote proc * @mem_type: one of 'enum rproc_mem_type' * @driver_plat_data: driver specific platform data that may be needed. * * This can be accessed with dev_get_uclass_platdata() for any UCLASS_REMOTEPROC * device. * */ struct dm_rproc_uclass_pdata { const char *name; enum rproc_mem_type mem_type; void *driver_plat_data; }; /** |
31a839f81 remoteproc: fix f... |
48 49 50 |
* struct dm_rproc_ops - Driver model remote proc operations. * * This defines the operations provided by remote proc driver. |
ddf56bc7e drivers: Introduc... |
51 52 |
*/ struct dm_rproc_ops { |
31a839f81 remoteproc: fix f... |
53 54 55 56 57 58 59 60 61 62 |
/** * init() - Initialize the remoteproc device (optional) * * This is called after the probe is completed allowing the remote * processor drivers to split up the initializations between probe and * init if needed. * * @dev: Remote proc device * @return 0 if all ok, else appropriate error value. */ |
ddf56bc7e drivers: Introduc... |
63 |
int (*init)(struct udevice *dev); |
31a839f81 remoteproc: fix f... |
64 65 66 67 68 69 70 71 72 73 74 |
/** * load() - Load the remoteproc device using data provided (mandatory) * * Load the remoteproc device with an image, do not start the device. * * @dev: Remote proc device * @addr: Address of the image to be loaded * @size: Size of the image to be loaded * @return 0 if all ok, else appropriate error value. */ |
ddf56bc7e drivers: Introduc... |
75 |
int (*load)(struct udevice *dev, ulong addr, ulong size); |
31a839f81 remoteproc: fix f... |
76 77 78 79 80 81 82 |
/** * start() - Start the remoteproc device (mandatory) * * @dev: Remote proc device * @return 0 if all ok, else appropriate error value. */ |
ddf56bc7e drivers: Introduc... |
83 |
int (*start)(struct udevice *dev); |
31a839f81 remoteproc: fix f... |
84 85 86 87 88 89 90 |
/** * stop() - Stop the remoteproc device (optional) * * @dev: Remote proc device * @return 0 if all ok, else appropriate error value. */ |
ddf56bc7e drivers: Introduc... |
91 |
int (*stop)(struct udevice *dev); |
31a839f81 remoteproc: fix f... |
92 93 94 95 96 97 98 |
/** * reset() - Reset the remoteproc device (optional) * * @dev: Remote proc device * @return 0 if all ok, else appropriate error value. */ |
ddf56bc7e drivers: Introduc... |
99 |
int (*reset)(struct udevice *dev); |
31a839f81 remoteproc: fix f... |
100 101 102 103 104 105 106 |
/** * is_running() - Check if the remote processor is running (optional) * * @dev: Remote proc device * @return 0 if running, 1 if not running, -ve on error. */ |
ddf56bc7e drivers: Introduc... |
107 |
int (*is_running)(struct udevice *dev); |
31a839f81 remoteproc: fix f... |
108 109 110 111 112 113 114 |
/** * ping() - Ping the remote device for basic communication (optional) * * @dev: Remote proc device * @return 0 on success, 1 if not responding, -ve on other errors. */ |
ddf56bc7e drivers: Introduc... |
115 |
int (*ping)(struct udevice *dev); |
163b7d770 remoteproc: add d... |
116 117 118 119 120 121 122 123 124 |
/** * device_to_virt() - Return translated virtual address (optional) * * Translate a device address (remote processor view) to virtual * address (main processor view). * * @dev: Remote proc device * @da: Device address |
c08eb9362 remoteproc: ops: ... |
125 |
* @size: Size of the memory region @da is pointing to |
163b7d770 remoteproc: add d... |
126 127 |
* @return virtual address. */ |
c08eb9362 remoteproc: ops: ... |
128 |
void * (*device_to_virt)(struct udevice *dev, ulong da, ulong size); |
ddf56bc7e drivers: Introduc... |
129 130 131 132 |
}; /* Accessor */ #define rproc_get_ops(dev) ((struct dm_rproc_ops *)(dev)->driver->ops) |
26557d102 remoteproc: Fix p... |
133 |
#if CONFIG_IS_ENABLED(REMOTEPROC) |
ddf56bc7e drivers: Introduc... |
134 135 |
/** * rproc_init() - Initialize all bound remote proc devices |
31a839f81 remoteproc: fix f... |
136 |
* @return 0 if all ok, else appropriate error value. |
ddf56bc7e drivers: Introduc... |
137 138 139 140 |
*/ int rproc_init(void); /** |
81ae6e6d0 remoteproc: Allow... |
141 142 |
* rproc_dev_init() - Initialize a remote proc device based on id * @id: id of the remote processor |
31a839f81 remoteproc: fix f... |
143 |
* @return 0 if all ok, else appropriate error value. |
81ae6e6d0 remoteproc: Allow... |
144 145 146 147 |
*/ int rproc_dev_init(int id); /** |
ddf56bc7e drivers: Introduc... |
148 |
* rproc_is_initialized() - check to see if remoteproc devices are initialized |
31a839f81 remoteproc: fix f... |
149 |
* @return true if all devices are initialized, false otherwise. |
ddf56bc7e drivers: Introduc... |
150 151 152 153 |
*/ bool rproc_is_initialized(void); /** |
7a7c4cb0f remoteproc: add e... |
154 |
* rproc_load() - load binary or elf to a remote processor |
ddf56bc7e drivers: Introduc... |
155 |
* @id: id of the remote processor |
7a7c4cb0f remoteproc: add e... |
156 157 |
* @addr: address in memory where the image is located * @size: size of the image |
31a839f81 remoteproc: fix f... |
158 |
* @return 0 if all ok, else appropriate error value. |
ddf56bc7e drivers: Introduc... |
159 160 161 162 163 164 |
*/ int rproc_load(int id, ulong addr, ulong size); /** * rproc_start() - Start a remote processor * @id: id of the remote processor |
31a839f81 remoteproc: fix f... |
165 |
* @return 0 if all ok, else appropriate error value. |
ddf56bc7e drivers: Introduc... |
166 167 168 169 170 171 |
*/ int rproc_start(int id); /** * rproc_stop() - Stop a remote processor * @id: id of the remote processor |
31a839f81 remoteproc: fix f... |
172 |
* @return 0 if all ok, else appropriate error value. |
ddf56bc7e drivers: Introduc... |
173 174 175 176 177 178 |
*/ int rproc_stop(int id); /** * rproc_reset() - reset a remote processor * @id: id of the remote processor |
31a839f81 remoteproc: fix f... |
179 |
* @return 0 if all ok, else appropriate error value. |
ddf56bc7e drivers: Introduc... |
180 181 182 183 184 185 |
*/ int rproc_reset(int id); /** * rproc_ping() - ping a remote processor to check if it can communicate * @id: id of the remote processor |
31a839f81 remoteproc: fix f... |
186 |
* @return 0 if all ok, else appropriate error value. |
ddf56bc7e drivers: Introduc... |
187 188 189 190 |
* * NOTE: this might need communication path available, which is not implemented * as part of remoteproc framework - hook on to appropriate bus architecture to * do the same |
ddf56bc7e drivers: Introduc... |
191 192 193 194 195 196 |
*/ int rproc_ping(int id); /** * rproc_is_running() - check to see if remote processor is running * @id: id of the remote processor |
31a839f81 remoteproc: fix f... |
197 |
* @return 0 if running, 1 if not running, -ve on error. |
ddf56bc7e drivers: Introduc... |
198 199 200 |
* * NOTE: this may not involve actual communication capability of the remote * processor, but just ensures that it is out of reset and executing code. |
ddf56bc7e drivers: Introduc... |
201 202 |
*/ int rproc_is_running(int id); |
7a7c4cb0f remoteproc: add e... |
203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
/** * rproc_elf32_sanity_check() - Verify if an image is a valid ELF32 one * * Check if a valid ELF32 image exists at the given memory location. Verify * basic ELF32 format requirements like magic number and sections size. * * @addr: address of the image to verify * @size: size of the image * @return 0 if the image looks good, else appropriate error value. */ int rproc_elf32_sanity_check(ulong addr, ulong size); /** |
e3c4d6f01 remoteproc: elf-l... |
217 218 219 220 221 222 223 224 225 226 227 228 |
* rproc_elf64_sanity_check() - Verify if an image is a valid ELF32 one * * Check if a valid ELF64 image exists at the given memory location. Verify * basic ELF64 format requirements like magic number and sections size. * * @addr: address of the image to verify * @size: size of the image * @return 0 if the image looks good, else appropriate error value. */ int rproc_elf64_sanity_check(ulong addr, ulong size); /** |
856c0ad41 remoteproc: elf_l... |
229 230 231 232 233 234 235 236 237 238 239 240 241 |
* rproc_elf_sanity_check() - Verify if an image is a valid ELF one * * Check if a valid ELF image exists at the given memory location. Auto * detects ELF32/ELF64 and verifies basic ELF64/ELF32 format requirements * like magic number and sections size. * * @addr: address of the image to verify * @size: size of the image * @return 0 if the image looks good, else appropriate error value. */ int rproc_elf_sanity_check(ulong addr, ulong size); /** |
7a7c4cb0f remoteproc: add e... |
242 243 244 |
* rproc_elf32_load_image() - load an ELF32 image * @dev: device loading the ELF32 image * @addr: valid ELF32 image address |
14d963d1b remoteproc: elf_l... |
245 |
* @size: size of the image |
7a7c4cb0f remoteproc: add e... |
246 247 |
* @return 0 if the image is successfully loaded, else appropriate error value. */ |
14d963d1b remoteproc: elf_l... |
248 |
int rproc_elf32_load_image(struct udevice *dev, unsigned long addr, ulong size); |
e3c4d6f01 remoteproc: elf-l... |
249 250 251 252 253 254 255 256 257 |
/** * rproc_elf64_load_image() - load an ELF64 image * @dev: device loading the ELF64 image * @addr: valid ELF64 image address * @size: size of the image * @return 0 if the image is successfully loaded, else appropriate error value. */ int rproc_elf64_load_image(struct udevice *dev, ulong addr, ulong size); |
856c0ad41 remoteproc: elf_l... |
258 259 260 261 262 263 264 265 266 267 268 |
/** * rproc_elf_load_image() - load an ELF image * @dev: device loading the ELF image * @addr: valid ELF image address * @size: size of the image * * Auto detects if the image is ELF32 or ELF64 image and load accordingly. * @return 0 if the image is successfully loaded, else appropriate error value. */ int rproc_elf_load_image(struct udevice *dev, unsigned long addr, ulong size); |
81e39fbd9 remoteproc: elf_l... |
269 270 271 272 273 274 275 276 277 278 |
/** * rproc_elf_get_boot_addr() - Get rproc's boot address. * @dev: device loading the ELF image * @addr: valid ELF image address * * This function returns the entry point address of the ELF * image. */ ulong rproc_elf_get_boot_addr(struct udevice *dev, ulong addr); |
ffcb880de remoteproc: elf_l... |
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
/** * rproc_elf32_load_rsc_table() - load the resource table from an ELF32 image * * Search for the resource table in an ELF32 image, and if found, copy it to * device memory. * * @dev: device loading the resource table * @fw_addr: ELF image address * @fw_size: size of the ELF image * @rsc_addr: pointer to the found resource table address. Updated on * operation success * @rsc_size: pointer to the found resource table size. Updated on operation * success * * @return 0 if a valid resource table is successfully loaded, -ENODATA if there * is no resource table (which is optional), or another appropriate error value. */ int rproc_elf32_load_rsc_table(struct udevice *dev, ulong fw_addr, ulong fw_size, ulong *rsc_addr, ulong *rsc_size); /** * rproc_elf64_load_rsc_table() - load the resource table from an ELF64 image * * Search for the resource table in an ELF64 image, and if found, copy it to * device memory. * * @dev: device loading the resource table * @fw_addr: ELF image address * @fw_size: size of the ELF image * @rsc_addr: pointer to the found resource table address. Updated on * operation success * @rsc_size: pointer to the found resource table size. Updated on operation * success * * @return 0 if a valid resource table is successfully loaded, -ENODATA if there * is no resource table (which is optional), or another appropriate error value. */ int rproc_elf64_load_rsc_table(struct udevice *dev, ulong fw_addr, ulong fw_size, ulong *rsc_addr, ulong *rsc_size); /** * rproc_elf_load_rsc_table() - load the resource table from an ELF image * * Auto detects if the image is ELF32 or ELF64 image and search accordingly for * the resource table, and if found, copy it to device memory. * * @dev: device loading the resource table * @fw_addr: ELF image address * @fw_size: size of the ELF image * @rsc_addr: pointer to the found resource table address. Updated on * operation success * @rsc_size: pointer to the found resource table size. Updated on operation * success * * @return 0 if a valid resource table is successfully loaded, -ENODATA if there * is no resource table (which is optional), or another appropriate error value. */ int rproc_elf_load_rsc_table(struct udevice *dev, ulong fw_addr, ulong fw_size, ulong *rsc_addr, ulong *rsc_size); |
ddf56bc7e drivers: Introduc... |
337 338 |
#else static inline int rproc_init(void) { return -ENOSYS; } |
81ae6e6d0 remoteproc: Allow... |
339 |
static inline int rproc_dev_init(int id) { return -ENOSYS; } |
ddf56bc7e drivers: Introduc... |
340 341 342 343 344 345 346 |
static inline bool rproc_is_initialized(void) { return false; } static inline int rproc_load(int id, ulong addr, ulong size) { return -ENOSYS; } static inline int rproc_start(int id) { return -ENOSYS; } static inline int rproc_stop(int id) { return -ENOSYS; } static inline int rproc_reset(int id) { return -ENOSYS; } static inline int rproc_ping(int id) { return -ENOSYS; } static inline int rproc_is_running(int id) { return -ENOSYS; } |
7a7c4cb0f remoteproc: add e... |
347 348 |
static inline int rproc_elf32_sanity_check(ulong addr, ulong size) { return -ENOSYS; } |
e3c4d6f01 remoteproc: elf-l... |
349 350 |
static inline int rproc_elf64_sanity_check(ulong addr, ulong size) { return -ENOSYS; } |
856c0ad41 remoteproc: elf_l... |
351 352 |
static inline int rproc_elf_sanity_check(ulong addr, ulong size) { return -ENOSYS; } |
7a7c4cb0f remoteproc: add e... |
353 |
static inline int rproc_elf32_load_image(struct udevice *dev, |
14d963d1b remoteproc: elf_l... |
354 355 |
unsigned long addr, ulong size) { return -ENOSYS; } |
e3c4d6f01 remoteproc: elf-l... |
356 357 358 |
static inline int rproc_elf64_load_image(struct udevice *dev, ulong addr, ulong size) { return -ENOSYS; } |
856c0ad41 remoteproc: elf_l... |
359 360 361 |
static inline int rproc_elf_load_image(struct udevice *dev, ulong addr, ulong size) { return -ENOSYS; } |
81e39fbd9 remoteproc: elf_l... |
362 363 |
static inline ulong rproc_elf_get_boot_addr(struct udevice *dev, ulong addr) { return 0; } |
ffcb880de remoteproc: elf_l... |
364 365 366 367 368 369 370 371 372 373 374 375 |
static inline int rproc_elf32_load_rsc_table(struct udevice *dev, ulong fw_addr, ulong fw_size, ulong *rsc_addr, ulong *rsc_size) { return -ENOSYS; } static inline int rproc_elf64_load_rsc_table(struct udevice *dev, ulong fw_addr, ulong fw_size, ulong *rsc_addr, ulong *rsc_size) { return -ENOSYS; } static inline int rproc_elf_load_rsc_table(struct udevice *dev, ulong fw_addr, ulong fw_size, ulong *rsc_addr, ulong *rsc_size) { return -ENOSYS; } |
ddf56bc7e drivers: Introduc... |
376 377 378 |
#endif #endif /* _RPROC_H_ */ |