/arch/arm/mach-fsm/npa_remote.h

https://bitbucket.org/sammyz/iscream_thunderc-2.6.35-rebase · C++ Header · 234 lines · 89 code · 26 blank · 119 comment · 0 complexity · f61a9f573571c3ee382279d252569913 MD5 · raw file

  1. /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are
  5. * met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above
  9. * copyright notice, this list of conditions and the following
  10. * disclaimer in the documentation and/or other materials provided
  11. * with the distribution.
  12. * * Neither the name of Code Aurora Forum, Inc. nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  20. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  23. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  25. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  26. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. */
  29. /*
  30. * Node Power Architecture (NPA) remote header file.
  31. */
  32. #ifndef NPA_REMOTE_H
  33. #define NPA_REMOTE_H
  34. #include <linux/errno.h>
  35. #include "npa.h"
  36. #include "npa_resource.h"
  37. #ifdef CONFIG_MSM_NPA_REMOTE
  38. #define NPA_REMOTE_VERSION_MAJOR 1
  39. #define NPA_REMOTE_VERSION_MINOR 0
  40. #define NPA_REMOTE_VERSION_BUILD 0
  41. /* Return Error Codes */
  42. #define NPA_REMOTE_PROTOCOL_FAILURE -1
  43. #define NPA_REMOTE_FAILURE 1
  44. enum npa_remote_client_type {
  45. NPA_REMOTE_CLIENT_RESERVED1,
  46. NPA_REMOTE_CLIENT_RESERVED2,
  47. NPA_REMOTE_CLIENT_CUSTOM1,
  48. NPA_REMOTE_CLIENT_CUSTOM2,
  49. NPA_REMOTE_CLIENT_CUSTOM3,
  50. NPA_REMOTE_CLIENT_CUSTOM4,
  51. NPA_REMOTE_CLIENT_REQUIRED,
  52. NPA_REMOTE_CLIENT_ISOCHRONOUS,
  53. NPA_REMOTE_CLIENT_IMPULSE,
  54. NPA_REMOTE_CLIENT_LIMIT_MAX,
  55. NPA_REMOTE_CLIENT_SIZE = 0x7FFFFFFF, /* Signed 32 bit max */
  56. };
  57. typedef int (*npa_remote_callback)(void *context, unsigned int event_type,
  58. int *data, unsigned int data_size);
  59. /* NPA Remoting Library API. */
  60. /* NULL procedure to test if the remote server is reachable or not.
  61. */
  62. int npa_remote_null(void);
  63. /* Remote setup initialization.
  64. *
  65. * @major: The major number of this remoting API.
  66. * @minor: The minor number of this remoting API.
  67. * @build: The build number of this remoting API.
  68. * @calback: The callback function that will be invoked when the version
  69. * number matches.
  70. * @context: The context pointer that is passed will be returned.
  71. *
  72. * Return:
  73. * 0: Success, the version information matches
  74. * NPA_REMOTE_FAILURE: The server returned a failure.
  75. * NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
  76. */
  77. int npa_remote_init(unsigned int major, unsigned int minor, unsigned int build,
  78. npa_remote_callback callback, void *context);
  79. /* Checks if the remote resource is available.
  80. * The return value does not indicate the availability of the resource.
  81. * If the resource is available the callback is called, if its not, then
  82. * the callback is executed when the resource becomes available.
  83. *
  84. * @resource_name: NULL terminated name limited to NPA_NAME_MAX
  85. * @callback: The callback to be invoked when the resource is available.
  86. * @context: The passed in context pointer that will be returned with the
  87. * callback.
  88. *
  89. * Returns:
  90. * 0: Success if the server received the request.
  91. * NPA_REMOTE_FAILURE: The server returned a failure.
  92. * NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
  93. */
  94. int npa_remote_resource_available(const char *resource_name,
  95. npa_remote_callback callback, void *context);
  96. /* Creates a remote client on the server.
  97. * The server returns a handle that identifies the npa_client on the server.
  98. *
  99. * @resource_name: NULL terminated name limited to NPA_NAME_MAX
  100. * @client_name: NULL terminated name limited to NPA_NAME_MAX
  101. * @client_type: The type of the sync client to be created.
  102. * @handle: The handle to the remote client returned by the server.
  103. *
  104. * Returns:
  105. * 0: Success if the server created a remote client.
  106. * NPA_REMOTE_FAILURE: The server returned a failure.
  107. * NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
  108. */
  109. int npa_remote_create_sync_client(const char *resource_name,
  110. const char *client_name,
  111. enum npa_remote_client_type client_type,
  112. void **handle);
  113. /* Destroy a remote client.
  114. *
  115. * @handle: Handle to the remote client.
  116. *
  117. * Returns:
  118. * 0: Success if the server received the request.
  119. * NPA_REMOTE_FAILURE: The server returned a failure.
  120. * NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
  121. */
  122. int npa_remote_destroy_client(void *handle);
  123. /* Issues a required request to the remote server through the client handle.
  124. *
  125. * @handle: Handle to the remote client
  126. * @state: Required new state
  127. * @new_state: The resource state after this request. The state returned
  128. * will be the old state if the remote request failed.
  129. *
  130. * Returns:
  131. * 0: Success if the server received the request.
  132. * NPA_REMOTE_FAILURE: The server returned a failure.
  133. * NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
  134. *
  135. * Note: If CONFIG_MSM_NPA_PROC_COMM is defined, then this API uses PROC COMM
  136. * to issue requests to the modem.
  137. */
  138. int npa_remote_issue_required_request(void *handle, unsigned int state,
  139. unsigned int *new_state);
  140. /** PUBLIC NPA REMOTE API **/
  141. /* Helper Driver functions */
  142. unsigned int npa_remote_agg_driver_fn(struct npa_resource *resource,
  143. struct npa_client *client, unsigned int state);
  144. unsigned int npa_local_agg_driver_fn(struct npa_resource *resource,
  145. struct npa_client *client, unsigned int state);
  146. /* Remote aggregation plugin */
  147. extern const struct npa_resource_plugin_ops npa_remote_agg_plugin;
  148. #define DECLARE_RESOURCE_LOCAL_AGGREGATION(n, r, r_name, u_name, val, p) \
  149. struct npa_resource_definition r = { \
  150. .name = r_name, \
  151. .units = u_name, \
  152. .attributes = NPA_RESOURCE_DEFAULT, \
  153. .max = val, \
  154. .plugin = &p, \
  155. .data = NULL, \
  156. }; \
  157. struct npa_node_definition n = { \
  158. .name = r_name, \
  159. .attributes = NPA_NODE_DEFAULT, \
  160. .driver_fn = npa_local_agg_driver_fn, \
  161. .dependencies = NULL, \
  162. .dependency_count = 0, \
  163. .resources = &r, \
  164. .resource_count = 1, \
  165. };
  166. #define DECLARE_RESOURCE_REMOTE_AGGREGATION(n, r, r_name, u_name, val) \
  167. struct npa_resource_definition r = { \
  168. .name = r_name, \
  169. .units = u_name, \
  170. .attributes = NPA_RESOURCE_DEFAULT, \
  171. .max = val, \
  172. .plugin = &npa_remote_agg_plugin, \
  173. .data = NULL, \
  174. }; \
  175. struct npa_node_definition n = {\
  176. .name = r_name, \
  177. .attributes = NPA_NODE_DEFAULT, \
  178. .driver_fn = npa_remote_agg_driver_fn, \
  179. .dependencies = NULL, \
  180. .dependency_count = 0, \
  181. .resources = &r, \
  182. .resource_count = 1, \
  183. };
  184. /* Defines the remote node.
  185. *
  186. * @initial_state: The initial state vector of the resources.
  187. * @callback: Function to be called when the resource is defined and active
  188. * on the remote processor .
  189. * @user_data: Argument to the callback function.
  190. *
  191. * NOTE: Remoting supports only single resource node. If there are multiple
  192. * resources for the actual node, multiple remote nodes need to be created.
  193. *
  194. * Return:
  195. * -ENODEV: If the remote server was not initialized.
  196. * -EINVAL: Invalid input.
  197. * 0: The resource is created or awaiting dependencies.
  198. */
  199. int npa_remote_define_node(struct npa_node_definition *node,
  200. unsigned int init_state, npa_cb_fn callback, void *data);
  201. #else
  202. static inline int npa_remote_define_node(struct npa_node_definition *node,
  203. unsigned int init_state, npa_cb_fn callback, void *data)
  204. {
  205. return -ENOSYS;
  206. }
  207. #endif
  208. #endif