[PATCH] BCM2835: Support cpufreq statistics

Andreas Platschek platschek at ict.tuwien.ac.at
Tue May 6 13:23:42 PDT 2014


The BCM2835 cpufreq driver lacked statistics support. This
patch adds the related calls to the cpufreq-stats module.

Signed-off-by: Andreas Platschek<platschek at ict.tuwien.ac.at>
---
   drivers/cpufreq/bcm2835-cpufreq.c |   19 +++++++++++++++++++
   1 file changed, 19 insertions(+)

diff --git a/drivers/cpufreq/bcm2835-cpufreq.c
b/drivers/cpufreq/bcm2835-cpufreq.c
index 7bc55bd..c33926b 100755
--- a/drivers/cpufreq/bcm2835-cpufreq.c
+++ b/drivers/cpufreq/bcm2835-cpufreq.c
@@ -63,6 +63,8 @@ struct vc_msg {
   /* ---------- GLOBALS ---------- */
   static struct cpufreq_driver bcm2835_cpufreq_driver;   /* the cpufreq
driver global */

+static struct cpufreq_frequency_table freq_table[3];
+
   /*
    ===============================================
     clk_rate either gets or sets the clock rates.
@@ -165,6 +167,14 @@ static int bcm2835_cpufreq_driver_init(struct
cpufreq_policy *policy)
          policy->cur = bcm2835_cpufreq_get_clock(VCMSG_GET_CLOCK_RATE);

          print_info("min=%d max=%d cur=%d\n", policy->min, policy->max,
policy->cur);
+
+       freq_table[0].frequency = policy->min;
+       freq_table[1].frequency = policy->max;
+       freq_table[2].frequency = CPUFREQ_TABLE_END;
+
+       cpufreq_frequency_table_cpuinfo(policy, freq_table);
+       cpufreq_frequency_table_get_attr(freq_table, policy->cpu);
+
          return 0;
   }

@@ -180,6 +190,8 @@ static int bcm2835_cpufreq_driver_target(struct
cpufreq_policy *policy, unsigned
   #ifdef CPUFREQ_DEBUG_ENABLE
          unsigned int cur = policy->cur;
   #endif
+       struct cpufreq_freqs freqs;
+
          print_debug("%s: min=%d max=%d cur=%d
target=%d\n",policy->governor->name,policy->min,policy->max,policy->cur,target_freq);

          /* if we are above min and using ondemand, then just use max */
@@ -189,6 +201,10 @@ static int bcm2835_cpufreq_driver_target(struct
cpufreq_policy *policy, unsigned
          if (target == policy->cur)
                  return 0;

+       freqs.old = policy->cur;
+       freqs.new = target;
+
+       cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
          /* otherwise were good to set the clock frequency */
          policy->cur = bcm2835_cpufreq_set_clock(policy->cur, target);

@@ -199,6 +215,9 @@ static int bcm2835_cpufreq_driver_target(struct
cpufreq_policy *policy, unsigned
                  return -EINVAL;
          }
          print_debug("Freq %d->%d (min=%d max=%d target=%d
request=%d)\n", cur, policy->cur, policy->min, policy->max, target_freq,
target);
+
+       cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+
          return 0;
   }

-- 1.7.10.4



More information about the linux-rpi-kernel mailing list