blob: ca1d103ec4492bfebe1f35f7316c8871beb9d9b2 [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 */
Viresh Kumar4814d9c2021-05-20 09:56:18 +053018static const struct of_device_id allowlist[] __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 */
Viresh Kumar4814d9c2021-05-20 09:56:18 +0530103static const struct of_device_id blocklist[] __initconst = {
Yangtao Lif3285842019-06-12 12:28:15 -0400104 { .compatible = "allwinner,sun50i-h6", },
105
Sudeep Hollafbb31cb2021-02-18 22:23:26 +0000106 { .compatible = "arm,vexpress", },
107
Viresh Kumarff768982017-09-19 08:23:22 -0700108 { .compatible = "calxeda,highbank", },
109 { .compatible = "calxeda,ecx-2000", },
110
Peng Fana08e1b62020-04-20 15:55:13 +0800111 { .compatible = "fsl,imx7ulp", },
Leonard Cresteze6abaca2019-06-05 13:37:06 +0300112 { .compatible = "fsl,imx7d", },
Leonard Crestez4d28ba12019-05-13 11:01:38 +0000113 { .compatible = "fsl,imx8mq", },
114 { .compatible = "fsl,imx8mm", },
Anson Huang8ec50352019-08-18 02:32:21 -0400115 { .compatible = "fsl,imx8mn", },
Anson Huang24f371f2019-12-26 14:52:46 +0800116 { .compatible = "fsl,imx8mp", },
Leonard Crestez4d28ba12019-05-13 11:01:38 +0000117
Viresh Kumarff768982017-09-19 08:23:22 -0700118 { .compatible = "marvell,armadaxp", },
119
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800120 { .compatible = "mediatek,mt2701", },
121 { .compatible = "mediatek,mt2712", },
122 { .compatible = "mediatek,mt7622", },
123 { .compatible = "mediatek,mt7623", },
Fabien Parentde4ca302020-10-13 11:27:08 +0200124 { .compatible = "mediatek,mt8167", },
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800125 { .compatible = "mediatek,mt817x", },
126 { .compatible = "mediatek,mt8173", },
127 { .compatible = "mediatek,mt8176", },
Andrew-sh.Cheng9176b422019-08-13 21:31:48 +0800128 { .compatible = "mediatek,mt8183", },
Fabien Parent70d99a82021-05-19 18:25:50 +0200129 { .compatible = "mediatek,mt8365", },
Fabien Parent75118c82020-10-13 11:27:09 +0200130 { .compatible = "mediatek,mt8516", },
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800131
Dmitry Osipenko26a7a472019-11-18 19:45:08 +0300132 { .compatible = "nvidia,tegra20", },
133 { .compatible = "nvidia,tegra30", },
Viresh Kumarff768982017-09-19 08:23:22 -0700134 { .compatible = "nvidia,tegra124", },
Joseph Lo43c36002019-01-04 11:06:55 +0800135 { .compatible = "nvidia,tegra210", },
Viresh Kumarff768982017-09-19 08:23:22 -0700136
Ilia Lin46e28562018-05-30 05:39:28 +0300137 { .compatible = "qcom,apq8096", },
138 { .compatible = "qcom,msm8996", },
Jorge Ramirez-Ortiz248b5f22019-07-25 12:41:36 +0200139 { .compatible = "qcom,qcs404", },
Bjorn Andersson5e79d6d2021-08-20 14:57:00 -0700140 { .compatible = "qcom,sa8155p" },
Sibi Sankarfb091802020-06-22 13:46:46 +0530141 { .compatible = "qcom,sc7180", },
Sibi Sankar17a8b0b2021-05-12 13:41:22 +0530142 { .compatible = "qcom,sc7280", },
Bjorn Anderssond66cd5d2021-07-24 20:02:14 -0700143 { .compatible = "qcom,sc8180x", },
Sibi Sankar49ef1222020-06-22 13:46:45 +0530144 { .compatible = "qcom,sdm845", },
Bjorn Andersson5e79d6d2021-08-20 14:57:00 -0700145 { .compatible = "qcom,sm6350", },
Thara Gopinath5d79e5c2021-08-04 16:34:20 -0400146 { .compatible = "qcom,sm8150", },
Bjorn Andersson5e79d6d2021-08-20 14:57:00 -0700147 { .compatible = "qcom,sm8250", },
148 { .compatible = "qcom,sm8350", },
Ilia Lin46e28562018-05-30 05:39:28 +0300149
Viresh Kumarff768982017-09-19 08:23:22 -0700150 { .compatible = "st,stih407", },
151 { .compatible = "st,stih410", },
Alain Volmat305accf2020-08-31 08:10:12 +0200152 { .compatible = "st,stih418", },
Viresh Kumarff768982017-09-19 08:23:22 -0700153
Suniel Maheshd477bf32017-09-21 19:09:03 +0530154 { .compatible = "ti,am33xx", },
155 { .compatible = "ti,am43", },
156 { .compatible = "ti,dra7", },
H. Nikolaus Schallerb7dbe342019-09-11 19:47:08 +0200157 { .compatible = "ti,omap3", },
Suniel Maheshd477bf32017-09-21 19:09:03 +0530158
Ansuel Smitha8811ec2020-03-13 18:52:13 +0100159 { .compatible = "qcom,ipq8064", },
160 { .compatible = "qcom,apq8064", },
161 { .compatible = "qcom,msm8974", },
162 { .compatible = "qcom,msm8960", },
163
Viresh Kumaredeec422017-08-16 11:07:27 +0530164 { }
165};
166
167static bool __init cpu0_node_has_opp_v2_prop(void)
168{
169 struct device_node *np = of_cpu_device_node_get(0);
170 bool ret = false;
171
172 if (of_get_property(np, "operating-points-v2", NULL))
173 ret = true;
174
175 of_node_put(np);
176 return ret;
177}
178
Viresh Kumarf56aad12016-03-30 13:45:26 +0530179static int __init cpufreq_dt_platdev_init(void)
180{
181 struct device_node *np = of_find_node_by_path("/");
Masahiro Yamadaca5eda52016-06-27 14:50:13 +0900182 const struct of_device_id *match;
Viresh Kumaredeec422017-08-16 11:07:27 +0530183 const void *data = NULL;
Viresh Kumarf56aad12016-03-30 13:45:26 +0530184
185 if (!np)
186 return -ENODEV;
187
Viresh Kumar4814d9c2021-05-20 09:56:18 +0530188 match = of_match_node(allowlist, np);
Viresh Kumaredeec422017-08-16 11:07:27 +0530189 if (match) {
190 data = match->data;
191 goto create_pdev;
192 }
Viresh Kumarf56aad12016-03-30 13:45:26 +0530193
Viresh Kumar4814d9c2021-05-20 09:56:18 +0530194 if (cpu0_node_has_opp_v2_prop() && !of_match_node(blocklist, np))
Viresh Kumaredeec422017-08-16 11:07:27 +0530195 goto create_pdev;
196
197 of_node_put(np);
198 return -ENODEV;
199
200create_pdev:
201 of_node_put(np);
Viresh Kumar297a6622016-09-09 16:48:08 +0530202 return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
Viresh Kumaredeec422017-08-16 11:07:27 +0530203 -1, data,
Viresh Kumar297a6622016-09-09 16:48:08 +0530204 sizeof(struct cpufreq_dt_platform_data)));
Viresh Kumarf56aad12016-03-30 13:45:26 +0530205}
Amit Kucheria57db08f2019-10-21 17:45:13 +0530206core_initcall(cpufreq_dt_platdev_init);