summaryrefslogtreecommitdiff
path: root/arch/arm/mach-wmt/wmt_secure_wait_wake.c
diff options
context:
space:
mode:
authorSrikant Patnaik2015-01-11 12:28:04 +0530
committerSrikant Patnaik2015-01-11 12:28:04 +0530
commit871480933a1c28f8a9fed4c4d34d06c439a7a422 (patch)
tree8718f573808810c2a1e8cb8fb6ac469093ca2784 /arch/arm/mach-wmt/wmt_secure_wait_wake.c
parent9d40ac5867b9aefe0722bc1f110b965ff294d30d (diff)
downloadFOSSEE-netbook-kernel-source-871480933a1c28f8a9fed4c4d34d06c439a7a422.tar.gz
FOSSEE-netbook-kernel-source-871480933a1c28f8a9fed4c4d34d06c439a7a422.tar.bz2
FOSSEE-netbook-kernel-source-871480933a1c28f8a9fed4c4d34d06c439a7a422.zip
Moved, renamed, and deleted files
The original directory structure was scattered and unorganized. Changes are basically to make it look like kernel structure.
Diffstat (limited to 'arch/arm/mach-wmt/wmt_secure_wait_wake.c')
-rwxr-xr-xarch/arm/mach-wmt/wmt_secure_wait_wake.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/arch/arm/mach-wmt/wmt_secure_wait_wake.c b/arch/arm/mach-wmt/wmt_secure_wait_wake.c
new file mode 100755
index 00000000..7f52cb43
--- /dev/null
+++ b/arch/arm/mach-wmt/wmt_secure_wait_wake.c
@@ -0,0 +1,92 @@
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/wait.h>
+#include <linux/workqueue.h>
+#include <linux/sched.h>
+
+#include <mach/wmt_secure.h>
+#include <mach/wmt_env.h>
+
+#define WMT_SMC_CMD_WW_BASE 60
+#define WMT_SMC_CMD_WAIT_STUB (WMT_SMC_CMD_WW_BASE + 1)
+#define WMT_SMC_CMD_WAKE_STUB (WMT_SMC_CMD_WW_BASE + 2)
+#define WMT_SMC_CMD_WAKE_BEGIN (WMT_SMC_CMD_WW_BASE + 3)
+#define WMT_SMC_CMD_WAKE_DONE (WMT_SMC_CMD_WW_BASE + 4)
+#define WMT_SMC_CMD_WW_TEST (WMT_SMC_CMD_WW_BASE + 5)
+
+DECLARE_WAIT_QUEUE_HEAD(wmt_smc_wait);
+static int smc_done = 0;
+
+static void wmt_smc_wait_stub(void)
+{
+ wait_event_interruptible(wmt_smc_wait, smc_done);
+ smc_done = 0;
+ wmt_smc(WMT_SMC_CMD_WAKE_DONE, 0);
+}
+
+static void wmt_smc_wake_stub(void)
+{
+ /* irq already been disabled in secure world */
+ smc_done = 1;
+ wake_up_interruptible(&wmt_smc_wait);
+ wmt_smc(WMT_SMC_CMD_WAKE_BEGIN, 0);
+}
+
+static void wmt_setup_wait_stub(u32 wait_stub)
+{
+ wmt_smc(WMT_SMC_CMD_WAIT_STUB, wait_stub);
+}
+
+static void wmt_setup_wake_stub(u32 wake_stub)
+{
+ wmt_smc(WMT_SMC_CMD_WAKE_STUB, wake_stub);
+}
+
+static int __init wmt_check_secure_env(void)
+{
+ int ret = 0;
+ int varlen = 128;
+ unsigned int sec_en = 0;
+ unsigned char buf[128] = {0};
+
+ /* uboot env name is: wmt.secure.param */
+ ret = wmt_getsyspara("wmt.secure.param", buf, &varlen);
+ if (ret) {
+ ret = -ENODATA;
+ goto out;
+ }
+
+ sscanf(buf, "%d", &sec_en);
+ if (sec_en != 1) {
+ printk(KERN_INFO "wmt security extension disaled\n");
+ ret = -ENODEV;
+ goto out;
+ }
+
+out:
+ return ret;
+}
+static int __init wmt_secure_wait_wake_init(void)
+{
+ /* if secure os disabled, we do not setup stubs */
+ if (wmt_check_secure_env())
+ return -EINVAL;
+
+ wmt_setup_wait_stub((u32)wmt_smc_wait_stub);
+ wmt_setup_wake_stub((u32)wmt_smc_wake_stub);
+
+ return 0;
+}
+module_init(wmt_secure_wait_wake_init);
+
+static void __exit wmt_secure_wait_wake_exit(void)
+{
+ return ;
+}
+module_exit(wmt_secure_wait_wake_exit);
+
+MODULE_AUTHOR("WonderMedia Technologies, Inc");
+MODULE_DESCRIPTION("WMT Secure Wait & Wake Implementation");
+MODULE_LICENSE("Dual BSD/GPL");