]> git.neil.brown.name Git - history.git/commitdiff
[ARM] CPUFREQ updates from Dominik
authorRussell King <rmk@flint.arm.linux.org.uk>
Sat, 11 Jan 2003 23:12:02 +0000 (23:12 +0000)
committerRussell King <rmk@flint.arm.linux.org.uk>
Sat, 11 Jan 2003 23:12:02 +0000 (23:12 +0000)
cpu-sa11x0: CPUFREQ_ALL_CPUS shouldn't be passed as argument to
cpufreq_notify_transition() any more, but the exact CPU number.

mach-integrator: cpufreq_notify_transition() isn't called -- which
means that the transition notifiers are not informed. This patch adds
these callbacks. Also, CPUFREQ_ALL_CPUS can't passed to
cpufreq_driver->set_policy any longer, so some code can safely be
removed.

arch/arm/mach-integrator/cpu.c
arch/arm/mach-sa1100/cpu-sa1100.c
arch/arm/mach-sa1100/cpu-sa1110.c

index 70f1066d81864fa760c70daba4b3e4d5460f59f6..e59d1abf5f4ff685bd6399956319a7b1db82f860 100644 (file)
@@ -97,11 +97,19 @@ static int integrator_verify_speed(struct cpufreq_policy *policy)
        return 0;
 }
 
-static void do_set_policy(int cpu, struct cpufreq_policy *policy)
+static int integrator_set_policy(struct cpufreq_policy *policy)
 {
-       struct vco vco = freq_to_vco(policy->max, 1);
+       unsigned long cpus_allowed;
+       int cpu = policy->cpu;
+       struct vco vco;
+       struct cpufreq_freqs freqs;
        u_int cm_osc;
 
+       /*
+        * Save this threads cpus_allowed mask.
+        */
+       cpus_allowed = current->cpus_allowed;
+
        /*
         * Bind to the specified CPU.  When this call returns,
         * we should be running on the right CPU.
@@ -109,6 +117,23 @@ static void do_set_policy(int cpu, struct cpufreq_policy *policy)
        set_cpus_allowed(current, 1 << cpu);
        BUG_ON(cpu != smp_processor_id());
 
+       /* get current setting */
+       cm_osc = __raw_readl(CM_OSC);
+       vco.od = (cm_osc >> 8) & 7;
+       vco.vdw = cm_osc & 255;
+
+       freqs.old = vco_to_freq(vco, 1);
+       freqs.new = target_freq;
+       freqs.cpu = policy->cpu;
+
+       if (freqs.old == freqs.new) {
+               set_cpus_allowed(current, cpus_allowed);
+               return 0;
+       }
+
+       cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+       vco = freq_to_vco(policy->max, 1);
+
        cm_osc = __raw_readl(CM_OSC);
        cm_osc &= 0xfffff800;
        cm_osc |= vco.vdw | vco.od << 8;
@@ -116,32 +141,14 @@ static void do_set_policy(int cpu, struct cpufreq_policy *policy)
        __raw_writel(0xa05f, CM_LOCK);
        __raw_writel(cm_osc, CM_OSC);
        __raw_writel(0, CM_LOCK);
-}
-
-static int integrator_set_policy(struct cpufreq_policy *policy)
-{
-       unsigned long cpus_allowed;
-       int cpu;
-
-       /*
-        * Save this threads cpus_allowed mask.
-        */
-       cpus_allowed = current->cpus_allowed;
-
-       if (policy->cpu == CPUFREQ_ALL_CPUS) {
-               for (cpu = 0; cpu < NR_CPUS; cpu++) {
-                       if (!cpu_online(cpu))
-                               continue;
-                       do_set_policy(cpu, policy);
-               }
-       } else
-               do_set_policy(policy->cpu, policy);
 
        /*
         * Restore the CPUs allowed mask.
         */
        set_cpus_allowed(current, cpus_allowed);
 
+       cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+
        return 0;
 }
 
@@ -149,8 +156,8 @@ static struct cpufreq_policy integrator_policy = {
        .cpu            = 0,
        .policy         = CPUFREQ_POLICY_POWERSAVE,
        .cpuinfo        = {
-               .max_cpu_freq           = 160000,
-               .min_cpu_freq           = 12000,
+               .max_freq               = 160000,
+               .min_freq               = 12000,
                .transition_latency     = CPUFREQ_ETERNAL,
        },
 };
@@ -168,7 +175,7 @@ static int __init integrator_cpu_init(void)
        unsigned long cpus_allowed;
        int cpu;
 
-       policies = kmalloc(sizeof(struct cpufreq_freqs) * NR_CPUS,
+       policies = kmalloc(sizeof(struct cpufreq_policy) * NR_CPUS,
                           GFP_KERNEL);
        if (!policies) {
                printk(KERN_ERR "CPU: unable to allocate policies structure\n");
index eb457a2d8feaa4e088b0551f92a69c3c09da45b6..31378afc1d3f9738274cba0c28b4f07164b3c652 100644 (file)
@@ -183,7 +183,7 @@ static int sa1100_setspeed(struct cpufreq_policy *policy)
 
        freqs.old = cur;
        freqs.new = policy->max;
-       freqs.cpu = CPUFREQ_ALL_CPUS;
+       freqs.cpu = 0;
 
        cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
 
index 7b2b9858741daf68933c0695b1c85278ebe88830..f46c170631822dab37f0a66aba4808df913f6dfa 100644 (file)
@@ -242,7 +242,7 @@ static int sa1110_setspeed(struct cpufreq_policy *policy)
 
        freqs.old = sa11x0_getspeed();
        freqs.new = policy->max;
-       freqs.cpu = CPUFREQ_ALL_CPUS;
+       freqs.cpu = 0;
 
        cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);