remoteproc.h 5.1 KB

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