cpufreq: AVR32: move cpufreq driver to drivers/cpufreq
authorViresh Kumar <viresh.kumar@linaro.org>
Thu, 4 Apr 2013 12:54:17 +0000 (12:54 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 10 Apr 2013 11:19:25 +0000 (13:19 +0200)
This patch moves cpufreq driver of AVR32 based at32ap platform to
drivers/cpufreq.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
20 files changed:
arch/avr32/Kconfig
arch/avr32/configs/atngw100_defconfig
arch/avr32/configs/atngw100_evklcd100_defconfig
arch/avr32/configs/atngw100_evklcd101_defconfig
arch/avr32/configs/atngw100_mrmt_defconfig
arch/avr32/configs/atngw100mkii_defconfig
arch/avr32/configs/atngw100mkii_evklcd100_defconfig
arch/avr32/configs/atngw100mkii_evklcd101_defconfig
arch/avr32/configs/atstk1002_defconfig
arch/avr32/configs/atstk1003_defconfig
arch/avr32/configs/atstk1004_defconfig
arch/avr32/configs/atstk1006_defconfig
arch/avr32/configs/favr-32_defconfig
arch/avr32/configs/hammerhead_defconfig
arch/avr32/configs/mimc200_defconfig
arch/avr32/mach-at32ap/Makefile
arch/avr32/mach-at32ap/cpufreq.c [deleted file]
drivers/cpufreq/Kconfig
drivers/cpufreq/Makefile
drivers/cpufreq/at32ap-cpufreq.c [new file with mode: 0644]

index c1a868d398bd284f6c7552d31279e24215792f51..22c40308360bb0a76071db11c5493ecd09aff6af 100644 (file)
@@ -250,20 +250,7 @@ config ARCH_SUSPEND_POSSIBLE
        def_bool y
 
 menu "CPU Frequency scaling"
-
 source "drivers/cpufreq/Kconfig"
-
-config CPU_FREQ_AT32AP
-       bool "CPU frequency driver for AT32AP"
-       depends on CPU_FREQ && PLATFORM_AT32AP
-       default n
-       help
-         This enables the CPU frequency driver for AT32AP processors.
-
-         For details, take a look in <file:Documentation/cpu-freq>.
-
-         If in doubt, say N.
-
 endmenu
 
 endmenu
index f4025db184ff754fd6cf8974535c4ca3e0d56571..d5aff36ade922f07ca18c34552b140919d598dfc 100644 (file)
@@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index c76a49b9e9d06130a75f6d41a7a73dd0ceb1c1e6..4abcf435d599a4a88b26ae1049b401dfcfa8a2e8 100644 (file)
@@ -28,7 +28,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index 2d8ab089a64e36d007a52f238d43483703e59725..18f3fa0470ff294a9755cd263d30c4a4080198e7 100644 (file)
@@ -27,7 +27,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index b189e0cab04b38c6c209801091c71fddf013fd87..06e389cfcd126e4c75111398758a5813d7fe2275 100644 (file)
@@ -23,7 +23,7 @@ CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index 2e4de42a53c4ab8be5a4d0c27225609972138087..2518a1368d7caea758cfba9b152abe07b59870d0 100644 (file)
@@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index fad3cd22dfd3c873141de7b0272730b0c42eeada..245ef6bd0fa61f56de23c1b4ce57abb51771489c 100644 (file)
@@ -29,7 +29,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index 29986230aaa5a48b1426f21fc3d9883e9f88b0d0..fa6cbac6e4189c2e5a39eed8b6cb49ec44a3dd96 100644 (file)
@@ -28,7 +28,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index a582465e1cefb809a22262aaf661a3e8c694d0f0..bbd5131021a57d840bed7dede2db9d61b074e8f4 100644 (file)
@@ -25,7 +25,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index 57a79df2ce5dd47f1419694582edd9ae382006a5..c1cd726f901233b1dd552cb3d28f3375682f3ad9 100644 (file)
@@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index 1a49bd8c6340c70bda11dcd964aa55e332ac29d9..754ae56b276739a58113bc89b87395d0b35b6ab2 100644 (file)
@@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index 206a1b67f763e3f1d6e98598a156a8359459a44c..58589d8cc0acd829af7612b782368a907f6c3e64 100644 (file)
@@ -26,7 +26,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
 CONFIG_NET=y
 CONFIG_PACKET=y
index 0421498d666b979b992446fe83603325786f2e03..57788a42ff83ac261928489f029540d9b6965d88 100644 (file)
@@ -27,7 +27,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index 82f24eb251bdf44da77341e14d373f72d4763efa..ba7c31e269cb0aed7b0ba9a72c1ce641cf0e346a 100644 (file)
@@ -31,7 +31,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index 1bee51f2215475e5f4bdbbaf00b49e84daf6719a..0a8bfdc420e0e6730c4ba1464de3ee92fafd8a2f 100644 (file)
@@ -24,7 +24,7 @@ CONFIG_CPU_FREQ=y
 # CONFIG_CPU_FREQ_STAT is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
-CONFIG_CPU_FREQ_AT32AP=y
+CONFIG_AVR32_AT32AP_CPUFREQ=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
index 514c9a9b009a2f09a6abae839cadc1f85da805f2..fc09ec4bc725c90d9c4279c63373ae07ee9fefb5 100644 (file)
@@ -1,7 +1,6 @@
 obj-y                          += pdc.o clock.o intc.o extint.o pio.o hsmc.o
 obj-y                          += hmatrix.o
 obj-$(CONFIG_CPU_AT32AP700X)   += at32ap700x.o pm-at32ap700x.o
-obj-$(CONFIG_CPU_FREQ_AT32AP)  += cpufreq.o
 obj-$(CONFIG_PM)               += pm.o
 
 ifeq ($(CONFIG_PM_DEBUG),y)
diff --git a/arch/avr32/mach-at32ap/cpufreq.c b/arch/avr32/mach-at32ap/cpufreq.c
deleted file mode 100644 (file)
index 6544887..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2004-2007 Atmel Corporation
- *
- * Based on MIPS implementation arch/mips/kernel/time.c
- *   Copyright 2001 MontaVista Software Inc.
- *
- * 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.
- */
-
-/*#define DEBUG*/
-
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/cpufreq.h>
-#include <linux/io.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/export.h>
-
-static struct clk *cpuclk;
-
-static int at32_verify_speed(struct cpufreq_policy *policy)
-{
-       if (policy->cpu != 0)
-               return -EINVAL;
-
-       cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
-                       policy->cpuinfo.max_freq);
-       return 0;
-}
-
-static unsigned int at32_get_speed(unsigned int cpu)
-{
-       /* No SMP support */
-       if (cpu)
-               return 0;
-       return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000);
-}
-
-static unsigned int    ref_freq;
-static unsigned long   loops_per_jiffy_ref;
-
-static int at32_set_target(struct cpufreq_policy *policy,
-                         unsigned int target_freq,
-                         unsigned int relation)
-{
-       struct cpufreq_freqs freqs;
-       long freq;
-
-       /* Convert target_freq from kHz to Hz */
-       freq = clk_round_rate(cpuclk, target_freq * 1000);
-
-       /* Check if policy->min <= new_freq <= policy->max */
-       if(freq < (policy->min * 1000) || freq > (policy->max * 1000))
-               return -EINVAL;
-
-       pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000);
-
-       freqs.old = at32_get_speed(0);
-       freqs.new = (freq + 500) / 1000;
-       freqs.flags = 0;
-
-       if (!ref_freq) {
-               ref_freq = freqs.old;
-               loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy;
-       }
-
-       cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
-       if (freqs.old < freqs.new)
-               boot_cpu_data.loops_per_jiffy = cpufreq_scale(
-                               loops_per_jiffy_ref, ref_freq, freqs.new);
-       clk_set_rate(cpuclk, freq);
-       if (freqs.new < freqs.old)
-               boot_cpu_data.loops_per_jiffy = cpufreq_scale(
-                               loops_per_jiffy_ref, ref_freq, freqs.new);
-       cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
-
-       pr_debug("cpufreq: set frequency %lu Hz\n", freq);
-
-       return 0;
-}
-
-static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
-{
-       if (policy->cpu != 0)
-               return -EINVAL;
-
-       cpuclk = clk_get(NULL, "cpu");
-       if (IS_ERR(cpuclk)) {
-               pr_debug("cpufreq: could not get CPU clk\n");
-               return PTR_ERR(cpuclk);
-       }
-
-       policy->cpuinfo.min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000;
-       policy->cpuinfo.max_freq = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
-       policy->cpuinfo.transition_latency = 0;
-       policy->cur = at32_get_speed(0);
-       policy->min = policy->cpuinfo.min_freq;
-       policy->max = policy->cpuinfo.max_freq;
-
-       printk("cpufreq: AT32AP CPU frequency driver\n");
-
-       return 0;
-}
-
-static struct cpufreq_driver at32_driver = {
-       .name           = "at32ap",
-       .owner          = THIS_MODULE,
-       .init           = at32_cpufreq_driver_init,
-       .verify         = at32_verify_speed,
-       .target         = at32_set_target,
-       .get            = at32_get_speed,
-       .flags          = CPUFREQ_STICKY,
-};
-
-static int __init at32_cpufreq_init(void)
-{
-       return cpufreq_register_driver(&at32_driver);
-}
-late_initcall(at32_cpufreq_init);
index cbcb21e32771df7bf6fb0b18ce9033f5cdc779a5..d7ce6ccf5c9106ee94575dfe3b29bffc81e03220 100644 (file)
@@ -205,6 +205,19 @@ depends on ARM
 source "drivers/cpufreq/Kconfig.arm"
 endmenu
 
+menu "AVR32 CPU frequency scaling drivers"
+depends on AVR32
+
+config AVR32_AT32AP_CPUFREQ
+       bool "CPU frequency driver for AT32AP"
+       depends on PLATFORM_AT32AP
+       default n
+       help
+         This enables the CPU frequency driver for AT32AP processors.
+         If in doubt, say N.
+
+endmenu
+
 menu "PowerPC CPU frequency scaling drivers"
 depends on PPC32 || PPC64
 source "drivers/cpufreq/Kconfig.powerpc"
index 8b21016ac1577fdf405a461a095b2c59d9dd4dbf..2701acafd65b0a360d0413f1d51668448ad4c657 100644 (file)
@@ -74,3 +74,7 @@ obj-$(CONFIG_ARCH_TEGRA)              += tegra-cpufreq.o
 ##################################################################################
 # PowerPC platform drivers
 obj-$(CONFIG_CPU_FREQ_MAPLE)           += maple-cpufreq.o
+
+##################################################################################
+# Other platform drivers
+obj-$(CONFIG_AVR32_AT32AP_CPUFREQ)     += at32ap-cpufreq.o
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
new file mode 100644 (file)
index 0000000..6544887
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2004-2007 Atmel Corporation
+ *
+ * Based on MIPS implementation arch/mips/kernel/time.c
+ *   Copyright 2001 MontaVista Software Inc.
+ *
+ * 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.
+ */
+
+/*#define DEBUG*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/cpufreq.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/export.h>
+
+static struct clk *cpuclk;
+
+static int at32_verify_speed(struct cpufreq_policy *policy)
+{
+       if (policy->cpu != 0)
+               return -EINVAL;
+
+       cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
+                       policy->cpuinfo.max_freq);
+       return 0;
+}
+
+static unsigned int at32_get_speed(unsigned int cpu)
+{
+       /* No SMP support */
+       if (cpu)
+               return 0;
+       return (unsigned int)((clk_get_rate(cpuclk) + 500) / 1000);
+}
+
+static unsigned int    ref_freq;
+static unsigned long   loops_per_jiffy_ref;
+
+static int at32_set_target(struct cpufreq_policy *policy,
+                         unsigned int target_freq,
+                         unsigned int relation)
+{
+       struct cpufreq_freqs freqs;
+       long freq;
+
+       /* Convert target_freq from kHz to Hz */
+       freq = clk_round_rate(cpuclk, target_freq * 1000);
+
+       /* Check if policy->min <= new_freq <= policy->max */
+       if(freq < (policy->min * 1000) || freq > (policy->max * 1000))
+               return -EINVAL;
+
+       pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000);
+
+       freqs.old = at32_get_speed(0);
+       freqs.new = (freq + 500) / 1000;
+       freqs.flags = 0;
+
+       if (!ref_freq) {
+               ref_freq = freqs.old;
+               loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy;
+       }
+
+       cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
+       if (freqs.old < freqs.new)
+               boot_cpu_data.loops_per_jiffy = cpufreq_scale(
+                               loops_per_jiffy_ref, ref_freq, freqs.new);
+       clk_set_rate(cpuclk, freq);
+       if (freqs.new < freqs.old)
+               boot_cpu_data.loops_per_jiffy = cpufreq_scale(
+                               loops_per_jiffy_ref, ref_freq, freqs.new);
+       cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
+
+       pr_debug("cpufreq: set frequency %lu Hz\n", freq);
+
+       return 0;
+}
+
+static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy)
+{
+       if (policy->cpu != 0)
+               return -EINVAL;
+
+       cpuclk = clk_get(NULL, "cpu");
+       if (IS_ERR(cpuclk)) {
+               pr_debug("cpufreq: could not get CPU clk\n");
+               return PTR_ERR(cpuclk);
+       }
+
+       policy->cpuinfo.min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000;
+       policy->cpuinfo.max_freq = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
+       policy->cpuinfo.transition_latency = 0;
+       policy->cur = at32_get_speed(0);
+       policy->min = policy->cpuinfo.min_freq;
+       policy->max = policy->cpuinfo.max_freq;
+
+       printk("cpufreq: AT32AP CPU frequency driver\n");
+
+       return 0;
+}
+
+static struct cpufreq_driver at32_driver = {
+       .name           = "at32ap",
+       .owner          = THIS_MODULE,
+       .init           = at32_cpufreq_driver_init,
+       .verify         = at32_verify_speed,
+       .target         = at32_set_target,
+       .get            = at32_get_speed,
+       .flags          = CPUFREQ_STICKY,
+};
+
+static int __init at32_cpufreq_init(void)
+{
+       return cpufreq_register_driver(&at32_driver);
+}
+late_initcall(at32_cpufreq_init);