cpufreq: integrator: move cpufreq driver to drivers/cpufreq
authorViresh Kumar <viresh.kumar@linaro.org>
Thu, 4 Apr 2013 12:54:14 +0000 (12:54 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 8 Apr 2013 11:02:31 +0000 (13:02 +0200)
This patch moves cpufreq driver of ARM based integrator platform to
drivers/cpufreq.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
arch/arm/Kconfig
arch/arm/mach-integrator/Makefile
arch/arm/mach-integrator/cpu.c [deleted file]
drivers/cpufreq/Kconfig.arm
drivers/cpufreq/Makefile
drivers/cpufreq/integrator-cpufreq.c [new file with mode: 0644]

index 76eb836793a149331a833a623d839f922da2cb6f..c3563f6dc9f2389800fdd5c3955c1e2a1f9011f0 100644 (file)
@@ -2166,17 +2166,6 @@ config CPU_FREQ_SA1100
 config CPU_FREQ_SA1110
        bool
 
-config CPU_FREQ_INTEGRATOR
-       tristate "CPUfreq driver for ARM Integrator CPUs"
-       depends on ARCH_INTEGRATOR && CPU_FREQ
-       default y
-       help
-         This enables the CPUfreq driver for ARM Integrator CPUs.
-
-         For details, take a look at <file:Documentation/cpu-freq>.
-
-         If in doubt, say Y.
-
 config CPU_FREQ_S3C
        bool
        help
index 5521d18bf19afce7d1c4244623262471bc08b044..d14d6b76f4c24289d0d2c42507a7f30c7d06cdde 100644 (file)
@@ -9,5 +9,4 @@ obj-$(CONFIG_ARCH_INTEGRATOR_AP)        += integrator_ap.o
 obj-$(CONFIG_ARCH_INTEGRATOR_CP)       += integrator_cp.o
 
 obj-$(CONFIG_PCI)                      += pci_v3.o pci.o
-obj-$(CONFIG_CPU_FREQ_INTEGRATOR)      += cpu.o
 obj-$(CONFIG_INTEGRATOR_IMPD1)         += impd1.o
diff --git a/arch/arm/mach-integrator/cpu.c b/arch/arm/mach-integrator/cpu.c
deleted file mode 100644 (file)
index df863c3..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- *  linux/arch/arm/mach-integrator/cpu.c
- *
- *  Copyright (C) 2001-2002 Deep Blue Solutions Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * CPU support functions
- */
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/cpufreq.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/init.h>
-#include <linux/io.h>
-
-#include <mach/hardware.h>
-#include <mach/platform.h>
-#include <asm/mach-types.h>
-#include <asm/hardware/icst.h>
-
-static struct cpufreq_driver integrator_driver;
-
-#define CM_ID          __io_address(INTEGRATOR_HDR_ID)
-#define CM_OSC __io_address(INTEGRATOR_HDR_OSC)
-#define CM_STAT __io_address(INTEGRATOR_HDR_STAT)
-#define CM_LOCK __io_address(INTEGRATOR_HDR_LOCK)
-
-static const struct icst_params lclk_params = {
-       .ref            = 24000000,
-       .vco_max        = ICST525_VCO_MAX_5V,
-       .vco_min        = ICST525_VCO_MIN,
-       .vd_min         = 8,
-       .vd_max         = 132,
-       .rd_min         = 24,
-       .rd_max         = 24,
-       .s2div          = icst525_s2div,
-       .idx2s          = icst525_idx2s,
-};
-
-static const struct icst_params cclk_params = {
-       .ref            = 24000000,
-       .vco_max        = ICST525_VCO_MAX_5V,
-       .vco_min        = ICST525_VCO_MIN,
-       .vd_min         = 12,
-       .vd_max         = 160,
-       .rd_min         = 24,
-       .rd_max         = 24,
-       .s2div          = icst525_s2div,
-       .idx2s          = icst525_idx2s,
-};
-
-/*
- * Validate the speed policy.
- */
-static int integrator_verify_policy(struct cpufreq_policy *policy)
-{
-       struct icst_vco vco;
-
-       cpufreq_verify_within_limits(policy, 
-                                    policy->cpuinfo.min_freq, 
-                                    policy->cpuinfo.max_freq);
-
-       vco = icst_hz_to_vco(&cclk_params, policy->max * 1000);
-       policy->max = icst_hz(&cclk_params, vco) / 1000;
-
-       vco = icst_hz_to_vco(&cclk_params, policy->min * 1000);
-       policy->min = icst_hz(&cclk_params, vco) / 1000;
-
-       cpufreq_verify_within_limits(policy, 
-                                    policy->cpuinfo.min_freq, 
-                                    policy->cpuinfo.max_freq);
-
-       return 0;
-}
-
-
-static int integrator_set_target(struct cpufreq_policy *policy,
-                                unsigned int target_freq,
-                                unsigned int relation)
-{
-       cpumask_t cpus_allowed;
-       int cpu = policy->cpu;
-       struct icst_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.
-        */
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
-       BUG_ON(cpu != smp_processor_id());
-
-       /* get current setting */
-       cm_osc = __raw_readl(CM_OSC);
-
-       if (machine_is_integrator()) {
-               vco.s = (cm_osc >> 8) & 7;
-       } else if (machine_is_cintegrator()) {
-               vco.s = 1;
-       }
-       vco.v = cm_osc & 255;
-       vco.r = 22;
-       freqs.old = icst_hz(&cclk_params, vco) / 1000;
-
-       /* icst_hz_to_vco rounds down -- so we need the next
-        * larger freq in case of CPUFREQ_RELATION_L.
-        */
-       if (relation == CPUFREQ_RELATION_L)
-               target_freq += 999;
-       if (target_freq > policy->max)
-               target_freq = policy->max;
-       vco = icst_hz_to_vco(&cclk_params, target_freq * 1000);
-       freqs.new = icst_hz(&cclk_params, vco) / 1000;
-
-       if (freqs.old == freqs.new) {
-               set_cpus_allowed(current, cpus_allowed);
-               return 0;
-       }
-
-       cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-
-       cm_osc = __raw_readl(CM_OSC);
-
-       if (machine_is_integrator()) {
-               cm_osc &= 0xfffff800;
-               cm_osc |= vco.s << 8;
-       } else if (machine_is_cintegrator()) {
-               cm_osc &= 0xffffff00;
-       }
-       cm_osc |= vco.v;
-
-       __raw_writel(0xa05f, CM_LOCK);
-       __raw_writel(cm_osc, CM_OSC);
-       __raw_writel(0, CM_LOCK);
-
-       /*
-        * Restore the CPUs allowed mask.
-        */
-       set_cpus_allowed(current, cpus_allowed);
-
-       cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
-       return 0;
-}
-
-static unsigned int integrator_get(unsigned int cpu)
-{
-       cpumask_t cpus_allowed;
-       unsigned int current_freq;
-       u_int cm_osc;
-       struct icst_vco vco;
-
-       cpus_allowed = current->cpus_allowed;
-
-       set_cpus_allowed(current, cpumask_of_cpu(cpu));
-       BUG_ON(cpu != smp_processor_id());
-
-       /* detect memory etc. */
-       cm_osc = __raw_readl(CM_OSC);
-
-       if (machine_is_integrator()) {
-               vco.s = (cm_osc >> 8) & 7;
-       } else {
-               vco.s = 1;
-       }
-       vco.v = cm_osc & 255;
-       vco.r = 22;
-
-       current_freq = icst_hz(&cclk_params, vco) / 1000; /* current freq */
-
-       set_cpus_allowed(current, cpus_allowed);
-
-       return current_freq;
-}
-
-static int integrator_cpufreq_init(struct cpufreq_policy *policy)
-{
-
-       /* set default policy and cpuinfo */
-       policy->cpuinfo.max_freq = 160000;
-       policy->cpuinfo.min_freq = 12000;
-       policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */
-       policy->cur = policy->min = policy->max = integrator_get(policy->cpu);
-
-       return 0;
-}
-
-static struct cpufreq_driver integrator_driver = {
-       .verify         = integrator_verify_policy,
-       .target         = integrator_set_target,
-       .get            = integrator_get,
-       .init           = integrator_cpufreq_init,
-       .name           = "integrator",
-};
-
-static int __init integrator_cpu_init(void)
-{
-       return cpufreq_register_driver(&integrator_driver);
-}
-
-static void __exit integrator_cpu_exit(void)
-{
-       cpufreq_unregister_driver(&integrator_driver);
-}
-
-MODULE_AUTHOR ("Russell M. King");
-MODULE_DESCRIPTION ("cpufreq driver for ARM Integrator CPUs");
-MODULE_LICENSE ("GPL");
-
-module_init(integrator_cpu_init);
-module_exit(integrator_cpu_exit);
index 25d866a32f51508c3e71a4be509f350b79b61506..97f208daf8aef68a57085aeda7a9c23fa247de1b 100644 (file)
@@ -66,6 +66,14 @@ config ARM_IMX6Q_CPUFREQ
 
          If in doubt, say N.
 
+config ARM_INTEGRATOR
+       tristate "CPUfreq driver for ARM Integrator CPUs"
+       depends on ARCH_INTEGRATOR
+       default y
+       help
+         This enables the CPUfreq driver for ARM Integrator CPUs.
+         If in doubt, say Y.
+
 config ARM_KIRKWOOD_CPUFREQ
        def_bool ARCH_KIRKWOOD && OF
        help
index aa766fb855132de41d25dd1f0c9126b355e6284d..8d5801645f9d4b860a7f46c15a058797a92b6176 100644 (file)
@@ -57,6 +57,7 @@ obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)  += exynos4x12-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)   += exynos5250-cpufreq.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ)     += highbank-cpufreq.o
 obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)                += imx6q-cpufreq.o
+obj-$(CONFIG_ARM_INTEGRATOR)           += integrator-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)     += kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)    += omap-cpufreq.o
 obj-$(CONFIG_PXA25x)                   += pxa2xx-cpufreq.o
diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c
new file mode 100644 (file)
index 0000000..f7c99df
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ *  Copyright (C) 2001-2002 Deep Blue Solutions Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * CPU support functions
+ */
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/cpufreq.h>
+#include <linux/sched.h>
+#include <linux/smp.h>
+#include <linux/init.h>
+#include <linux/io.h>
+
+#include <mach/hardware.h>
+#include <mach/platform.h>
+#include <asm/mach-types.h>
+#include <asm/hardware/icst.h>
+
+static struct cpufreq_driver integrator_driver;
+
+#define CM_ID          __io_address(INTEGRATOR_HDR_ID)
+#define CM_OSC __io_address(INTEGRATOR_HDR_OSC)
+#define CM_STAT __io_address(INTEGRATOR_HDR_STAT)
+#define CM_LOCK __io_address(INTEGRATOR_HDR_LOCK)
+
+static const struct icst_params lclk_params = {
+       .ref            = 24000000,
+       .vco_max        = ICST525_VCO_MAX_5V,
+       .vco_min        = ICST525_VCO_MIN,
+       .vd_min         = 8,
+       .vd_max         = 132,
+       .rd_min         = 24,
+       .rd_max         = 24,
+       .s2div          = icst525_s2div,
+       .idx2s          = icst525_idx2s,
+};
+
+static const struct icst_params cclk_params = {
+       .ref            = 24000000,
+       .vco_max        = ICST525_VCO_MAX_5V,
+       .vco_min        = ICST525_VCO_MIN,
+       .vd_min         = 12,
+       .vd_max         = 160,
+       .rd_min         = 24,
+       .rd_max         = 24,
+       .s2div          = icst525_s2div,
+       .idx2s          = icst525_idx2s,
+};
+
+/*
+ * Validate the speed policy.
+ */
+static int integrator_verify_policy(struct cpufreq_policy *policy)
+{
+       struct icst_vco vco;
+
+       cpufreq_verify_within_limits(policy, 
+                                    policy->cpuinfo.min_freq, 
+                                    policy->cpuinfo.max_freq);
+
+       vco = icst_hz_to_vco(&cclk_params, policy->max * 1000);
+       policy->max = icst_hz(&cclk_params, vco) / 1000;
+
+       vco = icst_hz_to_vco(&cclk_params, policy->min * 1000);
+       policy->min = icst_hz(&cclk_params, vco) / 1000;
+
+       cpufreq_verify_within_limits(policy, 
+                                    policy->cpuinfo.min_freq, 
+                                    policy->cpuinfo.max_freq);
+
+       return 0;
+}
+
+
+static int integrator_set_target(struct cpufreq_policy *policy,
+                                unsigned int target_freq,
+                                unsigned int relation)
+{
+       cpumask_t cpus_allowed;
+       int cpu = policy->cpu;
+       struct icst_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.
+        */
+       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       BUG_ON(cpu != smp_processor_id());
+
+       /* get current setting */
+       cm_osc = __raw_readl(CM_OSC);
+
+       if (machine_is_integrator()) {
+               vco.s = (cm_osc >> 8) & 7;
+       } else if (machine_is_cintegrator()) {
+               vco.s = 1;
+       }
+       vco.v = cm_osc & 255;
+       vco.r = 22;
+       freqs.old = icst_hz(&cclk_params, vco) / 1000;
+
+       /* icst_hz_to_vco rounds down -- so we need the next
+        * larger freq in case of CPUFREQ_RELATION_L.
+        */
+       if (relation == CPUFREQ_RELATION_L)
+               target_freq += 999;
+       if (target_freq > policy->max)
+               target_freq = policy->max;
+       vco = icst_hz_to_vco(&cclk_params, target_freq * 1000);
+       freqs.new = icst_hz(&cclk_params, vco) / 1000;
+
+       if (freqs.old == freqs.new) {
+               set_cpus_allowed(current, cpus_allowed);
+               return 0;
+       }
+
+       cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+
+       cm_osc = __raw_readl(CM_OSC);
+
+       if (machine_is_integrator()) {
+               cm_osc &= 0xfffff800;
+               cm_osc |= vco.s << 8;
+       } else if (machine_is_cintegrator()) {
+               cm_osc &= 0xffffff00;
+       }
+       cm_osc |= vco.v;
+
+       __raw_writel(0xa05f, CM_LOCK);
+       __raw_writel(cm_osc, CM_OSC);
+       __raw_writel(0, CM_LOCK);
+
+       /*
+        * Restore the CPUs allowed mask.
+        */
+       set_cpus_allowed(current, cpus_allowed);
+
+       cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+
+       return 0;
+}
+
+static unsigned int integrator_get(unsigned int cpu)
+{
+       cpumask_t cpus_allowed;
+       unsigned int current_freq;
+       u_int cm_osc;
+       struct icst_vco vco;
+
+       cpus_allowed = current->cpus_allowed;
+
+       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+       BUG_ON(cpu != smp_processor_id());
+
+       /* detect memory etc. */
+       cm_osc = __raw_readl(CM_OSC);
+
+       if (machine_is_integrator()) {
+               vco.s = (cm_osc >> 8) & 7;
+       } else {
+               vco.s = 1;
+       }
+       vco.v = cm_osc & 255;
+       vco.r = 22;
+
+       current_freq = icst_hz(&cclk_params, vco) / 1000; /* current freq */
+
+       set_cpus_allowed(current, cpus_allowed);
+
+       return current_freq;
+}
+
+static int integrator_cpufreq_init(struct cpufreq_policy *policy)
+{
+
+       /* set default policy and cpuinfo */
+       policy->cpuinfo.max_freq = 160000;
+       policy->cpuinfo.min_freq = 12000;
+       policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */
+       policy->cur = policy->min = policy->max = integrator_get(policy->cpu);
+
+       return 0;
+}
+
+static struct cpufreq_driver integrator_driver = {
+       .verify         = integrator_verify_policy,
+       .target         = integrator_set_target,
+       .get            = integrator_get,
+       .init           = integrator_cpufreq_init,
+       .name           = "integrator",
+};
+
+static int __init integrator_cpu_init(void)
+{
+       return cpufreq_register_driver(&integrator_driver);
+}
+
+static void __exit integrator_cpu_exit(void)
+{
+       cpufreq_unregister_driver(&integrator_driver);
+}
+
+MODULE_AUTHOR ("Russell M. King");
+MODULE_DESCRIPTION ("cpufreq driver for ARM Integrator CPUs");
+MODULE_LICENSE ("GPL");
+
+module_init(integrator_cpu_init);
+module_exit(integrator_cpu_exit);