blob: 7c67a6c74fdc65afe483114eca135d5dfedb95f7 [file] [log] [blame]
Viresh Kumarf56aad12016-03-30 13:45:26 +05301/*
2 * Copyright (C) 2016 Linaro.
3 * Viresh Kumar <viresh.kumar@linaro.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/err.h>
11#include <linux/of.h>
Viresh Kumaredeec422017-08-16 11:07:27 +053012#include <linux/of_device.h>
Viresh Kumarf56aad12016-03-30 13:45:26 +053013#include <linux/platform_device.h>
14
Viresh Kumar297a6622016-09-09 16:48:08 +053015#include "cpufreq-dt.h"
16
Viresh Kumaredeec422017-08-16 11:07:27 +053017/*
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 = {
Viresh Kumar117d4f52016-04-22 16:58:45 +053022 { .compatible = "allwinner,sun4i-a10", },
23 { .compatible = "allwinner,sun5i-a10s", },
24 { .compatible = "allwinner,sun5i-a13", },
25 { .compatible = "allwinner,sun5i-r8", },
26 { .compatible = "allwinner,sun6i-a31", },
27 { .compatible = "allwinner,sun6i-a31s", },
28 { .compatible = "allwinner,sun7i-a20", },
29 { .compatible = "allwinner,sun8i-a23", },
30 { .compatible = "allwinner,sun8i-a33", },
31 { .compatible = "allwinner,sun8i-a83t", },
32 { .compatible = "allwinner,sun8i-h3", },
33
Hoan Trane11b6292016-12-15 14:55:00 -080034 { .compatible = "apm,xgene-shadowcat", },
35
Linus Walleij650ec6c2016-10-25 09:21:24 +020036 { .compatible = "arm,integrator-ap", },
37 { .compatible = "arm,integrator-cp", },
38
Tao Wanga0df7732017-05-23 16:13:18 +080039 { .compatible = "hisilicon,hi3660", },
Viresh Kumar3920be42016-04-22 16:58:47 +053040 { .compatible = "hisilicon,hi6220", },
41
Viresh Kumar7ead83f2016-04-22 16:58:41 +053042 { .compatible = "fsl,imx27", },
43 { .compatible = "fsl,imx51", },
44 { .compatible = "fsl,imx53", },
45 { .compatible = "fsl,imx7d", },
46
Viresh Kumara59511d2016-04-22 16:58:40 +053047 { .compatible = "marvell,berlin", },
Robert Jarzmikdcd2ea42016-10-31 20:54:53 +010048 { .compatible = "marvell,pxa250", },
49 { .compatible = "marvell,pxa270", },
Viresh Kumara59511d2016-04-22 16:58:40 +053050
Viresh Kumar2249c002016-03-30 13:45:28 +053051 { .compatible = "samsung,exynos3250", },
52 { .compatible = "samsung,exynos4210", },
53 { .compatible = "samsung,exynos4212", },
54 { .compatible = "samsung,exynos4412", },
55 { .compatible = "samsung,exynos5250", },
56#ifndef CONFIG_BL_SWITCHER
57 { .compatible = "samsung,exynos5420", },
Chanwoo Choic4b40572016-08-16 15:27:19 +090058 { .compatible = "samsung,exynos5433", },
Viresh Kumar2249c002016-03-30 13:45:28 +053059 { .compatible = "samsung,exynos5800", },
60#endif
Viresh Kumar7694ca62016-04-22 16:58:42 +053061
Viresh Kumara399dc92016-04-22 16:58:44 +053062 { .compatible = "renesas,emev2", },
63 { .compatible = "renesas,r7s72100", },
64 { .compatible = "renesas,r8a73a4", },
65 { .compatible = "renesas,r8a7740", },
Geert Uytterhoevenf0da8982016-11-16 11:05:51 +010066 { .compatible = "renesas,r8a7743", },
67 { .compatible = "renesas,r8a7745", },
Viresh Kumara399dc92016-04-22 16:58:44 +053068 { .compatible = "renesas,r8a7778", },
69 { .compatible = "renesas,r8a7779", },
70 { .compatible = "renesas,r8a7790", },
71 { .compatible = "renesas,r8a7791", },
Geert Uytterhoevenffdf8b82016-09-06 14:18:20 +020072 { .compatible = "renesas,r8a7792", },
Viresh Kumara399dc92016-04-22 16:58:44 +053073 { .compatible = "renesas,r8a7793", },
74 { .compatible = "renesas,r8a7794", },
Khiem Nguyen034def52017-08-04 15:18:00 +020075 { .compatible = "renesas,r8a7795", },
Khiem Nguyenbea2ebc2017-08-11 17:36:57 +020076 { .compatible = "renesas,r8a7796", },
Viresh Kumara399dc92016-04-22 16:58:44 +053077 { .compatible = "renesas,sh73a0", },
78
Finley Xiao014400c2016-04-22 16:58:43 +053079 { .compatible = "rockchip,rk2928", },
80 { .compatible = "rockchip,rk3036", },
81 { .compatible = "rockchip,rk3066a", },
82 { .compatible = "rockchip,rk3066b", },
83 { .compatible = "rockchip,rk3188", },
84 { .compatible = "rockchip,rk3228", },
85 { .compatible = "rockchip,rk3288", },
Finley Xiao319af402017-08-04 09:52:31 +080086 { .compatible = "rockchip,rk3328", },
Finley Xiao014400c2016-04-22 16:58:43 +053087 { .compatible = "rockchip,rk3366", },
88 { .compatible = "rockchip,rk3368", },
89 { .compatible = "rockchip,rk3399", },
90
Masahiro Yamada1758b332016-10-27 01:41:33 +090091 { .compatible = "socionext,uniphier-pro5", },
92 { .compatible = "socionext,uniphier-pxs2", },
93 { .compatible = "socionext,uniphier-ld6b", },
94 { .compatible = "socionext,uniphier-ld11", },
95 { .compatible = "socionext,uniphier-ld20", },
96
Linus Walleijff6c3492017-08-16 10:19:12 +020097 { .compatible = "st-ericsson,u8500", },
98 { .compatible = "st-ericsson,u8540", },
99 { .compatible = "st-ericsson,u9500", },
100 { .compatible = "st-ericsson,u9540", },
101
Viresh Kumar7694ca62016-04-22 16:58:42 +0530102 { .compatible = "ti,omap2", },
103 { .compatible = "ti,omap3", },
104 { .compatible = "ti,omap4", },
105 { .compatible = "ti,omap5", },
Viresh Kumar5e4249c2016-04-22 16:58:46 +0530106
107 { .compatible = "xlnx,zynq-7000", },
Shubhrajyoti Dattaa5685782017-07-13 11:19:10 +0200108 { .compatible = "xlnx,zynqmp", },
Wei Yongjunbd37e022016-08-21 15:41:44 +0000109
Baoyou Xieab838052016-11-30 15:35:29 +0800110 { .compatible = "zte,zx296718", },
111
Wei Yongjunbd37e022016-08-21 15:41:44 +0000112 { }
Viresh Kumarf56aad12016-03-30 13:45:26 +0530113};
114
Viresh Kumaredeec422017-08-16 11:07:27 +0530115/*
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
Viresh Kumarf56aad12016-03-30 13:45:26 +0530135static int __init cpufreq_dt_platdev_init(void)
136{
137 struct device_node *np = of_find_node_by_path("/");
Masahiro Yamadaca5eda52016-06-27 14:50:13 +0900138 const struct of_device_id *match;
Viresh Kumaredeec422017-08-16 11:07:27 +0530139 const void *data = NULL;
Viresh Kumarf56aad12016-03-30 13:45:26 +0530140
141 if (!np)
142 return -ENODEV;
143
Viresh Kumaredeec422017-08-16 11:07:27 +0530144 match = of_match_node(whitelist, np);
145 if (match) {
146 data = match->data;
147 goto create_pdev;
148 }
Viresh Kumarf56aad12016-03-30 13:45:26 +0530149
Viresh Kumaredeec422017-08-16 11:07:27 +0530150 if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
151 goto create_pdev;
152
153 of_node_put(np);
154 return -ENODEV;
155
156create_pdev:
157 of_node_put(np);
Viresh Kumar297a6622016-09-09 16:48:08 +0530158 return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
Viresh Kumaredeec422017-08-16 11:07:27 +0530159 -1, data,
Viresh Kumar297a6622016-09-09 16:48:08 +0530160 sizeof(struct cpufreq_dt_platform_data)));
Viresh Kumarf56aad12016-03-30 13:45:26 +0530161}
162device_initcall(cpufreq_dt_platdev_init);