blob: f1d170dcf4d310cfa7c936ab1638b93b67f109ca [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", },
Geert Uytterhoevenf0da8982016-11-16 11:05:51 +010056 { .compatible = "renesas,r8a7743", },
Biju Dasd1e13032018-09-11 11:12:51 +010057 { .compatible = "renesas,r8a7744", },
Geert Uytterhoevenf0da8982016-11-16 11:05:51 +010058 { .compatible = "renesas,r8a7745", },
Viresh Kumara399dc92016-04-22 16:58:44 +053059 { .compatible = "renesas,r8a7778", },
60 { .compatible = "renesas,r8a7779", },
61 { .compatible = "renesas,r8a7790", },
62 { .compatible = "renesas,r8a7791", },
Geert Uytterhoevenffdf8b82016-09-06 14:18:20 +020063 { .compatible = "renesas,r8a7792", },
Viresh Kumara399dc92016-04-22 16:58:44 +053064 { .compatible = "renesas,r8a7793", },
65 { .compatible = "renesas,r8a7794", },
66 { .compatible = "renesas,sh73a0", },
67
Finley Xiao014400c2016-04-22 16:58:43 +053068 { .compatible = "rockchip,rk2928", },
69 { .compatible = "rockchip,rk3036", },
70 { .compatible = "rockchip,rk3066a", },
71 { .compatible = "rockchip,rk3066b", },
72 { .compatible = "rockchip,rk3188", },
73 { .compatible = "rockchip,rk3228", },
74 { .compatible = "rockchip,rk3288", },
Finley Xiao319af402017-08-04 09:52:31 +080075 { .compatible = "rockchip,rk3328", },
Finley Xiao014400c2016-04-22 16:58:43 +053076 { .compatible = "rockchip,rk3366", },
77 { .compatible = "rockchip,rk3368", },
Dmitry Torokhov9d21d332018-10-05 12:00:58 -070078 { .compatible = "rockchip,rk3399",
79 .data = &(struct cpufreq_dt_platform_data)
80 { .have_governor_per_policy = true, },
81 },
Finley Xiao014400c2016-04-22 16:58:43 +053082
Linus Walleijff6c3492017-08-16 10:19:12 +020083 { .compatible = "st-ericsson,u8500", },
84 { .compatible = "st-ericsson,u8540", },
85 { .compatible = "st-ericsson,u9500", },
86 { .compatible = "st-ericsson,u9540", },
87
Viresh Kumar7694ca62016-04-22 16:58:42 +053088 { .compatible = "ti,omap2", },
Viresh Kumar7694ca62016-04-22 16:58:42 +053089 { .compatible = "ti,omap4", },
90 { .compatible = "ti,omap5", },
Viresh Kumar5e4249c2016-04-22 16:58:46 +053091
92 { .compatible = "xlnx,zynq-7000", },
Shubhrajyoti Dattaa5685782017-07-13 11:19:10 +020093 { .compatible = "xlnx,zynqmp", },
Wei Yongjunbd37e022016-08-21 15:41:44 +000094
95 { }
Viresh Kumarf56aad12016-03-30 13:45:26 +053096};
97
Viresh Kumaredeec422017-08-16 11:07:27 +053098/*
99 * Machines for which the cpufreq device is *not* created, mostly used for
100 * platforms using "operating-points-v2" property.
101 */
102static const struct of_device_id blacklist[] __initconst = {
Yangtao Lif3285842019-06-12 12:28:15 -0400103 { .compatible = "allwinner,sun50i-h6", },
104
Viresh Kumarff768982017-09-19 08:23:22 -0700105 { .compatible = "calxeda,highbank", },
106 { .compatible = "calxeda,ecx-2000", },
107
Leonard Cresteze6abaca2019-06-05 13:37:06 +0300108 { .compatible = "fsl,imx7d", },
Leonard Crestez4d28ba12019-05-13 11:01:38 +0000109 { .compatible = "fsl,imx8mq", },
110 { .compatible = "fsl,imx8mm", },
Anson Huang8ec50352019-08-18 02:32:21 -0400111 { .compatible = "fsl,imx8mn", },
Leonard Crestez4d28ba12019-05-13 11:01:38 +0000112
Viresh Kumarff768982017-09-19 08:23:22 -0700113 { .compatible = "marvell,armadaxp", },
114
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800115 { .compatible = "mediatek,mt2701", },
116 { .compatible = "mediatek,mt2712", },
117 { .compatible = "mediatek,mt7622", },
118 { .compatible = "mediatek,mt7623", },
119 { .compatible = "mediatek,mt817x", },
120 { .compatible = "mediatek,mt8173", },
121 { .compatible = "mediatek,mt8176", },
Andrew-sh.Cheng9176b422019-08-13 21:31:48 +0800122 { .compatible = "mediatek,mt8183", },
Andrew-sh Cheng6066998c2017-12-08 14:07:56 +0800123
Viresh Kumarff768982017-09-19 08:23:22 -0700124 { .compatible = "nvidia,tegra124", },
Joseph Lo43c36002019-01-04 11:06:55 +0800125 { .compatible = "nvidia,tegra210", },
Viresh Kumarff768982017-09-19 08:23:22 -0700126
Ilia Lin46e28562018-05-30 05:39:28 +0300127 { .compatible = "qcom,apq8096", },
128 { .compatible = "qcom,msm8996", },
Jorge Ramirez-Ortiz248b5f22019-07-25 12:41:36 +0200129 { .compatible = "qcom,qcs404", },
Ilia Lin46e28562018-05-30 05:39:28 +0300130
Viresh Kumarff768982017-09-19 08:23:22 -0700131 { .compatible = "st,stih407", },
132 { .compatible = "st,stih410", },
133
134 { .compatible = "sigma,tango4", },
135
Suniel Maheshd477bf32017-09-21 19:09:03 +0530136 { .compatible = "ti,am33xx", },
137 { .compatible = "ti,am43", },
138 { .compatible = "ti,dra7", },
H. Nikolaus Schallerb7dbe342019-09-11 19:47:08 +0200139 { .compatible = "ti,omap3", },
Suniel Maheshd477bf32017-09-21 19:09:03 +0530140
Viresh Kumaredeec422017-08-16 11:07:27 +0530141 { }
142};
143
144static bool __init cpu0_node_has_opp_v2_prop(void)
145{
146 struct device_node *np = of_cpu_device_node_get(0);
147 bool ret = false;
148
149 if (of_get_property(np, "operating-points-v2", NULL))
150 ret = true;
151
152 of_node_put(np);
153 return ret;
154}
155
Viresh Kumarf56aad12016-03-30 13:45:26 +0530156static int __init cpufreq_dt_platdev_init(void)
157{
158 struct device_node *np = of_find_node_by_path("/");
Masahiro Yamadaca5eda52016-06-27 14:50:13 +0900159 const struct of_device_id *match;
Viresh Kumaredeec422017-08-16 11:07:27 +0530160 const void *data = NULL;
Viresh Kumarf56aad12016-03-30 13:45:26 +0530161
162 if (!np)
163 return -ENODEV;
164
Viresh Kumaredeec422017-08-16 11:07:27 +0530165 match = of_match_node(whitelist, np);
166 if (match) {
167 data = match->data;
168 goto create_pdev;
169 }
Viresh Kumarf56aad12016-03-30 13:45:26 +0530170
Viresh Kumaredeec422017-08-16 11:07:27 +0530171 if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
172 goto create_pdev;
173
174 of_node_put(np);
175 return -ENODEV;
176
177create_pdev:
178 of_node_put(np);
Viresh Kumar297a6622016-09-09 16:48:08 +0530179 return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
Viresh Kumaredeec422017-08-16 11:07:27 +0530180 -1, data,
Viresh Kumar297a6622016-09-09 16:48:08 +0530181 sizeof(struct cpufreq_dt_platform_data)));
Viresh Kumarf56aad12016-03-30 13:45:26 +0530182}
Amit Kucheria57db08f2019-10-21 17:45:13 +0530183core_initcall(cpufreq_dt_platdev_init);