ipclite_client.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __IPCLITE_CLIENT_H__
  6. #define __IPCLITE_CLIENT_H__
  7. typedef atomic_t ipclite_atomic_uint32_t;
  8. typedef atomic_t ipclite_atomic_int32_t;
  9. /**
  10. * A list of hosts supported in IPCMEM
  11. */
  12. enum ipcmem_host_type {
  13. IPCMEM_APPS = 0, /**< Apps Processor */
  14. IPCMEM_MODEM = 1, /**< Modem processor */
  15. IPCMEM_LPASS = 2, /**< Audio processor */
  16. IPCMEM_SLPI = 3, /**< Sensor processor */
  17. IPCMEM_GPU = 4, /**< Graphics processor */
  18. IPCMEM_CDSP = 5, /**< Compute DSP processor */
  19. IPCMEM_CVP = 6, /**< Computer Vision processor */
  20. IPCMEM_CAM = 7, /**< Camera processor */
  21. IPCMEM_VPU = 8, /**< Video processor */
  22. IPCMEM_NUM_HOSTS = 9, /**< Max number of host in target */
  23. IPCMEM_GLOBAL_HOST = 0xFE, /**< Global Host */
  24. IPCMEM_INVALID_HOST = 0xFF, /**< Invalid processor */
  25. };
  26. struct global_region_info {
  27. void *virt_base;
  28. uint32_t size;
  29. };
  30. typedef int (*IPCLite_Client)(uint32_t proc_id, int64_t data, void *priv);
  31. /**
  32. * ipclite_msg_send() - Sends message to remote client.
  33. *
  34. * @proc_id : Identifier for remote client or subsystem.
  35. * @data : 64 bit message value.
  36. *
  37. * @return Zero on successful registration, negative on failure.
  38. */
  39. int ipclite_msg_send(int32_t proc_id, uint64_t data);
  40. /**
  41. * ipclite_register_client() - Registers client callback with framework.
  42. *
  43. * @cb_func_ptr : Client callback function to be called on message receive.
  44. * @priv : Private data required by client for handling callback.
  45. *
  46. * @return Zero on successful registration, negative on failure.
  47. */
  48. int ipclite_register_client(IPCLite_Client cb_func_ptr, void *priv);
  49. /**
  50. * ipclite_test_msg_send() - Sends message to remote client.
  51. *
  52. * @proc_id : Identifier for remote client or subsystem.
  53. * @data : 64 bit message value.
  54. *
  55. * @return Zero on successful registration, negative on failure.
  56. */
  57. int ipclite_test_msg_send(int32_t proc_id, uint64_t data);
  58. /**
  59. * ipclite_register_test_client() - Registers client callback with framework.
  60. *
  61. * @cb_func_ptr : Client callback function to be called on message receive.
  62. * @priv : Private data required by client for handling callback.
  63. *
  64. * @return Zero on successful registration, negative on failure.
  65. */
  66. int ipclite_register_test_client(IPCLite_Client cb_func_ptr, void *priv);
  67. /**
  68. * get_global_partition_info() - Gets info about IPCMEM's global partitions.
  69. *
  70. * @global_ipcmem : Pointer to global_region_info structure.
  71. *
  72. * @return Zero on successful registration, negative on failure.
  73. */
  74. int get_global_partition_info(struct global_region_info *global_ipcmem);
  75. /**
  76. * ipclite_recover() - Recovers the ipclite if any core goes for SSR
  77. *
  78. * core_id : takes the core id of the core which went to SSR.
  79. *
  80. * @return None.
  81. */
  82. void ipclite_recover(enum ipcmem_host_type core_id);
  83. /**
  84. * ipclite_hw_mutex_acquire() - Locks the hw mutex reserved for ipclite.
  85. *
  86. * @return Zero on successful acquire, negative on failure.
  87. */
  88. int ipclite_hw_mutex_acquire(void);
  89. /**
  90. * ipclite_hw_mutex_release() - Unlocks the hw mutex reserved for ipclite.
  91. *
  92. * @return Zero on successful release, negative on failure.
  93. */
  94. int ipclite_hw_mutex_release(void);
  95. /**
  96. * ipclite_atomic_init_u32() - Initializes the global memory with uint32_t value.
  97. *
  98. * @addr : Pointer to global memory
  99. * @data : Value to store in global memory
  100. *
  101. * @return None.
  102. */
  103. void ipclite_atomic_init_u32(ipclite_atomic_uint32_t *addr, uint32_t data);
  104. /**
  105. * ipclite_atomic_init_i32() - Initializes the global memory with int32_t value.
  106. *
  107. * @addr : Pointer to global memory
  108. * @data : Value to store in global memory
  109. *
  110. * @return None.
  111. */
  112. void ipclite_atomic_init_i32(ipclite_atomic_int32_t *addr, int32_t data);
  113. /**
  114. * ipclite_global_atomic_store_u32() - Writes uint32_t value to global memory.
  115. *
  116. * @addr : Pointer to global memory
  117. * @data : Value to store in global memory
  118. *
  119. * @return None.
  120. */
  121. void ipclite_global_atomic_store_u32(ipclite_atomic_uint32_t *addr, uint32_t data);
  122. /**
  123. * ipclite_global_atomic_store_i32() - Writes int32_t value to global memory.
  124. *
  125. * @addr : Pointer to global memory
  126. * @data : Value to store in global memory
  127. *
  128. * @return None.
  129. */
  130. void ipclite_global_atomic_store_i32(ipclite_atomic_int32_t *addr, int32_t data);
  131. /**
  132. * ipclite_global_atomic_load_u32() - Reads the value from global memory.
  133. *
  134. * @addr : Pointer to global memory
  135. *
  136. * @return uint32_t value.
  137. */
  138. uint32_t ipclite_global_atomic_load_u32(ipclite_atomic_uint32_t *addr);
  139. /**
  140. * ipclite_global_atomic_load_i32() - Reads the value from global memory.
  141. *
  142. * @addr : Pointer to global memory
  143. *
  144. * @return int32_t value.
  145. */
  146. int32_t ipclite_global_atomic_load_i32(ipclite_atomic_int32_t *addr);
  147. /**
  148. * ipclite_global_test_and_set_bit() - Sets a bit in global memory.
  149. *
  150. * @nr : Bit position to set.
  151. * @addr : Pointer to global memory
  152. *
  153. * @return previous value.
  154. */
  155. uint32_t ipclite_global_test_and_set_bit(uint32_t nr, ipclite_atomic_uint32_t *addr);
  156. /**
  157. * ipclite_global_test_and_clear_bit() - Clears a bit in global memory.
  158. *
  159. * @nr : Bit position to clear.
  160. * @addr : Pointer to global memory
  161. *
  162. * @return previous value.
  163. */
  164. uint32_t ipclite_global_test_and_clear_bit(uint32_t nr, ipclite_atomic_uint32_t *addr);
  165. /**
  166. * ipclite_global_atomic_inc() - Increments an atomic variable by one.
  167. *
  168. * @addr : Pointer to global memory
  169. *
  170. * @return previous value.
  171. */
  172. int32_t ipclite_global_atomic_inc(ipclite_atomic_int32_t *addr);
  173. /**
  174. * ipclite_global_atomic_dec() - Decrements an atomic variable by one.
  175. *
  176. * @addr : Pointer to global variable
  177. *
  178. * @return previous value.
  179. */
  180. int32_t ipclite_global_atomic_dec(ipclite_atomic_int32_t *addr);
  181. #endif