1 /* arch/arm/mach-rk30/rk_pm_tests.c
3 * Copyright (C) 2010 ROCKCHIP, Inc.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 /*************************************************************************/
18 /* COPYRIGHT (C) ROCK-CHIPS FUZHOU . ALL RIGHTS RESERVED.*/
19 /*************************************************************************
21 DESC : Power management in dynning state
27 #include <linux/clk.h>
28 #include <linux/kobject.h>
29 ***************************************************************************/
30 #include <linux/string.h>
31 #include <linux/resume-trace.h>
32 #include <linux/workqueue.h>
33 #include <linux/mutex.h>
34 #include <linux/module.h>
35 #include <linux/syscalls.h>
36 #include <linux/init.h>
37 #include <linux/interrupt.h>
38 #include <linux/delay.h>
39 #include <linux/cpu.h>
40 #include <linux/slab.h>
41 #include <linux/dma-mapping.h>
42 #include <linux/regulator/machine.h>
43 #include <linux/mfd/wm831x/core.h>
44 #include <linux/sysfs.h>
45 #include <linux/err.h>
47 #include "rk_pm_tests.h"
50 #include "cpu_usage.h"
51 #include "dvfs_table_scan.h"
53 struct kobject *rk_pm_tests_kobj=NULL;
55 struct attribute attr;
56 ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
58 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
59 const char *buf, size_t n);
62 extern ssize_t pvtm_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf);
63 extern ssize_t pvtm_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t n);
65 static struct pm_attribute pm_attrs[] = {
66 /* node_name permision show_func store_func*/
67 __ATTR(clk_rate, S_IRUGO | S_IWUSR | S_IWUGO, clk_rate_show, clk_rate_store),
68 __ATTR(clk_volt, S_IRUGO | S_IWUSR | S_IWUGO, clk_volt_show, clk_volt_store),
69 __ATTR(dvfs_table_scan, S_IRUGO | S_IWUSR | S_IWUGO, dvfs_table_scan_show, dvfs_table_scan_store),
70 __ATTR(cpu_usage, S_IRUGO | S_IWUSR, cpu_usage_show, cpu_usage_store),
71 __ATTR(pvtm, S_IRUGO | S_IWUSR, pvtm_show, pvtm_store),
73 __ATTR(maxfreq_volt, S_IRUGO | S_IWUSR, maxfreq_show, maxfreq_store),
74 __ATTR(freq_limit, S_IRUGO | S_IWUSR, freq_limit_show, freq_limit_store),
75 __ATTR(cpu_usage, S_IRUGO | S_IWUSR, cpu_usage_show, cpu_usage_store),
76 __ATTR(auto_wakeup, S_IRUGO | S_IWUSR, auto_wakeup_show, auto_wakeup_store),
77 __ATTR(suspend_test, S_IRUGO | S_IWUSR, suspend_test_show, suspend_test_store),
78 __ATTR(clk_auto_volt, S_IRUGO | S_IWUSR, clk_auto_volt_show, clk_auto_volt_store),
82 static void __exit rk_pm_tests_exit(void)
84 kobject_put(rk_pm_tests_kobj);
87 struct kobject *get_rk_pm_tests_kobj(void)
90 if(rk_pm_tests_kobj==NULL)
92 rk_pm_tests_kobj = kobject_create_and_add("pm_tests", NULL);
94 if (!rk_pm_tests_kobj)
97 return rk_pm_tests_kobj;
100 int rk_pm_tests_kobj_atrradd(const struct attribute *attr)
103 struct kobject * pm_kobj;
104 pm_kobj =get_rk_pm_tests_kobj();
109 ret = sysfs_create_file(pm_kobj,attr);
111 PM_ERR("pm tests create %s node error\n",attr->name);
117 static int __init rk_pm_tests_init(void)
120 struct kobject * pm_kobj;
121 pm_kobj =get_rk_pm_tests_kobj();
126 for (i = 0; i < ARRAY_SIZE(pm_attrs); i++) {
127 ret = sysfs_create_file(pm_kobj, &pm_attrs[i].attr);
129 PM_ERR("create index %d error\n", i);
137 late_initcall(rk_pm_tests_init);
138 module_exit(rk_pm_tests_exit);