^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2016 Linaro.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Viresh Kumar <viresh.kumar@linaro.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/of_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "cpufreq-dt.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Machines for which the cpufreq device is *always* created, mostly used for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * platforms using "operating-points" (V1) property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static const struct of_device_id whitelist[] __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) { .compatible = "allwinner,sun4i-a10", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) { .compatible = "allwinner,sun5i-a10s", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) { .compatible = "allwinner,sun5i-a13", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) { .compatible = "allwinner,sun5i-r8", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) { .compatible = "allwinner,sun6i-a31", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) { .compatible = "allwinner,sun6i-a31s", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) { .compatible = "allwinner,sun7i-a20", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) { .compatible = "allwinner,sun8i-a23", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) { .compatible = "allwinner,sun8i-a83t", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) { .compatible = "allwinner,sun8i-h3", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) { .compatible = "apm,xgene-shadowcat", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) { .compatible = "arm,integrator-ap", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) { .compatible = "arm,integrator-cp", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) { .compatible = "hisilicon,hi3660", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) { .compatible = "fsl,imx27", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) { .compatible = "fsl,imx51", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) { .compatible = "fsl,imx53", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) { .compatible = "marvell,berlin", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) { .compatible = "marvell,pxa250", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) { .compatible = "marvell,pxa270", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) { .compatible = "samsung,exynos3250", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) { .compatible = "samsung,exynos4210", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) { .compatible = "samsung,exynos5250", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #ifndef CONFIG_BL_SWITCHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) { .compatible = "samsung,exynos5800", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) { .compatible = "renesas,emev2", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) { .compatible = "renesas,r7s72100", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) { .compatible = "renesas,r8a73a4", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) { .compatible = "renesas,r8a7740", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) { .compatible = "renesas,r8a7742", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) { .compatible = "renesas,r8a7743", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) { .compatible = "renesas,r8a7744", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) { .compatible = "renesas,r8a7745", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) { .compatible = "renesas,r8a7778", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) { .compatible = "renesas,r8a7779", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) { .compatible = "renesas,r8a7790", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) { .compatible = "renesas,r8a7791", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) { .compatible = "renesas,r8a7792", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) { .compatible = "renesas,r8a7793", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) { .compatible = "renesas,r8a7794", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) { .compatible = "renesas,sh73a0", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) { .compatible = "st-ericsson,u8500", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) { .compatible = "st-ericsson,u8540", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) { .compatible = "st-ericsson,u9500", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) { .compatible = "st-ericsson,u9540", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) { .compatible = "ti,omap2", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) { .compatible = "ti,omap4", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) { .compatible = "ti,omap5", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) { .compatible = "xlnx,zynq-7000", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) { .compatible = "xlnx,zynqmp", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * Machines for which the cpufreq device is *not* created, mostly used for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * platforms using "operating-points-v2" property.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) static const struct of_device_id blacklist[] __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) { .compatible = "allwinner,sun50i-h6", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) { .compatible = "arm,vexpress", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) { .compatible = "calxeda,highbank", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) { .compatible = "calxeda,ecx-2000", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) { .compatible = "fsl,imx7ulp", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) { .compatible = "fsl,imx7d", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) { .compatible = "fsl,imx8mq", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) { .compatible = "fsl,imx8mm", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) { .compatible = "fsl,imx8mn", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) { .compatible = "fsl,imx8mp", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) { .compatible = "marvell,armadaxp", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) { .compatible = "mediatek,mt2701", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) { .compatible = "mediatek,mt2712", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) { .compatible = "mediatek,mt7622", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) { .compatible = "mediatek,mt7623", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) { .compatible = "mediatek,mt817x", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) { .compatible = "mediatek,mt8173", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) { .compatible = "mediatek,mt8176", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) { .compatible = "mediatek,mt8183", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) { .compatible = "nvidia,tegra20", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) { .compatible = "nvidia,tegra30", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) { .compatible = "nvidia,tegra124", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) { .compatible = "nvidia,tegra210", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) { .compatible = "qcom,apq8096", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) { .compatible = "qcom,msm8996", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) { .compatible = "qcom,qcs404", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) { .compatible = "qcom,sc7180", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) { .compatible = "qcom,sdm845", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) { .compatible = "qcom,sm8150", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) { .compatible = "rockchip,px30", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) { .compatible = "rockchip,rk2928", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) { .compatible = "rockchip,rk3036", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) { .compatible = "rockchip,rk3066a", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) { .compatible = "rockchip,rk3066b", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) { .compatible = "rockchip,rk3126", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) { .compatible = "rockchip,rk3128", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) { .compatible = "rockchip,rk3188", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) { .compatible = "rockchip,rk3228", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) { .compatible = "rockchip,rk3229", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) { .compatible = "rockchip,rk3288", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) { .compatible = "rockchip,rk3288w", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) { .compatible = "rockchip,rk3308", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) { .compatible = "rockchip,rk3326", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) { .compatible = "rockchip,rk3328", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) { .compatible = "rockchip,rk3366", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) { .compatible = "rockchip,rk3368", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) { .compatible = "rockchip,rk3399", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) { .compatible = "rockchip,rk3399pro", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) { .compatible = "rockchip,rk3566", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) { .compatible = "rockchip,rk3568", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) { .compatible = "rockchip,rk3588", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) { .compatible = "rockchip,rv1103", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) { .compatible = "rockchip,rv1106", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) { .compatible = "rockchip,rv1109", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) { .compatible = "rockchip,rv1126", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) { .compatible = "st,stih407", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) { .compatible = "st,stih410", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) { .compatible = "st,stih418", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) { .compatible = "sigma,tango4", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) { .compatible = "ti,am33xx", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) { .compatible = "ti,am43", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) { .compatible = "ti,dra7", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) { .compatible = "ti,omap3", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) { .compatible = "qcom,ipq8064", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) { .compatible = "qcom,apq8064", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) { .compatible = "qcom,msm8974", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) { .compatible = "qcom,msm8960", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static bool __init cpu0_node_has_opp_v2_prop(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct device_node *np = of_cpu_device_node_get(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) bool ret = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (of_get_property(np, "operating-points-v2", NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) ret = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static int __init cpufreq_dt_platdev_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct device_node *np = of_find_node_by_path("/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) const struct of_device_id *match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) const void *data = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (!np)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) match = of_match_node(whitelist, np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (match) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) data = match->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) goto create_pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) goto create_pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) create_pdev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) of_node_put(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) -1, data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) sizeof(struct cpufreq_dt_platform_data)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) core_initcall(cpufreq_dt_platdev_init);