summaryrefslogtreecommitdiff
path: root/include/soc/qcom/rpm-smd.h
blob: 020ffe3082847b30dd00fb69968c33681f2a76ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
/* Copyright (c) 2012, 2014-2015, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#ifndef __ARCH_ARM_MACH_MSM_RPM_SMD_H
#define __ARCH_ARM_MACH_MSM_RPM_SMD_H

/**
 * enum msm_rpm_set - RPM enumerations for sleep/active set
 * %MSM_RPM_CTX_SET_0: Set resource parameters for active mode.
 * %MSM_RPM_CTX_SET_SLEEP: Set resource parameters for sleep.
 */
enum msm_rpm_set {
	MSM_RPM_CTX_ACTIVE_SET,
	MSM_RPM_CTX_SLEEP_SET,
};

struct msm_rpm_request;

struct msm_rpm_kvp {
	uint32_t key;
	uint32_t length;
	uint8_t *data;
};
#ifdef CONFIG_MSM_RPM_SMD
/**
 * msm_rpm_request() - Creates a parent element to identify the
 * resource on the RPM, that stores the KVPs for different fields modified
 * for a hardware resource
 *
 * @set: if the device is setting the active/sleep set parameter
 * for the resource
 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
 * @num_elements: number of KVPs pairs associated with the resource
 *
 * returns pointer to a msm_rpm_request on success, NULL on error
 */
struct msm_rpm_request *msm_rpm_create_request(
		enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, int num_elements);

/**
 * msm_rpm_request_noirq() - Creates a parent element to identify the
 * resource on the RPM, that stores the KVPs for different fields modified
 * for a hardware resource. This function is similar to msm_rpm_create_request
 * except that it has to be called with interrupts masked.
 *
 * @set: if the device is setting the active/sleep set parameter
 * for the resource
 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
 * @num_elements: number of KVPs pairs associated with the resource
 *
 * returns pointer to a msm_rpm_request on success, NULL on error
 */
struct msm_rpm_request *msm_rpm_create_request_noirq(
		enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, int num_elements);

/**
 * msm_rpm_add_kvp_data() - Adds a Key value pair to a existing RPM resource.
 *
 * @handle: RPM resource handle to which the data should be appended
 * @key:  unsigned integer identify the parameter modified
 * @data: byte array that contains the value corresponding to key.
 * @size:   size of data in bytes.
 *
 * returns 0 on success or errno
 */
int msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
		uint32_t key, const uint8_t *data, int size);

/**
 * msm_rpm_add_kvp_data_noirq() - Adds a Key value pair to a existing RPM
 * resource. This function is similar to msm_rpm_add_kvp_data except that it
 * has to be called with interrupts masked.
 *
 * @handle: RPM resource handle to which the data should be appended
 * @key:  unsigned integer identify the parameter modified
 * @data: byte array that contains the value corresponding to key.
 * @size:   size of data in bytes.
 *
 * returns 0 on success or errno
 */
int msm_rpm_add_kvp_data_noirq(struct msm_rpm_request *handle,
		uint32_t key, const uint8_t *data, int size);

/** msm_rpm_free_request() - clean up the RPM request handle created with
 * msm_rpm_create_request
 *
 * @handle: RPM resource handle to be cleared.
 */

void msm_rpm_free_request(struct msm_rpm_request *handle);

/**
 * msm_rpm_send_request() - Send the RPM messages using SMD. The function
 * assigns a message id before sending the data out to the RPM. RPM hardware
 * uses the message id to acknowledge the messages.
 *
 * @handle: pointer to the msm_rpm_request for the resource being modified.
 *
 * returns non-zero message id on success and zero on a failed transaction.
 * The drivers use message id to wait for ACK from RPM.
 */
int msm_rpm_send_request(struct msm_rpm_request *handle);

/**
 * msm_rpm_send_request_noack() - Send the RPM messages using SMD. The function
 * assigns a message id before sending the data out to the RPM. RPM hardware
 * uses the message id to acknowledge the messages, but this API does not wait
 * on the ACK for this message id and it does not add the message id to the wait
 * list.
 *
 * @handle: pointer to the msm_rpm_request for the resource being modified.
 *
 * returns NULL on success and PTR_ERR on a failed transaction.
 */
void *msm_rpm_send_request_noack(struct msm_rpm_request *handle);

/**
 * msm_rpm_send_request_noirq() - Send the RPM messages using SMD. The
 * function assigns a message id before sending the data out to the RPM.
 * RPM hardware uses the message id to acknowledge the messages. This function
 * is similar to msm_rpm_send_request except that it has to be called with
 * interrupts masked.
 *
 * @handle: pointer to the msm_rpm_request for the resource being modified.
 *
 * returns non-zero message id on success and zero on a failed transaction.
 * The drivers use message id to wait for ACK from RPM.
 */
int msm_rpm_send_request_noirq(struct msm_rpm_request *handle);

/**
 * msm_rpm_wait_for_ack() - A blocking call that waits for acknowledgment of
 * a message from RPM.
 *
 * @msg_id: the return from msm_rpm_send_requests
 *
 * returns 0 on success or errno
 */
int msm_rpm_wait_for_ack(uint32_t msg_id);

/**
 * msm_rpm_wait_for_ack_noirq() - A blocking call that waits for acknowledgment
 * of a message from RPM. This function is similar to msm_rpm_wait_for_ack
 * except that it has to be called with interrupts masked.
 *
 * @msg_id: the return from msm_rpm_send_request
 *
 * returns 0 on success or errno
 */
int msm_rpm_wait_for_ack_noirq(uint32_t msg_id);

/**
 * msm_rpm_send_message() -Wrapper function for clients to send data given an
 * array of key value pairs.
 *
 * @set: if the device is setting the active/sleep set parameter
 * for the resource
 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
 * @kvp: array of KVP data.
 * @nelem: number of KVPs pairs associated with the message.
 *
 * returns  0 on success and errno on failure.
 */
int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);

/**
 * msm_rpm_send_message_noack() -Wrapper function for clients to send data
 * given an array of key value pairs without waiting for ack.
 *
 * @set: if the device is setting the active/sleep set parameter
 * for the resource
 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
 * @kvp: array of KVP data.
 * @nelem: number of KVPs pairs associated with the message.
 *
 * returns  NULL on success and PTR_ERR(errno) on failure.
 */
void *msm_rpm_send_message_noack(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);

/**
 * msm_rpm_send_message_noirq() -Wrapper function for clients to send data
 * given an array of key value pairs. This function is similar to the
 * msm_rpm_send_message() except that it has to be called with interrupts
 * disabled. Clients should choose the irq version when possible for system
 * performance.
 *
 * @set: if the device is setting the active/sleep set parameter
 * for the resource
 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
 * @kvp: array of KVP data.
 * @nelem: number of KVPs pairs associated with the message.
 *
 * returns  0 on success and errno on failure.
 */
int msm_rpm_send_message_noirq(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);

/**
 * msm_rpm_driver_init() - Initialization function that registers for a
 * rpm platform driver.
 *
 * returns 0 on success.
 */
int __init msm_rpm_driver_init(void);

#else

static inline struct msm_rpm_request *msm_rpm_create_request(
		enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, int num_elements)
{
	return NULL;
}

static inline struct msm_rpm_request *msm_rpm_create_request_noirq(
		enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, int num_elements)
{
	return NULL;

}
static inline uint32_t msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
		uint32_t key, const uint8_t *data, int count)
{
	return 0;
}
static inline uint32_t msm_rpm_add_kvp_data_noirq(
		struct msm_rpm_request *handle, uint32_t key,
		const uint8_t *data, int count)
{
	return 0;
}

static inline void msm_rpm_free_request(struct msm_rpm_request *handle)
{
	return;
}

static inline int msm_rpm_send_request(struct msm_rpm_request *handle)
{
	return 0;
}

static inline int msm_rpm_send_request_noirq(struct msm_rpm_request *handle)
{
	return 0;

}

static inline void *msm_rpm_send_request_noack(struct msm_rpm_request *handle)
{
	return NULL;
}

static inline int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
		uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
{
	return 0;
}

static inline int msm_rpm_send_message_noirq(enum msm_rpm_set set,
		uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp,
		int nelems)
{
	return 0;
}

static inline void *msm_rpm_send_message_noack(enum msm_rpm_set set,
		uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp,
		int nelems)
{
	return NULL;
}

static inline int msm_rpm_wait_for_ack(uint32_t msg_id)
{
	return 0;

}
static inline int msm_rpm_wait_for_ack_noirq(uint32_t msg_id)
{
	return 0;
}

static inline int __init msm_rpm_driver_init(void)
{
	return 0;
}
#endif
#endif /*__ARCH_ARM_MACH_MSM_RPM_SMD_H*/