msm: scm-io: Replace open-coded register call with SCM atomic

Instead of open-coding the SCM register calling convention, use
the SCM atomic apis.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
This commit is contained in:
Stephen Boyd
2011-07-18 10:36:54 -07:00
committed by Bryan Huntsman
parent 551cd96450
commit e2016608c6
2 changed files with 8 additions and 31 deletions

View File

@@ -16,6 +16,7 @@
#define SCM_SVC_PIL 0x2 #define SCM_SVC_PIL 0x2
#define SCM_SVC_UTIL 0x3 #define SCM_SVC_UTIL 0x3
#define SCM_SVC_TZ 0x4 #define SCM_SVC_TZ 0x4
#define SCM_SVC_IO 0x5
#define SCM_SVC_TZSCHEDULER 0xFC #define SCM_SVC_TZSCHEDULER 0xFC
extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len, extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,

View File

@@ -14,10 +14,11 @@
#include <linux/io.h> #include <linux/io.h>
#include <mach/msm_iomap.h> #include <mach/msm_iomap.h>
#include <mach/scm.h>
#include <mach/scm-io.h> #include <mach/scm-io.h>
#define SCM_IO_READ ((((0x5 << 10) | 0x1) << 12) | (0x2 << 8) | 0x1) #define SCM_IO_READ 0x1
#define SCM_IO_WRITE ((((0x5 << 10) | 0x2) << 12) | (0x2 << 8) | 0x2) #define SCM_IO_WRITE 0x2
#define BETWEEN(p, st, sz) ((p) >= (void __iomem *)(st) && \ #define BETWEEN(p, st, sz) ((p) >= (void __iomem *)(st) && \
(p) < ((void __iomem *)(st) + (sz))) (p) < ((void __iomem *)(st) + (sz)))
@@ -25,21 +26,10 @@
static u32 __secure_readl(u32 addr) static u32 __secure_readl(u32 addr)
{ {
u32 context_id; u32 r;
register u32 r0 asm("r0") = SCM_IO_READ; r = scm_call_atomic1(SCM_SVC_IO, SCM_IO_READ, addr);
register u32 r1 asm("r1") = (u32)&context_id;
register u32 r2 asm("r2") = addr;
asm(
__asmeq("%0", "r0")
__asmeq("%1", "r0")
__asmeq("%2", "r1")
__asmeq("%3", "r2")
"smc #0 @ switch to secure world\n"
: "=r" (r0)
: "r" (r0), "r" (r1), "r" (r2)
);
__iormb(); __iormb();
return r0; return r;
} }
u32 secure_readl(void __iomem *c) u32 secure_readl(void __iomem *c)
@@ -55,22 +45,8 @@ EXPORT_SYMBOL(secure_readl);
static void __secure_writel(u32 v, u32 addr) static void __secure_writel(u32 v, u32 addr)
{ {
u32 context_id;
register u32 r0 asm("r0") = SCM_IO_WRITE;
register u32 r1 asm("r1") = (u32)&context_id;
register u32 r2 asm("r2") = addr;
register u32 r3 asm("r3") = v;
__iowmb(); __iowmb();
asm( scm_call_atomic2(SCM_SVC_IO, SCM_IO_WRITE, addr, v);
__asmeq("%0", "r0")
__asmeq("%1", "r1")
__asmeq("%2", "r2")
__asmeq("%3", "r3")
"smc #0 @ switch to secure world\n"
: /* No return value */
: "r" (r0), "r" (r1), "r" (r2), "r" (r3)
);
} }
void secure_writel(u32 v, void __iomem *c) void secure_writel(u32 v, void __iomem *c)