blob: 3ba2f716fe9783c829e99b6bff345098ba0b477f [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Viresh Kumarf56aad12016-03-30 13:45:26 +05302/*
3 * Copyright (C) 2016 Linaro.
4 * Viresh Kumar <viresh.kumar@linaro.org>
Viresh Kumarf56aad12016-03-30 13:45:26 +05305 */
6
7#include <linux/err.h>
8#include <linux/of.h>
Viresh Kumaredeec422017-08-16 11:07:27 +05309#include <linux/of_device.h>
Viresh Kumarf56aad12016-03-30 13:45:26 +053010#include <linux/platform_device.h>
11
Viresh Kumar297a6622016-09-09 16:48:08 +053012#include "cpufreq-dt.h"
13
Viresh Kumaredeec422017-08-16 11:07:27 +053014/*
15 * Machines for which the cpufreq device is *always* created, mostly used for
16 * platforms using "operating-points" (V1) property.
17 */
18static const struct of_device_id whitelist[] __initconst = {
Viresh Kumar117d4f52016-04-22 16:58:45 +053019 { .compatible = "allwinner,sun4i-a10", },
20 { .compatible = "allwinner,sun5i-a10s", },
21 { .compatible = "allwinner,sun5i-a13", },
22 { .compatible = "allwinner,sun5i-r8", },
23 { .compatible = "allwinner,sun6i-a31", },
24 { .compatible = "allwinner,sun6i-a31s", },
25 { .compatible = "allwinner,sun7i-a20", },
26 { .compatible = "allwinner,sun8i-a23", },
Viresh Kumar117d4f52016-04-22 16:58:45 +053027 { .compatible = "allwinner,sun8i-a83t", },
28 { .compatible = "allwinner,sun8i-h3", },
29
Hoan Trane11b6292016-12-15 14:55:00 -080030 { .compatible = "apm,xgene-shadowcat", },
31
Linus Walleij650ec6c2016-10-25 09:21:24 +020032 { .compatible = "arm,integrator-ap", },
33 { .compatible = "arm,integrator-cp", },
34
Tao Wanga0df7732017-05-23 16:13:18 +080035 { .compatible = "hisilicon,hi3660", },
Viresh Kumar3920be42016-04-22 16:58:47 +053036
Viresh Kumar7ead83f2016-04-22 16:58:41 +053037 { .compatible = "fsl,imx27", },
38 { .compatible = "fsl,imx51", },
39 { .compatible = "fsl,imx53", },
Viresh Kumar7ead83f2016-04-22 16:58:41 +053040
Viresh Kumara59511d2016-04-22 16:58:40 +053041 { .compatible = "marvell,berlin", },
Robert Jarzmikdcd2ea42016-10-31 20:54:53 +010042 { .compatible = "marvell,pxa250", },
43 { .compatible = "marvell,pxa270", },
Viresh Kumara59511d2016-04-22 16:58:40 +053044
Viresh Kumar2249c002016-03-30 13:45:28 +053045 { .compatible = "samsung,exynos3250", },
46 { .compatible = "samsung,exynos4210", },
Viresh Kumar2249c002016-03-30 13:45:28 +053047 { .compatible = "samsung,exynos5250", },
48#ifndef CONFIG_BL_SWITCHER
Viresh Kumar2249c002016-03-30 13:45:28 +053049 { .compatible = "samsung,exynos5800", },
50#endif
Viresh Kumar7694ca62016-04-22 16:58:42 +053051
Viresh Kumara399dc92016-04-22 16:58:44 +053052 { .compatible = "renesas,emev2", },
53 { .compatible = "renesas,r7s72100", },
54 { .compatible = "renesas,r8a73a4", },
55 { .compatible = "renesas,r8a7740", },
Lad Prabhakara6d1bfa2020-04-27 13:53:30 +010056 { .compatible = "renesas,r8a7742", },
Geert Uytterhoevenf0da8982016-11-16 11:05:51 +010057 { .compatible = "renesas,r8a7743", },
Biju Dasd1e13032018-09-11 11:12:51 +010058 { .compatible = "renesas,r8a7744", },
Geert Uytterhoevenf0da8982016-11-16 11:05:51 +010059 { .compatible = "renesas,r8a7745", },
Viresh Kumara399dc92016-04-22 16:58:44 +053060 { .compatible = "renesas,r8a7778", },
61 { .compatible = "renesas,r8a7779", },
62 { .compatible = "renesas,r8a7790", },
63 { .compatible = "renesas,r8a7791", },
Geert Uytterhoevenffdf8b82016-09-06 14:18:20 +020064 { .compatible = "renesas,r8a7792", },
Viresh Kumara399dc92016-04-22 16:58:44 +053065 { .compatible = "renesas,r8a7793", },
66 { .compatible = "renesas,r8a7794", },
67 { .compatible = "renesas,sh73a0", },
68
Finley Xiao014400c2016-04-22 16:58:43 +053069 { .compatible = "rockchip,rk2928", },
70 { .compatible = "rockchip,rk3036", },
71 { .compatible = "rockchip,rk3066a", },
72 { .compatible = "rockchip,rk3066b", },
73 { .compatible = "rockchip,rk3188", },
74 { .compatible = "rockchip,rk3228", },
75 { .compatible = "rockchip,rk3288", },
Finley Xiao319af402017-08-04 09:52:31 +080076 { .compatible = "rockchip,rk3328", },
Finley Xiao014400c2016-04-22 16:58:43 +053077 { .compatible = "rockchip,rk3366", },
78 { .compatible = "rockchip,rk3368", },
Dmitry Torokhov9d21d332018-10-05 12:00:58 -070079 { .compatible = "rockchip,rk3399",
80 .data = &(struct cpufreq_dt_platform_data)
81 { .have_governor_per_policy = true, },
82 },
Finley Xiao014400c2016-04-22 16:58:43 +053083
Linus Walleijff6c3492017-08-16 10:19:12 +020084 { .compatible = "st-ericsson,u8500", },
85 { .compatible = "st-ericsson,u8540", },
86 { .compatible = "st-ericsson,u9500", },
87 { .compatible = "st-ericsson,u9540", },
88
Viresh Kumar7694ca62016-04-22 16:58:42 +053089 { .compatible = "ti,omap2", },
Viresh Kumar7694ca62016-04-22 16:58:42 +053090 { .compatible = "ti,omap4", },
91 { .compatible = "ti,omap5", },
Viresh Kumar5e4249c2016-04-22 16:58:46 +053092
93 { .compatible = "xlnx,zynq-7000", },
Shubhrajyoti Dattaa5685782017-07-13 11:19:10 +020094 { .compatible = "xlnx,zynqmp", },
Wei Yongjunbd37e022016-08-21 15:41:44 +000095
96 { }
Viresh Kumarf56aad12016-03-30 13:45:26 +053097};
98
Viresh Kumaredeec422017-08-16 11:07:27 +053099/*
100 * Machines for which the cpufreq device is *not* created, mostly used for
101 * platforms using "operating-points-v2" property.
102 */
103static const struct of_device_id blacklist[] __initconst = {
Yangtao Lif3285842019-06-12 12:28:15 -0400104 { .compatible = "allwinner,sun50i-h6", },
105
Viresh Kumarff768982017-09-19 08:23:22 -0700106 { .compatible = "calxeda,highbank", },
107 { .compatible = "calxeda,ecx-2000", },
108
Peng Fana08e1b62020-04-20 15:55:13 +0800109 { .compatible = "fsl,imx7ulp", },
Leonard Cresteze6abaca2019-06-05 13:37:06 +0300110 { .compatible = "fsl,imx7d", },
Leonard Crestez4d28ba12019-05-13 11:01:38 +0000111 { .compatible = "fsl,imx8mq", },
112 { .compatible = "fsl,imx8mm", },
Anson Huang8ec50352019-08-18 02:32:21 -0400113 { .compatible = "fsl,imx8mn", },
Anson Huang24f371f2019-12-26 14:52:46 +0800114 { .compatible = "fsl,imx8mp", },
Leonard Crestez4d28ba12019-05-13 11:01:38 +0000115
Viresh Kumarff768982017-09-19 08:23:22 -0700116 { .compatible = "marvell,armadaxp", },
117
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800118 { .compatible = "mediatek,mt2701", },
119 { .compatible = "mediatek,mt2712", },
120 { .compatible = "mediatek,mt7622", },
121 { .compatible = "mediatek,mt7623", },
Fabien Parentde4ca302020-10-13 11:27:08 +0200122 { .compatible = "mediatek,mt8167", },
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800123 { .compatible = "mediatek,mt817x", },
124 { .compatible = "mediatek,mt8173", },
125 { .compatible = "mediatek,mt8176", },
Andrew-sh.Cheng9176b422019-08-13 21:31:48 +0800126 { .compatible = "mediatek,mt8183", },
Fabien Parent75118c82020-10-13 11:27:09 +0200127 { .compatible = "mediatek,mt8516", },
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800128
Dmitry Osipenko26a7a472019-11-18 19:45:08 +0300129 { .compatible = "nvidia,tegra20", },
130 { .compatible = "nvidia,tegra30", },
Viresh Kumarff768982017-09-19 08:23:22 -0700131 { .compatible = "nvidia,tegra124", },
Joseph Lo43c36002019-01-04 11:06:55 +0800132 { .compatible = "nvidia,tegra210", },
Viresh Kumarff768982017-09-19 08:23:22 -0700133
Ilia Lin46e28562018-05-30 05:39:28 +0300134 { .compatible = "qcom,apq8096", },
135 { .compatible = "qcom,msm8996", },
Jorge Ramirez-Ortiz248b5f22019-07-25 12:41:36 +0200136 { .compatible = "qcom,qcs404", },
Sibi Sankarfb091802020-06-22 13:46:46 +0530137 { .compatible = "qcom,sc7180", },
Sibi Sankar49ef1222020-06-22 13:46:45 +0530138 { .compatible = "qcom,sdm845", },
Ilia Lin46e28562018-05-30 05:39:28 +0300139
Viresh Kumarff768982017-09-19 08:23:22 -0700140 { .compatible = "st,stih407", },
141 { .compatible = "st,stih410", },
Alain Volmat305accf2020-08-31 08:10:12 +0200142 { .compatible = "st,stih418", },
Viresh Kumarff768982017-09-19 08:23:22 -0700143
Suniel Maheshd477bf32017-09-21 19:09:03 +0530144 { .compatible = "ti,am33xx", },
145 { .compatible = "ti,am43", },
146 { .compatible = "ti,dra7", },
H. Nikolaus Schallerb7dbe342019-09-11 19:47:08 +0200147 { .compatible = "ti,omap3", },
Suniel Maheshd477bf32017-09-21 19:09:03 +0530148
Ansuel Smitha8811ec2020-03-13 18:52:13 +0100149 { .compatible = "qcom,ipq8064", },
150 { .compatible = "qcom,apq8064", },
151 { .compatible = "qcom,msm8974", },
152 { .compatible = "qcom,msm8960", },
153
Viresh Kumaredeec422017-08-16 11:07:27 +0530154 { }
155};
156
157static bool __init cpu0_node_has_opp_v2_prop(void)
158{
159 struct device_node *np = of_cpu_device_node_get(0);
160 bool ret = false;
161
162 if (of_get_property(np, "operating-points-v2", NULL))
163 ret = true;
164
165 of_node_put(np);
166 return ret;
167}
168
Viresh Kumarf56aad12016-03-30 13:45:26 +0530169static int __init cpufreq_dt_platdev_init(void)
170{
171 struct device_node *np = of_find_node_by_path("/");
Masahiro Yamadaca5eda52016-06-27 14:50:13 +0900172 const struct of_device_id *match;
Viresh Kumaredeec422017-08-16 11:07:27 +0530173 const void *data = NULL;
Viresh Kumarf56aad12016-03-30 13:45:26 +0530174
175 if (!np)
176 return -ENODEV;
177
Viresh Kumaredeec422017-08-16 11:07:27 +0530178 match = of_match_node(whitelist, np);
179 if (match) {
180 data = match->data;
181 goto create_pdev;
182 }
Viresh Kumarf56aad12016-03-30 13:45:26 +0530183
Viresh Kumaredeec422017-08-16 11:07:27 +0530184 if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
185 goto create_pdev;
186
187 of_node_put(np);
188 return -ENODEV;
189
190create_pdev:
191 of_node_put(np);
Viresh Kumar297a6622016-09-09 16:48:08 +0530192 return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
Viresh Kumaredeec422017-08-16 11:07:27 +0530193 -1, data,
Viresh Kumar297a6622016-09-09 16:48:08 +0530194 sizeof(struct cpufreq_dt_platform_data)));
Viresh Kumarf56aad12016-03-30 13:45:26 +0530195}
Amit Kucheria57db08f2019-10-21 17:45:13 +0530196core_initcall(cpufreq_dt_platdev_init);