blob: 0239e36b8a9aad79e87d68f70d82bcdb748a725c [file] [log] [blame]
Mahesh Sivasubramaniana8ff9922012-03-27 17:50:42 -06001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef __ARCH_ARM_MACH_MSM_RPM_SMD_H
15#define __ARCH_ARM_MACH_MSM_RPM_SMD_H
16
17/**
18 * enum msm_rpm_set - RPM enumerations for sleep/active set
19 * %MSM_RPM_CTX_SET_0: Set resource parameters for active mode.
20 * %MSM_RPM_CTX_SET_SLEEP: Set resource parameters for sleep.
21 */
22enum msm_rpm_set {
23 MSM_RPM_CTX_ACTIVE_SET,
24 MSM_RPM_CTX_SLEEP_SET,
25};
26
27struct msm_rpm_request;
28
29struct msm_rpm_kvp {
30 uint32_t key;
31 uint32_t length;
32 uint8_t *data;
33};
34#ifdef CONFIG_MSM_RPM_SMD
35/**
36 * msm_rpm_request() - Creates a parent element to identify the
37 * resource on the RPM, that stores the KVPs for different fields modified
38 * for a hardware resource
39 *
40 * @set: if the device is setting the active/sleep set parameter
41 * for the resource
42 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
43 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
44 * @num_elements: number of KVPs pairs associated with the resource
45 *
46 * returns pointer to a msm_rpm_request on success, NULL on error
47 */
48struct msm_rpm_request *msm_rpm_create_request(
49 enum msm_rpm_set set, uint32_t rsc_type,
50 uint32_t rsc_id, int num_elements);
51
52/**
53 * msm_rpm_request_noirq() - Creates a parent element to identify the
54 * resource on the RPM, that stores the KVPs for different fields modified
55 * for a hardware resource. This function is similar to msm_rpm_create_request
56 * except that it has to be called with interrupts masked.
57 *
58 * @set: if the device is setting the active/sleep set parameter
59 * for the resource
60 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
61 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
62 * @num_elements: number of KVPs pairs associated with the resource
63 *
64 * returns pointer to a msm_rpm_request on success, NULL on error
65 */
66struct msm_rpm_request *msm_rpm_create_request_noirq(
67 enum msm_rpm_set set, uint32_t rsc_type,
68 uint32_t rsc_id, int num_elements);
69
70/**
71 * msm_rpm_add_kvp_data() - Adds a Key value pair to a existing RPM resource.
72 *
73 * @handle: RPM resource handle to which the data should be appended
74 * @key: unsigned integer identify the parameter modified
75 * @data: byte array that contains the value corresponding to key.
76 * @size: size of data in bytes.
77 *
78 * returns 0 on success or errno
79 */
80int msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
81 uint32_t key, const uint8_t *data, int size);
82
83/**
84 * msm_rpm_add_kvp_data_noirq() - Adds a Key value pair to a existing RPM
85 * resource. This function is similar to msm_rpm_add_kvp_data except that it
86 * has to be called with interrupts masked.
87 *
88 * @handle: RPM resource handle to which the data should be appended
89 * @key: unsigned integer identify the parameter modified
90 * @data: byte array that contains the value corresponding to key.
91 * @size: size of data in bytes.
92 *
93 * returns 0 on success or errno
94 */
95int msm_rpm_add_kvp_data_noirq(struct msm_rpm_request *handle,
96 uint32_t key, const uint8_t *data, int size);
97
98/** msm_rpm_free_request() - clean up the RPM request handle created with
99 * msm_rpm_create_request
100 *
101 * @handle: RPM resource handle to be cleared.
102 */
103
104void msm_rpm_free_request(struct msm_rpm_request *handle);
105
106/**
107 * msm_rpm_send_request() - Send the RPM messages using SMD. The function
108 * assigns a message id before sending the data out to the RPM. RPM hardware
109 * uses the message id to acknowledge the messages.
110 *
111 * @handle: pointer to the msm_rpm_request for the resource being modified.
112 *
113 * returns non-zero message id on success and zero on a failed transaction.
114 * The drivers use message id to wait for ACK from RPM.
115 */
116int msm_rpm_send_request(struct msm_rpm_request *handle);
117
118/**
119 * msm_rpm_send_request_noirq() - Send the RPM messages using SMD. The
120 * function assigns a message id before sending the data out to the RPM.
121 * RPM hardware uses the message id to acknowledge the messages. This function
122 * is similar to msm_rpm_send_request except that it has to be called with
123 * interrupts masked.
124 *
125 * @handle: pointer to the msm_rpm_request for the resource being modified.
126 *
127 * returns non-zero message id on success and zero on a failed transaction.
128 * The drivers use message id to wait for ACK from RPM.
129 */
130int msm_rpm_send_request_noirq(struct msm_rpm_request *handle);
131
132/**
133 * msm_rpm_wait_for_ack() - A blocking call that waits for acknowledgment of
134 * a message from RPM.
135 *
136 * @msg_id: the return from msm_rpm_send_requests
137 *
138 * returns 0 on success or errno
139 */
140int msm_rpm_wait_for_ack(uint32_t msg_id);
141
142/**
143 * msm_rpm_wait_for_ack_noirq() - A blocking call that waits for acknowledgment
144 * of a message from RPM. This function is similar to msm_rpm_wait_for_ack
145 * except that it has to be called with interrupts masked.
146 *
147 * @msg_id: the return from msm_rpm_send_request
148 *
149 * returns 0 on success or errno
150 */
151int msm_rpm_wait_for_ack_noirq(uint32_t msg_id);
152
153/**
154 * msm_rpm_send_message() -Wrapper function for clients to send data given an
155 * array of key value pairs.
156 *
157 * @set: if the device is setting the active/sleep set parameter
158 * for the resource
159 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
160 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
161 * @kvp: array of KVP data.
162 * @nelem: number of KVPs pairs associated with the message.
163 *
164 * returns 0 on success and errno on failure.
165 */
166int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
167 uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);
168
169/**
170 * msm_rpm_send_message_noirq() -Wrapper function for clients to send data
171 * given an array of key value pairs. This function is similar to the
172 * msm_rpm_send_message() except that it has to be called with interrupts
173 * disabled. Clients should choose the irq version when possible for system
174 * performance.
175 *
176 * @set: if the device is setting the active/sleep set parameter
177 * for the resource
178 * @rsc_type: unsigned 32 bit integer that identifies the type of the resource
179 * @rsc_id: unsigned 32 bit that uniquely identifies a resource within a type
180 * @kvp: array of KVP data.
181 * @nelem: number of KVPs pairs associated with the message.
182 *
183 * returns 0 on success and errno on failure.
184 */
185int msm_rpm_send_message_noirq(enum msm_rpm_set set, uint32_t rsc_type,
186 uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems);
187
188/**
189 * msm_rpm_driver_init() - Initialization function that registers for a
190 * rpm platform driver.
191 *
192 * returns 0 on success.
193 */
194int __init msm_rpm_driver_init(void);
195
196#else
197
198static inline struct msm_rpm_request *msm_rpm_create_request(
199 enum msm_rpm_set set, uint32_t rsc_type,
200 uint32_t rsc_id, int num_elements)
201{
202 return NULL;
203}
204
205static inline struct msm_rpm_request *msm_rpm_create_request_noirq(
206 enum msm_rpm_set set, uint32_t rsc_type,
207 uint32_t rsc_id, int num_elements)
208{
209 return NULL;
210
211}
212static inline uint32_t msm_rpm_add_kvp_data(struct msm_rpm_request *handle,
213 uint32_t key, const uint8_t *data, int count)
214{
215 return 0;
216}
217static inline uint32_t msm_rpm_add_kvp_data_noirq(
218 struct msm_rpm_request *handle, uint32_t key,
219 const uint8_t *data, int count)
220{
221 return 0;
222}
223
224static inline void msm_rpm_free_request(struct msm_rpm_request *handle)
225{
226 return ;
227}
228
229static inline int msm_rpm_send_request(struct msm_rpm_request *handle)
230{
231 return 0;
232}
233
234static inline int msm_rpm_send_request_noirq(struct msm_rpm_request *handle)
235{
236 return 0;
237
238}
Vikram Mulukutlabe97fbe2012-05-16 21:36:33 -0700239
240static inline int msm_rpm_send_message(enum msm_rpm_set set, uint32_t rsc_type,
241 uint32_t rsc_id, struct msm_rpm_kvp *kvp, int nelems)
242{
243 return 0;
244}
245
246static inline int msm_rpm_send_message_noirq(enum msm_rpm_set set,
247 uint32_t rsc_type, uint32_t rsc_id, struct msm_rpm_kvp *kvp,
248 int nelems)
249{
250 return 0;
251}
252
Mahesh Sivasubramaniana8ff9922012-03-27 17:50:42 -0600253static inline int msm_rpm_wait_for_ack(uint32_t msg_id)
254{
255 return 0;
256
257}
258static inline int msm_rpm_wait_for_ack_noirq(uint32_t msg_id)
259{
260 return 0;
261}
262
263static inline int __init msm_rpm_driver_init(void)
264{
265 return 0;
266}
267#endif
268#endif /*__ARCH_ARM_MACH_MSM_RPM_SMD_H*/