ipclite_client.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 int32_t (*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. int32_t 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. int32_t 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. int32_t 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. int32_t 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. int32_t 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_atomic_init_u32() - Initializes the global memory with uint32_t value.
  85. *
  86. * @addr : Pointer to global memory
  87. * @data : Value to store in global memory
  88. *
  89. * @return None.
  90. */
  91. void ipclite_atomic_init_u32(ipclite_atomic_uint32_t *addr, uint32_t data);
  92. /**
  93. * ipclite_atomic_init_i32() - Initializes the global memory with int32_t value.
  94. *
  95. * @addr : Pointer to global memory
  96. * @data : Value to store in global memory
  97. *
  98. * @return None.
  99. */
  100. void ipclite_atomic_init_i32(ipclite_atomic_int32_t *addr, int32_t data);
  101. /**
  102. * ipclite_global_atomic_store_u32() - Writes uint32_t value to global memory.
  103. *
  104. * @addr : Pointer to global memory
  105. * @data : Value to store in global memory
  106. *
  107. * @return None.
  108. */
  109. void ipclite_global_atomic_store_u32(ipclite_atomic_uint32_t *addr, uint32_t data);
  110. /**
  111. * ipclite_global_atomic_store_i32() - Writes int32_t value to global memory.
  112. *
  113. * @addr : Pointer to global memory
  114. * @data : Value to store in global memory
  115. *
  116. * @return None.
  117. */
  118. void ipclite_global_atomic_store_i32(ipclite_atomic_int32_t *addr, int32_t data);
  119. /**
  120. * ipclite_global_atomic_load_u32() - Reads the value from global memory.
  121. *
  122. * @addr : Pointer to global memory
  123. *
  124. * @return uint32_t value.
  125. */
  126. uint32_t ipclite_global_atomic_load_u32(ipclite_atomic_uint32_t *addr);
  127. /**
  128. * ipclite_global_atomic_load_i32() - Reads the value from global memory.
  129. *
  130. * @addr : Pointer to global memory
  131. *
  132. * @return int32_t value.
  133. */
  134. int32_t ipclite_global_atomic_load_i32(ipclite_atomic_int32_t *addr);
  135. /**
  136. * ipclite_global_test_and_set_bit() - Sets a bit in global memory.
  137. *
  138. * @nr : Bit position to set.
  139. * @addr : Pointer to global memory
  140. *
  141. * @return previous value.
  142. */
  143. uint32_t ipclite_global_test_and_set_bit(uint32_t nr, ipclite_atomic_uint32_t *addr);
  144. /**
  145. * ipclite_global_test_and_clear_bit() - Clears a bit in global memory.
  146. *
  147. * @nr : Bit position to clear.
  148. * @addr : Pointer to global memory
  149. *
  150. * @return previous value.
  151. */
  152. uint32_t ipclite_global_test_and_clear_bit(uint32_t nr, ipclite_atomic_uint32_t *addr);
  153. /**
  154. * ipclite_global_atomic_inc() - Increments an atomic variable by one.
  155. *
  156. * @addr : Pointer to global memory
  157. *
  158. * @return previous value.
  159. */
  160. int32_t ipclite_global_atomic_inc(ipclite_atomic_int32_t *addr);
  161. /**
  162. * ipclite_global_atomic_dec() - Decrements an atomic variable by one.
  163. *
  164. * @addr : Pointer to global variable
  165. *
  166. * @return previous value.
  167. */
  168. int32_t ipclite_global_atomic_dec(ipclite_atomic_int32_t *addr);
  169. #endif