Commit | Line | Data |
---|---|---|
8a67f0ef VK |
1 | /* |
2 | * Generic big.LITTLE CPUFreq Interface driver | |
3 | * | |
4 | * It provides necessary ops to arm_big_little cpufreq driver and gets | |
5 | * Frequency information from Device Tree. Freq table in DT must be in KHz. | |
6 | * | |
7 | * Copyright (C) 2013 Linaro. | |
8 | * Viresh Kumar <viresh.kumar@linaro.org> | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License version 2 as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | |
15 | * kind, whether express or implied; without even the implied warranty | |
16 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | */ | |
19 | ||
20 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
21 | ||
22 | #include <linux/cpufreq.h> | |
23 | #include <linux/device.h> | |
24 | #include <linux/export.h> | |
25 | #include <linux/module.h> | |
26 | #include <linux/of.h> | |
27 | #include <linux/opp.h> | |
28 | #include <linux/slab.h> | |
29 | #include <linux/types.h> | |
30 | #include "arm_big_little.h" | |
31 | ||
32 | static int dt_init_opp_table(struct device *cpu_dev) | |
33 | { | |
34 | struct device_node *np = NULL; | |
35 | int count = 0, ret; | |
36 | ||
37 | for_each_child_of_node(of_find_node_by_path("/cpus"), np) { | |
38 | if (count++ != cpu_dev->id) | |
39 | continue; | |
40 | if (!of_get_property(np, "operating-points", NULL)) | |
41 | return -ENODATA; | |
42 | ||
43 | cpu_dev->of_node = np; | |
44 | ||
45 | ret = of_init_opp_table(cpu_dev); | |
46 | if (ret) | |
47 | return ret; | |
48 | ||
49 | return 0; | |
50 | } | |
51 | ||
52 | return -ENODEV; | |
53 | } | |
54 | ||
55 | static int dt_get_transition_latency(struct device *cpu_dev) | |
56 | { | |
57 | struct device_node *np = NULL; | |
58 | u32 transition_latency = CPUFREQ_ETERNAL; | |
59 | int count = 0; | |
60 | ||
61 | for_each_child_of_node(of_find_node_by_path("/cpus"), np) { | |
62 | if (count++ != cpu_dev->id) | |
63 | continue; | |
64 | ||
65 | of_property_read_u32(np, "clock-latency", &transition_latency); | |
66 | return 0; | |
67 | } | |
68 | ||
69 | return -ENODEV; | |
70 | } | |
71 | ||
72 | static struct cpufreq_arm_bL_ops dt_bL_ops = { | |
73 | .name = "dt-bl", | |
74 | .get_transition_latency = dt_get_transition_latency, | |
75 | .init_opp_table = dt_init_opp_table, | |
76 | }; | |
77 | ||
78 | static int generic_bL_init(void) | |
79 | { | |
80 | return bL_cpufreq_register(&dt_bL_ops); | |
81 | } | |
82 | module_init(generic_bL_init); | |
83 | ||
84 | static void generic_bL_exit(void) | |
85 | { | |
86 | return bL_cpufreq_unregister(&dt_bL_ops); | |
87 | } | |
88 | module_exit(generic_bL_exit); | |
89 | ||
90 | MODULE_AUTHOR("Viresh Kumar <viresh.kumar@linaro.org>"); | |
91 | MODULE_DESCRIPTION("Generic ARM big LITTLE cpufreq driver via DT"); | |
92 | MODULE_LICENSE("GPL"); |