diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-04-26 23:22:27 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-04-28 09:22:43 -0400 |
commit | 9f123def55d3fd0d76d49e0009419bcb994f6f1f (patch) | |
tree | 2b803cf47fe9c8ae78bd92153c6abfbefe59ec38 | |
parent | eb96924acddc709db58221c210ca05cd9effb1df (diff) |
cpufreq: mvebu: Move cpufreq code into drivers/cpufreq/
Move cpufreq bits for mvebu into drivers/cpufreq/ directory, that's
where they really belong to.
Compiled tested only.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | MAINTAINERS | 1 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/pmsu.c | 85 | ||||
-rw-r--r-- | drivers/cpufreq/Makefile | 1 | ||||
-rw-r--r-- | drivers/cpufreq/mvebu-cpufreq.c | 107 |
4 files changed, 109 insertions, 85 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 1d5b4becab6f..0bb566e7df9b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -1322,6 +1322,7 @@ F: drivers/rtc/rtc-armada38x.c | |||
1322 | F: arch/arm/boot/dts/armada* | 1322 | F: arch/arm/boot/dts/armada* |
1323 | F: arch/arm/boot/dts/kirkwood* | 1323 | F: arch/arm/boot/dts/kirkwood* |
1324 | F: arch/arm64/boot/dts/marvell/armada* | 1324 | F: arch/arm64/boot/dts/marvell/armada* |
1325 | F: drivers/cpufreq/mvebu-cpufreq.c | ||
1325 | 1326 | ||
1326 | 1327 | ||
1327 | ARM/Marvell Berlin SoC support | 1328 | ARM/Marvell Berlin SoC support |
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index 8928f7caaf70..b44442338e4e 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/of_address.h> | 28 | #include <linux/of_address.h> |
29 | #include <linux/of_device.h> | 29 | #include <linux/of_device.h> |
30 | #include <linux/platform_device.h> | 30 | #include <linux/platform_device.h> |
31 | #include <linux/pm_opp.h> | ||
32 | #include <linux/resource.h> | 31 | #include <linux/resource.h> |
33 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
34 | #include <linux/smp.h> | 33 | #include <linux/smp.h> |
@@ -607,87 +606,3 @@ int mvebu_pmsu_dfs_request(int cpu) | |||
607 | 606 | ||
608 | return 0; | 607 | return 0; |
609 | } | 608 | } |
610 | |||
611 | static int __init armada_xp_pmsu_cpufreq_init(void) | ||
612 | { | ||
613 | struct device_node *np; | ||
614 | struct resource res; | ||
615 | int ret, cpu; | ||
616 | |||
617 | if (!of_machine_is_compatible("marvell,armadaxp")) | ||
618 | return 0; | ||
619 | |||
620 | /* | ||
621 | * In order to have proper cpufreq handling, we need to ensure | ||
622 | * that the Device Tree description of the CPU clock includes | ||
623 | * the definition of the PMU DFS registers. If not, we do not | ||
624 | * register the clock notifier and the cpufreq driver. This | ||
625 | * piece of code is only for compatibility with old Device | ||
626 | * Trees. | ||
627 | */ | ||
628 | np = of_find_compatible_node(NULL, NULL, "marvell,armada-xp-cpu-clock"); | ||
629 | if (!np) | ||
630 | return 0; | ||
631 | |||
632 | ret = of_address_to_resource(np, 1, &res); | ||
633 | if (ret) { | ||
634 | pr_warn(FW_WARN "not enabling cpufreq, deprecated armada-xp-cpu-clock binding\n"); | ||
635 | of_node_put(np); | ||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | of_node_put(np); | ||
640 | |||
641 | /* | ||
642 | * For each CPU, this loop registers the operating points | ||
643 | * supported (which are the nominal CPU frequency and half of | ||
644 | * it), and registers the clock notifier that will take care | ||
645 | * of doing the PMSU part of a frequency transition. | ||
646 | */ | ||
647 | for_each_possible_cpu(cpu) { | ||
648 | struct device *cpu_dev; | ||
649 | struct clk *clk; | ||
650 | int ret; | ||
651 | |||
652 | cpu_dev = get_cpu_device(cpu); | ||
653 | if (!cpu_dev) { | ||
654 | pr_err("Cannot get CPU %d\n", cpu); | ||
655 | continue; | ||
656 | } | ||
657 | |||
658 | clk = clk_get(cpu_dev, 0); | ||
659 | if (IS_ERR(clk)) { | ||
660 | pr_err("Cannot get clock for CPU %d\n", cpu); | ||
661 | return PTR_ERR(clk); | ||
662 | } | ||
663 | |||
664 | /* | ||
665 | * In case of a failure of dev_pm_opp_add(), we don't | ||
666 | * bother with cleaning up the registered OPP (there's | ||
667 | * no function to do so), and simply cancel the | ||
668 | * registration of the cpufreq device. | ||
669 | */ | ||
670 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0); | ||
671 | if (ret) { | ||
672 | clk_put(clk); | ||
673 | return ret; | ||
674 | } | ||
675 | |||
676 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0); | ||
677 | if (ret) { | ||
678 | clk_put(clk); | ||
679 | return ret; | ||
680 | } | ||
681 | |||
682 | ret = dev_pm_opp_set_sharing_cpus(cpu_dev, | ||
683 | cpumask_of(cpu_dev->id)); | ||
684 | if (ret) | ||
685 | dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", | ||
686 | __func__, ret); | ||
687 | } | ||
688 | |||
689 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
690 | return 0; | ||
691 | } | ||
692 | |||
693 | device_initcall(armada_xp_pmsu_cpufreq_init); | ||
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 2cce2cd400f9..e1eb11ee3570 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -79,6 +79,7 @@ obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o | |||
79 | obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o | 79 | obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o |
80 | obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o | 80 | obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o |
81 | obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o | 81 | obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o |
82 | obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o | ||
82 | 83 | ||
83 | 84 | ||
84 | ################################################################################## | 85 | ################################################################################## |
diff --git a/drivers/cpufreq/mvebu-cpufreq.c b/drivers/cpufreq/mvebu-cpufreq.c new file mode 100644 index 000000000000..e920889b9ac2 --- /dev/null +++ b/drivers/cpufreq/mvebu-cpufreq.c | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * CPUFreq support for Armada 370/XP platforms. | ||
3 | * | ||
4 | * Copyright (C) 2012-2016 Marvell | ||
5 | * | ||
6 | * Yehuda Yitschak <yehuday@marvell.com> | ||
7 | * Gregory Clement <gregory.clement@free-electrons.com> | ||
8 | * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | ||
9 | * | ||
10 | * This file is licensed under the terms of the GNU General Public | ||
11 | * License version 2. This program is licensed "as is" without any | ||
12 | * warranty of any kind, whether express or implied. | ||
13 | */ | ||
14 | |||
15 | #define pr_fmt(fmt) "mvebu-pmsu: " fmt | ||
16 | |||
17 | #include <linux/clk.h> | ||
18 | #include <linux/cpu.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/of_address.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/pm_opp.h> | ||
24 | #include <linux/resource.h> | ||
25 | |||
26 | static int __init armada_xp_pmsu_cpufreq_init(void) | ||
27 | { | ||
28 | struct device_node *np; | ||
29 | struct resource res; | ||
30 | int ret, cpu; | ||
31 | |||
32 | if (!of_machine_is_compatible("marvell,armadaxp")) | ||
33 | return 0; | ||
34 | |||
35 | /* | ||
36 | * In order to have proper cpufreq handling, we need to ensure | ||
37 | * that the Device Tree description of the CPU clock includes | ||
38 | * the definition of the PMU DFS registers. If not, we do not | ||
39 | * register the clock notifier and the cpufreq driver. This | ||
40 | * piece of code is only for compatibility with old Device | ||
41 | * Trees. | ||
42 | */ | ||
43 | np = of_find_compatible_node(NULL, NULL, "marvell,armada-xp-cpu-clock"); | ||
44 | if (!np) | ||
45 | return 0; | ||
46 | |||
47 | ret = of_address_to_resource(np, 1, &res); | ||
48 | if (ret) { | ||
49 | pr_warn(FW_WARN "not enabling cpufreq, deprecated armada-xp-cpu-clock binding\n"); | ||
50 | of_node_put(np); | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | of_node_put(np); | ||
55 | |||
56 | /* | ||
57 | * For each CPU, this loop registers the operating points | ||
58 | * supported (which are the nominal CPU frequency and half of | ||
59 | * it), and registers the clock notifier that will take care | ||
60 | * of doing the PMSU part of a frequency transition. | ||
61 | */ | ||
62 | for_each_possible_cpu(cpu) { | ||
63 | struct device *cpu_dev; | ||
64 | struct clk *clk; | ||
65 | int ret; | ||
66 | |||
67 | cpu_dev = get_cpu_device(cpu); | ||
68 | if (!cpu_dev) { | ||
69 | pr_err("Cannot get CPU %d\n", cpu); | ||
70 | continue; | ||
71 | } | ||
72 | |||
73 | clk = clk_get(cpu_dev, 0); | ||
74 | if (IS_ERR(clk)) { | ||
75 | pr_err("Cannot get clock for CPU %d\n", cpu); | ||
76 | return PTR_ERR(clk); | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * In case of a failure of dev_pm_opp_add(), we don't | ||
81 | * bother with cleaning up the registered OPP (there's | ||
82 | * no function to do so), and simply cancel the | ||
83 | * registration of the cpufreq device. | ||
84 | */ | ||
85 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0); | ||
86 | if (ret) { | ||
87 | clk_put(clk); | ||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0); | ||
92 | if (ret) { | ||
93 | clk_put(clk); | ||
94 | return ret; | ||
95 | } | ||
96 | |||
97 | ret = dev_pm_opp_set_sharing_cpus(cpu_dev, | ||
98 | cpumask_of(cpu_dev->id)); | ||
99 | if (ret) | ||
100 | dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", | ||
101 | __func__, ret); | ||
102 | } | ||
103 | |||
104 | platform_device_register_simple("cpufreq-dt", -1, NULL, 0); | ||
105 | return 0; | ||
106 | } | ||
107 | device_initcall(armada_xp_pmsu_cpufreq_init); | ||