From eac42ad1855ea206c193ab666b1a6ce48d8c60e0 Mon Sep 17 00:00:00 2001 From: chenxing Date: Fri, 10 May 2013 10:22:13 +0800 Subject: [PATCH] rk: pm_tests: add delayline support --- arch/arm/plat-rk/rk_pm_tests/Kconfig | 5 ++ arch/arm/plat-rk/rk_pm_tests/Makefile | 1 + arch/arm/plat-rk/rk_pm_tests/delayline.c | 87 ++++++++++++++++++++++ arch/arm/plat-rk/rk_pm_tests/delayline.h | 8 ++ arch/arm/plat-rk/rk_pm_tests/rk_pm_tests.c | 4 + 5 files changed, 105 insertions(+) create mode 100644 arch/arm/plat-rk/rk_pm_tests/delayline.c create mode 100644 arch/arm/plat-rk/rk_pm_tests/delayline.h diff --git a/arch/arm/plat-rk/rk_pm_tests/Kconfig b/arch/arm/plat-rk/rk_pm_tests/Kconfig index 4acf1bf425f6..1b137269e3ce 100755 --- a/arch/arm/plat-rk/rk_pm_tests/Kconfig +++ b/arch/arm/plat-rk/rk_pm_tests/Kconfig @@ -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 diff --git a/arch/arm/plat-rk/rk_pm_tests/Makefile b/arch/arm/plat-rk/rk_pm_tests/Makefile index 6d01b0bcdbad..09c3d4425ef9 100644 --- a/arch/arm/plat-rk/rk_pm_tests/Makefile +++ b/arch/arm/plat-rk/rk_pm_tests/Makefile @@ -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 index 000000000000..1ed73d9f15f3 --- /dev/null +++ b/arch/arm/plat-rk/rk_pm_tests/delayline.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#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 index 000000000000..766e24d7548d --- /dev/null +++ b/arch/arm/plat-rk/rk_pm_tests/delayline.h @@ -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 diff --git a/arch/arm/plat-rk/rk_pm_tests/rk_pm_tests.c b/arch/arm/plat-rk/rk_pm_tests/rk_pm_tests.c index e20cd5e0c333..239e0759fb43 100755 --- a/arch/arm/plat-rk/rk_pm_tests/rk_pm_tests.c +++ b/arch/arm/plat-rk/rk_pm_tests/rk_pm_tests.c @@ -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), -- 2.34.1