cpufreq-dt-platdev.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  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. #include <linux/err.h>
  10. #include <linux/of.h>
  11. #include <linux/of_device.h>
  12. #include <linux/platform_device.h>
  13. #include "cpufreq-dt.h"
  14. /*
  15. * Machines for which the cpufreq device is *always* created, mostly used for
  16. * platforms using "operating-points" (V1) property.
  17. */
  18. static const struct of_device_id whitelist[] __initconst = {
  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", },
  27. { .compatible = "allwinner,sun8i-a83t", },
  28. { .compatible = "allwinner,sun8i-h3", },
  29. { .compatible = "apm,xgene-shadowcat", },
  30. { .compatible = "arm,integrator-ap", },
  31. { .compatible = "arm,integrator-cp", },
  32. { .compatible = "hisilicon,hi3660", },
  33. { .compatible = "fsl,imx27", },
  34. { .compatible = "fsl,imx51", },
  35. { .compatible = "fsl,imx53", },
  36. { .compatible = "fsl,imx7d", },
  37. { .compatible = "marvell,berlin", },
  38. { .compatible = "marvell,pxa250", },
  39. { .compatible = "marvell,pxa270", },
  40. { .compatible = "samsung,exynos3250", },
  41. { .compatible = "samsung,exynos4210", },
  42. { .compatible = "samsung,exynos4212", },
  43. { .compatible = "samsung,exynos5250", },
  44. #ifndef CONFIG_BL_SWITCHER
  45. { .compatible = "samsung,exynos5800", },
  46. #endif
  47. { .compatible = "renesas,emev2", },
  48. { .compatible = "renesas,r7s72100", },
  49. { .compatible = "renesas,r8a73a4", },
  50. { .compatible = "renesas,r8a7740", },
  51. { .compatible = "renesas,r8a7743", },
  52. { .compatible = "renesas,r8a7745", },
  53. { .compatible = "renesas,r8a7778", },
  54. { .compatible = "renesas,r8a7779", },
  55. { .compatible = "renesas,r8a7790", },
  56. { .compatible = "renesas,r8a7791", },
  57. { .compatible = "renesas,r8a7792", },
  58. { .compatible = "renesas,r8a7793", },
  59. { .compatible = "renesas,r8a7794", },
  60. { .compatible = "renesas,r8a7795", },
  61. { .compatible = "renesas,r8a7796", },
  62. { .compatible = "renesas,sh73a0", },
  63. { .compatible = "rockchip,rk2928", },
  64. { .compatible = "rockchip,rk3036", },
  65. { .compatible = "rockchip,rk3066a", },
  66. { .compatible = "rockchip,rk3066b", },
  67. { .compatible = "rockchip,rk3188", },
  68. { .compatible = "rockchip,rk3228", },
  69. { .compatible = "rockchip,rk3288", },
  70. { .compatible = "rockchip,rk3328", },
  71. { .compatible = "rockchip,rk3366", },
  72. { .compatible = "rockchip,rk3368", },
  73. { .compatible = "rockchip,rk3399", },
  74. { .compatible = "socionext,uniphier-ld6b", },
  75. { .compatible = "st-ericsson,u8500", },
  76. { .compatible = "st-ericsson,u8540", },
  77. { .compatible = "st-ericsson,u9500", },
  78. { .compatible = "st-ericsson,u9540", },
  79. { .compatible = "ti,omap2", },
  80. { .compatible = "ti,omap3", },
  81. { .compatible = "ti,omap4", },
  82. { .compatible = "ti,omap5", },
  83. { .compatible = "xlnx,zynq-7000", },
  84. { .compatible = "xlnx,zynqmp", },
  85. { }
  86. };
  87. /*
  88. * Machines for which the cpufreq device is *not* created, mostly used for
  89. * platforms using "operating-points-v2" property.
  90. */
  91. static const struct of_device_id blacklist[] __initconst = {
  92. { .compatible = "calxeda,highbank", },
  93. { .compatible = "calxeda,ecx-2000", },
  94. { .compatible = "marvell,armadaxp", },
  95. { .compatible = "mediatek,mt2701", },
  96. { .compatible = "mediatek,mt2712", },
  97. { .compatible = "mediatek,mt7622", },
  98. { .compatible = "mediatek,mt7623", },
  99. { .compatible = "mediatek,mt8168", },
  100. { .compatible = "mediatek,mt817x", },
  101. { .compatible = "mediatek,mt8173", },
  102. { .compatible = "mediatek,mt8176", },
  103. { .compatible = "mediatek,mt8167", },
  104. { .compatible = "nvidia,tegra124", },
  105. { .compatible = "st,stih407", },
  106. { .compatible = "st,stih410", },
  107. { .compatible = "sigma,tango4", },
  108. { .compatible = "ti,am33xx", },
  109. { .compatible = "ti,am43", },
  110. { .compatible = "ti,dra7", },
  111. { }
  112. };
  113. static bool __init cpu0_node_has_opp_v2_prop(void)
  114. {
  115. struct device_node *np = of_cpu_device_node_get(0);
  116. bool ret = false;
  117. if (of_get_property(np, "operating-points-v2", NULL))
  118. ret = true;
  119. of_node_put(np);
  120. return ret;
  121. }
  122. static int __init cpufreq_dt_platdev_init(void)
  123. {
  124. struct device_node *np = of_find_node_by_path("/");
  125. const struct of_device_id *match;
  126. const void *data = NULL;
  127. if (!np)
  128. return -ENODEV;
  129. match = of_match_node(whitelist, np);
  130. if (match) {
  131. data = match->data;
  132. goto create_pdev;
  133. }
  134. if (cpu0_node_has_opp_v2_prop() && !of_match_node(blacklist, np))
  135. goto create_pdev;
  136. of_node_put(np);
  137. return -ENODEV;
  138. create_pdev:
  139. of_node_put(np);
  140. return PTR_ERR_OR_ZERO(platform_device_register_data(NULL, "cpufreq-dt",
  141. -1, data,
  142. sizeof(struct cpufreq_dt_platform_data)));
  143. }
  144. device_initcall(cpufreq_dt_platdev_init);