aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq-dt-platdev.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2017-08-16 01:37:27 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-08-24 19:41:03 -0400
commitedeec420de2407618de097977e76b572d9de1bcf (patch)
tree87a78ea59dea36b66c5108e4eb8924d340073c8b /drivers/cpufreq/cpufreq-dt-platdev.c
parentec4259aa4497d61d7dc168e0c303971b1fc6747d (diff)
cpufreq: dt-platdev: Automatically create cpufreq device with OPP v2
The initial idea of creating the cpufreq-dt-platdev.c file was to keep a list of platforms that use the "operating-points" (V1) bindings and create cpufreq device for them only, as we weren't sure which platforms would want the device to get created automatically as some had their own cpufreq drivers as well, or wanted to initialize cpufreq after doing some stuff from platform code. But that wasn't the case with platforms using "operating-points-v2" property. We wanted the device to get created automatically without the need of adding them to the whitelist. Though, we will still have some exceptions where we don't want to create the device automatically. Rename the earlier platform list as *whitelist* and create a new *blacklist* as well. The cpufreq-dt device will get created if: - The platform is there in the whitelist OR - The platform has "operating-points-v2" property in CPU0's DT node and isn't part of the blacklist . Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Simon Horman <horms+renesas@verge.net.au> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq-dt-platdev.c')
-rw-r--r--drivers/cpufreq/cpufreq-dt-platdev.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c
index 8b88768b565d..7c67a6c74fdc 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -9,11 +9,16 @@
9 9
10#include <linux/err.h> 10#include <linux/err.h>
11#include <linux/of.h> 11#include <linux/of.h>
12#include <linux/of_device.h>
12#include <linux/platform_device.h> 13#include <linux/platform_device.h>
13 14
14#include "cpufreq-dt.h" 15#include "cpufreq-dt.h"
15 16
16static const struct of_device_id machines[] __initconst = { 17/*
18 * Machines for which the cpufreq device is *always* created, mostly used for
19 * platforms using "operating-points" (V1) property.
20 */
21static const struct of_device_id whitelist[] __initconst = {
17 { .compatible = "allwinner,sun4i-a10", }, 22 { .compatible = "allwinner,sun4i-a10", },
18 { .compatible = "allwinner,sun5i-a10s", }, 23 { .compatible = "allwinner,sun5i-a10s", },
19 { .compatible = "allwinner,sun5i-a13", }, 24 { .compatible = "allwinner,sun5i-a13", },
@@ -107,21 +112,51 @@ static const struct of_device_id machines[] __initconst = {
107 { } 112 { }
108}; 113};
109 114
115/*
116 * Machines for which the cpufreq device is *not* created, mostly used for
117 * platforms using "operating-points-v2" property.
118 */
119static const struct of_device_id blacklist[] __initconst = {
120 { }
121};
122
123static bool __init cpu0_node_has_opp_v2_prop(void)
124{
125 struct device_node *np = of_cpu_device_node_get(0);
126 bool ret = false;
127
128 if (of_get_property(np, "operating-points-v2", NULL))
129 ret = true;
130
131 of_node_put(np);
132 return ret;
133}
134
110static int __init cpufreq_dt_platdev_init(void) 135static int __init cpufreq_dt_platdev_init(void)
111{ 136{
112 struct device_node *np = of_find_node_by_path("/"); 137 struct device_node *np = of_find_node_by_path("/");
113 const struct of_device_id *match; 138 const struct of_device_id *match;
139 const void *data = NULL;
114 140
115 if (!np) 141 if (!np)
116 return -ENODEV; 142 return -ENODEV;
117 143
118 match = of_match_node(machines, np); 144 match = of_match_node(whitelist, np);
145 if (match) {
146 data = match->data;
147 goto create_pdev;
148 }
149
150 if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
151 goto create_pdev;
152
119 of_node_put(np); 153 of_node_put(np);
120 if (!match) 154 return -ENODEV;
121 return -ENODEV;
122 155
156create_pdev:
157 of_node_put(np);
123 return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt", 158 return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
124 -1, match->data, 159 -1, data,
125 sizeof(struct cpufreq_dt_platform_data))); 160 sizeof(struct cpufreq_dt_platform_data)));
126} 161}
127device_initcall(cpufreq_dt_platdev_init); 162device_initcall(cpufreq_dt_platdev_init);