2 #include <linux/kobject.h>
3 #include <linux/string.h>
4 #include <linux/resume-trace.h>
5 #include <linux/workqueue.h>
6 #include <linux/mutex.h>
7 #include <linux/module.h>
8 #include <linux/syscalls.h>
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
11 #include <linux/delay.h>
12 #include <linux/cpu.h>
13 #include <linux/slab.h>
14 #include <linux/dma-mapping.h>
15 #include <linux/regulator/machine.h>
16 #include <linux/mfd/wm831x/core.h>
17 #include <linux/sysfs.h>
18 #include <linux/err.h>
19 #include <linux/rockchip/dvfs.h>
21 #include "rk_pm_tests.h"
23 /***************************************************************************/
24 ssize_t clk_volt_show(struct kobject *kobj, struct kobj_attribute *attr,
28 str += sprintf(str, "usage:\n");
29 str += sprintf(str, "get voltage:get [regulaotr_name]\n");
30 str += sprintf(str, "set voltage:set [regulaotr_name] [voltage(uV)]\n");
31 str += sprintf(str, "set suspend voltage:set [regulaotr_name] [voltage(uV)+1]\n");
38 #define SET_SUSPEND_VOLT_FLAG (1<<0)
40 ssize_t clk_volt_store(struct kobject *kobj, struct kobj_attribute *attr,
41 const char *buf, size_t n)
44 struct regulator *regulator;
45 char cmd[20], regulator_name[20];
47 int need_put_regulator=0, ret=0;
49 sscanf(buf, "%s %s %u", cmd, regulator_name, &volt);
51 PM_DBG("%s: cmd(%s), regulator_name(%s), volt(%u)\n",
52 __func__, cmd, regulator_name, volt);
54 regulator = dvfs_get_regulator(regulator_name);
55 if (IS_ERR_OR_NULL(regulator)) {
56 regulator = regulator_get(NULL, regulator_name);
57 if (IS_ERR(regulator)){
58 PM_ERR("%s: get dvfs_regulator %s error\n", __func__, regulator_name);
61 need_put_regulator = 1;
64 if (!strncmp(cmd, "set", strlen("set"))){
65 if (volt & SET_SUSPEND_VOLT_FLAG){
66 volt &= ~SET_SUSPEND_VOLT_FLAG;
67 //ret = regulator_set_suspend_voltage(regulator, volt);
69 PM_DBG("%s: set %s suspend volt to %u uV ok\n", __func__, regulator_name, volt);
71 PM_DBG("%s: regulator_set_suspend_voltage err(%d)\n", __func__, ret);
73 ret = regulator_set_voltage(regulator, volt, volt);
75 PM_DBG("%s: set %s volt to %u uV ok\n", __func__, regulator_name, regulator_get_voltage(regulator));
77 PM_DBG("%s: regulator_set_voltage err(%d)\n", __func__, ret);
81 if (!strncmp(cmd, "get", strlen("get"))){
82 printk("%s: %s current is %d uV\n",
83 __func__, regulator_name, regulator_get_voltage(regulator));
86 if (need_put_regulator)
87 regulator_put(regulator);