rk: pm_tests: add delayline support
authorchenxing <chenxing@rock-chips.com>
Fri, 10 May 2013 02:22:13 +0000 (10:22 +0800)
committerchenxing <chenxing@rock-chips.com>
Fri, 10 May 2013 02:22:28 +0000 (10:22 +0800)
arch/arm/plat-rk/rk_pm_tests/Kconfig
arch/arm/plat-rk/rk_pm_tests/Makefile
arch/arm/plat-rk/rk_pm_tests/delayline.c [new file with mode: 0644]
arch/arm/plat-rk/rk_pm_tests/delayline.h [new file with mode: 0644]
arch/arm/plat-rk/rk_pm_tests/rk_pm_tests.c

index 4acf1bf425f6349b3c82a1a9c125ab767fa00b9b..1b137269e3ce06b1864fd91f487f1f147aaa46f2 100755 (executable)
@@ -43,4 +43,9 @@ config PM_TEST_CLK_AUTO_VOLT
        help
          Use to auto scale regulator's voltage by step
 
+config PM_TEST_DELAYLINE
+       bool "Get delayline value"
+       help
+         Use to get delayline value
+
 endif
index 6d01b0bcdbad23af744e90a9e51b0edc530ece2b..09c3d4425ef90f596e1096d748255820561b95b4 100644 (file)
@@ -8,3 +8,4 @@ obj-$(CONFIG_PM_TEST_FREQ_LIMIT) += freq_limit.o
 obj-$(CONFIG_PM_TEST_CPU_USAGE) += cpu_usage.o
 obj-$(CONFIG_PM_TEST_SUSPEND_DBG) += rk_suspend_test.o
 obj-$(CONFIG_PM_TEST_CLK_AUTO_VOLT) += clk_auto_volt.o
+obj-$(CONFIG_PM_TEST_DELAYLINE) += delayline.o
diff --git a/arch/arm/plat-rk/rk_pm_tests/delayline.c b/arch/arm/plat-rk/rk_pm_tests/delayline.c
new file mode 100644 (file)
index 0000000..1ed73d9
--- /dev/null
@@ -0,0 +1,87 @@
+#include <linux/clk.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/resume-trace.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <linux/syscalls.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/cpu.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/regulator/machine.h>
+#include <plat/dma-pl330.h>
+#include <linux/mfd/wm831x/core.h>
+#include <linux/sysfs.h>
+#include <linux/err.h>
+#include <linux/cpufreq.h>
+#include <mach/ddr.h>
+#include <mach/dvfs.h>
+
+#include <linux/fs.h>
+#include <asm/unistd.h>
+#include <asm/uaccess.h>
+#include "rk_pm_tests.h"
+#include "delayline.h"
+/***************************************************************************/
+#define ARM_MODE_TIMER_MSEC    500
+static int delayline_time_msec = ARM_MODE_TIMER_MSEC;
+
+static struct timer_list delayline_timer;
+int running = 0;
+extern int rk3188_get_delayline_value(void);
+
+static void timer_handler(unsigned long data)
+{
+       int delayline = rk3188_get_delayline_value();
+       PM_DBG("enter %s\n", __func__);
+
+       if (running == 0) {
+               PM_DBG("STOP\n");
+               return ;
+       }
+
+       mod_timer(&delayline_timer, jiffies + msecs_to_jiffies(delayline_time_msec));
+       printk("Current delayline value = %d\n", delayline);
+}
+
+ssize_t delayline_show(struct kobject *kobj, struct kobj_attribute *attr,
+               char *buf)
+{
+       char *str = buf;
+       int delayline = rk3188_get_delayline_value();
+       str += sprintf(str, "Current delayline value = %d\necho start [time] > delayline\n", delayline);
+       if (str != buf)
+               *(str - 1) = '\n';
+       return (str - buf);
+
+}
+
+ssize_t delayline_store(struct kobject *kobj, struct kobj_attribute *attr,
+               const char *buf, size_t n)
+{
+       
+       char cmd[20];
+       sscanf(buf, "%s %d", cmd, &delayline_time_msec);
+
+       if((strncmp(cmd, "start", strlen("start")) == 0)) {
+               PM_DBG("get cmd start, time = %d\n", delayline_time_msec);
+               running = 1;
+               delayline_timer.expires = jiffies + msecs_to_jiffies(delayline_time_msec);
+               add_timer(&delayline_timer);
+       }else if ((strncmp(cmd, "stop", strlen("stop")) == 0)) {
+               PM_DBG("get cmd stop\n");
+               running = 0;
+       }
+       return n;
+}
+
+static int __init delayline_init(void)
+{
+       setup_timer(&delayline_timer, timer_handler, (unsigned int)NULL);
+       return 0;
+}
+late_initcall(delayline_init);
diff --git a/arch/arm/plat-rk/rk_pm_tests/delayline.h b/arch/arm/plat-rk/rk_pm_tests/delayline.h
new file mode 100644 (file)
index 0000000..766e24d
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef _DELAYLINE_H_
+#define _DELAYLINE_H_
+ssize_t delayline_show(struct kobject *kobj, struct kobj_attribute *attr,
+               char *buf);
+ssize_t delayline_store(struct kobject *kobj, struct kobj_attribute *attr,
+               const char *buf, size_t n);
+
+#endif
index e20cd5e0c33382a991554f2ca617f32fcfca1c46..239e0759fb43c6eaa15c64c051d7a8a1803746cd 100755 (executable)
@@ -55,6 +55,7 @@ REVISION 0.01
 #include "cpu_usage.h"
 #include "rk_suspend_test.h"
 #include "clk_auto_volt.h"
+#include "delayline.h"
 //#include "rk2928_freq.h"
 //#include "rk2928_max_freq.h"
 //#include "cpu_calc.h"
@@ -95,6 +96,9 @@ static struct pm_attribute pm_attrs[] = {
 #ifdef CONFIG_PM_TEST_CLK_AUTO_VOLT
        __ATTR(clk_auto_volt, S_IRUGO | S_IWUSR, clk_auto_volt_show, clk_auto_volt_store),
 #endif
+#ifdef CONFIG_PM_TEST_DELAYLINE
+       __ATTR(delayline, S_IRUGO | S_IWUSR, delayline_show, delayline_store),
+#endif
 #if 0
        __ATTR(ddr_scale_freq, S_IRUGO | S_IWUSR, ddr_scale_freq_show, ddr_scale_freq_store),
        __ATTR(pmic_delay, S_IRUGO | S_IWUSR, pmic_delay_show, pmic_delay_store),