Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Linaro. |
| 4 | * Viresh Kumar <viresh.kumar@linaro.org> |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <linux/err.h> |
| 8 | #include <linux/of.h> |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 9 | #include <linux/of_device.h> |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 10 | #include <linux/platform_device.h> |
| 11 | |
Viresh Kumar | 297a662 | 2016-09-09 16:48:08 +0530 | [diff] [blame] | 12 | #include "cpufreq-dt.h" |
| 13 | |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 14 | /* |
| 15 | * Machines for which the cpufreq device is *always* created, mostly used for |
| 16 | * platforms using "operating-points" (V1) property. |
| 17 | */ |
Viresh Kumar | 4814d9c | 2021-05-20 09:56:18 +0530 | [diff] [blame] | 18 | static const struct of_device_id allowlist[] __initconst = { |
Viresh Kumar | 117d4f5 | 2016-04-22 16:58:45 +0530 | [diff] [blame] | 19 | { .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 Kumar | 117d4f5 | 2016-04-22 16:58:45 +0530 | [diff] [blame] | 27 | { .compatible = "allwinner,sun8i-a83t", }, |
| 28 | { .compatible = "allwinner,sun8i-h3", }, |
| 29 | |
Hoan Tran | e11b629 | 2016-12-15 14:55:00 -0800 | [diff] [blame] | 30 | { .compatible = "apm,xgene-shadowcat", }, |
| 31 | |
Linus Walleij | 650ec6c | 2016-10-25 09:21:24 +0200 | [diff] [blame] | 32 | { .compatible = "arm,integrator-ap", }, |
| 33 | { .compatible = "arm,integrator-cp", }, |
| 34 | |
Tao Wang | a0df773 | 2017-05-23 16:13:18 +0800 | [diff] [blame] | 35 | { .compatible = "hisilicon,hi3660", }, |
Viresh Kumar | 3920be4 | 2016-04-22 16:58:47 +0530 | [diff] [blame] | 36 | |
Viresh Kumar | 7ead83f | 2016-04-22 16:58:41 +0530 | [diff] [blame] | 37 | { .compatible = "fsl,imx27", }, |
| 38 | { .compatible = "fsl,imx51", }, |
| 39 | { .compatible = "fsl,imx53", }, |
Viresh Kumar | 7ead83f | 2016-04-22 16:58:41 +0530 | [diff] [blame] | 40 | |
Viresh Kumar | a59511d | 2016-04-22 16:58:40 +0530 | [diff] [blame] | 41 | { .compatible = "marvell,berlin", }, |
Robert Jarzmik | dcd2ea4 | 2016-10-31 20:54:53 +0100 | [diff] [blame] | 42 | { .compatible = "marvell,pxa250", }, |
| 43 | { .compatible = "marvell,pxa270", }, |
Viresh Kumar | a59511d | 2016-04-22 16:58:40 +0530 | [diff] [blame] | 44 | |
Viresh Kumar | 2249c00 | 2016-03-30 13:45:28 +0530 | [diff] [blame] | 45 | { .compatible = "samsung,exynos3250", }, |
| 46 | { .compatible = "samsung,exynos4210", }, |
Viresh Kumar | 2249c00 | 2016-03-30 13:45:28 +0530 | [diff] [blame] | 47 | { .compatible = "samsung,exynos5250", }, |
| 48 | #ifndef CONFIG_BL_SWITCHER |
Viresh Kumar | 2249c00 | 2016-03-30 13:45:28 +0530 | [diff] [blame] | 49 | { .compatible = "samsung,exynos5800", }, |
| 50 | #endif |
Viresh Kumar | 7694ca6 | 2016-04-22 16:58:42 +0530 | [diff] [blame] | 51 | |
Viresh Kumar | a399dc9 | 2016-04-22 16:58:44 +0530 | [diff] [blame] | 52 | { .compatible = "renesas,emev2", }, |
| 53 | { .compatible = "renesas,r7s72100", }, |
| 54 | { .compatible = "renesas,r8a73a4", }, |
| 55 | { .compatible = "renesas,r8a7740", }, |
Lad Prabhakar | a6d1bfa | 2020-04-27 13:53:30 +0100 | [diff] [blame] | 56 | { .compatible = "renesas,r8a7742", }, |
Geert Uytterhoeven | f0da898 | 2016-11-16 11:05:51 +0100 | [diff] [blame] | 57 | { .compatible = "renesas,r8a7743", }, |
Biju Das | d1e1303 | 2018-09-11 11:12:51 +0100 | [diff] [blame] | 58 | { .compatible = "renesas,r8a7744", }, |
Geert Uytterhoeven | f0da898 | 2016-11-16 11:05:51 +0100 | [diff] [blame] | 59 | { .compatible = "renesas,r8a7745", }, |
Viresh Kumar | a399dc9 | 2016-04-22 16:58:44 +0530 | [diff] [blame] | 60 | { .compatible = "renesas,r8a7778", }, |
| 61 | { .compatible = "renesas,r8a7779", }, |
| 62 | { .compatible = "renesas,r8a7790", }, |
| 63 | { .compatible = "renesas,r8a7791", }, |
Geert Uytterhoeven | ffdf8b8 | 2016-09-06 14:18:20 +0200 | [diff] [blame] | 64 | { .compatible = "renesas,r8a7792", }, |
Viresh Kumar | a399dc9 | 2016-04-22 16:58:44 +0530 | [diff] [blame] | 65 | { .compatible = "renesas,r8a7793", }, |
| 66 | { .compatible = "renesas,r8a7794", }, |
| 67 | { .compatible = "renesas,sh73a0", }, |
| 68 | |
Finley Xiao | 014400c | 2016-04-22 16:58:43 +0530 | [diff] [blame] | 69 | { .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 Xiao | 319af40 | 2017-08-04 09:52:31 +0800 | [diff] [blame] | 76 | { .compatible = "rockchip,rk3328", }, |
Finley Xiao | 014400c | 2016-04-22 16:58:43 +0530 | [diff] [blame] | 77 | { .compatible = "rockchip,rk3366", }, |
| 78 | { .compatible = "rockchip,rk3368", }, |
Dmitry Torokhov | 9d21d33 | 2018-10-05 12:00:58 -0700 | [diff] [blame] | 79 | { .compatible = "rockchip,rk3399", |
| 80 | .data = &(struct cpufreq_dt_platform_data) |
| 81 | { .have_governor_per_policy = true, }, |
| 82 | }, |
Finley Xiao | 014400c | 2016-04-22 16:58:43 +0530 | [diff] [blame] | 83 | |
Linus Walleij | ff6c349 | 2017-08-16 10:19:12 +0200 | [diff] [blame] | 84 | { .compatible = "st-ericsson,u8500", }, |
| 85 | { .compatible = "st-ericsson,u8540", }, |
| 86 | { .compatible = "st-ericsson,u9500", }, |
| 87 | { .compatible = "st-ericsson,u9540", }, |
| 88 | |
Viresh Kumar | 7694ca6 | 2016-04-22 16:58:42 +0530 | [diff] [blame] | 89 | { .compatible = "ti,omap2", }, |
Viresh Kumar | 7694ca6 | 2016-04-22 16:58:42 +0530 | [diff] [blame] | 90 | { .compatible = "ti,omap4", }, |
| 91 | { .compatible = "ti,omap5", }, |
Viresh Kumar | 5e4249c | 2016-04-22 16:58:46 +0530 | [diff] [blame] | 92 | |
| 93 | { .compatible = "xlnx,zynq-7000", }, |
Shubhrajyoti Datta | a568578 | 2017-07-13 11:19:10 +0200 | [diff] [blame] | 94 | { .compatible = "xlnx,zynqmp", }, |
Wei Yongjun | bd37e02 | 2016-08-21 15:41:44 +0000 | [diff] [blame] | 95 | |
| 96 | { } |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 97 | }; |
| 98 | |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 99 | /* |
| 100 | * Machines for which the cpufreq device is *not* created, mostly used for |
| 101 | * platforms using "operating-points-v2" property. |
| 102 | */ |
Viresh Kumar | 4814d9c | 2021-05-20 09:56:18 +0530 | [diff] [blame] | 103 | static const struct of_device_id blocklist[] __initconst = { |
Yangtao Li | f328584 | 2019-06-12 12:28:15 -0400 | [diff] [blame] | 104 | { .compatible = "allwinner,sun50i-h6", }, |
| 105 | |
Sudeep Holla | fbb31cb | 2021-02-18 22:23:26 +0000 | [diff] [blame] | 106 | { .compatible = "arm,vexpress", }, |
| 107 | |
Viresh Kumar | ff76898 | 2017-09-19 08:23:22 -0700 | [diff] [blame] | 108 | { .compatible = "calxeda,highbank", }, |
| 109 | { .compatible = "calxeda,ecx-2000", }, |
| 110 | |
Peng Fan | a08e1b6 | 2020-04-20 15:55:13 +0800 | [diff] [blame] | 111 | { .compatible = "fsl,imx7ulp", }, |
Leonard Crestez | e6abaca | 2019-06-05 13:37:06 +0300 | [diff] [blame] | 112 | { .compatible = "fsl,imx7d", }, |
Leonard Crestez | 4d28ba1 | 2019-05-13 11:01:38 +0000 | [diff] [blame] | 113 | { .compatible = "fsl,imx8mq", }, |
| 114 | { .compatible = "fsl,imx8mm", }, |
Anson Huang | 8ec5035 | 2019-08-18 02:32:21 -0400 | [diff] [blame] | 115 | { .compatible = "fsl,imx8mn", }, |
Anson Huang | 24f371f | 2019-12-26 14:52:46 +0800 | [diff] [blame] | 116 | { .compatible = "fsl,imx8mp", }, |
Leonard Crestez | 4d28ba1 | 2019-05-13 11:01:38 +0000 | [diff] [blame] | 117 | |
Viresh Kumar | ff76898 | 2017-09-19 08:23:22 -0700 | [diff] [blame] | 118 | { .compatible = "marvell,armadaxp", }, |
| 119 | |
Andrew-sh Cheng | 6066998c | 2017-12-08 14:07:56 +0800 | [diff] [blame] | 120 | { .compatible = "mediatek,mt2701", }, |
| 121 | { .compatible = "mediatek,mt2712", }, |
| 122 | { .compatible = "mediatek,mt7622", }, |
| 123 | { .compatible = "mediatek,mt7623", }, |
Fabien Parent | de4ca30 | 2020-10-13 11:27:08 +0200 | [diff] [blame] | 124 | { .compatible = "mediatek,mt8167", }, |
Andrew-sh Cheng | 6066998c | 2017-12-08 14:07:56 +0800 | [diff] [blame] | 125 | { .compatible = "mediatek,mt817x", }, |
| 126 | { .compatible = "mediatek,mt8173", }, |
| 127 | { .compatible = "mediatek,mt8176", }, |
Andrew-sh.Cheng | 9176b42 | 2019-08-13 21:31:48 +0800 | [diff] [blame] | 128 | { .compatible = "mediatek,mt8183", }, |
Fabien Parent | 70d99a8 | 2021-05-19 18:25:50 +0200 | [diff] [blame] | 129 | { .compatible = "mediatek,mt8365", }, |
Fabien Parent | 75118c8 | 2020-10-13 11:27:09 +0200 | [diff] [blame] | 130 | { .compatible = "mediatek,mt8516", }, |
Andrew-sh Cheng | 6066998c | 2017-12-08 14:07:56 +0800 | [diff] [blame] | 131 | |
Dmitry Osipenko | 26a7a47 | 2019-11-18 19:45:08 +0300 | [diff] [blame] | 132 | { .compatible = "nvidia,tegra20", }, |
| 133 | { .compatible = "nvidia,tegra30", }, |
Viresh Kumar | ff76898 | 2017-09-19 08:23:22 -0700 | [diff] [blame] | 134 | { .compatible = "nvidia,tegra124", }, |
Joseph Lo | 43c3600 | 2019-01-04 11:06:55 +0800 | [diff] [blame] | 135 | { .compatible = "nvidia,tegra210", }, |
Viresh Kumar | ff76898 | 2017-09-19 08:23:22 -0700 | [diff] [blame] | 136 | |
Ilia Lin | 46e2856 | 2018-05-30 05:39:28 +0300 | [diff] [blame] | 137 | { .compatible = "qcom,apq8096", }, |
| 138 | { .compatible = "qcom,msm8996", }, |
Jorge Ramirez-Ortiz | 248b5f2 | 2019-07-25 12:41:36 +0200 | [diff] [blame] | 139 | { .compatible = "qcom,qcs404", }, |
Bjorn Andersson | 5e79d6d | 2021-08-20 14:57:00 -0700 | [diff] [blame] | 140 | { .compatible = "qcom,sa8155p" }, |
Sibi Sankar | fb09180 | 2020-06-22 13:46:46 +0530 | [diff] [blame] | 141 | { .compatible = "qcom,sc7180", }, |
Sibi Sankar | 17a8b0b | 2021-05-12 13:41:22 +0530 | [diff] [blame] | 142 | { .compatible = "qcom,sc7280", }, |
Bjorn Andersson | d66cd5d | 2021-07-24 20:02:14 -0700 | [diff] [blame] | 143 | { .compatible = "qcom,sc8180x", }, |
Sibi Sankar | 49ef122 | 2020-06-22 13:46:45 +0530 | [diff] [blame] | 144 | { .compatible = "qcom,sdm845", }, |
Bjorn Andersson | 5e79d6d | 2021-08-20 14:57:00 -0700 | [diff] [blame] | 145 | { .compatible = "qcom,sm6350", }, |
Thara Gopinath | 5d79e5c | 2021-08-04 16:34:20 -0400 | [diff] [blame] | 146 | { .compatible = "qcom,sm8150", }, |
Bjorn Andersson | 5e79d6d | 2021-08-20 14:57:00 -0700 | [diff] [blame] | 147 | { .compatible = "qcom,sm8250", }, |
| 148 | { .compatible = "qcom,sm8350", }, |
Ilia Lin | 46e2856 | 2018-05-30 05:39:28 +0300 | [diff] [blame] | 149 | |
Viresh Kumar | ff76898 | 2017-09-19 08:23:22 -0700 | [diff] [blame] | 150 | { .compatible = "st,stih407", }, |
| 151 | { .compatible = "st,stih410", }, |
Alain Volmat | 305accf | 2020-08-31 08:10:12 +0200 | [diff] [blame] | 152 | { .compatible = "st,stih418", }, |
Viresh Kumar | ff76898 | 2017-09-19 08:23:22 -0700 | [diff] [blame] | 153 | |
Suniel Mahesh | d477bf3 | 2017-09-21 19:09:03 +0530 | [diff] [blame] | 154 | { .compatible = "ti,am33xx", }, |
| 155 | { .compatible = "ti,am43", }, |
| 156 | { .compatible = "ti,dra7", }, |
H. Nikolaus Schaller | b7dbe34 | 2019-09-11 19:47:08 +0200 | [diff] [blame] | 157 | { .compatible = "ti,omap3", }, |
Suniel Mahesh | d477bf3 | 2017-09-21 19:09:03 +0530 | [diff] [blame] | 158 | |
Ansuel Smith | a8811ec | 2020-03-13 18:52:13 +0100 | [diff] [blame] | 159 | { .compatible = "qcom,ipq8064", }, |
| 160 | { .compatible = "qcom,apq8064", }, |
| 161 | { .compatible = "qcom,msm8974", }, |
| 162 | { .compatible = "qcom,msm8960", }, |
| 163 | |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 164 | { } |
| 165 | }; |
| 166 | |
| 167 | static 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 Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 179 | static int __init cpufreq_dt_platdev_init(void) |
| 180 | { |
| 181 | struct device_node *np = of_find_node_by_path("/"); |
Masahiro Yamada | ca5eda5 | 2016-06-27 14:50:13 +0900 | [diff] [blame] | 182 | const struct of_device_id *match; |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 183 | const void *data = NULL; |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 184 | |
| 185 | if (!np) |
| 186 | return -ENODEV; |
| 187 | |
Viresh Kumar | 4814d9c | 2021-05-20 09:56:18 +0530 | [diff] [blame] | 188 | match = of_match_node(allowlist, np); |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 189 | if (match) { |
| 190 | data = match->data; |
| 191 | goto create_pdev; |
| 192 | } |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 193 | |
Viresh Kumar | 4814d9c | 2021-05-20 09:56:18 +0530 | [diff] [blame] | 194 | if (cpu0_node_has_opp_v2_prop() && !of_match_node(blocklist, np)) |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 195 | goto create_pdev; |
| 196 | |
| 197 | of_node_put(np); |
| 198 | return -ENODEV; |
| 199 | |
| 200 | create_pdev: |
| 201 | of_node_put(np); |
Viresh Kumar | 297a662 | 2016-09-09 16:48:08 +0530 | [diff] [blame] | 202 | return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt", |
Viresh Kumar | edeec42 | 2017-08-16 11:07:27 +0530 | [diff] [blame] | 203 | -1, data, |
Viresh Kumar | 297a662 | 2016-09-09 16:48:08 +0530 | [diff] [blame] | 204 | sizeof(struct cpufreq_dt_platform_data))); |
Viresh Kumar | f56aad1 | 2016-03-30 13:45:26 +0530 | [diff] [blame] | 205 | } |
Amit Kucheria | 57db08f | 2019-10-21 17:45:13 +0530 | [diff] [blame] | 206 | core_initcall(cpufreq_dt_platdev_init); |