Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/arch/arm/mach-tegra/dvfs.c b/arch/arm/mach-tegra/dvfs.c
- index 2efae06..1f751cf 100644
- --- a/arch/arm/mach-tegra/dvfs.c
- +++ b/arch/arm/mach-tegra/dvfs.c
- @@ -42,6 +42,11 @@ static DEFINE_MUTEX(dvfs_lock);
- static int dvfs_rail_update(struct dvfs_rail *rail);
- +#ifdef CONFIG_TEGRA_OC
- +struct dvfs *cpu_dvfs = NULL;
- +extern int *UV_mV_Ptr;
- +#endif
- +
- void tegra_dvfs_add_relationships(struct dvfs_relationship *rels, int n)
- {
- int i;
- @@ -227,8 +232,19 @@ __tegra_dvfs_set_rate(struct dvfs *d, unsigned long rate)
- } else {
- while (i < d->num_freqs && rate > d->freqs[i])
- i++;
- +#ifdef CONFIG_TEGRA_OC
- + if(UV_mV_Ptr != NULL)
- + d->cur_millivolts = d->millivolts[i] - UV_mV_Ptr[i];
- + else
- + d->cur_millivolts = d->millivolts[i];
- + //printk( "d->clk_name = %s || ", d->clk_name );
- + //printk( "d->freqs[%i] = %li || ", i, d->freqs[i] );
- + //printk( "d->millivolts[%i] = %i || ", i, d->millivolts[i] );
- + //printk( "d->cur_millivolts = %i\n", d->cur_millivolts );
- +#else
- d->cur_millivolts = d->millivolts[i];
- +#endif
- }
- d->cur_rate = rate;
- @@ -287,6 +303,16 @@ int __init tegra_enable_dvfs_on_clk(struct clk *c, struct dvfs *d)
- }
- c->dvfs = d;
- +#ifdef CONFIG_TEGRA_OC
- + if(cpu_dvfs == NULL)
- + {
- + if(strcmp(d->clk_name, "cpu")==0)
- + {
- + printk( "TEGRA_OC: CPU DVFS FOUND" );
- + cpu_dvfs = d;
- + }
- + }
- +#endif // CONFIG_TEGRA_OC
- mutex_lock(&dvfs_lock);
- list_add_tail(&d->reg_node, &d->dvfs_rail->dvfs);
- diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
- index ad0c008..5dc8ad6 100644
- --- a/drivers/cpufreq/cpufreq.c
- +++ b/drivers/cpufreq/cpufreq.c
- @@ -31,6 +31,12 @@
- #include <trace/events/power.h>
- +#ifdef CONFIG_TEGRA_OC
- +#include "../dvfs.h"
- +int *UV_mV_Ptr; // Stored voltage table from cpufreq sysfs
- +extern struct dvfs *cpu_dvfs;
- +#endif
- +
- #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
- "cpufreq-core", msg)
- @@ -663,6 +669,55 @@ static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
- return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
- }
- +#ifdef CONFIG_TEGRA_OC
- +static ssize_t show_frequency_voltage_table(struct cpufreq_policy *policy, char *buf)
- +{
- + int i = 0;
- + char *table = buf;
- +
- + if(cpu_dvfs == NULL)
- + return sprintf(buf, "INIT\n");
- +
- + for(i=cpu_dvfs->num_freqs-1; i>-1; i--)
- + table += sprintf(table, "%li %d %d\n", cpu_dvfs->freqs[i]/1000, cpu_dvfs->millivolts[i], cpu_dvfs->millivolts[i] - UV_mV_Ptr[i] );
- +
- + return table - buf;
- +}
- +
- +
- +static ssize_t show_UV_mV_table(struct cpufreq_policy *policy, char *buf)
- +{
- + int i;
- + char *table = buf;
- +
- + if(cpu_dvfs == NULL)
- + return sprintf(buf, "INIT\n");
- +
- + for(i=cpu_dvfs->num_freqs-1; i>-1; i--)
- + {
- + table += sprintf(table, "%d ", UV_mV_Ptr[i] );
- + }
- + table += sprintf(table, "\n" );
- + return table - buf;
- +}
- +
- +static ssize_t store_UV_mV_table(struct cpufreq_policy *policy, const char *buf, size_t count)
- +{
- + int ret = sscanf( buf, "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i", &UV_mV_Ptr[14],
- + &UV_mV_Ptr[13], &UV_mV_Ptr[12],
- + &UV_mV_Ptr[11], &UV_mV_Ptr[10],
- + &UV_mV_Ptr[9], &UV_mV_Ptr[8],
- + &UV_mV_Ptr[7], &UV_mV_Ptr[6],
- + &UV_mV_Ptr[5], &UV_mV_Ptr[4],
- + &UV_mV_Ptr[3], &UV_mV_Ptr[2],
- + &UV_mV_Ptr[1], &UV_mV_Ptr[0] );
- + if (ret != 1)
- + return -EINVAL;
- +
- + return count;
- +}
- +#endif // CONFIG_TEGRA_OC
- +
- cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
- cpufreq_freq_attr_ro(cpuinfo_min_freq);
- cpufreq_freq_attr_ro(cpuinfo_max_freq);
- @@ -677,6 +732,10 @@ cpufreq_freq_attr_rw(scaling_min_freq);
- cpufreq_freq_attr_rw(scaling_max_freq);
- cpufreq_freq_attr_rw(scaling_governor);
- cpufreq_freq_attr_rw(scaling_setspeed);
- +#ifdef CONFIG_TEGRA_OC
- +cpufreq_freq_attr_ro(frequency_voltage_table);
- +cpufreq_freq_attr_rw(UV_mV_table);
- +#endif // CONFIG_TEGRA_OC
- static struct attribute *default_attrs[] = {
- &cpuinfo_min_freq.attr,
- @@ -690,6 +749,10 @@ static struct attribute *default_attrs[] = {
- &scaling_driver.attr,
- &scaling_available_governors.attr,
- &scaling_setspeed.attr,
- +#ifdef CONFIG_TEGRA_OC
- + &frequency_voltage_table.attr,
- + &UV_mV_table.attr,
- +#endif // CONFIG_TEGRA_OC
- NULL
- };
- @@ -2010,6 +2073,11 @@ static int __init cpufreq_core_init(void)
- {
- int cpu;
- +#ifdef CONFIG_TEGRA_OC
- + // Allocate some memory for the voltage tab
- + UV_mV_Ptr = kzalloc(sizeof(int)*(15), GFP_KERNEL);
- +#endif // CONFIG_TEGRA_OC
- +
- for_each_possible_cpu(cpu) {
- per_cpu(cpufreq_policy_cpu, cpu) = -1;
- init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
Advertisement
Add Comment
Please, Sign In to add comment