Guest User

Untitled

a guest
Sep 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.57 KB | None | 0 0
  1. diff --git a/arch/arm/mach-tegra/dvfs.c b/arch/arm/mach-tegra/dvfs.c
  2. index 2efae06..1f751cf 100644
  3. --- a/arch/arm/mach-tegra/dvfs.c
  4. +++ b/arch/arm/mach-tegra/dvfs.c
  5. @@ -42,6 +42,11 @@ static DEFINE_MUTEX(dvfs_lock);
  6.  
  7.  static int dvfs_rail_update(struct dvfs_rail *rail);
  8.  
  9. +#ifdef CONFIG_TEGRA_OC
  10. +struct dvfs *cpu_dvfs = NULL;
  11. +extern int *UV_mV_Ptr;
  12. +#endif
  13. +
  14.  void tegra_dvfs_add_relationships(struct dvfs_relationship *rels, int n)
  15.  {
  16.     int i;
  17. @@ -227,8 +232,19 @@ __tegra_dvfs_set_rate(struct dvfs *d, unsigned long rate)
  18.     } else {
  19.         while (i < d->num_freqs && rate > d->freqs[i])
  20.             i++;
  21. +#ifdef CONFIG_TEGRA_OC
  22. +       if(UV_mV_Ptr != NULL)
  23. +           d->cur_millivolts = d->millivolts[i] - UV_mV_Ptr[i];
  24. +       else
  25. +           d->cur_millivolts = d->millivolts[i];
  26.  
  27. +       //printk( "d->clk_name = %s || ", d->clk_name );
  28. +       //printk( "d->freqs[%i] = %li || ", i, d->freqs[i] );
  29. +       //printk( "d->millivolts[%i] = %i || ", i, d->millivolts[i] );
  30. +       //printk( "d->cur_millivolts = %i\n", d->cur_millivolts );
  31. +#else
  32.         d->cur_millivolts = d->millivolts[i];
  33. +#endif
  34.     }
  35.  
  36.     d->cur_rate = rate;
  37. @@ -287,6 +303,16 @@ int __init tegra_enable_dvfs_on_clk(struct clk *c, struct dvfs *d)
  38.     }
  39.  
  40.     c->dvfs = d;
  41. +#ifdef CONFIG_TEGRA_OC
  42. +   if(cpu_dvfs == NULL)
  43. +   {
  44. +       if(strcmp(d->clk_name, "cpu")==0)
  45. +       {
  46. +           printk( "TEGRA_OC: CPU DVFS FOUND" );
  47. +           cpu_dvfs = d;
  48. +       }
  49. +   }
  50. +#endif // CONFIG_TEGRA_OC
  51.  
  52.     mutex_lock(&dvfs_lock);
  53.     list_add_tail(&d->reg_node, &d->dvfs_rail->dvfs);
  54. diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
  55. index ad0c008..5dc8ad6 100644
  56. --- a/drivers/cpufreq/cpufreq.c
  57. +++ b/drivers/cpufreq/cpufreq.c
  58. @@ -31,6 +31,12 @@
  59.  
  60.  #include <trace/events/power.h>
  61.  
  62. +#ifdef CONFIG_TEGRA_OC
  63. +#include "../dvfs.h"
  64. +int *UV_mV_Ptr; // Stored voltage table from cpufreq sysfs
  65. +extern struct dvfs *cpu_dvfs;
  66. +#endif
  67. +
  68.  #define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
  69.                         "cpufreq-core", msg)
  70.  
  71. @@ -663,6 +669,55 @@ static ssize_t show_bios_limit(struct cpufreq_policy *policy, char *buf)
  72.     return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
  73.  }
  74.  
  75. +#ifdef CONFIG_TEGRA_OC
  76. +static ssize_t show_frequency_voltage_table(struct cpufreq_policy *policy, char *buf)
  77. +{
  78. +   int i = 0;
  79. +   char *table = buf;
  80. +
  81. +   if(cpu_dvfs == NULL)
  82. +       return sprintf(buf, "INIT\n");
  83. +
  84. +   for(i=cpu_dvfs->num_freqs-1; i>-1; i--)
  85. +       table += sprintf(table, "%li %d %d\n", cpu_dvfs->freqs[i]/1000, cpu_dvfs->millivolts[i], cpu_dvfs->millivolts[i] - UV_mV_Ptr[i] );
  86. +
  87. +   return table - buf;
  88. +}
  89. +
  90. +
  91. +static ssize_t show_UV_mV_table(struct cpufreq_policy *policy, char *buf)
  92. +{
  93. +   int i;
  94. +   char *table = buf;
  95. +
  96. +   if(cpu_dvfs == NULL)
  97. +       return sprintf(buf, "INIT\n");
  98. +
  99. +   for(i=cpu_dvfs->num_freqs-1; i>-1; i--)
  100. +   {
  101. +       table += sprintf(table, "%d ", UV_mV_Ptr[i] );
  102. +   }
  103. +   table += sprintf(table, "\n" );
  104. +   return table - buf;
  105. +}
  106. +
  107. +static ssize_t store_UV_mV_table(struct cpufreq_policy *policy, const char *buf, size_t count)
  108. +{
  109. +   int ret = sscanf( buf, "%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",  &UV_mV_Ptr[14],
  110. +                               &UV_mV_Ptr[13], &UV_mV_Ptr[12],
  111. +                               &UV_mV_Ptr[11], &UV_mV_Ptr[10],
  112. +                               &UV_mV_Ptr[9], &UV_mV_Ptr[8],
  113. +                               &UV_mV_Ptr[7], &UV_mV_Ptr[6],
  114. +                               &UV_mV_Ptr[5], &UV_mV_Ptr[4],
  115. +                               &UV_mV_Ptr[3], &UV_mV_Ptr[2],
  116. +                               &UV_mV_Ptr[1], &UV_mV_Ptr[0] );
  117. +   if (ret != 1)
  118. +       return -EINVAL;
  119. +
  120. +   return count;
  121. +}
  122. +#endif // CONFIG_TEGRA_OC
  123. +
  124.  cpufreq_freq_attr_ro_perm(cpuinfo_cur_freq, 0400);
  125.  cpufreq_freq_attr_ro(cpuinfo_min_freq);
  126.  cpufreq_freq_attr_ro(cpuinfo_max_freq);
  127. @@ -677,6 +732,10 @@ cpufreq_freq_attr_rw(scaling_min_freq);
  128.  cpufreq_freq_attr_rw(scaling_max_freq);
  129.  cpufreq_freq_attr_rw(scaling_governor);
  130.  cpufreq_freq_attr_rw(scaling_setspeed);
  131. +#ifdef CONFIG_TEGRA_OC
  132. +cpufreq_freq_attr_ro(frequency_voltage_table);
  133. +cpufreq_freq_attr_rw(UV_mV_table);
  134. +#endif // CONFIG_TEGRA_OC
  135.  
  136.  static struct attribute *default_attrs[] = {
  137.     &cpuinfo_min_freq.attr,
  138. @@ -690,6 +749,10 @@ static struct attribute *default_attrs[] = {
  139.     &scaling_driver.attr,
  140.     &scaling_available_governors.attr,
  141.     &scaling_setspeed.attr,
  142. +#ifdef CONFIG_TEGRA_OC
  143. +   &frequency_voltage_table.attr,
  144. +   &UV_mV_table.attr,
  145. +#endif // CONFIG_TEGRA_OC
  146.     NULL
  147.  };
  148.  
  149. @@ -2010,6 +2073,11 @@ static int __init cpufreq_core_init(void)
  150.  {
  151.     int cpu;
  152.  
  153. +#ifdef CONFIG_TEGRA_OC
  154. +   // Allocate some memory for the voltage tab
  155. +   UV_mV_Ptr = kzalloc(sizeof(int)*(15), GFP_KERNEL);
  156. +#endif // CONFIG_TEGRA_OC
  157. +
  158.     for_each_possible_cpu(cpu) {
  159.         per_cpu(cpufreq_policy_cpu, cpu) = -1;
  160.         init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));
Advertisement
Add Comment
Please, Sign In to add comment