summaryrefslogtreecommitdiff
path: root/arch/arm/mach-ux500/test/pwr.c
diff options
context:
space:
mode:
authorJonas Aaberg <jonas.aberg@stericsson.com>2011-12-22 09:34:40 +0100
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-06-04 19:45:08 +0800
commitca2d9e858b38d71a97b535b0dca41fe02dae7a0b (patch)
tree09188b43ae4c2ecb2c40f4bde5e43817ece9d17f /arch/arm/mach-ux500/test/pwr.c
parent9ce0109275e82697ada4b005325e663ba72c3181 (diff)
[ANDROID]: ARM: u8500: pm: debug: Add suspend test casepm-android
Add automatic suspend testcase that can be used from android. To use, write the number of time you wish to do suspend to <debugfs>/pwr_test/suspend and when done read the same file. It will answer PASS or FAIL. ST-Ericsson Linux next: - ST-Ericsson ID: 370799 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Iad7d5365e7cde8b9aeeb87e99318e5455d56201f Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/43663
Diffstat (limited to 'arch/arm/mach-ux500/test/pwr.c')
-rw-r--r--arch/arm/mach-ux500/test/pwr.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/arch/arm/mach-ux500/test/pwr.c b/arch/arm/mach-ux500/test/pwr.c
index 5d5d24a38ab..b03492a8fa5 100644
--- a/arch/arm/mach-ux500/test/pwr.c
+++ b/arch/arm/mach-ux500/test/pwr.c
@@ -19,13 +19,18 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/db8500-prcmu.h>
+#include <linux/wakelock.h>
#include <mach/hardware.h>
#include <mach/pm.h>
+#include "../pm/suspend_dbg.h"
#include "../../../drivers/regulator/dbx500-prcmu.h"
#include "../../../drivers/regulator/ab8500-debug.h"
+/* To reach main_wake_lock */
+#include "../../../../kernel/power/power.h"
+
#define PRCC_PCKSR 0x010
#define PRCC_KCKSR 0x014
@@ -777,6 +782,50 @@ static int pwr_test_idle(struct seq_file *s, void *data)
return 0;
}
+static bool suspend_testing;
+static int suspend_test_length;
+
+static ssize_t pm_test_suspend_set(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ long unsigned val;
+ int err;
+
+ err = kstrtoul_from_user(user_buf, count, 0, &val);
+
+ if (err)
+ return err;
+
+ suspend_test_length = (int)val;
+
+ ux500_suspend_dbg_test_start(suspend_test_length);
+
+ suspend_testing = true;
+ wake_unlock(&main_wake_lock);
+
+ pr_info("Will do suspend %d times.\n", suspend_test_length);
+ return count;
+}
+
+static int pwr_test_suspend_status(struct seq_file *s, void *data)
+{
+ bool ongoing = true;
+ bool success;
+
+ if (!suspend_testing) {
+ pr_info("Suspend test not started\n");
+ seq_printf(s, "FAIL\n");
+ return 0;
+ }
+
+ success = ux500_suspend_test_success(&ongoing);
+
+ seq_printf(s,
+ "%s\n", ongoing ? "ONGOING" : (success ? "PASS" : "FAIL"));
+
+ return 0;
+}
int dbx500_regulator_testcase(struct dbx500_regulator_info *regulator_info,
int num_regulators)
@@ -794,6 +843,14 @@ static int pwr_test_debugfs_open(struct inode *inode,
NULL);
}
+static int pwr_test_suspend_debugfs_open(struct inode *inode,
+ struct file *file)
+{
+ return single_open(file,
+ pwr_test_suspend_status,
+ inode->i_private);
+}
+
static const struct file_operations pwr_test_debugfs_ops = {
.open = pwr_test_debugfs_open,
.read = seq_read,
@@ -801,6 +858,14 @@ static const struct file_operations pwr_test_debugfs_ops = {
.release = single_release,
};
+static const struct file_operations pwr_test_suspend_debugfs_ops = {
+ .open = pwr_test_suspend_debugfs_open,
+ .read = seq_read,
+ .write = pm_test_suspend_set,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static struct dentry *debugfs_dir;
static int __init pwr_test_init(void)
@@ -820,6 +885,16 @@ static int __init pwr_test_init(void)
err = PTR_ERR(err_ptr);
goto out;
}
+
+ err_ptr = debugfs_create_file("suspend",
+ S_IWUSR | S_IFREG | S_IRUGO,
+ debugfs_dir, NULL,
+ &pwr_test_suspend_debugfs_ops);
+ if (IS_ERR(err_ptr)) {
+ err = PTR_ERR(err_ptr);
+ goto out;
+ }
+
return 0;
out:
debugfs_remove_recursive(debugfs_dir);