Initial OC-UV
/drivers/cpufreq/cpufreq.c
blob:25fa11f7bb4610d4c8f372cd530fef1be6643f22 -> blob:6837af6dc8e3840a333602575931bd6f98251e09
--- drivers/cpufreq/cpufreq.c
+++ drivers/cpufreq/cpufreq.c
@@ -28,7 +28,6 @@
#include <linux/cpu.h>
#include <linux/completion.h>
#include <linux/mutex.h>
-#include <linux/sched.h>
#include <linux/syscore_ops.h>
#include <trace/events/power.h>
@@ -699,6 +698,59 @@ static ssize_t show_bios_limit(struct cp
return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
}
+#ifdef CONFIG_VDD_USERSPACE
+extern ssize_t acpuclk_get_vdd_levels_str(char *buf);
+static ssize_t show_vdd_levels(struct kobject *a, struct attribute *b, 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 kobject *a, struct attribute *b, 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 /* CONFIG_VDD_USERSPACE */
+
cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
cpufreq_freq_attr_ro(cpuinfo_min_freq);
cpufreq_freq_attr_ro(cpuinfo_max_freq);
@@ -717,6 +769,10 @@ cpufreq_freq_attr_rw(scaling_max_freq);
cpufreq_freq_attr_rw(scaling_governor);
cpufreq_freq_attr_rw(scaling_setspeed);
+#ifdef CONFIG_VDD_USERSPACE
+define_one_global_rw(vdd_levels);
+#endif
+
static struct attribute *default_attrs[] = {
&cpuinfo_min_freq.attr,
&cpuinfo_max_freq.attr,
@@ -735,6 +791,18 @@ static struct attribute *default_attrs[]
NULL
};
+#ifdef CONFIG_VDD_USERSPACE
+static struct attribute *vddtbl_attrs[] = {
+ &vdd_levels.attr,
+ NULL
+};
+
+static struct attribute_group vddtbl_attr_group = {
+ .attrs = vddtbl_attrs,
+ .name = "vdd_table",
+};
+#endif /* CONFIG_VDD_USERSPACE */
+
struct kobject *cpufreq_global_kobject;
EXPORT_SYMBOL(cpufreq_global_kobject);
@@ -1635,12 +1703,6 @@ int __cpufreq_driver_target(struct cpufr
target_freq, relation);
if (cpu_online(policy->cpu) && cpufreq_driver->target)
retval = cpufreq_driver->target(policy, target_freq, relation);
- if (likely(retval != -EINVAL)) {
- if (target_freq == policy->max)
- cpu_nonscaling(policy->cpu);
- else
- cpu_scaling(policy->cpu);
- }
return retval;
}
@@ -1884,6 +1946,7 @@ static int __cpufreq_set_policy(struct c
/* start new governor */
data->governor = policy->governor;
+ if (!cpu_online(1)) cpu_up(1);
if (__cpufreq_governor(data, CPUFREQ_GOV_START)) {
/* new governor failed, so re-start old one */
pr_debug("starting governor %s failed\n",
@@ -2066,7 +2129,7 @@ int cpufreq_set_limit(unsigned int flag,
max_value = user_max_freq_limit;
}
- /* set min freq */
+ /* set min freq
if (freq_limit_start_flag & TOUCH_BOOSTER_FIRST_BIT)
min_value = TOUCH_BOOSTER_FIRST_FREQ_LIMIT;
else if (freq_limit_start_flag & TOUCH_BOOSTER_SECOND_BIT)
@@ -2074,13 +2137,13 @@ int cpufreq_set_limit(unsigned int flag,
else if (freq_limit_start_flag & TOUCH_BOOSTER_BIT)
min_value = TOUCH_BOOSTER_FREQ_LIMIT;
else
- min_value = MIN_FREQ_LIMIT;
+ min_value = MIN_FREQ_LIMIT;*/
- /* cpufreq_min_limit */
+ /* cpufreq_min_limit
if (freq_limit_start_flag & APPS_MIN_BIT) {
if (min_value < app_min_freq_limit)
min_value = app_min_freq_limit;
- }
+ }*/
/* user */
if (freq_limit_start_flag & USER_MIN_BIT) {
@@ -2339,6 +2402,9 @@ EXPORT_SYMBOL_GPL(cpufreq_unregister_dri
static int __init cpufreq_core_init(void)
{
int cpu;
+#ifdef CONFIG_VDD_USERSPACE
+ int rc;
+#endif /* CONFIG_VDD_USERSPACE */
for_each_possible_cpu(cpu) {
per_cpu(cpufreq_policy_cpu, cpu) = -1;
@@ -2356,6 +2422,10 @@ static int __init cpufreq_core_init(void
#endif
register_syscore_ops(&cpufreq_syscore_ops);
+#ifdef CONFIG_VDD_USERSPACE
+ rc = sysfs_create_group(cpufreq_global_kobject, &vddtbl_attr_group);
+#endif /* CONFIG_VDD_USERSPACE */
+
return 0;
}
core_initcall(cpufreq_core_init);