PageRenderTime 31ms CodeModel.GetById 19ms app.highlight 10ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  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/*
 31 * Node Power Architecture (NPA) remote header file.
 32 */
 33
 34#ifndef NPA_REMOTE_H
 35#define NPA_REMOTE_H
 36
 37#include <linux/errno.h>
 38
 39#include "npa.h"
 40#include "npa_resource.h"
 41
 42#ifdef CONFIG_MSM_NPA_REMOTE
 43
 44#define NPA_REMOTE_VERSION_MAJOR	1
 45#define NPA_REMOTE_VERSION_MINOR	0
 46#define NPA_REMOTE_VERSION_BUILD	0
 47
 48/* Return Error Codes */
 49#define NPA_REMOTE_PROTOCOL_FAILURE	-1
 50#define NPA_REMOTE_FAILURE		1
 51
 52enum npa_remote_client_type {
 53	NPA_REMOTE_CLIENT_RESERVED1,
 54	NPA_REMOTE_CLIENT_RESERVED2,
 55	NPA_REMOTE_CLIENT_CUSTOM1,
 56	NPA_REMOTE_CLIENT_CUSTOM2,
 57	NPA_REMOTE_CLIENT_CUSTOM3,
 58	NPA_REMOTE_CLIENT_CUSTOM4,
 59	NPA_REMOTE_CLIENT_REQUIRED,
 60	NPA_REMOTE_CLIENT_ISOCHRONOUS,
 61	NPA_REMOTE_CLIENT_IMPULSE,
 62	NPA_REMOTE_CLIENT_LIMIT_MAX,
 63	NPA_REMOTE_CLIENT_SIZE = 0x7FFFFFFF, /* Signed 32 bit max */
 64};
 65
 66typedef int (*npa_remote_callback)(void *context, unsigned int event_type,
 67		int *data, unsigned int data_size);
 68
 69/* NPA Remoting Library API. */
 70
 71/* NULL procedure to test if the remote server is reachable or not.
 72 */
 73int npa_remote_null(void);
 74
 75/* Remote setup initialization.
 76 *
 77 * @major: The major number of this remoting API.
 78 * @minor: The minor number of this remoting API.
 79 * @build: The build number of this remoting API.
 80 * @calback: The callback function that will be invoked when the version
 81 * number matches.
 82 * @context: The context pointer that is passed will be returned.
 83 *
 84 * Return:
 85 *   0: Success, the version information matches
 86 *   NPA_REMOTE_FAILURE: The server returned a failure.
 87 *   NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
 88 */
 89int npa_remote_init(unsigned int major, unsigned int minor, unsigned int build,
 90		npa_remote_callback callback, void *context);
 91
 92/* Checks if the remote resource is available.
 93 * The return value does not indicate the availability of the resource.
 94 * If the resource is available the callback is called, if its not, then
 95 * the callback is executed when the resource becomes available.
 96 *
 97 * @resource_name: NULL terminated name limited to NPA_NAME_MAX
 98 * @callback: The callback to be invoked when the resource is available.
 99 * @context: The passed in context pointer that will be returned with the
100 * callback.
101 *
102 * Returns:
103 *   0: Success if the server received the request.
104 *   NPA_REMOTE_FAILURE: The server returned a failure.
105 *   NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
106 */
107int npa_remote_resource_available(const char *resource_name,
108		npa_remote_callback callback, void *context);
109
110/* Creates a remote client on the server.
111 * The server returns a handle that identifies the npa_client on the server.
112 *
113 * @resource_name: NULL terminated name limited to NPA_NAME_MAX
114 * @client_name: NULL terminated name limited to NPA_NAME_MAX
115 * @client_type: The type of the sync client to be created.
116 * @handle: The handle to the remote client returned by the server.
117 *
118 * Returns:
119 *   0: Success if the server created a remote client.
120 *   NPA_REMOTE_FAILURE: The server returned a failure.
121 *   NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
122 */
123int npa_remote_create_sync_client(const char *resource_name,
124		const char *client_name,
125		enum npa_remote_client_type client_type,
126		void **handle);
127
128/* Destroy a remote client.
129 *
130 * @handle: Handle to the remote client.
131 *
132 * Returns:
133 *   0: Success if the server received the request.
134 *   NPA_REMOTE_FAILURE: The server returned a failure.
135 *   NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
136 */
137int npa_remote_destroy_client(void *handle);
138
139/* Issues a required request to the remote server through the client handle.
140 *
141 * @handle: Handle to the remote client
142 * @state: Required new state
143 * @new_state: The resource state after this request. The state returned
144 * will be the old state if the remote request failed.
145 *
146 * Returns:
147 *   0: Success if the server received the request.
148 *   NPA_REMOTE_FAILURE: The server returned a failure.
149 *   NPA_REMOTE_PROTOCOL_FAILURE: The transport protocol layer failed.
150 *
151 * Note: If CONFIG_MSM_NPA_PROC_COMM is defined, then this API uses PROC COMM
152 * to issue requests to the modem.
153 */
154int npa_remote_issue_required_request(void *handle, unsigned int state,
155		unsigned int *new_state);
156
157/** PUBLIC NPA REMOTE API **/
158
159/* Helper Driver functions */
160unsigned int npa_remote_agg_driver_fn(struct npa_resource *resource,
161		struct npa_client *client, unsigned int state);
162unsigned int npa_local_agg_driver_fn(struct npa_resource *resource,
163		struct npa_client *client, unsigned int state);
164
165/* Remote aggregation plugin */
166extern const struct npa_resource_plugin_ops npa_remote_agg_plugin;
167
168#define DECLARE_RESOURCE_LOCAL_AGGREGATION(n, r, r_name, u_name, val, p) \
169	struct npa_resource_definition r = { \
170		.name = r_name, \
171		.units = u_name, \
172		.attributes = NPA_RESOURCE_DEFAULT, \
173		.max = val, \
174		.plugin = &p, \
175		.data = NULL, \
176	}; \
177	struct npa_node_definition n = { \
178		.name = r_name, \
179		.attributes = NPA_NODE_DEFAULT, \
180		.driver_fn = npa_local_agg_driver_fn, \
181		.dependencies = NULL, \
182		.dependency_count = 0, \
183		.resources = &r, \
184		.resource_count = 1, \
185	};
186
187#define DECLARE_RESOURCE_REMOTE_AGGREGATION(n, r, r_name, u_name, val) \
188	struct npa_resource_definition r = { \
189		.name = r_name, \
190		.units = u_name, \
191		.attributes = NPA_RESOURCE_DEFAULT, \
192		.max = val, \
193		.plugin = &npa_remote_agg_plugin, \
194		.data = NULL, \
195	}; \
196	struct npa_node_definition n = {\
197		.name = r_name, \
198		.attributes = NPA_NODE_DEFAULT, \
199		.driver_fn = npa_remote_agg_driver_fn, \
200		.dependencies = NULL, \
201		.dependency_count = 0, \
202		.resources = &r, \
203		.resource_count = 1, \
204	};
205
206/* Defines the remote node.
207 *
208 * @initial_state: The initial state vector of the resources.
209 * @callback: Function to be called when the resource is defined and active
210 * on the remote processor .
211 * @user_data: Argument to the callback function.
212 *
213 * NOTE: Remoting supports only single resource node. If there are multiple
214 * resources for the actual node, multiple remote nodes need to be created.
215 *
216 * Return:
217 *   -ENODEV: If the remote server was not initialized.
218 *   -EINVAL: Invalid input.
219 *   0: The resource is created or awaiting dependencies.
220 */
221int npa_remote_define_node(struct npa_node_definition *node,
222		unsigned int init_state, npa_cb_fn callback, void *data);
223
224#else
225
226static inline int npa_remote_define_node(struct npa_node_definition *node,
227		unsigned int init_state, npa_cb_fn callback, void *data)
228{
229	return -ENOSYS;
230}
231
232#endif
233
234#endif