Implement sqn-'s CPU Vdd levels sysfs interface
/drivers/cpufreq/cpufreq.c
blob:c18e65e572c7c3144440bad43ade9a7d507fc4b0 -> blob:82ca016d5bbf4a60775ada004f60df3ee7a23104
--- drivers/cpufreq/cpufreq.c
+++ drivers/cpufreq/cpufreq.c
@@ -647,6 +647,74 @@ static ssize_t show_scaling_setspeed(str
return policy->governor->show_setspeed(policy, buf);
}
+#ifdef CONFIG_CPU_FREQ_VDD_LEVELS
+
+extern ssize_t acpuclk_get_vdd_levels_str(char *buf);
+static ssize_t show_vdd_levels(struct cpufreq_policy *policy, char *buf)
+{
+ return acpuclk_get_vdd_levels_str(buf);
+}
+
+extern void acpuclk_set_vdd(unsigned acpu_khz, int vdd);
+static ssize_t store_vdd_levels(struct cpufreq_policy *policy, const char *buf, size_t count)
+{
+ int i = 0, j;
+ int pair[2] = { 0, 0 };
+ int sign = 0;
+
+ if (count < 1)
+ return 0;
+
+ if (buf[0] == '-')
+ {
+ sign = -1;
+ i++;
+ }
+ else if (buf[0] == '+')
+ {
+ sign = 1;
+ i++;
+ }
+
+ for (j = 0; i < count; i++)
+ {
+ char c = buf[i];
+ if ((c >= '0') && (c <= '9'))
+ {
+ pair[j] *= 10;
+ pair[j] += (c - '0');
+ }
+ else if ((c == ' ') || (c == '\t'))
+ {
+ if (pair[j] != 0)
+ {
+ j++;
+ if ((sign != 0) || (j > 1))
+ break;
+ }
+ }
+ else
+ break;
+ }
+
+ if (sign != 0)
+ {
+ if (pair[0] > 0)
+ acpuclk_set_vdd(0, sign * pair[0]);
+ }
+ else
+ {
+ if ((pair[0] > 0) && (pair[1] > 0))
+ acpuclk_set_vdd((unsigned)pair[0], pair[1]);
+ else
+ return -EINVAL;
+ }
+
+ return count;
+}
+
+#endif
+
#define define_one_ro(_name) \
static struct freq_attr _name = \
__ATTR(_name, 0444, show_##_name, NULL)
@@ -672,6 +740,9 @@ define_one_rw(scaling_min_freq);
define_one_rw(scaling_max_freq);
define_one_rw(scaling_governor);
define_one_rw(scaling_setspeed);
+#ifdef CONFIG_CPU_FREQ_VDD_LEVELS
+define_one_rw(vdd_levels);
+#endif
static struct attribute *default_attrs[] = {
&cpuinfo_min_freq.attr,
@@ -685,6 +756,9 @@ static struct attribute *default_attrs[]
&scaling_driver.attr,
&scaling_available_governors.attr,
&scaling_setspeed.attr,
+#ifdef CONFIG_CPU_FREQ_VDD_LEVELS
+ &vdd_levels.attr,
+#endif
NULL
};