aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-qcom
diff options
context:
space:
mode:
authorKumar Gala <galak@codeaurora.org>2015-02-04 17:30:46 -0500
committerKumar Gala <galak@codeaurora.org>2015-03-11 16:06:37 -0400
commit4de43476fc1baaf2bb7a520fc9e3b1797943b615 (patch)
tree1f68e9c580db33a5ce0e064469fb7a5f6d12475f /arch/arm/mach-qcom
parentb97fdb6dc0effe0612bc60fc9db7017b9fd81932 (diff)
ARM: qcom: Prep scm code for move to drivers/firmware
Add qcom prefix to functions, etc to create a unique name space for the scm code as it gets ready to move out of qcom specific mach dir. Signed-off-by: Kumar Gala <galak@codeaurora.org>
Diffstat (limited to 'arch/arm/mach-qcom')
-rw-r--r--arch/arm/mach-qcom/platsmp.c8
-rw-r--r--arch/arm/mach-qcom/scm.c148
-rw-r--r--arch/arm/mach-qcom/scm.h24
3 files changed, 90 insertions, 90 deletions
diff --git a/arch/arm/mach-qcom/platsmp.c b/arch/arm/mach-qcom/platsmp.c
index 8f4962ebf8c2..596e6237dc7e 100644
--- a/arch/arm/mach-qcom/platsmp.c
+++ b/arch/arm/mach-qcom/platsmp.c
@@ -323,9 +323,9 @@ static void __init qcom_smp_prepare_cpus(unsigned int max_cpus)
323 unsigned int flags = 0; 323 unsigned int flags = 0;
324 static const int cold_boot_flags[] = { 324 static const int cold_boot_flags[] = {
325 0, 325 0,
326 SCM_FLAG_COLDBOOT_CPU1, 326 QCOM_SCM_FLAG_COLDBOOT_CPU1,
327 SCM_FLAG_COLDBOOT_CPU2, 327 QCOM_SCM_FLAG_COLDBOOT_CPU2,
328 SCM_FLAG_COLDBOOT_CPU3, 328 QCOM_SCM_FLAG_COLDBOOT_CPU3,
329 }; 329 };
330 330
331 for_each_present_cpu(cpu) { 331 for_each_present_cpu(cpu) {
@@ -337,7 +337,7 @@ static void __init qcom_smp_prepare_cpus(unsigned int max_cpus)
337 flags |= cold_boot_flags[map]; 337 flags |= cold_boot_flags[map];
338 } 338 }
339 339
340 if (scm_set_boot_addr(virt_to_phys(secondary_startup_arm), flags)) { 340 if (qcom_scm_set_boot_addr(virt_to_phys(secondary_startup_arm), flags)) {
341 for_each_present_cpu(cpu) { 341 for_each_present_cpu(cpu) {
342 if (cpu == smp_processor_id()) 342 if (cpu == smp_processor_id())
343 continue; 343 continue;
diff --git a/arch/arm/mach-qcom/scm.c b/arch/arm/mach-qcom/scm.c
index 5147666be096..3e0e334374de 100644
--- a/arch/arm/mach-qcom/scm.c
+++ b/arch/arm/mach-qcom/scm.c
@@ -27,40 +27,40 @@
27 27
28#include "scm.h" 28#include "scm.h"
29 29
30#define SCM_ENOMEM -5 30#define QCOM_SCM_ENOMEM -5
31#define SCM_EOPNOTSUPP -4 31#define QCOM_SCM_EOPNOTSUPP -4
32#define SCM_EINVAL_ADDR -3 32#define QCOM_SCM_EINVAL_ADDR -3
33#define SCM_EINVAL_ARG -2 33#define QCOM_SCM_EINVAL_ARG -2
34#define SCM_ERROR -1 34#define QCOM_SCM_ERROR -1
35#define SCM_INTERRUPTED 1 35#define QCOM_SCM_INTERRUPTED 1
36 36
37static DEFINE_MUTEX(scm_lock); 37static DEFINE_MUTEX(qcom_scm_lock);
38 38
39/** 39/**
40 * struct scm_command - one SCM command buffer 40 * struct qcom_scm_command - one SCM command buffer
41 * @len: total available memory for command and response 41 * @len: total available memory for command and response
42 * @buf_offset: start of command buffer 42 * @buf_offset: start of command buffer
43 * @resp_hdr_offset: start of response buffer 43 * @resp_hdr_offset: start of response buffer
44 * @id: command to be executed 44 * @id: command to be executed
45 * @buf: buffer returned from scm_get_command_buffer() 45 * @buf: buffer returned from qcom_scm_get_command_buffer()
46 * 46 *
47 * An SCM command is laid out in memory as follows: 47 * An SCM command is laid out in memory as follows:
48 * 48 *
49 * ------------------- <--- struct scm_command 49 * ------------------- <--- struct qcom_scm_command
50 * | command header | 50 * | command header |
51 * ------------------- <--- scm_get_command_buffer() 51 * ------------------- <--- qcom_scm_get_command_buffer()
52 * | command buffer | 52 * | command buffer |
53 * ------------------- <--- struct scm_response and 53 * ------------------- <--- struct qcom_scm_response and
54 * | response header | scm_command_to_response() 54 * | response header | qcom_scm_command_to_response()
55 * ------------------- <--- scm_get_response_buffer() 55 * ------------------- <--- qcom_scm_get_response_buffer()
56 * | response buffer | 56 * | response buffer |
57 * ------------------- 57 * -------------------
58 * 58 *
59 * There can be arbitrary padding between the headers and buffers so 59 * There can be arbitrary padding between the headers and buffers so
60 * you should always use the appropriate scm_get_*_buffer() routines 60 * you should always use the appropriate qcom_scm_get_*_buffer() routines
61 * to access the buffers in a safe manner. 61 * to access the buffers in a safe manner.
62 */ 62 */
63struct scm_command { 63struct qcom_scm_command {
64 __le32 len; 64 __le32 len;
65 __le32 buf_offset; 65 __le32 buf_offset;
66 __le32 resp_hdr_offset; 66 __le32 resp_hdr_offset;
@@ -69,38 +69,38 @@ struct scm_command {
69}; 69};
70 70
71/** 71/**
72 * struct scm_response - one SCM response buffer 72 * struct qcom_scm_response - one SCM response buffer
73 * @len: total available memory for response 73 * @len: total available memory for response
74 * @buf_offset: start of response data relative to start of scm_response 74 * @buf_offset: start of response data relative to start of qcom_scm_response
75 * @is_complete: indicates if the command has finished processing 75 * @is_complete: indicates if the command has finished processing
76 */ 76 */
77struct scm_response { 77struct qcom_scm_response {
78 __le32 len; 78 __le32 len;
79 __le32 buf_offset; 79 __le32 buf_offset;
80 __le32 is_complete; 80 __le32 is_complete;
81}; 81};
82 82
83/** 83/**
84 * alloc_scm_command() - Allocate an SCM command 84 * alloc_qcom_scm_command() - Allocate an SCM command
85 * @cmd_size: size of the command buffer 85 * @cmd_size: size of the command buffer
86 * @resp_size: size of the response buffer 86 * @resp_size: size of the response buffer
87 * 87 *
88 * Allocate an SCM command, including enough room for the command 88 * Allocate an SCM command, including enough room for the command
89 * and response headers as well as the command and response buffers. 89 * and response headers as well as the command and response buffers.
90 * 90 *
91 * Returns a valid &scm_command on success or %NULL if the allocation fails. 91 * Returns a valid &qcom_scm_command on success or %NULL if the allocation fails.
92 */ 92 */
93static struct scm_command *alloc_scm_command(size_t cmd_size, size_t resp_size) 93static struct qcom_scm_command *alloc_qcom_scm_command(size_t cmd_size, size_t resp_size)
94{ 94{
95 struct scm_command *cmd; 95 struct qcom_scm_command *cmd;
96 size_t len = sizeof(*cmd) + sizeof(struct scm_response) + cmd_size + 96 size_t len = sizeof(*cmd) + sizeof(struct qcom_scm_response) + cmd_size +
97 resp_size; 97 resp_size;
98 u32 offset; 98 u32 offset;
99 99
100 cmd = kzalloc(PAGE_ALIGN(len), GFP_KERNEL); 100 cmd = kzalloc(PAGE_ALIGN(len), GFP_KERNEL);
101 if (cmd) { 101 if (cmd) {
102 cmd->len = cpu_to_le32(len); 102 cmd->len = cpu_to_le32(len);
103 offset = offsetof(struct scm_command, buf); 103 offset = offsetof(struct qcom_scm_command, buf);
104 cmd->buf_offset = cpu_to_le32(offset); 104 cmd->buf_offset = cpu_to_le32(offset);
105 cmd->resp_hdr_offset = cpu_to_le32(offset + cmd_size); 105 cmd->resp_hdr_offset = cpu_to_le32(offset + cmd_size);
106 } 106 }
@@ -108,62 +108,62 @@ static struct scm_command *alloc_scm_command(size_t cmd_size, size_t resp_size)
108} 108}
109 109
110/** 110/**
111 * free_scm_command() - Free an SCM command 111 * free_qcom_scm_command() - Free an SCM command
112 * @cmd: command to free 112 * @cmd: command to free
113 * 113 *
114 * Free an SCM command. 114 * Free an SCM command.
115 */ 115 */
116static inline void free_scm_command(struct scm_command *cmd) 116static inline void free_qcom_scm_command(struct qcom_scm_command *cmd)
117{ 117{
118 kfree(cmd); 118 kfree(cmd);
119} 119}
120 120
121/** 121/**
122 * scm_command_to_response() - Get a pointer to a scm_response 122 * qcom_scm_command_to_response() - Get a pointer to a qcom_scm_response
123 * @cmd: command 123 * @cmd: command
124 * 124 *
125 * Returns a pointer to a response for a command. 125 * Returns a pointer to a response for a command.
126 */ 126 */
127static inline struct scm_response *scm_command_to_response( 127static inline struct qcom_scm_response *qcom_scm_command_to_response(
128 const struct scm_command *cmd) 128 const struct qcom_scm_command *cmd)
129{ 129{
130 return (void *)cmd + le32_to_cpu(cmd->resp_hdr_offset); 130 return (void *)cmd + le32_to_cpu(cmd->resp_hdr_offset);
131} 131}
132 132
133/** 133/**
134 * scm_get_command_buffer() - Get a pointer to a command buffer 134 * qcom_scm_get_command_buffer() - Get a pointer to a command buffer
135 * @cmd: command 135 * @cmd: command
136 * 136 *
137 * Returns a pointer to the command buffer of a command. 137 * Returns a pointer to the command buffer of a command.
138 */ 138 */
139static inline void *scm_get_command_buffer(const struct scm_command *cmd) 139static inline void *qcom_scm_get_command_buffer(const struct qcom_scm_command *cmd)
140{ 140{
141 return (void *)cmd->buf; 141 return (void *)cmd->buf;
142} 142}
143 143
144/** 144/**
145 * scm_get_response_buffer() - Get a pointer to a response buffer 145 * qcom_scm_get_response_buffer() - Get a pointer to a response buffer
146 * @rsp: response 146 * @rsp: response
147 * 147 *
148 * Returns a pointer to a response buffer of a response. 148 * Returns a pointer to a response buffer of a response.
149 */ 149 */
150static inline void *scm_get_response_buffer(const struct scm_response *rsp) 150static inline void *qcom_scm_get_response_buffer(const struct qcom_scm_response *rsp)
151{ 151{
152 return (void *)rsp + le32_to_cpu(rsp->buf_offset); 152 return (void *)rsp + le32_to_cpu(rsp->buf_offset);
153} 153}
154 154
155static int scm_remap_error(int err) 155static int qcom_scm_remap_error(int err)
156{ 156{
157 pr_err("scm_call failed with error code %d\n", err); 157 pr_err("qcom_scm_call failed with error code %d\n", err);
158 switch (err) { 158 switch (err) {
159 case SCM_ERROR: 159 case QCOM_SCM_ERROR:
160 return -EIO; 160 return -EIO;
161 case SCM_EINVAL_ADDR: 161 case QCOM_SCM_EINVAL_ADDR:
162 case SCM_EINVAL_ARG: 162 case QCOM_SCM_EINVAL_ARG:
163 return -EINVAL; 163 return -EINVAL;
164 case SCM_EOPNOTSUPP: 164 case QCOM_SCM_EOPNOTSUPP:
165 return -EOPNOTSUPP; 165 return -EOPNOTSUPP;
166 case SCM_ENOMEM: 166 case QCOM_SCM_ENOMEM:
167 return -ENOMEM; 167 return -ENOMEM;
168 } 168 }
169 return -EINVAL; 169 return -EINVAL;
@@ -188,12 +188,12 @@ static u32 smc(u32 cmd_addr)
188 : "=r" (r0) 188 : "=r" (r0)
189 : "r" (r0), "r" (r1), "r" (r2) 189 : "r" (r0), "r" (r1), "r" (r2)
190 : "r3"); 190 : "r3");
191 } while (r0 == SCM_INTERRUPTED); 191 } while (r0 == QCOM_SCM_INTERRUPTED);
192 192
193 return r0; 193 return r0;
194} 194}
195 195
196static int __scm_call(const struct scm_command *cmd) 196static int __qcom_scm_call(const struct qcom_scm_command *cmd)
197{ 197{
198 int ret; 198 int ret;
199 u32 cmd_addr = virt_to_phys(cmd); 199 u32 cmd_addr = virt_to_phys(cmd);
@@ -207,12 +207,12 @@ static int __scm_call(const struct scm_command *cmd)
207 207
208 ret = smc(cmd_addr); 208 ret = smc(cmd_addr);
209 if (ret < 0) 209 if (ret < 0)
210 ret = scm_remap_error(ret); 210 ret = qcom_scm_remap_error(ret);
211 211
212 return ret; 212 return ret;
213} 213}
214 214
215static void scm_inv_range(unsigned long start, unsigned long end) 215static void qcom_scm_inv_range(unsigned long start, unsigned long end)
216{ 216{
217 u32 cacheline_size, ctr; 217 u32 cacheline_size, ctr;
218 218
@@ -232,7 +232,7 @@ static void scm_inv_range(unsigned long start, unsigned long end)
232} 232}
233 233
234/** 234/**
235 * scm_call() - Send an SCM command 235 * qcom_scm_call() - Send an SCM command
236 * @svc_id: service identifier 236 * @svc_id: service identifier
237 * @cmd_id: command identifier 237 * @cmd_id: command identifier
238 * @cmd_buf: command buffer 238 * @cmd_buf: command buffer
@@ -244,51 +244,51 @@ static void scm_inv_range(unsigned long start, unsigned long end)
244 * 244 *
245 * A note on cache maintenance: 245 * A note on cache maintenance:
246 * Note that any buffers that are expected to be accessed by the secure world 246 * Note that any buffers that are expected to be accessed by the secure world
247 * must be flushed before invoking scm_call and invalidated in the cache 247 * must be flushed before invoking qcom_scm_call and invalidated in the cache
248 * immediately after scm_call returns. Cache maintenance on the command and 248 * immediately after qcom_scm_call returns. Cache maintenance on the command
249 * response buffers is taken care of by scm_call; however, callers are 249 * and response buffers is taken care of by qcom_scm_call; however, callers are
250 * responsible for any other cached buffers passed over to the secure world. 250 * responsible for any other cached buffers passed over to the secure world.
251 */ 251 */
252static int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, 252static int qcom_scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf,
253 void *resp_buf, size_t resp_len) 253 size_t cmd_len, void *resp_buf, size_t resp_len)
254{ 254{
255 int ret; 255 int ret;
256 struct scm_command *cmd; 256 struct qcom_scm_command *cmd;
257 struct scm_response *rsp; 257 struct qcom_scm_response *rsp;
258 unsigned long start, end; 258 unsigned long start, end;
259 259
260 cmd = alloc_scm_command(cmd_len, resp_len); 260 cmd = alloc_qcom_scm_command(cmd_len, resp_len);
261 if (!cmd) 261 if (!cmd)
262 return -ENOMEM; 262 return -ENOMEM;
263 263
264 cmd->id = cpu_to_le32((svc_id << 10) | cmd_id); 264 cmd->id = cpu_to_le32((svc_id << 10) | cmd_id);
265 if (cmd_buf) 265 if (cmd_buf)
266 memcpy(scm_get_command_buffer(cmd), cmd_buf, cmd_len); 266 memcpy(qcom_scm_get_command_buffer(cmd), cmd_buf, cmd_len);
267 267
268 mutex_lock(&scm_lock); 268 mutex_lock(&qcom_scm_lock);
269 ret = __scm_call(cmd); 269 ret = __qcom_scm_call(cmd);
270 mutex_unlock(&scm_lock); 270 mutex_unlock(&qcom_scm_lock);
271 if (ret) 271 if (ret)
272 goto out; 272 goto out;
273 273
274 rsp = scm_command_to_response(cmd); 274 rsp = qcom_scm_command_to_response(cmd);
275 start = (unsigned long)rsp; 275 start = (unsigned long)rsp;
276 276
277 do { 277 do {
278 scm_inv_range(start, start + sizeof(*rsp)); 278 qcom_scm_inv_range(start, start + sizeof(*rsp));
279 } while (!rsp->is_complete); 279 } while (!rsp->is_complete);
280 280
281 end = (unsigned long)scm_get_response_buffer(rsp) + resp_len; 281 end = (unsigned long)qcom_scm_get_response_buffer(rsp) + resp_len;
282 scm_inv_range(start, end); 282 qcom_scm_inv_range(start, end);
283 283
284 if (resp_buf) 284 if (resp_buf)
285 memcpy(resp_buf, scm_get_response_buffer(rsp), resp_len); 285 memcpy(resp_buf, qcom_scm_get_response_buffer(rsp), resp_len);
286out: 286out:
287 free_scm_command(cmd); 287 free_qcom_scm_command(cmd);
288 return ret; 288 return ret;
289} 289}
290 290
291u32 scm_get_version(void) 291u32 qcom_scm_get_version(void)
292{ 292{
293 int context_id; 293 int context_id;
294 static u32 version = -1; 294 static u32 version = -1;
@@ -298,7 +298,7 @@ u32 scm_get_version(void)
298 if (version != -1) 298 if (version != -1)
299 return version; 299 return version;
300 300
301 mutex_lock(&scm_lock); 301 mutex_lock(&qcom_scm_lock);
302 302
303 r0 = 0x1 << 8; 303 r0 = 0x1 << 8;
304 r1 = (u32)&context_id; 304 r1 = (u32)&context_id;
@@ -315,21 +315,21 @@ u32 scm_get_version(void)
315 : "=r" (r0), "=r" (r1) 315 : "=r" (r0), "=r" (r1)
316 : "r" (r0), "r" (r1) 316 : "r" (r0), "r" (r1)
317 : "r2", "r3"); 317 : "r2", "r3");
318 } while (r0 == SCM_INTERRUPTED); 318 } while (r0 == QCOM_SCM_INTERRUPTED);
319 319
320 version = r1; 320 version = r1;
321 mutex_unlock(&scm_lock); 321 mutex_unlock(&qcom_scm_lock);
322 322
323 return version; 323 return version;
324} 324}
325EXPORT_SYMBOL(scm_get_version); 325EXPORT_SYMBOL(qcom_scm_get_version);
326 326
327#define SCM_SVC_BOOT 0x1 327#define QCOM_SCM_SVC_BOOT 0x1
328#define SCM_BOOT_ADDR 0x1 328#define QCOM_SCM_BOOT_ADDR 0x1
329/* 329/*
330 * Set the cold/warm boot address for one of the CPU cores. 330 * Set the cold/warm boot address for one of the CPU cores.
331 */ 331 */
332int scm_set_boot_addr(u32 addr, int flags) 332int qcom_scm_set_boot_addr(u32 addr, int flags)
333{ 333{
334 struct { 334 struct {
335 __le32 flags; 335 __le32 flags;
@@ -338,7 +338,7 @@ int scm_set_boot_addr(u32 addr, int flags)
338 338
339 cmd.addr = cpu_to_le32(addr); 339 cmd.addr = cpu_to_le32(addr);
340 cmd.flags = cpu_to_le32(flags); 340 cmd.flags = cpu_to_le32(flags);
341 return scm_call(SCM_SVC_BOOT, SCM_BOOT_ADDR, 341 return qcom_scm_call(QCOM_SCM_SVC_BOOT, QCOM_SCM_BOOT_ADDR,
342 &cmd, sizeof(cmd), NULL, 0); 342 &cmd, sizeof(cmd), NULL, 0);
343} 343}
344EXPORT_SYMBOL(scm_set_boot_addr); 344EXPORT_SYMBOL(qcom_scm_set_boot_addr);
diff --git a/arch/arm/mach-qcom/scm.h b/arch/arm/mach-qcom/scm.h
index d73c3786c881..6bb84cffb396 100644
--- a/arch/arm/mach-qcom/scm.h
+++ b/arch/arm/mach-qcom/scm.h
@@ -9,21 +9,21 @@
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details. 10 * GNU General Public License for more details.
11 */ 11 */
12#ifndef __MACH_SCM_H 12#ifndef __QCOM_SCM_H
13#define __MACH_SCM_H 13#define __QCOM_SCM_H
14 14
15#define SCM_FLAG_COLDBOOT_CPU1 0x01 15#define QCOM_SCM_FLAG_COLDBOOT_CPU1 0x01
16#define SCM_FLAG_COLDBOOT_CPU2 0x08 16#define QCOM_SCM_FLAG_COLDBOOT_CPU2 0x08
17#define SCM_FLAG_COLDBOOT_CPU3 0x20 17#define QCOM_SCM_FLAG_COLDBOOT_CPU3 0x20
18#define SCM_FLAG_WARMBOOT_CPU0 0x04 18#define QCOM_SCM_FLAG_WARMBOOT_CPU0 0x04
19#define SCM_FLAG_WARMBOOT_CPU1 0x02 19#define QCOM_SCM_FLAG_WARMBOOT_CPU1 0x02
20#define SCM_FLAG_WARMBOOT_CPU2 0x10 20#define QCOM_SCM_FLAG_WARMBOOT_CPU2 0x10
21#define SCM_FLAG_WARMBOOT_CPU3 0x40 21#define QCOM_SCM_FLAG_WARMBOOT_CPU3 0x40
22 22
23extern int scm_set_boot_addr(u32 addr, int flags); 23extern int qcom_scm_set_boot_addr(u32 addr, int flags);
24 24
25#define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF)) 25#define QCOM_SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF))
26 26
27extern u32 scm_get_version(void); 27extern u32 qcom_scm_get_version(void);
28 28
29#endif 29#endif